package com.mosty.base.manager.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.manager.service.TbJcglPzfzService;
import com.mosty.base.model.dto.jcgl.TbJcglPzfzDto;
import com.mosty.base.model.entity.jcgl.TbJcglPzfz;
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;
import java.util.Map;

@Api(tags = "分值配置相关接口")
@RestController
@AllArgsConstructor
@RequestMapping("/fzpz")
public class TbJcglPzfzController {

    private final TbJcglPzfzService tbJcglPzfzService;

    @ApiOperation("查询配置分值列表")
    @JwtSysUser
    @GetMapping({"/selectPzfzByPzrxm"})
    public ResponseResult<IPage<Map<String, Object>>> getPageList(TbJcglPzfzDto dto) {
        return ResponseResult.success(this.tbJcglPzfzService.getPageList(dto));
    }

    @ApiOperation("查询配置分值列表(无条件)")
    @JwtSysUser
    @GetMapping({"/selectPzfzwtj"})
    public ResponseResult<List<TbJcglPzfz>> getPageListWtj() {
        return ResponseResult.success(this.tbJcglPzfzService.getPageListWtj());
    }

    @ApiOperation("添加配置分值")
    @JwtSysUser
    @PostMapping({"/addPzfz"})
    @Log(title = "添加配置分值", businessType = BusinessType.INSERT)
    public ResponseResult<Integer> addEntity(@RequestBody TbJcglPzfzDto dto) {
        return ResponseResult.success(this.tbJcglPzfzService.addEntity(dto));
    }

    @ApiOperation("删除配置分值")
    @JwtSysUser
    @DeleteMapping({"/deleteEntity/{id}"})
    @Log(title = "删除配置分值", businessType = BusinessType.DELETE)
    public ResponseResult<Integer> deleteEntity(@PathVariable("id") String id) {
        tbJcglPzfzService.deleteEntity(id);
        return ResponseResult.success();
    }

    @ApiOperation("修改配置分值")
    @JwtSysUser
    @PutMapping({"/editEntity"})
    @Log(title = "修改配置分值", businessType = BusinessType.UPDATE)
    public ResponseResult<Integer> editEntity(@RequestBody TbJcglPzfzDto dto) {
        return ResponseResult.success(this.tbJcglPzfzService.editEntity(dto));
    }

    @ApiOperation("查询配置分值详情")
    @JwtSysUser
    @GetMapping("{pzlx}")
    public ResponseResult<TbJcglPzfz> getInfo(@PathVariable("pzlx") String pzlx) {
        return ResponseResult.success(this.tbJcglPzfzService.getInfo(pzlx));
    }

}
