guohongjin
2024-05-01 1901fceb6ddaa56a57f3131191454554c3e77e68
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package cn.stylefeng.guns.modular.business.controller;
 
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.StrUtil;
import cn.stylefeng.guns.modular.business.entity.SystemSet;
import cn.stylefeng.guns.modular.business.service.ISystemSetService;
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.annotation.BusinessLog;
import cn.stylefeng.roses.kernel.rule.enums.ResBizTypeEnum;
import cn.stylefeng.roses.kernel.rule.pojo.response.ErrorResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.List;
 
/**
 * 系统配置(H5、客服电话)管理类
 * @author guo
 */
@RestController
@Api(tags = "系统配置(H5、客服电话)管理类")
@ApiResource(name = "系统配置(H5、客服电话)管理类", resBizType = ResBizTypeEnum.BUSINESS)
@RequestMapping("/business")
public class SystemSetController  {
 
    @Resource
    private ISystemSetService systemSetService;
 
//    @ApiOperation("添加系统配置(H5、客服电话)")
//    @PostResource(name = "添加系统配置(H5、客服电话)", path = "/systemSet/add")
//    @BusinessLog
//    public ResponseData<?> add(@RequestBody SystemSet systemSet) {
//
//        this.systemSetService.save(systemSet);
//        return new SuccessResponseData<>();
//    }
 
    /**
     * 删除系统配置(H5、客服电话)
     */
    @ApiOperation("删除系统配置(H5、客服电话)")
    @PostResource(name = "删除系统配置(H5、客服电话)", path = "/systemSet/delete")
    @BusinessLog
    public ResponseData<?> delete(@RequestParam String ids) {
        if (StrUtil.isBlank(ids)){
            return new ErrorResponseData<>("500","id不能为空");
        }
        this.systemSetService.removeBatchByIds(ListUtil.toList(ids.split(",")));
        return new SuccessResponseData<>();
    }
 
    /**
     * 修改系统配置(H5、客服电话)
     */
    @ApiOperation("修改系统配置(H5、客服电话,咨询合同h5)")
    @PostResource(name = "修改系统配置(H5、客服电话,咨询合同h5)", path = "/systemSet/edit")
    @BusinessLog
    public ResponseData<?> edit(@RequestBody SystemSet systemSet) {
        LambdaQueryWrapper<SystemSet> wrapper = new LambdaQueryWrapper<SystemSet>()
                .eq(SystemSet::getId, systemSet.getId());
        if (StrUtil.isNotEmpty(systemSet.getKeyStr())) {
            wrapper.or().eq(SystemSet::getKeyStr, systemSet.getKeyStr());
        }
 
        SystemSet systemSet1 = this.systemSetService.getOne(wrapper);
        if (systemSet1 != null) {
            systemSet1.setContent(systemSet.getContent());
        } else {
            return new ErrorResponseData<>("500", "数据异常!");
        }
        this.systemSetService.update(new LambdaUpdateWrapper<SystemSet>().set(SystemSet::getContent,StrUtil.isBlank(systemSet.getContent())?null:systemSet.getContent())
                .eq(SystemSet::getId,systemSet1.getId()));
        return new SuccessResponseData<>();
    }
 
    /**
     * 获取系统配置(H5、客服电话)详情
     */
    @ApiOperation("获取系统配置(H5、客服电话)详情")
    @GetResource(name = "获取系统配置(H5、客服电话)详情", path = "/systemSet/detail/{id}", requiredPermission = false)
    public ResponseData<SystemSet> detail(@PathVariable("id") Long id) {
        SystemSet systemSet = this.systemSetService.getById(id);
        return new SuccessResponseData<>(systemSet);
    }
 
    @ApiOperation("根据key获取系统配置详情 COUNSELLING_CONTRACT-咨询合同h5,CUSTOMER_SERVICE_NUMBER-客服电话,COOPERATIVE_ENTERPRISE-合作企业h5")
    @GetResource(name = "根据key获取系统配置详情", path = "/systemSet/detailKey/{key}", requiredPermission = false)
    public ResponseData<SystemSet> detailKey(@PathVariable("key") String key) {
        SystemSet systemSet = this.systemSetService.getOne(new LambdaQueryWrapper<SystemSet>().eq(SystemSet::getKeyStr, key));
        return new SuccessResponseData<>(systemSet);
    }
    /**
     * 获取系统配置(H5、客服电话)列表
     */
    @ApiOperation("获取系统配置(H5、客服电话)列表")
    @GetResource(name = "获取系统配置(H5、客服电话)列表", path = "/systemSet/list", requiredPermission = false)
    public ResponseData<List<SystemSet>> list(SystemSet systemSet) {
        LambdaQueryWrapper<SystemSet> lambdaQueryWrapper = new LambdaQueryWrapper<SystemSet>()
                .eq(systemSet.getId() != null, SystemSet::getId, systemSet.getId())
                .eq(StrUtil.isNotEmpty(systemSet.getKeyStr()), SystemSet::getKeyStr, systemSet.getKeyStr())
                .like(StrUtil.isNotEmpty(systemSet.getRemark()), SystemSet::getRemark, systemSet.getRemark())
                .orderByDesc(SystemSet::getId);
        return new SuccessResponseData<>(systemSetService.list(lambdaQueryWrapper));
    }
 
    /**
     * 获取系统配置(H5、客服电话)列表(分页)
     */
    @ApiOperation("获取系统配置(H5、客服电话)列表(分页)")
    @GetResource(name = "获取系统配置(H5、客服电话)列表(分页)", path = "/systemSet/page", requiredPermission = false)
    public ResponseData<PageResult<SystemSet>> page(SystemSet systemSet) {
        LambdaQueryWrapper<SystemSet> lambdaQueryWrapper = new LambdaQueryWrapper<SystemSet>()
                .eq(systemSet.getId() != null, SystemSet::getId, systemSet.getId())
                .eq(StrUtil.isNotEmpty(systemSet.getKeyStr()), SystemSet::getKeyStr, systemSet.getKeyStr())
                .like(StrUtil.isNotEmpty(systemSet.getRemark()), SystemSet::getRemark, systemSet.getRemark())
                .orderByDesc(SystemSet::getId);
        Page<SystemSet> page = this.systemSetService.page(PageFactory.defaultPage(), lambdaQueryWrapper);
        return new SuccessResponseData<>(PageResultFactory.createPageResult(page));
    }
 
}