liujie
2026-05-12 76b3532393aa98c2daaeb67caeefa2ab9556e866
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package com.xiaopeng.operation.controller;
 
 
import com.xiaopeng.api.feignClient.maintenance.XpWorkOrderClient;
import com.xiaopeng.api.model.operation.XpFeedbackType;
import com.xiaopeng.common.core.domain.R;
import com.xiaopeng.common.core.exception.ServiceException;
import com.xiaopeng.common.log.annotation.AdminOperationLog;
import com.xiaopeng.common.log.enums.AdminBusinessType;
import com.xiaopeng.common.log.enums.AdminOperationType;
import com.xiaopeng.operation.constant.I18nKeyConstant;
import com.xiaopeng.operation.service.IXpFeedbackTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * <p>
 * 意见反馈类型表 前端控制器
 * </p>
 *
 * @author mitao
 * @since 2026-02-03
 */
 
@Slf4j
@RestController
@RequestMapping("/api/v1/feedbackType")
@Api(tags = "管理后台-意见反馈类型")
public class XpFeedbackTypeManagementController {
 
 
    private final IXpFeedbackTypeService xpFeedbackTypeService;
    private final XpWorkOrderClient xpWorkOrderClient;
 
 
 
    public XpFeedbackTypeManagementController(IXpFeedbackTypeService xpFeedbackTypeService, XpWorkOrderClient xpWorkOrderClient) {
        this.xpFeedbackTypeService = xpFeedbackTypeService;
        this.xpWorkOrderClient = xpWorkOrderClient;
 
    }
    @GetMapping("/getList")
    @ApiOperation(value = "获取意见反馈类型列表")
    public R<List<XpFeedbackType>> getList() {
        List<XpFeedbackType> list = xpFeedbackTypeService.list();
        return R.ok(list);
    }
    @ApiOperation(value = "新增意见反馈类型")
    @PostMapping(value = "/saveFeedbackType")
    @AdminOperationLog(
            businessType = AdminBusinessType.FEEDBACK_TYPE_MANAGEMENT,
            operationType = AdminOperationType.ADD,
            content = "新增意见反馈类型",
            appendRequestData = true
    )
    public R<Boolean> add(@RequestBody XpFeedbackType xpFeedbackType) {
        return R.ok(xpFeedbackTypeService.save(xpFeedbackType));
    }
    @ApiOperation(value = "编辑意见反馈类型")
    @PostMapping(value = "/updateFeedbackType")
    @AdminOperationLog(
            businessType = AdminBusinessType.FEEDBACK_TYPE_MANAGEMENT,
            operationType = AdminOperationType.EDIT,
            content = "编辑意见反馈类型",
            appendRequestData = true
    )
    public R<Boolean> updateFeedbackType(@RequestBody XpFeedbackType xpFeedbackType) {
        return R.ok(xpFeedbackTypeService.updateById(xpFeedbackType));
    }
    @ApiOperation(value = "删除意见反馈类型")
    @DeleteMapping(value = "/deleteFeedbackType")
    @AdminOperationLog(
            businessType = AdminBusinessType.FEEDBACK_TYPE_MANAGEMENT,
            operationType = AdminOperationType.DELETE,
            contentExpression = "'删除意见反馈类型,id=' + #p0",
            appendRequestData = false
    )
    public R<Boolean> deleteFeedbackType(Long id) {
        // 判断工单是否包含这个类型
        R<Boolean> include = xpWorkOrderClient.include(id);
        if(include==null || include.getData()){
           throw new ServiceException("该类型被工单引用,无法删除",I18nKeyConstant.INCLUDE);
        }
        return R.ok(xpFeedbackTypeService.removeById(id));
    }
}