package com.xjrsoft.module.evaluate.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.xjrsoft.common.model.result.RT;
import com.xjrsoft.module.evaluate.dto.EvaluateObjectGradeListDto;
import com.xjrsoft.module.evaluate.dto.EvaluateObjectListDto;
import com.xjrsoft.module.evaluate.dto.ObjectGradeDeleteDto;
import com.xjrsoft.module.evaluate.dto.SaveEvaluateObjectDto;
import com.xjrsoft.module.evaluate.service.IEvaluateObjectService;
import com.xjrsoft.module.evaluate.vo.EvaluateObjectGradeListVo;
import com.xjrsoft.module.evaluate.vo.EvaluateObjectListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
* @title: 评价管理
* @Author dzx
* @Date: 2024-01-16
* @Version 1.0
*/
@RestController
@RequestMapping("/evaluate" + "/evaluateobject")
@Api(value = "/evaluate"  + "/evaluateobject",tags = "被评对象管理代码")
@AllArgsConstructor
public class EvaluateObjectController {


    private final IEvaluateObjectService evaluateObjectService;

    @GetMapping(value = "/object-list")
    @ApiOperation(value="评价对象列表（已生成数据）")
    @SaCheckPermission("evaluateobject:detail")
    public RT<List<EvaluateObjectListVo>> objectList(@Valid EvaluateObjectListDto dto){
        List<EvaluateObjectListVo> list = evaluateObjectService.getObjectList(dto);
        return RT.ok(list);
    }

    @GetMapping(value = "/object-grade-list")
    @ApiOperation(value="评价对象根据年级分组的列表（已生成数据）")
    @SaCheckPermission("evaluateobject:detail")
    public RT<List<EvaluateObjectGradeListVo>> objectGradeList(@Valid EvaluateObjectGradeListDto dto){
        List<EvaluateObjectGradeListVo> list = evaluateObjectService.getObjectGradeList(dto);
        return RT.ok(list);
    }

    @DeleteMapping(value = "/object-grade-delete")
    @ApiOperation(value = "删除根据年级评价对象根据年级分组的列表（已生成数据）")
    @SaCheckPermission("evaluateobject:delete")
    public RT<Boolean> objectGradeDelete(@Valid @RequestBody ObjectGradeDeleteDto dto){
        return RT.ok(evaluateObjectService.objectGradeDelete(dto));
    }

    @PostMapping
    @ApiOperation(value = "评价对象保存")
    @SaCheckPermission("evaluateobject:save")
    public RT<Boolean> save(@Valid @RequestBody SaveEvaluateObjectDto dto){
        boolean isSuccess = evaluateObjectService.save(dto);
        return RT.ok(isSuccess);
    }


    @GetMapping(value = "/use-object-list")
    @ApiOperation(value="评价对象列表（用于选择的数据）")
    @SaCheckPermission("evaluateobject:detail")
    public RT<List<EvaluateObjectListVo>> useObjectList(@Valid EvaluateObjectListDto dto){
        List<EvaluateObjectListVo> list = evaluateObjectService.getNewObjectList(dto);
        return RT.ok(list);
    }


}