package com.mosty.base.manager.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mosty.base.manager.service.TbJcglKfdService;
import com.mosty.base.manager.service.TbJcglKhmxService;
import com.mosty.base.model.dto.jcgl.TbJcglKfdDto;
import com.mosty.base.model.dto.qwzx.AppSearchQuery;
import com.mosty.base.model.entity.jcgl.TbJcglKfd;
import com.mosty.base.model.entity.jcgl.TbJcglKhmx;
import com.mosty.base.model.query.jcgl.TbJcglKfdQuery;
import com.mosty.base.model.query.jcgl.TbJcglKhmxQuery;
import com.mosty.base.model.vo.jcgl.TbJcglKhmxVo;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.common.base.entity.log.BusinessType;
import com.mosty.common.base.entity.log.Log;
import com.mosty.common.token.JwtSysUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@AllArgsConstructor
@RequestMapping("/tbjcglKhmx")
@Api(tags = "考核模型")
public class TbJcglKhmxController {

    private final TbJcglKhmxService tbJcglKhmxService;

    @GetMapping({"/selectPage"})
    @JwtSysUser
    @ApiOperation(value = "查询考核模型")
    public ResponseResult<IPage<TbJcglKhmx>> selectKfdList(TbJcglKhmxQuery tbJcglkhmx) {
        return ResponseResult.success(tbJcglKhmxService.paginQuery(tbJcglkhmx));
    }

    @PostMapping("/addKhmx")
    @JwtSysUser
    @Log(title = "新增考核模型", businessType = BusinessType.INSERT)
    @ApiOperation("新增考核模型")
    public ResponseResult<Integer> addKhmx(@RequestBody TbJcglKhmx tbJcglKhmx) {
        return ResponseResult.success(tbJcglKhmxService.insert(tbJcglKhmx));
    }


    @PostMapping({"/updateKhmx"})
    @JwtSysUser
    @Log(title = "修改考核模型", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改考核模型")
    public ResponseResult<Integer> updateKhmx(@RequestBody TbJcglKhmx tbJcglKhmx) {
        return ResponseResult.success(tbJcglKhmxService.update(tbJcglKhmx));
    }

    @GetMapping({"/selectByid"})
    @JwtSysUser
    @ApiOperation(value = "查询考核模型详情")
    public ResponseResult<TbJcglKhmxVo> selectByid(String id) {
        return ResponseResult.success(tbJcglKhmxService.queryById(id));
    }

    @PostMapping({"/delete"})
    @JwtSysUser
    @Log(title = "删除考核模型", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除考核模型")
    public ResponseResult<Void> delete(@RequestBody List<String> id) {
        tbJcglKhmxService.deleteByIds(id);
        return ResponseResult.success();
    }


}
