feiyu02
2022-09-23 497475defd5d0ebf90ae6a8e2b080a16d78043ab
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/EvaluationruleController.kt
@@ -3,33 +3,42 @@
import cn.flightfeather.supervision.domain.entity.Evaluationrule
import cn.flightfeather.supervision.lightshare.service.EvaluationruleService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import org.springframework.web.bind.annotation.*
import springfox.documentation.annotations.ApiIgnore
@Api(tags = ["评分总规则API接口"])
@RestController
@RequestMapping("/evaluationrule")
class EvaluationruleController (val evaluationruleService: EvaluationruleService){
    @ApiOperation(value = "获取评分规则表")
    @GetMapping("/rule")
    fun getRules(
            @RequestParam(value = "erGuid", required = false) erGuid: String?,
            @RequestParam(value = "sceneTypeId", required = true) sceneTypeId: Int,
            @ApiParam(value = "评分表类型", allowableValues = "null/0: 手动评分;1:自动评分") @RequestParam(value = "erType", required = false) erType: Int?)
            = evaluationruleService.getRule(erGuid, sceneTypeId, erType)
        @ApiParam(value = "规则主键id") @RequestParam(value = "erGuid", required = false) erGuid: String?,
        @ApiParam(value = "场景类型id") @RequestParam(value = "sceneTypeId", required = true) sceneTypeId: Int,
        @ApiParam(value = "评分表类型", allowableValues = "null, 0, 1") @RequestParam(value = "erType", required = false) erType: Int?)
    = evaluationruleService.getRule(erGuid, sceneTypeId, erType)
    @ApiOperation(value = "获取所有评分规则表")
    @GetMapping
    fun getAll() = evaluationruleService.findAll()
    @ApiOperation(value = "上传评分规则表")
    @PutMapping
    fun add(@RequestBody evaluationrule: Evaluationrule) = evaluationruleService.save(evaluationrule)
    fun add(@ApiParam(value = "评分规则") @RequestBody evaluationrule: Evaluationrule) = evaluationruleService.save(evaluationrule)
    @ApiOperation(value = "更新评分规则表")
    @PostMapping
    fun update(@RequestBody evaluationrule: Evaluationrule) = evaluationruleService.update(evaluationrule)
    fun update(@ApiParam(value = "评分规则") @RequestBody evaluationrule: Evaluationrule) = evaluationruleService.update(evaluationrule)
    @ApiOperation(value = "查找评分规则表")
    @GetMapping("/{id}")
    fun getById(@PathVariable id:String) = evaluationruleService.findOne(id)
    fun getById(@ApiParam(value = "评分规则表id") @PathVariable id:String) = evaluationruleService.findOne(id)
    @ApiIgnore
    @ApiOperation(value = "删除评分规则表")
    @DeleteMapping("/{id}")
    fun delete (@PathVariable id: String) = evaluationruleService.delete(id)
}