Compare commits
11 Commits
d89676296a
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| fe803bfca6 | |||
| 445906fd14 | |||
| a8c771d483 | |||
| 2110c42d21 | |||
| 0341106d14 | |||
| 22140e6588 | |||
| e96f158860 | |||
| fce56b0a7c | |||
| b7b2a7e722 | |||
| 9a4faa65d6 | |||
| 6d6c5f93df |
@@ -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(type = IdType.AUTO)
|
||||||
|
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 EMPLOYEE_BIG_BROTHER_NOT_EXISTS = new ErrorCode(1_001_401_001, "大哥数据员工业务不存在");
|
||||||
ErrorCode COMMENT_NOT_EXISTS = new ErrorCode(1_001_501_001, "AI 评论内容不存在");
|
ErrorCode COMMENT_NOT_EXISTS = new ErrorCode(1_001_501_001, "AI 评论内容不存在");
|
||||||
ErrorCode LANGUAGE_NOT_EXISTS = new ErrorCode(1_001_501_002, "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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -132,6 +132,7 @@ public class EmployeeHostsServiceImpl implements EmployeeHostsService {
|
|||||||
newHostsDOArrayList.add(newHostsDO);
|
newHostsDOArrayList.add(newHostsDO);
|
||||||
EmployeeHostsDO employeeHostsDO = BeanUtils.toBean(employeeHostsSaveReqVO, EmployeeHostsDO.class);
|
EmployeeHostsDO employeeHostsDO = BeanUtils.toBean(employeeHostsSaveReqVO, EmployeeHostsDO.class);
|
||||||
employeeHostsDO.setOperationStatus(0);
|
employeeHostsDO.setOperationStatus(0);
|
||||||
|
employeeHostsDO.setCountryEng(employeeHostsSaveReqVO.getCountryEng());
|
||||||
employeeHostsDOS.add(employeeHostsDO);
|
employeeHostsDOS.add(employeeHostsDO);
|
||||||
}
|
}
|
||||||
Long tenantId = TenantContextHolder.getTenantId();
|
Long tenantId = TenantContextHolder.getTenantId();
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import javax.annotation.Resource;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
@@ -62,18 +63,21 @@ public class NewHostsServiceImpl implements NewHostsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteNewHostsListByIds(List<Long> ids) {
|
public void deleteNewHostsListByIds(List<Long> ids) {
|
||||||
// 校验存在
|
List<NewHostsDO> hostsList = getValidatedNewHosts(ids);
|
||||||
validateNewHostsExists(ids);
|
List<String> hostsIds = hostsList.stream()
|
||||||
// 删除
|
.map(NewHostsDO::getHostsId)
|
||||||
newHostsMapper.deleteByIds(ids);
|
.distinct()
|
||||||
}
|
.collect(Collectors.toList());
|
||||||
|
newHostsMapper.deleteBatch(NewHostsDO::getHostsId, hostsIds);
|
||||||
|
}
|
||||||
|
|
||||||
private void validateNewHostsExists(List<Long> ids) {
|
private List<NewHostsDO> getValidatedNewHosts(List<Long> ids) {
|
||||||
List<NewHostsDO> list = newHostsMapper.selectByIds(ids);
|
List<NewHostsDO> list = newHostsMapper.selectByIds(ids);
|
||||||
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
||||||
throw exception(ErrorCodeConstants.NEW_HOSTS_NOT_EXISTS);
|
throw exception(ErrorCodeConstants.NEW_HOSTS_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateNewHostsExists(Long id) {
|
private void validateNewHostsExists(Long id) {
|
||||||
@@ -111,4 +115,4 @@ public class NewHostsServiceImpl implements NewHostsService {
|
|||||||
newHostsMapper.deleteBatchIds(list);
|
newHostsMapper.deleteBatchIds(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.tkdata.dal.mysql.customserviceinfo.CustomServiceInfoMapper">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||||
|
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||||
|
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||||
|
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||||
|
-->
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -97,12 +97,12 @@
|
|||||||
INSERT IGNORE INTO server_employee_hosts
|
INSERT IGNORE INTO server_employee_hosts
|
||||||
(hosts_id, user_id, hosts_level, hosts_coins, Invitation_type,
|
(hosts_id, user_id, hosts_level, hosts_coins, Invitation_type,
|
||||||
online_fans, fans, fllowernum, yesterday_coins, country,
|
online_fans, fans, fllowernum, yesterday_coins, country,
|
||||||
operation_status, hosts_kind)
|
operation_status, hosts_kind,country_eng)
|
||||||
VALUES
|
VALUES
|
||||||
<foreach collection="list" item="item" separator=",">
|
<foreach collection="list" item="item" separator=",">
|
||||||
(#{item.hostsId}, #{item.userId}, #{item.hostsLevel}, #{item.hostsCoins}, #{item.invitationType},
|
(#{item.hostsId}, #{item.userId}, #{item.hostsLevel}, #{item.hostsCoins}, #{item.invitationType},
|
||||||
#{item.onlineFans}, #{item.fans}, #{item.fllowernum}, #{item.yesterdayCoins}, #{item.country},
|
#{item.onlineFans}, #{item.fans}, #{item.fllowernum}, #{item.yesterdayCoins}, #{item.country},
|
||||||
#{item.operationStatus}, #{item.hostsKind})
|
#{item.operationStatus}, #{item.hostsKind}, #{item.countryEng,jdbcType=VARCHAR})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant;
|
|||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.mzt.logapi.starter.annotation.DiffLogField;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
@@ -24,41 +25,52 @@ public class TenantSaveReqVO {
|
|||||||
|
|
||||||
@Schema(description = "租户名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
@Schema(description = "租户名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||||
@NotNull(message = "租户名不能为空")
|
@NotNull(message = "租户名不能为空")
|
||||||
|
@DiffLogField(name = "租户名")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Schema(description = "联系人", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
@Schema(description = "联系人", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||||
@NotNull(message = "联系人不能为空")
|
@NotNull(message = "联系人不能为空")
|
||||||
|
@DiffLogField(name = "联系人")
|
||||||
private String contactName;
|
private String contactName;
|
||||||
|
|
||||||
@Schema(description = "联系手机", example = "15601691300")
|
@Schema(description = "联系手机", example = "15601691300")
|
||||||
|
@DiffLogField(name = "联系手机")
|
||||||
private String contactMobile;
|
private String contactMobile;
|
||||||
|
|
||||||
@Schema(description = "租户状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "租户状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
@NotNull(message = "租户状态")
|
@NotNull(message = "租户状态")
|
||||||
|
@DiffLogField(name = "租户状态")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@Schema(description = "绑定域名", example = "https://www.iocoder.cn")
|
@Schema(description = "绑定域名", example = "https://www.iocoder.cn")
|
||||||
|
@DiffLogField(name = "绑定域名")
|
||||||
private String website;
|
private String website;
|
||||||
|
|
||||||
@Schema(description = "租户套餐编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "租户套餐编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
@NotNull(message = "租户套餐编号不能为空")
|
@NotNull(message = "租户套餐编号不能为空")
|
||||||
|
@DiffLogField(name = "租户套餐编号")
|
||||||
private Long packageId;
|
private Long packageId;
|
||||||
|
|
||||||
@Schema(description = "过期时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "过期时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotNull(message = "过期时间不能为空")
|
@NotNull(message = "过期时间不能为空")
|
||||||
|
@DiffLogField(name = "过期时间")
|
||||||
private LocalDateTime expireTime;
|
private LocalDateTime expireTime;
|
||||||
|
|
||||||
@Schema(description = "ai过期时间")
|
@Schema(description = "ai过期时间")
|
||||||
|
@DiffLogField(name = "AI 过期时间")
|
||||||
private LocalDateTime aiExpireTime;
|
private LocalDateTime aiExpireTime;
|
||||||
|
|
||||||
@Schema(description = "大哥过期时间")
|
@Schema(description = "大哥过期时间")
|
||||||
|
@DiffLogField(name = "大哥过期时间")
|
||||||
private LocalDateTime brotherExpireTime;
|
private LocalDateTime brotherExpireTime;
|
||||||
|
|
||||||
@Schema(description = "爬主播到期时间")
|
@Schema(description = "爬主播到期时间")
|
||||||
|
@DiffLogField(name = "爬主播到期时间")
|
||||||
private LocalDateTime crawlExpireTime;
|
private LocalDateTime crawlExpireTime;
|
||||||
|
|
||||||
@Schema(description = "账号数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "账号数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
@NotNull(message = "账号数量不能为空")
|
@NotNull(message = "账号数量不能为空")
|
||||||
|
@DiffLogField(name = "账号数量")
|
||||||
private Integer accountCount;
|
private Integer accountCount;
|
||||||
|
|
||||||
// ========== 仅【创建】时,需要传递的字段 ==========
|
// ========== 仅【创建】时,需要传递的字段 ==========
|
||||||
@@ -66,6 +78,7 @@ public class TenantSaveReqVO {
|
|||||||
@Schema(description = "用户账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao")
|
@Schema(description = "用户账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao")
|
||||||
@Pattern(regexp = "^[a-zA-Z0-9]{4,30}$", message = "用户账号由 数字、字母 组成")
|
@Pattern(regexp = "^[a-zA-Z0-9]{4,30}$", message = "用户账号由 数字、字母 组成")
|
||||||
@Size(min = 4, max = 30, message = "用户账号长度为 4-30 个字符")
|
@Size(min = 4, max = 30, message = "用户账号长度为 4-30 个字符")
|
||||||
|
@DiffLogField(name = "管理员账号")
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
||||||
@@ -80,19 +93,24 @@ public class TenantSaveReqVO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Schema(description = "是否允许登录爬虫客户端", example = "0不允许,1允许")
|
@Schema(description = "是否允许登录爬虫客户端", example = "0不允许,1允许")
|
||||||
|
@DiffLogField(name = "允许登录爬虫客户端")
|
||||||
private Byte crawl;
|
private Byte crawl;
|
||||||
|
|
||||||
@Schema(description = "是否允许登录爬虫客户端", example = "0不允许,1允许")
|
@Schema(description = "是否允许登录爬虫客户端", example = "0不允许,1允许")
|
||||||
|
@DiffLogField(name = "允许登录大哥客户端")
|
||||||
private Byte bigBrother;
|
private Byte bigBrother;
|
||||||
|
|
||||||
@Schema(description = "能否登录 AI 聊天工具", example = "0不允许,1允许")
|
@Schema(description = "能否登录 AI 聊天工具", example = "0不允许,1允许")
|
||||||
|
@DiffLogField(name = "允许登录 AI 聊天工具")
|
||||||
private Byte aiChat;
|
private Byte aiChat;
|
||||||
|
|
||||||
@Schema(description = "备注", example = "备注")
|
@Schema(description = "备注", example = "备注")
|
||||||
|
@DiffLogField(name = "备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
@Schema(description = "租户类型", example = "代理/客户")
|
@Schema(description = "租户类型", example = "代理/客户")
|
||||||
@NotNull(message = "租户类型不能为空")
|
@NotNull(message = "租户类型不能为空")
|
||||||
|
@DiffLogField(name = "租户类型")
|
||||||
private String tenantType;
|
private String tenantType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,7 +194,6 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@TenantIgnore
|
|
||||||
@PutMapping("update-client-role")
|
@PutMapping("update-client-role")
|
||||||
@Operation(summary = "修改用户客户端使用权限")
|
@Operation(summary = "修改用户客户端使用权限")
|
||||||
@PreAuthorize("@ss.hasPermission('system:user:update-client')")
|
@PreAuthorize("@ss.hasPermission('system:user:update-client')")
|
||||||
|
|||||||
@@ -1,42 +1,42 @@
|
|||||||
package cn.iocoder.yudao.module.system.controller.admin.user.vo.user;
|
package cn.iocoder.yudao.module.system.controller.admin.user.vo.user;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.iocoder.yudao.module.system.framework.operatelog.core.BooleanParseFunction;
|
||||||
import cn.iocoder.yudao.framework.common.validation.Mobile;
|
|
||||||
import cn.iocoder.yudao.module.system.framework.operatelog.core.DeptParseFunction;
|
|
||||||
import cn.iocoder.yudao.module.system.framework.operatelog.core.PostParseFunction;
|
|
||||||
import cn.iocoder.yudao.module.system.framework.operatelog.core.SexParseFunction;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import com.mzt.logapi.starter.annotation.DiffLogField;
|
import com.mzt.logapi.starter.annotation.DiffLogField;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.hibernate.validator.constraints.Length;
|
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 用户创建客户端用户/修改 Request VO")
|
@Schema(description = "管理后台 - 用户创建客户端用户/修改 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class UserClientSaveReqVO {
|
public class UserClientSaveReqVO {
|
||||||
|
|
||||||
@Schema(description = "用户编号", example = "1024")
|
@Schema(description = "用户编号", example = "1024")
|
||||||
|
@NotNull(message = "用户编号不能为空")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "是否允许登录主播爬虫客户端", example = "0不允许,1允许")
|
@Schema(description = "是否允许登录主播爬虫客户端", example = "0不允许,1允许")
|
||||||
|
@DiffLogField(name = "允许登录主播爬虫客户端", function = BooleanParseFunction.NAME)
|
||||||
private Byte crawl;
|
private Byte crawl;
|
||||||
|
|
||||||
@Schema(description = "是否允许登录大哥爬虫客户端", example = "0不允许,1允许")
|
@Schema(description = "是否允许登录大哥爬虫客户端", example = "0不允许,1允许")
|
||||||
|
@DiffLogField(name = "允许登录大哥爬虫客户端", function = BooleanParseFunction.NAME)
|
||||||
private Byte bigBrother;
|
private Byte bigBrother;
|
||||||
|
|
||||||
@Schema(description = "租户 Id", example = "1")
|
@Schema(description = "租户 Id", example = "1")
|
||||||
|
@DiffLogField(name = "租户编号")
|
||||||
private Long tenantId;
|
private Long tenantId;
|
||||||
|
|
||||||
@Schema(description = "能否登录 AI 聊天工具", example = "0不允许,1允许")
|
@Schema(description = "能否登录 AI 聊天工具", example = "0不允许,1允许")
|
||||||
|
@DiffLogField(name = "允许登录 AI 聊天工具", function = BooleanParseFunction.NAME)
|
||||||
private Byte aiChat;
|
private Byte aiChat;
|
||||||
|
|
||||||
@Schema(description = "是否允许使用 AI 回复", example = "0不允许,1允许")
|
@Schema(description = "是否允许使用 AI 回复", example = "0不允许,1允许")
|
||||||
|
@DiffLogField(name = "允许使用 AI 回复", function = BooleanParseFunction.NAME)
|
||||||
private Byte aiReplay;
|
private Byte aiReplay;
|
||||||
|
|
||||||
@Schema(description = "是否允许登录 Web AI 客户端", example = "0不允许,1允许")
|
@Schema(description = "是否允许登录 Web AI 客户端", example = "0不允许,1允许")
|
||||||
|
@DiffLogField(name = "允许登录 Web AI 客户端", function = BooleanParseFunction.NAME)
|
||||||
private Byte webAi;
|
private Byte webAi;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,4 +190,7 @@ public interface ErrorCodeConstants {
|
|||||||
// ========== 站内信发送 1-002-028-000 ==========
|
// ========== 站内信发送 1-002-028-000 ==========
|
||||||
ErrorCode NOTIFY_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(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, "客服信息不存在");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ public interface LogRecordConstants {
|
|||||||
String SYSTEM_USER_DELETE_SUCCESS = "删除了用户【{{#user.nickname}}】";
|
String SYSTEM_USER_DELETE_SUCCESS = "删除了用户【{{#user.nickname}}】";
|
||||||
String SYSTEM_USER_UPDATE_PASSWORD_SUB_TYPE = "重置用户密码";
|
String SYSTEM_USER_UPDATE_PASSWORD_SUB_TYPE = "重置用户密码";
|
||||||
String SYSTEM_USER_UPDATE_PASSWORD_SUCCESS = "将用户【{{#user.nickname}}】的密码从【{{#user.password}}】重置为【{{#newPassword}}】";
|
String SYSTEM_USER_UPDATE_PASSWORD_SUCCESS = "将用户【{{#user.nickname}}】的密码从【{{#user.password}}】重置为【{{#newPassword}}】";
|
||||||
|
String SYSTEM_USER_UPDATE_CLIENT_ROLE_SUB_TYPE = "更新用户客户端权限";
|
||||||
|
String SYSTEM_USER_UPDATE_CLIENT_ROLE_SUCCESS = "更新了用户【{{#user.username}}】客户端权限{{#clientRoleChangeDetail}}";
|
||||||
|
|
||||||
// ======================= SYSTEM_ROLE 角色 =======================
|
// ======================= SYSTEM_ROLE 角色 =======================
|
||||||
|
|
||||||
@@ -30,4 +32,12 @@ public interface LogRecordConstants {
|
|||||||
String SYSTEM_ROLE_DELETE_SUB_TYPE = "删除角色";
|
String SYSTEM_ROLE_DELETE_SUB_TYPE = "删除角色";
|
||||||
String SYSTEM_ROLE_DELETE_SUCCESS = "删除了角色【{{#role.name}}】";
|
String SYSTEM_ROLE_DELETE_SUCCESS = "删除了角色【{{#role.name}}】";
|
||||||
|
|
||||||
|
// ======================= SYSTEM_TENANT 租户 =======================
|
||||||
|
|
||||||
|
String SYSTEM_TENANT_TYPE = "SYSTEM 租户";
|
||||||
|
String SYSTEM_TENANT_CREATE_SUB_TYPE = "创建租户";
|
||||||
|
String SYSTEM_TENANT_CREATE_SUCCESS = "创建了租户【{{#tenant.name}}】: {_DIFF{#createReqVO}}";
|
||||||
|
String SYSTEM_TENANT_UPDATE_SUB_TYPE = "更新租户";
|
||||||
|
String SYSTEM_TENANT_UPDATE_SUCCESS = "更新了租户【{{#tenant.name}}】: {_DIFF{#updateReqVO}} {{#tenantChangeDetail}}";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ import cn.iocoder.yudao.module.system.service.tenantagencypackage.TenantAgencyPa
|
|||||||
import cn.iocoder.yudao.module.system.service.tenantbalance.TenantBalanceService;
|
import cn.iocoder.yudao.module.system.service.tenantbalance.TenantBalanceService;
|
||||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||||
|
import com.mzt.logapi.context.LogRecordContext;
|
||||||
|
import com.mzt.logapi.service.impl.DiffParseFunction;
|
||||||
|
import com.mzt.logapi.starter.annotation.LogRecord;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@@ -64,6 +67,7 @@ import javax.annotation.Resource;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -73,6 +77,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
||||||
|
import static cn.iocoder.yudao.module.system.enums.LogRecordConstants.*;
|
||||||
import static java.util.Collections.singleton;
|
import static java.util.Collections.singleton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -195,23 +200,32 @@ public class TenantServiceImpl implements TenantService {
|
|||||||
throw exception(TENANT_BALANCE_NOT_ENOUGH);
|
throw exception(TENANT_BALANCE_NOT_ENOUGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.notEqual(targetTenant.getPackageId(), updateReqVO.getPackageId())) {
|
||||||
|
targetTenant.setPackageId(tenantAgencyPackage.getId());
|
||||||
|
tenantMapper.updateById(targetTenant);
|
||||||
|
}
|
||||||
|
|
||||||
if (balanceService.consumption(tenantAgencyPackage.getId(), targetTenant.getId(), updateReqVO.getRemark())) {
|
if (balanceService.consumption(tenantAgencyPackage.getId(), targetTenant.getId(), updateReqVO.getRemark())) {
|
||||||
log.info("代理: {} 续费租户:{} 成功,套餐 Id:{}", currentTenantId,targetTenant.getId(),updateReqVO.getPackageId());
|
log.info("代理: {} 续费租户:{} 成功,套餐 Id:{}", currentTenantId,targetTenant.getId(),updateReqVO.getPackageId());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetTenant.getCrawlExpireTime().isBefore(LocalDateTime.now())){
|
|
||||||
targetTenant.setCrawlExpireTime(LocalDateTime.now().plusDays(tenantAgencyPackage.getDays()));
|
if (tenantAgencyPackage.getHostslClient()==1){
|
||||||
targetTenant.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
if (targetTenant.getCrawlExpireTime().isBefore(LocalDateTime.now())){
|
||||||
targetTenantUser.setCrawl((byte) 1);
|
targetTenant.setCrawlExpireTime(LocalDateTime.now().plusDays(tenantAgencyPackage.getDays()));
|
||||||
}else {
|
targetTenant.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||||
targetTenant.setCrawlExpireTime(targetTenant.getCrawlExpireTime().plusDays(tenantAgencyPackage.getDays()));
|
targetTenantUser.setCrawl((byte) 1);
|
||||||
|
}else {
|
||||||
|
targetTenant.setCrawlExpireTime(targetTenant.getCrawlExpireTime().plusDays(tenantAgencyPackage.getDays()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tenantAgencyPackage.getAiClient()==1){
|
if (tenantAgencyPackage.getWebAi()==1){
|
||||||
if (targetTenant.getAiExpireTime().isBefore(LocalDateTime.now())){
|
if (targetTenant.getAiExpireTime().isBefore(LocalDateTime.now())){
|
||||||
targetTenant.setAiExpireTime(LocalDateTime.now().plusDays(tenantAgencyPackage.getDays()));
|
targetTenant.setAiExpireTime(LocalDateTime.now().plusDays(tenantAgencyPackage.getDays()));
|
||||||
targetTenantUser.setAiReplay((byte) 1);
|
targetTenantUser.setAiReplay((byte) 1);
|
||||||
targetTenantUser.setAiChat((byte) 1);
|
targetTenantUser.setAiChat((byte) 1);
|
||||||
|
targetTenantUser.setWebAi((byte) 1);
|
||||||
}else {
|
}else {
|
||||||
targetTenant.setAiExpireTime(targetTenant.getAiExpireTime().plusDays(tenantAgencyPackage.getDays()));
|
targetTenant.setAiExpireTime(targetTenant.getAiExpireTime().plusDays(tenantAgencyPackage.getDays()));
|
||||||
}
|
}
|
||||||
@@ -225,6 +239,8 @@ public class TenantServiceImpl implements TenantService {
|
|||||||
targetTenant.setBrotherExpireTime(targetTenant.getBrotherExpireTime().plusDays(tenantAgencyPackage.getDays()));
|
targetTenant.setBrotherExpireTime(targetTenant.getBrotherExpireTime().plusDays(tenantAgencyPackage.getDays()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int updateInitialUserCount = userMapper.updateByIdWithRenwal(targetTenantUser);
|
int updateInitialUserCount = userMapper.updateByIdWithRenwal(targetTenantUser);
|
||||||
if (updateInitialUserCount <= 0) {
|
if (updateInitialUserCount <= 0) {
|
||||||
throw exception(TENANT_UPDATE_INITIAL_USER_INFO_FAIL);
|
throw exception(TENANT_UPDATE_INITIAL_USER_INFO_FAIL);
|
||||||
@@ -299,6 +315,8 @@ public class TenantServiceImpl implements TenantService {
|
|||||||
@Override
|
@Override
|
||||||
@DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换
|
@DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换
|
||||||
@DataPermission(enable = false) // 参见 https://gitee.com/zhijiantianya/ruoyi-vue-pro/pulls/1154 说明
|
@DataPermission(enable = false) // 参见 https://gitee.com/zhijiantianya/ruoyi-vue-pro/pulls/1154 说明
|
||||||
|
@LogRecord(type = SYSTEM_TENANT_TYPE, subType = SYSTEM_TENANT_CREATE_SUB_TYPE, bizNo = "{{#tenant.id}}",
|
||||||
|
success = SYSTEM_TENANT_CREATE_SUCCESS)
|
||||||
public Long createTenant(TenantSaveReqVO createReqVO) {
|
public Long createTenant(TenantSaveReqVO createReqVO) {
|
||||||
|
|
||||||
// 获取当前操作租户的ID(即创建者的租户ID)
|
// 获取当前操作租户的ID(即创建者的租户ID)
|
||||||
@@ -330,13 +348,16 @@ public class TenantServiceImpl implements TenantService {
|
|||||||
LocalDateTime localDateTime = LocalDateTimeUtil.of(dt); // 转换为LocalDateTime对象
|
LocalDateTime localDateTime = LocalDateTimeUtil.of(dt); // 转换为LocalDateTime对象
|
||||||
// 根据套餐天数计算过期时间:当前时间 + 套餐天数
|
// 根据套餐天数计算过期时间:当前时间 + 套餐天数
|
||||||
LocalDateTime offset = LocalDateTimeUtil.offset(localDateTime, tenantAgencyPackageDO.getDays(), ChronoUnit.DAYS);
|
LocalDateTime offset = LocalDateTimeUtil.offset(localDateTime, tenantAgencyPackageDO.getDays(), ChronoUnit.DAYS);
|
||||||
|
|
||||||
// 设置租户的基本过期时间
|
// 设置租户的基本过期时间
|
||||||
tenant.setExpireTime(offset);
|
tenant.setExpireTime(REGISTER_EXPIRE_TIME);
|
||||||
// 设置租户的初始用户名(创建者)
|
// 设置租户的初始用户名(创建者)
|
||||||
tenant.setInitialUser(createReqVO.getUsername());
|
tenant.setInitialUser(createReqVO.getUsername());
|
||||||
|
|
||||||
// 根据套餐配置设置特定功能的过期时间
|
// 根据套餐配置设置特定功能的过期时间
|
||||||
|
// 如果套餐包含"爬虫客户端"功能,则设置爬虫客户端的过期时间
|
||||||
|
if (tenantAgencyPackageDO.getHostslClient() == 1){
|
||||||
|
tenant.setCrawlExpireTime(offset);
|
||||||
|
}
|
||||||
// 如果套餐包含"大哥客户端"功能,则设置大哥客户端的过期时间
|
// 如果套餐包含"大哥客户端"功能,则设置大哥客户端的过期时间
|
||||||
if (tenantAgencyPackageDO.getBrotherClient() == 1){
|
if (tenantAgencyPackageDO.getBrotherClient() == 1){
|
||||||
tenant.setBrotherExpireTime(offset);
|
tenant.setBrotherExpireTime(offset);
|
||||||
@@ -410,6 +431,8 @@ public class TenantServiceImpl implements TenantService {
|
|||||||
tenantBalanceMapper.insert(tenantBalance); // 插入钱包记录
|
tenantBalanceMapper.insert(tenantBalance); // 插入钱包记录
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, new TenantSaveReqVO());
|
||||||
|
LogRecordContext.putVariable("tenant", tenant);
|
||||||
// 返回新创建的租户ID
|
// 返回新创建的租户ID
|
||||||
return tenant.getId();
|
return tenant.getId();
|
||||||
}
|
}
|
||||||
@@ -466,6 +489,8 @@ public class TenantServiceImpl implements TenantService {
|
|||||||
tenantBalanceMapper.insert(tenantBalance); // 插入钱包记录
|
tenantBalanceMapper.insert(tenantBalance); // 插入钱包记录
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, new TenantSaveReqVO());
|
||||||
|
LogRecordContext.putVariable("tenant", tenant);
|
||||||
// 返回新创建的租户ID
|
// 返回新创建的租户ID
|
||||||
return tenant.getId();
|
return tenant.getId();
|
||||||
}
|
}
|
||||||
@@ -502,6 +527,8 @@ public class TenantServiceImpl implements TenantService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换
|
@DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换
|
||||||
|
@LogRecord(type = SYSTEM_TENANT_TYPE, subType = SYSTEM_TENANT_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}",
|
||||||
|
success = SYSTEM_TENANT_UPDATE_SUCCESS)
|
||||||
public void updateTenant(TenantSaveReqVO updateReqVO) {
|
public void updateTenant(TenantSaveReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
TenantDO tenant = validateUpdateTenant(updateReqVO.getId());
|
TenantDO tenant = validateUpdateTenant(updateReqVO.getId());
|
||||||
@@ -511,7 +538,7 @@ public class TenantServiceImpl implements TenantService {
|
|||||||
validTenantWebsiteDuplicate(updateReqVO.getWebsite(), updateReqVO.getId());
|
validTenantWebsiteDuplicate(updateReqVO.getWebsite(), updateReqVO.getId());
|
||||||
// 校验套餐被禁用
|
// 校验套餐被禁用
|
||||||
|
|
||||||
if (updateReqVO.getTenantType().equals(TenantEnum.AGENCY.getTenantType()) || tenant.getParentId() != 1) {
|
if (updateReqVO.getTenantType().equals(TenantEnum.AGENCY.getTenantType()) && tenant.getParentId() != 1) {
|
||||||
TenantAgencyPackageDO tenantAgencyPackageDO = tenantAgencyPackageService.validTenantPackage(updateReqVO.getPackageId());
|
TenantAgencyPackageDO tenantAgencyPackageDO = tenantAgencyPackageService.validTenantPackage(updateReqVO.getPackageId());
|
||||||
// 更新租户
|
// 更新租户
|
||||||
TenantDO updateObj = BeanUtils.toBean(updateReqVO, TenantDO.class);
|
TenantDO updateObj = BeanUtils.toBean(updateReqVO, TenantDO.class);
|
||||||
@@ -531,8 +558,12 @@ public class TenantServiceImpl implements TenantService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(tenant, TenantSaveReqVO.class));
|
||||||
|
LogRecordContext.putVariable("tenant", tenant);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void validTenantNameDuplicate(String name, Long id) {
|
private void validTenantNameDuplicate(String name, Long id) {
|
||||||
TenantDO tenant = tenantMapper.selectByName(name);
|
TenantDO tenant = tenantMapper.selectByName(name);
|
||||||
if (tenant == null) {
|
if (tenant == null) {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
|||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
|
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
|
||||||
import cn.iocoder.yudao.framework.datapermission.core.util.DataPermissionUtils;
|
import cn.iocoder.yudao.framework.datapermission.core.util.DataPermissionUtils;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
||||||
import cn.iocoder.yudao.module.infra.api.config.ConfigApi;
|
import cn.iocoder.yudao.module.infra.api.config.ConfigApi;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthRegisterReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthRegisterReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO;
|
||||||
@@ -547,10 +547,74 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@LogRecord(type = SYSTEM_USER_TYPE, subType = SYSTEM_USER_UPDATE_CLIENT_ROLE_SUB_TYPE, bizNo = "{{#user.id}}",
|
||||||
|
success = SYSTEM_USER_UPDATE_CLIENT_ROLE_SUCCESS)
|
||||||
public void updateUserWithClientRole(UserClientSaveReqVO reqVO) {
|
public void updateUserWithClientRole(UserClientSaveReqVO reqVO) {
|
||||||
|
// 1. 校验用户存在
|
||||||
|
AdminUserDO oldUser = TenantUtils.executeIgnore(() -> validateUserExists(reqVO.getId()));
|
||||||
|
fillUserClientRoleReqIfAbsent(reqVO, oldUser);
|
||||||
|
LogRecordContext.putVariable("user", oldUser);
|
||||||
|
LogRecordContext.putVariable("clientRoleChangeDetail", buildClientRoleChangeDetail(oldUser, reqVO));
|
||||||
|
|
||||||
// 2.1 更新用户
|
// 2.1 更新用户
|
||||||
AdminUserDO updateObj = BeanUtils.toBean(reqVO, AdminUserDO.class);
|
AdminUserDO updateObj = BeanUtils.toBean(reqVO, AdminUserDO.class);
|
||||||
userMapper.updateById(updateObj);
|
TenantUtils.executeIgnore(() -> userMapper.updateById(updateObj));
|
||||||
|
|
||||||
|
// 3. 记录操作日志上下文
|
||||||
|
LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldUser, UserClientSaveReqVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillUserClientRoleReqIfAbsent(UserClientSaveReqVO reqVO, AdminUserDO oldUser) {
|
||||||
|
if (reqVO.getTenantId() == null) {
|
||||||
|
reqVO.setTenantId(oldUser.getTenantId());
|
||||||
|
}
|
||||||
|
if (reqVO.getCrawl() == null) {
|
||||||
|
reqVO.setCrawl(oldUser.getCrawl());
|
||||||
|
}
|
||||||
|
if (reqVO.getBigBrother() == null) {
|
||||||
|
reqVO.setBigBrother(oldUser.getBigBrother());
|
||||||
|
}
|
||||||
|
if (reqVO.getAiChat() == null) {
|
||||||
|
reqVO.setAiChat(oldUser.getAiChat());
|
||||||
|
}
|
||||||
|
if (reqVO.getAiReplay() == null) {
|
||||||
|
reqVO.setAiReplay(oldUser.getAiReplay());
|
||||||
|
}
|
||||||
|
if (reqVO.getWebAi() == null) {
|
||||||
|
reqVO.setWebAi(oldUser.getWebAi());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildClientRoleChangeDetail(AdminUserDO oldUser, UserClientSaveReqVO reqVO) {
|
||||||
|
List<String> changes = new ArrayList<>();
|
||||||
|
appendClientRoleChange(changes, "允许登录主播爬虫客户端", oldUser.getCrawl(), reqVO.getCrawl());
|
||||||
|
appendClientRoleChange(changes, "允许登录大哥爬虫客户端", oldUser.getBigBrother(), reqVO.getBigBrother());
|
||||||
|
appendClientRoleChange(changes, "允许登录 AI 聊天工具", oldUser.getAiChat(), reqVO.getAiChat());
|
||||||
|
appendClientRoleChange(changes, "允许使用 AI 回复", oldUser.getAiReplay(), reqVO.getAiReplay());
|
||||||
|
appendClientRoleChange(changes, "允许登录 Web AI 客户端", oldUser.getWebAi(), reqVO.getWebAi());
|
||||||
|
if (changes.isEmpty()) {
|
||||||
|
return "(未发现字段变更)";
|
||||||
|
}
|
||||||
|
return "(变更明细:" + String.join(";", changes) + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void appendClientRoleChange(List<String> changes, String fieldName, Byte oldValue, Byte newValue) {
|
||||||
|
if (ObjUtil.notEqual(oldValue, newValue)) {
|
||||||
|
changes.add(fieldName + ":【" + formatClientRoleValue(oldValue) + "】->【" + formatClientRoleValue(newValue) + "】");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String formatClientRoleValue(Byte value) {
|
||||||
|
if (value == null) {
|
||||||
|
return "-";
|
||||||
|
}
|
||||||
|
if (value == 1) {
|
||||||
|
return "允许";
|
||||||
|
}
|
||||||
|
if (value == 0) {
|
||||||
|
return "不允许";
|
||||||
|
}
|
||||||
|
return String.valueOf(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user