package com.jwipc.sys.controller.pc;

import com.jwipc.page.PageView;
import com.jwipc.sys.dto.DealtWithTargetInfoDTO;
import com.jwipc.sys.dto.DealtWithTargetInfoTreeDTO;
import com.jwipc.sys.logic.DealtInfoLogic;
import com.jwipc.sys.model.query.DealtInfoQuery;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.jwipc.sys.constant.ModuleConst.MODULE_ROOT;

/**
 * @author shenyang.ou
 * @date 2024/1/30 12:55
 * @desc 指标
 */
@RestController
@RequestMapping(MODULE_ROOT + "/dealt/info/rest")
@RequiredArgsConstructor
public class DealtInfoRestController {
    private final DealtInfoLogic dealtInfoLogic;

    /**
     * 列表
     *
     * @param query
     * @return
     */
    @RequestMapping("/list")
    public PageView list(DealtInfoQuery query) {
        return dealtInfoLogic.findByPage(query);
    }

    /**
     * 保存更新
     *
     * @param param 参数
     */
    @PostMapping("/saveOrUpdate")
    public ResponseEntity saveOrUpdate(DealtWithTargetInfoDTO param) {
        dealtInfoLogic.saveOrUpdate(param);
        return ResponseEntity.ok(true);
    }


    /**
     * 删除
     *
     * @param id 参数
     */
    @PostMapping("/remove")
    public ResponseEntity remove(Long id) {
        dealtInfoLogic.remove(id);
        return ResponseEntity.ok(true);
    }

    @GetMapping("/tree/grid")
    public ResponseEntity treeGrid() {
        List<DealtWithTargetInfoTreeDTO> result = dealtInfoLogic.getTreeGrid();
        return ResponseEntity.ok(result);
    }
    /**
     * 获取工作台代办页面指标
     *
     * @return 结果
     */
    @PostMapping("/getUserDealtWith")
    public ResponseEntity getUserDealtWith() {
        return ResponseEntity.ok(dealtInfoLogic.getUserDealtWith());
    }
}
