Compare commits
15 Commits
a685e4b5cb
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| fe803bfca6 | |||
| 445906fd14 | |||
| a8c771d483 | |||
| 2110c42d21 | |||
| 0341106d14 | |||
| 22140e6588 | |||
| e96f158860 | |||
| fce56b0a7c | |||
| b7b2a7e722 | |||
| 9a4faa65d6 | |||
| 6d6c5f93df | |||
| d89676296a | |||
| 0d32dc67e9 | |||
| 432ed8adf8 | |||
| eb936ce677 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -62,3 +62,5 @@ application-my.yaml
|
|||||||
/.claude/agents/backend-architect.md
|
/.claude/agents/backend-architect.md
|
||||||
/tkdata-model-server-issues.md
|
/tkdata-model-server-issues.md
|
||||||
/CLAUDE.md
|
/CLAUDE.md
|
||||||
|
/.omc/
|
||||||
|
/AGENTS.md
|
||||||
|
|||||||
@@ -44,4 +44,7 @@ public class CountryInfoRespVO {
|
|||||||
@ExcelProperty("创建时间")
|
@ExcelProperty("创建时间")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "国家英文名")
|
||||||
|
@ExcelProperty("国家英文名")
|
||||||
|
private String countryNameEnglish;
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -47,5 +47,5 @@ public class CountryInfoDO {
|
|||||||
*/
|
*/
|
||||||
private String languageName;
|
private String languageName;
|
||||||
|
|
||||||
|
private String countryNameEnglish;
|
||||||
}
|
}
|
||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
package cn.iocoder.yudao.framework.operatelog.core.service;
|
package cn.iocoder.yudao.framework.operatelog.core.service;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.biz.system.logger.OperateLogCommonApi;
|
import cn.iocoder.yudao.framework.common.biz.system.logger.OperateLogCommonApi;
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||||
import cn.iocoder.yudao.framework.common.biz.system.logger.dto.OperateLogCreateReqDTO;
|
import cn.iocoder.yudao.framework.common.biz.system.logger.dto.OperateLogCreateReqDTO;
|
||||||
import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
|
import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
|
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
||||||
import com.mzt.logapi.beans.LogRecord;
|
import com.mzt.logapi.beans.LogRecord;
|
||||||
import com.mzt.logapi.service.ILogRecordService;
|
import com.mzt.logapi.service.ILogRecordService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -50,11 +52,16 @@ public class LogRecordServiceImpl implements ILogRecordService {
|
|||||||
private static void fillUserFields(OperateLogCreateReqDTO reqDTO) {
|
private static void fillUserFields(OperateLogCreateReqDTO reqDTO) {
|
||||||
// 使用 SecurityFrameworkUtils。因为要考虑,rpc、mq、job,它其实不是 web;
|
// 使用 SecurityFrameworkUtils。因为要考虑,rpc、mq、job,它其实不是 web;
|
||||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||||
if (loginUser == null) {
|
if (loginUser != null) {
|
||||||
|
reqDTO.setUserId(loginUser.getId());
|
||||||
|
reqDTO.setUserType(loginUser.getUserType());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
reqDTO.setUserId(loginUser.getId());
|
// 匿名请求场景(例如注册),尝试从 Request Attribute 获取用户信息
|
||||||
reqDTO.setUserType(loginUser.getUserType());
|
Long loginUserId = WebFrameworkUtils.getLoginUserId();
|
||||||
|
Integer loginUserType = WebFrameworkUtils.getLoginUserType();
|
||||||
|
reqDTO.setUserId(loginUserId != null ? loginUserId : 0L);
|
||||||
|
reqDTO.setUserType(loginUserType != null ? loginUserType : UserTypeEnum.ADMIN.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void fillModuleFields(OperateLogCreateReqDTO reqDTO, LogRecord logRecord) {
|
public static void fillModuleFields(OperateLogCreateReqDTO reqDTO, LogRecord logRecord) {
|
||||||
|
|||||||
@@ -16,4 +16,6 @@ public class NoticePageReqVO extends PageParam {
|
|||||||
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
|
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "公告类型")
|
||||||
|
private String category;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,4 +27,6 @@ public class NoticeRespVO {
|
|||||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "公告类型")
|
||||||
|
private String category;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,4 +29,6 @@ public class NoticeSaveReqVO {
|
|||||||
@Schema(description = "状态,参见 CommonStatusEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "状态,参见 CommonStatusEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "公告类型")
|
||||||
|
private String category;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,14 @@ public class TenantController {
|
|||||||
return success(tenantService.createTenant(createReqVO));
|
return success(tenantService.createTenant(createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/register")
|
||||||
|
@PermitAll
|
||||||
|
@TenantIgnore
|
||||||
|
@Operation(summary = "注册租户")
|
||||||
|
public CommonResult<Long> registerTenant(@Valid @RequestBody TenantRegisterReqVO registerReqVO) {
|
||||||
|
return success(tenantService.registerTenant(registerReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新租户")
|
@Operation(summary = "更新租户")
|
||||||
@PreAuthorize("@ss.hasPermission('system:tenant:update')")
|
@PreAuthorize("@ss.hasPermission('system:tenant:update')")
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ public class TenantPageReqVO extends PageParam {
|
|||||||
@Schema(description = "爬大哥到期时间")
|
@Schema(description = "爬大哥到期时间")
|
||||||
private LocalDateTime[] brotherExpireTime;
|
private LocalDateTime[] brotherExpireTime;
|
||||||
|
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
@Schema(description = "爬主播到期时间")
|
||||||
|
private LocalDateTime[] crawlExpireTime;
|
||||||
|
|
||||||
@Schema
|
@Schema
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 租户注册 Request VO")
|
||||||
|
@Data
|
||||||
|
public class TenantRegisterReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "租户名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||||
|
@NotNull(message = "租户名不能为空")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "联系人", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||||
|
@NotNull(message = "联系人不能为空")
|
||||||
|
private String contactName;
|
||||||
|
|
||||||
|
@Schema(description = "联系手机", example = "15601691300")
|
||||||
|
private String contactMobile;
|
||||||
|
|
||||||
|
@Schema(description = "用户账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao")
|
||||||
|
@NotNull(message = "用户账号不能为空")
|
||||||
|
@Pattern(regexp = "^[a-zA-Z0-9]{4,30}$", message = "用户账号由 数字、字母 组成")
|
||||||
|
@Size(min = 4, max = 30, message = "用户账号长度为 4-30 个字符")
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
||||||
|
@NotNull(message = "密码不能为空")
|
||||||
|
@Length(min = 6, max = 16, message = "密码长度为 6-16 位")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@Schema(description = "Turnstile 令牌", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "Turnstile 令牌不能为空")
|
||||||
|
private String turnstileToken;
|
||||||
|
|
||||||
|
// @Schema(description = "是否允许登录爬虫客户端", example = "0不允许,1允许")
|
||||||
|
// private Byte crawl;
|
||||||
|
//
|
||||||
|
// @Schema(description = "是否允许登录大哥客户端", example = "0不允许,1允许")
|
||||||
|
// private Byte bigBrother;
|
||||||
|
//
|
||||||
|
// @Schema(description = "能否登录 AI 聊天工具", example = "0不允许,1允许")
|
||||||
|
// private Byte aiChat;
|
||||||
|
//
|
||||||
|
// @Schema(description = "备注", example = "备注")
|
||||||
|
// private String remark;
|
||||||
|
//
|
||||||
|
// @Schema(description = "租户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "代理/客户")
|
||||||
|
// @NotNull(message = "租户类型不能为空")
|
||||||
|
// private String tenantType;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -7,10 +7,13 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
|||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 租户 Response VO")
|
@Schema(description = "管理后台 - 租户 Response VO")
|
||||||
@Data
|
@Data
|
||||||
@ExcelIgnoreUnannotated
|
@ExcelIgnoreUnannotated
|
||||||
@@ -53,6 +56,8 @@ public class TenantRespVO {
|
|||||||
@Schema(description = "大哥过期时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "大哥过期时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
private LocalDateTime brotherExpireTime;
|
private LocalDateTime brotherExpireTime;
|
||||||
|
|
||||||
|
@Schema(description = "爬主播到期时间")
|
||||||
|
private LocalDateTime crawlExpireTime;
|
||||||
|
|
||||||
@Schema(description = "账号数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "账号数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
private Integer accountCount;
|
private Integer accountCount;
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ 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;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import javax.validation.constraints.AssertTrue;
|
import javax.validation.constraints.AssertTrue;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
@@ -12,6 +14,8 @@ import javax.validation.constraints.Pattern;
|
|||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import java.time.LocalDateTime;
|
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")
|
@Schema(description = "管理后台 - 租户创建/修改 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class TenantSaveReqVO {
|
public class TenantSaveReqVO {
|
||||||
@@ -21,39 +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 = "爬主播到期时间")
|
||||||
|
@DiffLogField(name = "爬主播到期时间")
|
||||||
|
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;
|
||||||
|
|
||||||
// ========== 仅【创建】时,需要传递的字段 ==========
|
// ========== 仅【创建】时,需要传递的字段 ==========
|
||||||
@@ -61,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")
|
||||||
@@ -75,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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,4 +44,5 @@ public class NoticeDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
private String category;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,12 @@ public class TenantDO extends BaseDO {
|
|||||||
* 大哥过期时间
|
* 大哥过期时间
|
||||||
*/
|
*/
|
||||||
private LocalDateTime brotherExpireTime;
|
private LocalDateTime brotherExpireTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 爬虫到期时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime crawlExpireTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账号数量
|
* 账号数量
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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}}";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package cn.iocoder.yudao.module.system.job;
|
package cn.iocoder.yudao.module.system.job;
|
||||||
|
|
||||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
|
||||||
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
|
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
|
||||||
@@ -13,7 +12,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -64,25 +62,39 @@ public class DisableCrawlExpiredAccount implements JobHandler{
|
|||||||
public String execute(String param) throws Exception {
|
public String execute(String param) throws Exception {
|
||||||
Long tenantId = TenantContextHolder.getTenantId();
|
Long tenantId = TenantContextHolder.getTenantId();
|
||||||
TenantDO tenant = tenantMapper.selectById(tenantId);
|
TenantDO tenant = tenantMapper.selectById(tenantId);
|
||||||
if (tenant.getExpireTime()!=null) {
|
|
||||||
Duration brotherDuration = LocalDateTimeUtil.between(tenant.getExpireTime(), LocalDateTime.now());
|
// 检查租户是否配置了爬虫过期时间
|
||||||
long minutes = brotherDuration.toMinutes();
|
if (tenant.getCrawlExpireTime() == null) {
|
||||||
LambdaQueryWrapper<AdminUserDO> aiUserQueryWrapper = new LambdaQueryWrapper<>();
|
return "租户未配置爬虫过期时间";
|
||||||
aiUserQueryWrapper.eq(AdminUserDO::getTenantId, tenantId);
|
|
||||||
aiUserQueryWrapper.eq(AdminUserDO::getCrawl, 1);
|
|
||||||
List<AdminUserDO> aiUserList = userMapper.selectList(aiUserQueryWrapper);
|
|
||||||
int aiAccountNum = 0 ;
|
|
||||||
if (minutes >= 0) {
|
|
||||||
for (AdminUserDO adminUserDO : aiUserList) {
|
|
||||||
adminUserDO.setCrawl((byte) 0);
|
|
||||||
userMapper.updateById(adminUserDO);
|
|
||||||
aiAccountNum++;
|
|
||||||
log.info("禁用过期爬虫账号,账号ID:{}", adminUserDO.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 返回操作结果:包含禁用的AI账号和大哥账号数量统计
|
|
||||||
return "禁用过期账号成功,禁用了 " + aiAccountNum + " 个 爬虫 账号。";
|
|
||||||
}
|
}
|
||||||
return "租户未配置过期时间";
|
|
||||||
|
// 判断是否已过期(当前时间 >= 过期时间)
|
||||||
|
if (LocalDateTime.now().isBefore(tenant.getCrawlExpireTime())) {
|
||||||
|
return "爬虫权限未过期,无需处理";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询当前租户下所有启用爬虫权限的用户ID
|
||||||
|
LambdaQueryWrapper<AdminUserDO> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(AdminUserDO::getTenantId, tenantId)
|
||||||
|
.eq(AdminUserDO::getCrawl, 1)
|
||||||
|
.select(AdminUserDO::getId);
|
||||||
|
List<AdminUserDO> crawlUserList = userMapper.selectList(queryWrapper);
|
||||||
|
|
||||||
|
if (crawlUserList.isEmpty()) {
|
||||||
|
return "无需禁用的爬虫账号";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量更新:禁用爬虫权限
|
||||||
|
AdminUserDO updateEntity = new AdminUserDO();
|
||||||
|
updateEntity.setCrawl((byte) 0);
|
||||||
|
LambdaQueryWrapper<AdminUserDO> updateWrapper = new LambdaQueryWrapper<>();
|
||||||
|
updateWrapper.eq(AdminUserDO::getTenantId, tenantId)
|
||||||
|
.eq(AdminUserDO::getCrawl, 1);
|
||||||
|
int updatedCount = userMapper.update(updateEntity, updateWrapper);
|
||||||
|
|
||||||
|
// 记录被禁用的账号ID
|
||||||
|
crawlUserList.forEach(user -> log.info("禁用过期爬虫账号,账号ID:{}", user.getId()));
|
||||||
|
|
||||||
|
return "禁用过期爬虫账号成功,共禁用 " + updatedCount + " 个账号";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package cn.iocoder.yudao.module.system.job;
|
package cn.iocoder.yudao.module.system.job;
|
||||||
|
|
||||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
|
||||||
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
|
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
|
||||||
@@ -13,7 +12,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;/*
|
import java.util.List;/*
|
||||||
* @author: ziin
|
* @author: ziin
|
||||||
@@ -43,26 +41,40 @@ public class DisableWebAIExpiredAccount implements JobHandler{
|
|||||||
public String execute(String param) throws Exception {
|
public String execute(String param) throws Exception {
|
||||||
Long tenantId = TenantContextHolder.getTenantId();
|
Long tenantId = TenantContextHolder.getTenantId();
|
||||||
TenantDO tenant = tenantMapper.selectById(tenantId);
|
TenantDO tenant = tenantMapper.selectById(tenantId);
|
||||||
if (tenant.getAiExpireTime()!=null) {
|
|
||||||
Duration brotherDuration = LocalDateTimeUtil.between(tenant.getAiExpireTime(), LocalDateTime.now());
|
// 检查租户是否配置了AI过期时间
|
||||||
long minutes = brotherDuration.toMinutes();
|
if (tenant.getAiExpireTime() == null) {
|
||||||
LambdaQueryWrapper<AdminUserDO> aiUserQueryWrapper = new LambdaQueryWrapper<>();
|
return "租户未配置AI过期时间";
|
||||||
aiUserQueryWrapper.eq(AdminUserDO::getTenantId, tenantId);
|
|
||||||
aiUserQueryWrapper.eq(AdminUserDO::getWebAi, 1);
|
|
||||||
List<AdminUserDO> aiUserList = userMapper.selectList(aiUserQueryWrapper);
|
|
||||||
int aiAccountNum = 0 ;
|
|
||||||
if (minutes >= 0) {
|
|
||||||
for (AdminUserDO adminUserDO : aiUserList) {
|
|
||||||
adminUserDO.setWebAi((byte) 0);
|
|
||||||
userMapper.updateById(adminUserDO);
|
|
||||||
aiAccountNum++;
|
|
||||||
log.info("禁用过期WebAI账号,账号ID:{}", adminUserDO.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 返回操作结果:包含禁用的AI账号和大哥账号数量统计
|
|
||||||
return "禁用过期账号成功,禁用了 " + aiAccountNum + " 个 WebAI 账号。";
|
|
||||||
}
|
}
|
||||||
return "租户未配置过期时间";
|
|
||||||
|
// 判断是否已过期(当前时间 >= 过期时间)
|
||||||
|
if (LocalDateTime.now().isBefore(tenant.getAiExpireTime())) {
|
||||||
|
return "WebAI权限未过期,无需处理";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询当前租户下所有启用WebAI权限的用户ID
|
||||||
|
LambdaQueryWrapper<AdminUserDO> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(AdminUserDO::getTenantId, tenantId)
|
||||||
|
.eq(AdminUserDO::getWebAi, 1)
|
||||||
|
.select(AdminUserDO::getId);
|
||||||
|
List<AdminUserDO> webAiUserList = userMapper.selectList(queryWrapper);
|
||||||
|
|
||||||
|
if (webAiUserList.isEmpty()) {
|
||||||
|
return "无需禁用的WebAI账号";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量更新:禁用WebAI权限
|
||||||
|
AdminUserDO updateEntity = new AdminUserDO();
|
||||||
|
updateEntity.setWebAi((byte) 0);
|
||||||
|
LambdaQueryWrapper<AdminUserDO> updateWrapper = new LambdaQueryWrapper<>();
|
||||||
|
updateWrapper.eq(AdminUserDO::getTenantId, tenantId)
|
||||||
|
.eq(AdminUserDO::getWebAi, 1);
|
||||||
|
int updatedCount = userMapper.update(updateEntity, updateWrapper);
|
||||||
|
|
||||||
|
// 记录被禁用的账号ID
|
||||||
|
webAiUserList.forEach(user -> log.info("禁用过期WebAI账号,账号ID:{}", user.getId()));
|
||||||
|
|
||||||
|
return "禁用过期WebAI账号成功,共禁用 " + updatedCount + " 个账号";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.service.tenant;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantRegisterReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantRenewalReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantRenewalReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO;
|
||||||
@@ -28,6 +29,14 @@ public interface TenantService {
|
|||||||
*/
|
*/
|
||||||
Long createTenant(@Valid TenantSaveReqVO createReqVO);
|
Long createTenant(@Valid TenantSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册租户(固定默认值)
|
||||||
|
*
|
||||||
|
* @param registerReqVO 注册信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long registerTenant(@Valid TenantRegisterReqVO registerReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新租户
|
* 更新租户
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -7,18 +7,24 @@ import cn.hutool.core.date.LocalDateTimeUtil;
|
|||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import cn.hutool.http.HttpResponse;
|
||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
|
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
|
||||||
import cn.iocoder.yudao.framework.tenant.config.TenantProperties;
|
import cn.iocoder.yudao.framework.tenant.config.TenantProperties;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
||||||
|
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleSaveReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantRegisterReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantRenewalReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantRenewalReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.system.convert.tenant.TenantConvert;
|
import cn.iocoder.yudao.module.system.convert.tenant.TenantConvert;
|
||||||
@@ -46,22 +52,32 @@ 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.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
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.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,6 +90,12 @@ import static java.util.Collections.singleton;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class TenantServiceImpl implements TenantService {
|
public class TenantServiceImpl implements TenantService {
|
||||||
|
|
||||||
|
private static final Long REGISTER_PACKAGE_ID = 999L;
|
||||||
|
private static final Integer REGISTER_ACCOUNT_COUNT = 99;
|
||||||
|
private static final LocalDateTime REGISTER_EXPIRE_TIME = LocalDateTime.of(2099, 12, 31, 23, 59, 59);
|
||||||
|
private static final String TenantType = "用户";
|
||||||
|
private static final String TURNSTILE_VERIFY_FAILED_REASON = "Turnstile 校验失败";
|
||||||
|
|
||||||
@SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection")
|
@SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection")
|
||||||
@Autowired(required = false) // 由于 yudao.tenant.enable 配置项,可以关闭多租户的功能,所以这里只能不强制注入
|
@Autowired(required = false) // 由于 yudao.tenant.enable 配置项,可以关闭多租户的功能,所以这里只能不强制注入
|
||||||
private TenantProperties tenantProperties;
|
private TenantProperties tenantProperties;
|
||||||
@@ -103,6 +125,18 @@ public class TenantServiceImpl implements TenantService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private TenantBalanceService tenantBalanceService;
|
private TenantBalanceService tenantBalanceService;
|
||||||
|
|
||||||
|
@Value("${yudao.turnstile.enable:false}")
|
||||||
|
private Boolean turnstileEnable;
|
||||||
|
|
||||||
|
@Value("${yudao.turnstile.secret-key:}")
|
||||||
|
private String turnstileSecretKey;
|
||||||
|
|
||||||
|
@Value("${yudao.turnstile.verify-url:https://challenges.cloudflare.com/turnstile/v0/siteverify}")
|
||||||
|
private String turnstileVerifyUrl;
|
||||||
|
|
||||||
|
@Value("${yudao.turnstile.timeout-millis:3000}")
|
||||||
|
private Integer turnstileTimeoutMillis;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Long> getTenantIdList() {
|
public List<Long> getTenantIdList() {
|
||||||
List<TenantDO> tenants = tenantMapper.selectList();
|
List<TenantDO> tenants = tenantMapper.selectList();
|
||||||
@@ -166,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.getExpireTime().isBefore(LocalDateTime.now())){
|
|
||||||
targetTenant.setExpireTime(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.setExpireTime(targetTenant.getExpireTime().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()));
|
||||||
}
|
}
|
||||||
@@ -196,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);
|
||||||
@@ -208,9 +253,70 @@ public class TenantServiceImpl implements TenantService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@DSTransactional
|
||||||
|
@DataPermission(enable = false)
|
||||||
|
public Long registerTenant(TenantRegisterReqVO registerReqVO) {
|
||||||
|
verifyTurnstile(registerReqVO.getTurnstileToken());
|
||||||
|
// 注册接口为匿名访问,需要补充操作人,避免 creator/updater 为空
|
||||||
|
fillSystemOperatorIfAbsent();
|
||||||
|
TenantSaveReqVO createReqVO = BeanUtils.toBean(registerReqVO, TenantSaveReqVO.class);
|
||||||
|
createReqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||||
|
createReqVO.setTenantType(TenantType);
|
||||||
|
createReqVO.setWebsite(registerReqVO.getContactMobile()+ ".yolozs.com");
|
||||||
|
createReqVO.setAccountCount(REGISTER_ACCOUNT_COUNT);
|
||||||
|
createReqVO.setPackageId(REGISTER_PACKAGE_ID);
|
||||||
|
createReqVO.setExpireTime(REGISTER_EXPIRE_TIME);
|
||||||
|
AtomicReference<Long> tenantIdRef = new AtomicReference<>();
|
||||||
|
TenantUtils.execute(1L, () -> tenantIdRef.set(createTenant(createReqVO)));
|
||||||
|
return tenantIdRef.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillSystemOperatorIfAbsent() {
|
||||||
|
HttpServletRequest request = WebFrameworkUtils.getRequest();
|
||||||
|
if (request == null || WebFrameworkUtils.getLoginUserId(request) != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
WebFrameworkUtils.setLoginUserId(request, 1L);
|
||||||
|
WebFrameworkUtils.setLoginUserType(request, UserTypeEnum.ADMIN.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void verifyTurnstile(String turnstileToken) {
|
||||||
|
if (!Boolean.TRUE.equals(turnstileEnable)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (StrUtil.isBlank(turnstileSecretKey)) {
|
||||||
|
throw exception(AUTH_REGISTER_CAPTCHA_CODE_ERROR, TURNSTILE_VERIFY_FAILED_REASON + ":secret-key 未配置");
|
||||||
|
}
|
||||||
|
Map<String, Object> verifyResp;
|
||||||
|
try (HttpResponse response = HttpRequest.post(turnstileVerifyUrl)
|
||||||
|
.timeout(turnstileTimeoutMillis)
|
||||||
|
.form(buildTurnstileForm(turnstileToken))
|
||||||
|
.execute()) {
|
||||||
|
verifyResp = JsonUtils.parseObject(response.body(), Map.class);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.error("[verifyTurnstile][Turnstile 请求失败]", ex);
|
||||||
|
throw exception(AUTH_REGISTER_CAPTCHA_CODE_ERROR, TURNSTILE_VERIFY_FAILED_REASON + ":request failed");
|
||||||
|
}
|
||||||
|
if (verifyResp == null || !Boolean.TRUE.equals(verifyResp.get("success"))) {
|
||||||
|
Object errorCodes = verifyResp == null ? null : verifyResp.get("error-codes");
|
||||||
|
throw exception(AUTH_REGISTER_CAPTCHA_CODE_ERROR,
|
||||||
|
TURNSTILE_VERIFY_FAILED_REASON + ":" + StrUtil.blankToDefault(StrUtil.toString(errorCodes), "unknown"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> buildTurnstileForm(String turnstileToken) {
|
||||||
|
Map<String, Object> form = new HashMap<>();
|
||||||
|
form.put("secret", turnstileSecretKey);
|
||||||
|
form.put("response", turnstileToken);
|
||||||
|
return form;
|
||||||
|
}
|
||||||
|
|
||||||
@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)
|
||||||
@@ -244,11 +350,14 @@ public class TenantServiceImpl implements TenantService {
|
|||||||
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);
|
||||||
@@ -322,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();
|
||||||
}
|
}
|
||||||
@@ -378,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();
|
||||||
}
|
}
|
||||||
@@ -414,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());
|
||||||
@@ -423,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);
|
||||||
@@ -443,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
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ aj:
|
|||||||
cache-number: 1000 # local 缓存的阈值,达到这个值,清除缓存
|
cache-number: 1000 # local 缓存的阈值,达到这个值,清除缓存
|
||||||
timing-clear: 180 # local定时清除过期缓存(单位秒),设置为0代表不执行
|
timing-clear: 180 # local定时清除过期缓存(单位秒),设置为0代表不执行
|
||||||
type: blockPuzzle # 验证码类型 default两种都实例化。 blockPuzzle 滑块拼图 clickWord 文字点选
|
type: blockPuzzle # 验证码类型 default两种都实例化。 blockPuzzle 滑块拼图 clickWord 文字点选
|
||||||
water-mark: 芋道源码 # 右下角水印文字(我的水印),可使用 https://tool.chinaz.com/tools/unicode.aspx 中文转 Unicode,Linux 可能需要转 unicode
|
water-mark: # 右下角水印文字(我的水印),可使用 https://tool.chinaz.com/tools/unicode.aspx 中文转 Unicode,Linux 可能需要转 unicode
|
||||||
interference-options: 0 # 滑动干扰项(0/1/2)
|
interference-options: 0 # 滑动干扰项(0/1/2)
|
||||||
req-frequency-limit-enable: false # 接口请求次数一分钟限制是否开启 true|false
|
req-frequency-limit-enable: false # 接口请求次数一分钟限制是否开启 true|false
|
||||||
req-get-lock-limit: 5 # 验证失败 5 次,get接口锁定
|
req-get-lock-limit: 5 # 验证失败 5 次,get接口锁定
|
||||||
@@ -212,6 +212,11 @@ yudao:
|
|||||||
send-maximum-quantity-per-day: 10
|
send-maximum-quantity-per-day: 10
|
||||||
begin-code: 9999 # 这里配置 9999 的原因是,测试方便。
|
begin-code: 9999 # 这里配置 9999 的原因是,测试方便。
|
||||||
end-code: 9999 # 这里配置 9999 的原因是,测试方便。
|
end-code: 9999 # 这里配置 9999 的原因是,测试方便。
|
||||||
|
turnstile: # Cloudflare Turnstile 服务端校验配置
|
||||||
|
enable: true # 生产开启后,必须配置 secret-key
|
||||||
|
secret-key: "0x4AAAAAACYSAQ2xlao9D8LlyDRhB3n1BmM"
|
||||||
|
verify-url: https://challenges.cloudflare.com/turnstile/v0/siteverify
|
||||||
|
timeout-millis: 3000
|
||||||
|
|
||||||
debug: false
|
debug: false
|
||||||
# 插件配置 TODO 芋艿:【IOT】需要处理下
|
# 插件配置 TODO 芋艿:【IOT】需要处理下
|
||||||
|
|||||||
Reference in New Issue
Block a user