package com.jwipc.sys.controller.pc;

import com.jwipc.page.PageView;
import com.jwipc.sys.dto.DealtWithTargetTypeDTO;
import com.jwipc.sys.logic.DealtTypeLogic;
import com.jwipc.sys.logic.LoginLogLogic;
import com.jwipc.sys.model.po.DealtWithTargetTypePO;
import com.jwipc.sys.model.query.DealtTypeQuery;
import com.jwipc.sys.model.query.LoginLogQuery;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
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/type/rest")
@RequiredArgsConstructor
public class DealtTypeRestController {
    private final DealtTypeLogic dealtTypeLogic;

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

    @RequestMapping("/listAll")
    public List<DealtWithTargetTypeDTO> listAll(DealtTypeQuery query) {
        return dealtTypeLogic.listAll(query);
    }

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


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