package com.energy.manage.service.controller.analysiscomment;

import com.energy.manage.common.reponse.ResultResp;
import com.energy.manage.service.config.annotations.UserLoginToken;
import com.energy.manage.service.controller.base.BaseServiceController;
import com.energy.manage.service.domain.dto.analysis.AnalysisCommentDescriptionDto;
import com.energy.manage.service.domain.dto.analysis.AnalysisCommentTypeRelationDto;
import com.energy.manage.service.domain.vo.analysis.AnalysisCommentDescriptionVo;
import com.energy.manage.service.service.analysiscomment.AnalysisCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author chy
 * @date 2024/5/24 17:09
 * @desc
 */
@Api(value = "AnalysisCommentController",tags = "富文本")
@Slf4j
@RestController
@RequestMapping("/analysisComment")
public class AnalysisCommentController extends BaseServiceController {

    @Autowired
    private AnalysisCommentService analysisCommentService;

    @UserLoginToken
    @ApiOperation(value = "富文本类型查询")
    @GetMapping("/analysisCommentTypeList")
    public ResultResp analysisCommentTypeList(@RequestParam(name = "batchCode") String batchCode,
                                              @RequestParam(name = "analysisTypeCode") String analysisTypeCode)
    {
        return success(analysisCommentService.analysisCommentTypeList(batchCode,analysisTypeCode));
    }

    @UserLoginToken
    @ApiOperation(value = "评论查询")
    @GetMapping("/analysisCommentDescList")
    public ResultResp<AnalysisCommentDescriptionVo> analysisCommentDescList(@RequestParam(name = "batchCode", required = false) String batchCode,
                                                                            @RequestParam(name = "analysisTypeCode", required = false) String analysisTypeCode)
    {
        return success(analysisCommentService.analysisCommentDescList(batchCode,analysisTypeCode));
    }

    @UserLoginToken
    @ApiOperation(value = "富文本类型添加")
    @PostMapping("/addAnalysisCommentType")
    public ResultResp addAnalysisCommentType(@RequestBody AnalysisCommentTypeRelationDto typeRelationDto)
    {
        typeRelationDto.setCreateBy(getUserId());
        return analysisCommentService.addAnalysisCommentType(typeRelationDto);
    }

    @UserLoginToken
    @ApiOperation(value = "富文本类型删除")
    @PostMapping("/delAnalysisCommentType")
    public ResultResp delAnalysisCommentType(@RequestParam("commentTypeCode") String commentTypeCode)
    {
        return analysisCommentService.delAnalysisCommentType(commentTypeCode);
    }

    @UserLoginToken
    @ApiOperation(value = "富文本编辑")
    @PostMapping("/analysisCommentEdit")
    public ResultResp analysisCommentEdit(@RequestBody AnalysisCommentDescriptionDto commentDescriptionDto)
    {
        Integer userId = getUserId();
        commentDescriptionDto.setCreateBy(userId);
        commentDescriptionDto.setUpdateBy(userId);
        return success(analysisCommentService.analysisCommentEdit(commentDescriptionDto));
    }

}
