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));
|
}
|
|
}
|