feat(tkdata): 新增客服信息管理模块
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
package cn.iocoder.yudao.module.tkdata.controller.admin.customserviceinfo;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.tkdata.controller.admin.customserviceinfo.vo.*;
|
||||
import cn.iocoder.yudao.module.tkdata.dal.dataobject.customserviceinfo.CustomServiceInfoDO;
|
||||
import cn.iocoder.yudao.module.tkdata.service.customserviceinfo.CustomServiceInfoService;
|
||||
|
||||
@Tag(name = "管理后台 - 客服信息")
|
||||
@RestController
|
||||
@RequestMapping("/server/custom-service-info")
|
||||
@Validated
|
||||
public class CustomServiceInfoController {
|
||||
|
||||
@Resource
|
||||
private CustomServiceInfoService customServiceInfoService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建客服信息")
|
||||
@PreAuthorize("@ss.hasPermission('server:custom-service-info:create')")
|
||||
public CommonResult<Long> createCustomServiceInfo(@Valid @RequestBody CustomServiceInfoSaveReqVO createReqVO) {
|
||||
return success(customServiceInfoService.createCustomServiceInfo(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新客服信息")
|
||||
@PreAuthorize("@ss.hasPermission('server:custom-service-info:update')")
|
||||
public CommonResult<Boolean> updateCustomServiceInfo(@Valid @RequestBody CustomServiceInfoSaveReqVO updateReqVO) {
|
||||
customServiceInfoService.updateCustomServiceInfo(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除客服信息")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('server:custom-service-info:delete')")
|
||||
public CommonResult<Boolean> deleteCustomServiceInfo(@RequestParam("id") Long id) {
|
||||
customServiceInfoService.deleteCustomServiceInfo(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除客服信息")
|
||||
@PreAuthorize("@ss.hasPermission('server:custom-service-info:delete')")
|
||||
public CommonResult<Boolean> deleteCustomServiceInfoList(@RequestParam("ids") List<Long> ids) {
|
||||
customServiceInfoService.deleteCustomServiceInfoListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得客服信息")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('server:custom-service-info:query')")
|
||||
public CommonResult<CustomServiceInfoRespVO> getCustomServiceInfo(@RequestParam("id") Long id) {
|
||||
CustomServiceInfoDO customServiceInfo = customServiceInfoService.getCustomServiceInfo(id);
|
||||
return success(BeanUtils.toBean(customServiceInfo, CustomServiceInfoRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得客服信息分页")
|
||||
@PreAuthorize("@ss.hasPermission('server:custom-service-info:query')")
|
||||
public CommonResult<PageResult<CustomServiceInfoRespVO>> getCustomServiceInfoPage(@Valid CustomServiceInfoPageReqVO pageReqVO) {
|
||||
PageResult<CustomServiceInfoDO> pageResult = customServiceInfoService.getCustomServiceInfoPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, CustomServiceInfoRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出客服信息 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('server:custom-service-info:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportCustomServiceInfoExcel(@Valid CustomServiceInfoPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<CustomServiceInfoDO> list = customServiceInfoService.getCustomServiceInfoPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "客服信息.xls", "数据", CustomServiceInfoRespVO.class,
|
||||
BeanUtils.toBean(list, CustomServiceInfoRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.iocoder.yudao.module.tkdata.controller.admin.customserviceinfo.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 客服信息分页 Request VO")
|
||||
@Data
|
||||
public class CustomServiceInfoPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "姓名", example = "芋艿")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "头像")
|
||||
private String avater;
|
||||
|
||||
@Schema(description = "简介", example = "你说的对")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "微信")
|
||||
private String concat;
|
||||
|
||||
@Schema(description = "手机号")
|
||||
private String phone;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package cn.iocoder.yudao.module.tkdata.controller.admin.customserviceinfo.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 客服信息 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class CustomServiceInfoRespVO {
|
||||
|
||||
@Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "17699")
|
||||
@ExcelProperty("主键id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "姓名", example = "芋艿")
|
||||
@ExcelProperty("姓名")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "头像")
|
||||
@ExcelProperty("头像")
|
||||
private String avater;
|
||||
|
||||
@Schema(description = "简介", example = "你说的对")
|
||||
@ExcelProperty("简介")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "微信")
|
||||
@ExcelProperty("微信")
|
||||
private String concat;
|
||||
|
||||
@Schema(description = "手机号")
|
||||
@ExcelProperty("手机号")
|
||||
private String phone;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.tkdata.controller.admin.customserviceinfo.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 客服信息新增/修改 Request VO")
|
||||
@Data
|
||||
public class CustomServiceInfoSaveReqVO {
|
||||
|
||||
@Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "17699")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "姓名", example = "芋艿")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "头像")
|
||||
private String avater;
|
||||
|
||||
@Schema(description = "简介", example = "你说的对")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "微信")
|
||||
private String concat;
|
||||
|
||||
@Schema(description = "手机号")
|
||||
private String phone;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.tkdata.dal.dataobject.customserviceinfo;
|
||||
|
||||
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 客服信息 DO
|
||||
*
|
||||
* @author ziin
|
||||
*/
|
||||
@TableName("server_custom_service_info")
|
||||
@KeySequence("server_custom_service_info_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TenantIgnore
|
||||
public class CustomServiceInfoDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avater;
|
||||
/**
|
||||
* 简介
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 微信
|
||||
*/
|
||||
private String concat;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.tkdata.dal.mysql.customserviceinfo;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.tkdata.dal.dataobject.customserviceinfo.CustomServiceInfoDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.tkdata.controller.admin.customserviceinfo.vo.*;
|
||||
|
||||
/**
|
||||
* 客服信息 Mapper
|
||||
*
|
||||
* @author ziin
|
||||
*/
|
||||
@Mapper
|
||||
public interface CustomServiceInfoMapper extends BaseMapperX<CustomServiceInfoDO> {
|
||||
|
||||
default PageResult<CustomServiceInfoDO> selectPage(CustomServiceInfoPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<CustomServiceInfoDO>()
|
||||
.likeIfPresent(CustomServiceInfoDO::getName, reqVO.getName())
|
||||
.eqIfPresent(CustomServiceInfoDO::getAvater, reqVO.getAvater())
|
||||
.eqIfPresent(CustomServiceInfoDO::getDescription, reqVO.getDescription())
|
||||
.eqIfPresent(CustomServiceInfoDO::getConcat, reqVO.getConcat())
|
||||
.eqIfPresent(CustomServiceInfoDO::getPhone, reqVO.getPhone())
|
||||
.betweenIfPresent(CustomServiceInfoDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(CustomServiceInfoDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,4 +16,5 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode EMPLOYEE_BIG_BROTHER_NOT_EXISTS = new ErrorCode(1_001_401_001, "大哥数据员工业务不存在");
|
||||
ErrorCode COMMENT_NOT_EXISTS = new ErrorCode(1_001_501_001, "AI 评论内容不存在");
|
||||
ErrorCode LANGUAGE_NOT_EXISTS = new ErrorCode(1_001_501_002, "AI 语言种类不存在");
|
||||
ErrorCode CUSTOM_SERVICE_INFO_NOT_EXISTS = new ErrorCode(1_002_029_001,"客服信息不存在");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package cn.iocoder.yudao.module.tkdata.service.customserviceinfo;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.tkdata.controller.admin.customserviceinfo.vo.*;
|
||||
import cn.iocoder.yudao.module.tkdata.dal.dataobject.customserviceinfo.CustomServiceInfoDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 客服信息 Service 接口
|
||||
*
|
||||
* @author ziin
|
||||
*/
|
||||
public interface CustomServiceInfoService {
|
||||
|
||||
/**
|
||||
* 创建客服信息
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createCustomServiceInfo(@Valid CustomServiceInfoSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新客服信息
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateCustomServiceInfo(@Valid CustomServiceInfoSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除客服信息
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteCustomServiceInfo(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除客服信息
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteCustomServiceInfoListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得客服信息
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 客服信息
|
||||
*/
|
||||
CustomServiceInfoDO getCustomServiceInfo(Long id);
|
||||
|
||||
/**
|
||||
* 获得客服信息分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 客服信息分页
|
||||
*/
|
||||
PageResult<CustomServiceInfoDO> getCustomServiceInfoPage(CustomServiceInfoPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package cn.iocoder.yudao.module.tkdata.service.customserviceinfo;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.tkdata.controller.admin.customserviceinfo.vo.CustomServiceInfoPageReqVO;
|
||||
import cn.iocoder.yudao.module.tkdata.controller.admin.customserviceinfo.vo.CustomServiceInfoSaveReqVO;
|
||||
import cn.iocoder.yudao.module.tkdata.dal.dataobject.customserviceinfo.CustomServiceInfoDO;
|
||||
import cn.iocoder.yudao.module.tkdata.dal.mysql.customserviceinfo.CustomServiceInfoMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;import static cn.iocoder.yudao.module.tkdata.enums.ErrorCodeConstants.CUSTOM_SERVICE_INFO_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 客服信息 Service 实现类
|
||||
*
|
||||
* @author ziin
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class CustomServiceInfoServiceImpl implements CustomServiceInfoService {
|
||||
|
||||
@Resource
|
||||
private CustomServiceInfoMapper customServiceInfoMapper;
|
||||
|
||||
@Override
|
||||
public Long createCustomServiceInfo(CustomServiceInfoSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
CustomServiceInfoDO customServiceInfo = BeanUtils.toBean(createReqVO, CustomServiceInfoDO.class);
|
||||
customServiceInfoMapper.insert(customServiceInfo);
|
||||
// 返回
|
||||
return customServiceInfo.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCustomServiceInfo(CustomServiceInfoSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateCustomServiceInfoExists(updateReqVO.getId());
|
||||
// 更新
|
||||
CustomServiceInfoDO updateObj = BeanUtils.toBean(updateReqVO, CustomServiceInfoDO.class);
|
||||
customServiceInfoMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCustomServiceInfo(Long id) {
|
||||
// 校验存在
|
||||
validateCustomServiceInfoExists(id);
|
||||
// 删除
|
||||
customServiceInfoMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCustomServiceInfoListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateCustomServiceInfoExists(ids);
|
||||
// 删除
|
||||
customServiceInfoMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
private void validateCustomServiceInfoExists(List<Long> ids) {
|
||||
List<CustomServiceInfoDO> list = customServiceInfoMapper.selectByIds(ids);
|
||||
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
||||
throw exception(CUSTOM_SERVICE_INFO_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateCustomServiceInfoExists(Long id) {
|
||||
if (customServiceInfoMapper.selectById(id) == null) {
|
||||
throw exception(CUSTOM_SERVICE_INFO_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomServiceInfoDO getCustomServiceInfo(Long id) {
|
||||
return customServiceInfoMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<CustomServiceInfoDO> getCustomServiceInfoPage(CustomServiceInfoPageReqVO pageReqVO) {
|
||||
return customServiceInfoMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.server.dal.mysql.customserviceinfo.CustomServiceInfoMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
@@ -190,4 +190,7 @@ public interface ErrorCodeConstants {
|
||||
// ========== 站内信发送 1-002-028-000 ==========
|
||||
ErrorCode NOTIFY_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_028_000, "模板参数({})缺失");
|
||||
|
||||
// ========== 客服信息 1-002-029-000 ==========
|
||||
ErrorCode CUSTOM_SERVICE_INFO_NOT_EXISTS = new ErrorCode(1_002_029_001, "客服信息不存在");
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user