Browse Source

企业

master
DX 2 months ago
parent
commit
12d4e8e74e
  1. 4
      yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
  2. 17
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/annotation/PrimaryKey.java
  3. 129
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/aspect/FieldChangeLogAspect.java
  4. 71
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/aspect/LogDeleteOperation.java
  5. 5
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java
  6. 3
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/vo/AuthSocialLoginReqVO.java
  7. 26
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/EnterpriseController.java
  8. 2
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterprisePageReqVO.java
  9. 4
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterpriseRespVO.java
  10. 5
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterpriseSaveReqVO.java
  11. 94
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/fieldchangelog/FieldChangeLogController.java
  12. 46
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/fieldchangelog/vo/FieldChangeLogPageReqVO.java
  13. 55
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/fieldchangelog/vo/FieldChangeLogRespVO.java
  14. 46
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/fieldchangelog/vo/FieldChangeLogSaveReqVO.java
  15. 4
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/fileInfo/FileInfoController.java
  16. 10
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/EnterpriseQualificationController.java
  17. 6
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/vo/EnterpriseQualificationRespVO.java
  18. 6
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/vo/EnterpriseQualificationSaveReqVO.java
  19. 2
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterprise/EnterpriseDO.java
  20. 62
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/fieldchangelog/FieldChangeLogDO.java
  21. 14
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/common/CommonMapper.java
  22. 4
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java
  23. 34
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/fieldchangelog/FieldChangeLogMapper.java
  24. 4
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java
  25. 7
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/common/CommonService.java
  26. 20
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/common/CommonServiceImpl.java
  27. 3
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseService.java
  28. 42
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseServiceImpl.java
  29. 56
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fieldchangelog/FieldChangeLogService.java
  30. 75
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fieldchangelog/FieldChangeLogServiceImpl.java
  31. 2
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java
  32. 3
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java
  33. 57
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/util/EntityUtils.java

4
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java

@ -166,8 +166,11 @@ public interface ErrorCodeConstants {
//==========企业信息相关 1-003-000-000
ErrorCode ENTERPRISE_NOT_EXISTS = new ErrorCode(1-003-000-000, "企业不存在");
ErrorCode ENTERPRISE_EXISTS = new ErrorCode(1-003-000-000, "企业信息已上传");
ErrorCode ENTERPRISE_QUALIFICATION_NOT_EXISTS = new ErrorCode(1-003-000-001, "企业资质不存在");
ErrorCode INSERT_ERROR = new ErrorCode(1-003-000-001, "添加失败");
//===============文件相关====================/
@ -175,5 +178,6 @@ public interface ErrorCodeConstants {
ErrorCode USER_AUDIT_LOG_NOT_EXISTS = new ErrorCode(1-003-001-001, "用户审核日志不存在");
ErrorCode FIELD_CHANGE_LOG_NOT_EXISTS = new ErrorCode(1-003-001-002, "字段变更不存在");
}

17
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/annotation/PrimaryKey.java

@ -0,0 +1,17 @@
package cn.iocoder.yudao.module.system.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface PrimaryKey {
/**
* 主键类型默认是 Long
*/
Class<?> type() default Long.class;
}

129
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/aspect/FieldChangeLogAspect.java

@ -0,0 +1,129 @@
package cn.iocoder.yudao.module.system.aspect;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.module.system.dal.dataobject.fieldchangelog.FieldChangeLogDO;
import cn.iocoder.yudao.module.system.dal.mysql.fieldchangelog.FieldChangeLogMapper;
import cn.iocoder.yudao.module.system.service.common.CommonService;
import cn.iocoder.yudao.module.system.service.fieldchangelog.FieldChangeLogService;
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import cn.iocoder.yudao.module.system.util.EntityUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.lang.reflect.Field;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Map;
import java.util.Objects;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
@Aspect
@Component
public class FieldChangeLogAspect {
@Resource
private FieldChangeLogService fieldChangeLogService;
@Resource
private FieldChangeLogMapper fieldChangeLogMapper;
@Resource
private CommonService commonService;
@Resource
private AdminUserService userService;
// 拦截 update 方法
@Pointcut("execution(* cn.iocoder.*.service.*.update*(..))")
public void updatePointCut() {}
@Around("updatePointCut()")
public Object logFieldChanges(ProceedingJoinPoint point) throws Throwable {
Object[] args = point.getArgs();
if (args.length == 0 || args[0] == null) {
return point.proceed(); // 跳过无效参数
}
Object updatedEntity = args[0];
// 判断是否包含 @PrimaryKey 注解
if (!EntityUtils.hasPrimaryKeyAnnotation(updatedEntity)) {
return point.proceed(); // 如果没有主键注解,跳过日志记录
}
// 使用工具类获取主键值和表名
Long recordId = EntityUtils.getPrimaryKeyValue(updatedEntity);
String tableName = EntityUtils.getTableName(updatedEntity);
// 动态查询原始记录
Map<String, Object> originalRecord = commonService.findById(tableName, recordId);
// 记录字段变更日志
saveFieldChangeLogs(originalRecord, updatedEntity, tableName, recordId);
return point.proceed(); // 执行原方法
}
private void saveFieldChangeLogs(Map<String, Object> original, Object updatedEntity, String tableName, Long recordId) {
final LoginUser loginUser = getLoginUser();
for (Field field : updatedEntity.getClass().getDeclaredFields()) {
field.setAccessible(true);
try {
String fieldName = field.getName();
String dbFieldName = toUnderlineCase(fieldName); // 将驼峰命名转换为下划线命名
Object oldValue = original.get(dbFieldName); // 获取原始值
Object newValue = field.get(updatedEntity); // 获取新值
// 如果原值和新值相等,则跳过
if ((newValue == null) || (oldValue != null && oldValue.equals(newValue))) {
continue;
}
if (!Objects.equals(oldValue, newValue)) {
FieldChangeLogDO log = new FieldChangeLogDO();
log.setTableName(tableName);
log.setRecordId(recordId);
log.setFieldName(fieldName);
log.setOldValue(oldValue != null ? oldValue.toString() : null);
log.setNewValue(newValue != null ? newValue.toString() : null);
log.setUserId(loginUser.getId());
final String realName = userService.getUser(loginUser.getId()).getRealName();
log.setUsername(realName);
log.setOperationType("修改");
fieldChangeLogMapper.insert(log);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
/**
* 将驼峰命名转换为下划线命名
*
* @param camelCase 驼峰格式字符串 contactName
* @return 下划线格式字符串 contact_name
*/
public static String toUnderlineCase(String camelCase) {
if (camelCase == null || camelCase.isEmpty()) {
return "";
}
// 使用正则表达式匹配驼峰命名的规则
return camelCase.replaceAll("([a-z])([A-Z])", "$1_$2").toLowerCase();
}
}

71
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/aspect/LogDeleteOperation.java

@ -0,0 +1,71 @@
//package cn.iocoder.yudao.module.system.aspect;
//
//
//import cn.iocoder.yudao.module.system.service.common.CommonService;
//import cn.iocoder.yudao.module.system.util.EntityUtils;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.util.Date;
//import java.util.Map;
//@Aspect
//@Component
//public class LogDeleteOperation {
//
// @Autowired
// private CommonService commonService;
//
// @Autowired
// private SysFieldChangeLogService fieldChangeLogService;
//
// @Around("execution(* com.ruoyi.*.service.*.delete*(..))")
// public Object logDeleteOperation(ProceedingJoinPoint point) throws Throwable {
// Object[] args = point.getArgs();
// if (args.length == 0) {
// return point.proceed();
// }
//
// Object entityToDelete = args[0];
//
// // 判断是否包含 @PrimaryKey 注解
// if (!EntityUtils.hasPrimaryKeyAnnotation(entityToDelete)) {
// return point.proceed(); // 如果没有主键注解,跳过日志记录
// }
//
//
// // 使用工具类获取主键值和表名
// Long recordId = EntityUtils.getPrimaryKeyValue(entityToDelete);
// String tableName = EntityUtils.getTableName(entityToDelete );
//
// // 动态查询记录
// Map<String, Object> originalRecord = commonService.findById(tableName, recordId);
//
// // 保存删除日志
// saveDeleteLogs(originalRecord, tableName, recordId);
//
// return point.proceed();
// }
//
// private void saveDeleteLogs(Map<String, Object> original, String tableName, Long recordId) {
// Long userId = SecurityUtils.getLoginUser().getUserId();
// String username = SecurityUtils.getLoginUser().getUsername();
//
// for (Map.Entry<String, Object> entry : original.entrySet()) {
// SysFieldChangeLog log = new SysFieldChangeLog();
// log.setTableName(tableName);
// log.setRecordId(recordId);
// log.setFieldName(entry.getKey());
// log.setOldValue(entry.getValue() != null ? entry.getValue().toString() : null);
// log.setNewValue(null); // 删除操作,新值为空
// log.setUserId(userId);
// log.setUsername(username);
// log.setOperationType("删除");
// log.setCreateTime(new Date());
// fieldChangeLogService.save(log);
// }
// }
//
//}

5
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java

@ -69,6 +69,7 @@ public class AuthController {
@Resource
private SocialUserService socialUserService;
@PostMapping("/login")
@PermitAll
@Operation(summary = "使用账号密码登录")
@ -79,7 +80,7 @@ public class AuthController {
@PermitAll
@PostMapping("/app_login")
@Operation(summary = "社交快捷登录,使用 code 授权码")
public CommonResult<AuthLoginRespVO> login(@RequestBody @Valid AuthSocialLoginReqVO reqVO) {
public CommonResult<AuthLoginRespVO> AppLogin(@RequestBody @Valid AuthSocialLoginReqVO reqVO) {
final AdminUserDO user = authService.miniAppLogin(reqVO);
if (!user.getIsBand()) {
@ -91,7 +92,7 @@ public class AuthController {
userBindReqDTO.setSocialType(reqVO.getType());
userBindReqDTO.setState(reqVO.getState());
socialUserService.bindSocialUser(userBindReqDTO);
//给用户添加默认角色
//给用户添加默认角色 可以编辑用户信息, 可以上传图片
}
return success(authService.createTokenAfterLoginSuccess2(user.getId(), user.getUsername(), LoginLogTypeEnum.LOGIN_SOCIAL));

3
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/vo/AuthSocialLoginReqVO.java

@ -31,4 +31,7 @@ public class AuthSocialLoginReqVO {
@NotEmpty(message = "state 不能为空")
private String state;
@Schema(description = "用户类型" )
private Integer userType;
}

26
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/EnterpriseController.java

@ -1,5 +1,8 @@
package cn.iocoder.yudao.module.system.controller.admin.enterprise;
import cn.iocoder.yudao.module.infra.api.file.FileApi;
import cn.iocoder.yudao.module.system.service.fileInfo.FileInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
@ -33,21 +36,26 @@ import javax.validation.Valid;
@RestController
@RequestMapping("/system/enterprise")
@Validated
@Slf4j
public class EnterpriseController {
@Resource
private EnterpriseService enterpriseService;
@Resource
private FileInfoService fileInfoService;
@Resource
private FileApi fileApi;
@PostMapping("/create")
@Operation(summary = "创建企业")
@PreAuthorize("@ss.hasPermission('system:enterprise:create')")
public CommonResult<Long> createEnterprise(@Valid @RequestBody EnterpriseSaveReqVO createReqVO) {
// @PreAuthorize("@ss.hasPermission('system:enterprise:create')")
public CommonResult<Long> createEnterprise(@RequestBody EnterpriseSaveReqVO createReqVO) {
return success(enterpriseService.createEnterprise(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新企业")
@PreAuthorize("@ss.hasPermission('system:enterprise:update')")
// @PreAuthorize("@ss.hasPermission('system:enterprise:update')")
public CommonResult<Boolean> updateEnterprise(@Valid @RequestBody EnterpriseSaveReqVO updateReqVO) {
enterpriseService.updateEnterprise(updateReqVO);
return success(true);
@ -79,6 +87,18 @@ public class EnterpriseController {
return success(BeanUtils.toBean(pageResult, EnterpriseRespVO.class));
}
@GetMapping("/getEnterpriseByUserId")
@Operation(summary = "用户获得所属企业列表")
public CommonResult<List<EnterpriseRespVO>> getEnterpriseByUserId(@Valid EnterprisePageReqVO pageReqVO) {
List<EnterpriseDO> pageResult = enterpriseService.getEnterpriseByUserId(pageReqVO);
// pageResult.forEach(item->{
//
// });
return success(BeanUtils.toBean(pageResult, EnterpriseRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出企业 Excel")
@PreAuthorize("@ss.hasPermission('system:enterprise:export')")

2
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterprisePageReqVO.java

@ -65,6 +65,6 @@ public class EnterprisePageReqVO extends PageParam {
private String updater;
@Schema(description = "管理部门", example = "26433")
private Long managerDeptId;
private Long deptId;
}

4
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterpriseRespVO.java

@ -60,7 +60,7 @@ public class EnterpriseRespVO {
@Schema(description = "企业成立时间")
@ExcelProperty("企业成立时间")
private LocalDate establishmentDate;
private String establishmentDate;
@Schema(description = "企业经纬度")
@ExcelProperty("企业经纬度")
@ -80,6 +80,6 @@ public class EnterpriseRespVO {
@Schema(description = "管理部门", example = "26433")
@ExcelProperty("管理部门")
private Long managerDeptId;
private Long deptId;
}

5
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterpriseSaveReqVO.java

@ -24,8 +24,7 @@ public class EnterpriseSaveReqVO {
@Schema(description = "企业类型:1.大型、2.中型、3.小型、4.环保重点", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
private String type;
@Schema(description = "企业所属区域:1.东区、2.西区、3.北区、4.南区", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "企业所属区域:1.东区、2.西区、3.北区、4.南区不能为空")
@Schema(description = "企业所属区域:1.东区、2.西区、3.北区、4.南区")
private String region;
@Schema(description = "企业名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
@ -60,7 +59,7 @@ public class EnterpriseSaveReqVO {
private String updateBy;
@Schema(description = "管理部门", example = "26433")
private Long managerDeptId;
private Long deptId;
@Schema(description = "文件id", example = "26433")
private Long[] fileIds;

94
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/fieldchangelog/FieldChangeLogController.java

@ -0,0 +1,94 @@
package cn.iocoder.yudao.module.system.controller.admin.fieldchangelog;
import org.springframework.web.bind.annotation.*;
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 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.system.controller.admin.fieldchangelog.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.fieldchangelog.FieldChangeLogDO;
import cn.iocoder.yudao.module.system.service.fieldchangelog.FieldChangeLogService;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
@Tag(name = "管理后台 - 字段变更日志")
@RestController
@RequestMapping("/system/field-change-log")
@Validated
public class FieldChangeLogController {
@Resource
private FieldChangeLogService fieldChangeLogService;
@PostMapping("/create")
@Operation(summary = "创建字段变更日志")
@PreAuthorize("@ss.hasPermission('system:field-change-log:create')")
public CommonResult<Long> createFieldChangeLog(@Valid @RequestBody FieldChangeLogSaveReqVO createReqVO) {
return success(fieldChangeLogService.createFieldChangeLog(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新字段变更日志")
@PreAuthorize("@ss.hasPermission('system:field-change-log:update')")
public CommonResult<Boolean> updateFieldChangeLog(@Valid @RequestBody FieldChangeLogSaveReqVO updateReqVO) {
fieldChangeLogService.updateFieldChangeLog(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除字段变更日志")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('system:field-change-log:delete')")
public CommonResult<Boolean> deleteFieldChangeLog(@RequestParam("id") Long id) {
fieldChangeLogService.deleteFieldChangeLog(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得字段变更日志")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:field-change-log:query')")
public CommonResult<FieldChangeLogRespVO> getFieldChangeLog(@RequestParam("id") Long id) {
FieldChangeLogDO fieldChangeLog = fieldChangeLogService.getFieldChangeLog(id);
return success(BeanUtils.toBean(fieldChangeLog, FieldChangeLogRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得字段变更日志分页")
@PreAuthorize("@ss.hasPermission('system:field-change-log:query')")
public CommonResult<PageResult<FieldChangeLogRespVO>> getFieldChangeLogPage(@Valid FieldChangeLogPageReqVO pageReqVO) {
PageResult<FieldChangeLogDO> pageResult = fieldChangeLogService.getFieldChangeLogPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, FieldChangeLogRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出字段变更日志 Excel")
@PreAuthorize("@ss.hasPermission('system:field-change-log:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportFieldChangeLogExcel(@Valid FieldChangeLogPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<FieldChangeLogDO> list = fieldChangeLogService.getFieldChangeLogPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "字段变更日志.xls", "数据", FieldChangeLogRespVO.class,
BeanUtils.toBean(list, FieldChangeLogRespVO.class));
}
}

46
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/fieldchangelog/vo/FieldChangeLogPageReqVO.java

@ -0,0 +1,46 @@
package cn.iocoder.yudao.module.system.controller.admin.fieldchangelog.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
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class FieldChangeLogPageReqVO extends PageParam {
@Schema(description = "表名", example = "王五")
private String tableName;
@Schema(description = "记录的主键值", example = "13548")
private Long recordId;
@Schema(description = "字段名", example = "赵六")
private String fieldName;
@Schema(description = "修改前值或删除前的值")
private String oldValue;
@Schema(description = "修改后值(删除时为空)")
private String newValue;
@Schema(description = "操作用户ID", example = "17114")
private Long userId;
@Schema(description = "操作用户名", example = "芋艿")
private String username;
@Schema(description = "操作时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "操作类型", example = "1")
private String operationType;
}

55
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/fieldchangelog/vo/FieldChangeLogRespVO.java

@ -0,0 +1,55 @@
package cn.iocoder.yudao.module.system.controller.admin.fieldchangelog.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 FieldChangeLogRespVO {
@Schema(description = "日志ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "12408")
@ExcelProperty("日志ID")
private Long id;
@Schema(description = "表名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@ExcelProperty("表名")
private String tableName;
@Schema(description = "记录的主键值", requiredMode = Schema.RequiredMode.REQUIRED, example = "13548")
@ExcelProperty("记录的主键值")
private Long recordId;
@Schema(description = "字段名", example = "赵六")
@ExcelProperty("字段名")
private String fieldName;
@Schema(description = "修改前值或删除前的值")
@ExcelProperty("修改前值或删除前的值")
private String oldValue;
@Schema(description = "修改后值(删除时为空)")
@ExcelProperty("修改后值(删除时为空)")
private String newValue;
@Schema(description = "操作用户ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "17114")
@ExcelProperty("操作用户ID")
private Long userId;
@Schema(description = "操作用户名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@ExcelProperty("操作用户名")
private String username;
@Schema(description = "操作时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("操作时间")
private LocalDateTime createTime;
@Schema(description = "操作类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@ExcelProperty("操作类型")
private String operationType;
}

46
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/fieldchangelog/vo/FieldChangeLogSaveReqVO.java

@ -0,0 +1,46 @@
package cn.iocoder.yudao.module.system.controller.admin.fieldchangelog.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.*;
@Schema(description = "管理后台 - 字段变更日志新增/修改 Request VO")
@Data
public class FieldChangeLogSaveReqVO {
@Schema(description = "日志ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "12408")
private Long id;
@Schema(description = "表名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "表名不能为空")
private String tableName;
@Schema(description = "记录的主键值", requiredMode = Schema.RequiredMode.REQUIRED, example = "13548")
@NotNull(message = "记录的主键值不能为空")
private Long recordId;
@Schema(description = "字段名", example = "赵六")
private String fieldName;
@Schema(description = "修改前值或删除前的值")
private String oldValue;
@Schema(description = "修改后值(删除时为空)")
private String newValue;
@Schema(description = "操作用户ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "17114")
@NotNull(message = "操作用户ID不能为空")
private Long userId;
@Schema(description = "操作用户名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@NotEmpty(message = "操作用户名不能为空")
private String username;
@Schema(description = "操作类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotEmpty(message = "操作类型不能为空")
private String operationType;
}

4
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/fileInfo/FileInfoController.java

@ -40,7 +40,7 @@ public class FileInfoController {
@PostMapping("/create")
@Operation(summary = "创建附件信息")
@PreAuthorize("@ss.hasPermission('system:file-info:create')")
// @PreAuthorize("@ss.hasPermission('system:file-info:create')")
public CommonResult<Long> createFileInfo(@Valid @RequestBody FileInfoSaveReqVO createReqVO) {
return success(fileInfoService.createFileInfo(createReqVO));
}
@ -56,7 +56,7 @@ public class FileInfoController {
@DeleteMapping("/delete")
@Operation(summary = "删除附件信息")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('system:file-info:delete')")
// @PreAuthorize("@ss.hasPermission('system:file-info:delete')")
public CommonResult<Boolean> deleteFileInfo(@RequestParam("id") Long id) {
fileInfoService.deleteFileInfo(id);
return success(true);

10
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/EnterpriseQualificationController.java

@ -39,7 +39,7 @@ public class EnterpriseQualificationController {
@PostMapping("/create")
@Operation(summary = "创建企业资质")
@PreAuthorize("@ss.hasPermission('system:enterprise-qualification:create')")
// @PreAuthorize("@ss.hasPermission('system:enterprise-qualification:create')")
public CommonResult<Long> createEnterpriseQualification(@Valid @RequestBody EnterpriseQualificationSaveReqVO createReqVO) {
return success(enterpriseQualificationService.createEnterpriseQualification(createReqVO));
}
@ -64,7 +64,7 @@ public class EnterpriseQualificationController {
@GetMapping("/get")
@Operation(summary = "获得企业资质")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:enterprise-qualification:query')")
// @PreAuthorize("@ss.hasPermission('system:enterprise-qualification:query')")
public CommonResult<EnterpriseQualificationRespVO> getEnterpriseQualification(@RequestParam("id") Long id) {
EnterpriseQualificationDO enterpriseQualification = enterpriseQualificationService.getEnterpriseQualification(id);
return success(BeanUtils.toBean(enterpriseQualification, EnterpriseQualificationRespVO.class));
@ -72,8 +72,8 @@ public class EnterpriseQualificationController {
@GetMapping("/page")
@Operation(summary = "获得企业资质分页")
@PreAuthorize("@ss.hasPermission('system:enterprise-qualification:query')")
public CommonResult<PageResult<EnterpriseQualificationRespVO>> getEnterpriseQualificationPage(@Valid EnterpriseQualificationPageReqVO pageReqVO) {
// @PreAuthorize("@ss.hasPermission('system:enterprise-qualification:query')")
public CommonResult<PageResult<EnterpriseQualificationRespVO>> getEnterpriseQualificationPage(EnterpriseQualificationPageReqVO pageReqVO) {
PageResult<EnterpriseQualificationDO> pageResult = enterpriseQualificationService.getEnterpriseQualificationPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, EnterpriseQualificationRespVO.class));
}
@ -91,4 +91,4 @@ public class EnterpriseQualificationController {
BeanUtils.toBean(list, EnterpriseQualificationRespVO.class));
}
}
}

6
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/vo/EnterpriseQualificationRespVO.java

@ -28,7 +28,7 @@ public class EnterpriseQualificationRespVO {
@Schema(description = "资质到期日期")
@ExcelProperty("资质到期日期")
private LocalDate expiryDate;
private String expiryDate;
@Schema(description = "资质描述,详细说明资质信息", example = "随便")
@ExcelProperty("资质描述,详细说明资质信息")
@ -48,10 +48,10 @@ public class EnterpriseQualificationRespVO {
@Schema(description = "办理日期")
@ExcelProperty("办理日期")
private LocalDate handleDate;
private String handleDate;
@Schema(description = "资质编号")
@ExcelProperty("资质编号")
private String enterpriseAuth;
}
}

6
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/vo/EnterpriseQualificationSaveReqVO.java

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.controller.admin.qualification.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.validation.constraints.NotNull;
import java.time.LocalDate;
import java.util.*;
@ -13,7 +14,8 @@ public class EnterpriseQualificationSaveReqVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "16561")
private Long id;
@Schema(description = "企业ID", example = "28564")
@Schema(description = "企业ID", example = "28564", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull
private Long enterpriseId;
@Schema(description = "资质名称,例如:排污许可证、环保合格证", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
@ -37,4 +39,4 @@ public class EnterpriseQualificationSaveReqVO {
@Schema(description = "资质编号")
private String enterpriseAuth;
}
}

2
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterprise/EnterpriseDO.java

@ -81,6 +81,6 @@ public class EnterpriseDO extends BaseDO {
/**
* 管理部门
*/
private Long managerDeptId;
private Long deptId;
}

62
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/fieldchangelog/FieldChangeLogDO.java

@ -0,0 +1,62 @@
package cn.iocoder.yudao.module.system.dal.dataobject.fieldchangelog;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 字段变更日志 DO
*
* @author 芋道源码
*/
@TableName("sys_field_change_log")
@KeySequence("sys_field_change_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class FieldChangeLogDO extends BaseDO {
/**
* 日志ID
*/
@TableId
private Long id;
/**
* 表名
*/
private String tableName;
/**
* 记录的主键值
*/
private Long recordId;
/**
* 字段名
*/
private String fieldName;
/**
* 修改前值或删除前的值
*/
private String oldValue;
/**
* 修改后值删除时为空
*/
private String newValue;
/**
* 操作用户ID
*/
private Long userId;
/**
* 操作用户名
*/
private String username;
/**
* 操作类型
*/
private String operationType;
}

14
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/common/CommonMapper.java

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.system.dal.mysql.common;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.Map;
@Mapper
public interface CommonMapper {
@Select("SELECT * FROM `${tableName}` WHERE id = #{id}")
Map<String, Object> selectById(@Param("tableName") String tableName, @Param("id") Long id);
}

4
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java

@ -34,8 +34,8 @@ public interface EnterpriseMapper extends BaseMapperX<EnterpriseDO> {
.eqIfPresent(EnterpriseDO::getCreator, reqVO.getCreate())
.betweenIfPresent(EnterpriseDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(EnterpriseDO::getUpdater, reqVO.getUpdater())
.eqIfPresent(EnterpriseDO::getManagerDeptId, reqVO.getManagerDeptId())
.eqIfPresent(EnterpriseDO::getDeptId, reqVO.getDeptId())
.orderByDesc(EnterpriseDO::getId));
}
}
}

34
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/fieldchangelog/FieldChangeLogMapper.java

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.system.dal.mysql.fieldchangelog;
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.system.dal.dataobject.fieldchangelog.FieldChangeLogDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.fieldchangelog.vo.*;
/**
* 字段变更日志 Mapper
*
* @author 芋道源码
*/
@Mapper
public interface FieldChangeLogMapper extends BaseMapperX<FieldChangeLogDO> {
default PageResult<FieldChangeLogDO> selectPage(FieldChangeLogPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<FieldChangeLogDO>()
.likeIfPresent(FieldChangeLogDO::getTableName, reqVO.getTableName())
.eqIfPresent(FieldChangeLogDO::getRecordId, reqVO.getRecordId())
.likeIfPresent(FieldChangeLogDO::getFieldName, reqVO.getFieldName())
.eqIfPresent(FieldChangeLogDO::getOldValue, reqVO.getOldValue())
.eqIfPresent(FieldChangeLogDO::getNewValue, reqVO.getNewValue())
.eqIfPresent(FieldChangeLogDO::getUserId, reqVO.getUserId())
.likeIfPresent(FieldChangeLogDO::getUsername, reqVO.getUsername())
.betweenIfPresent(FieldChangeLogDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(FieldChangeLogDO::getOperationType, reqVO.getOperationType())
.orderByDesc(FieldChangeLogDO::getId));
}
}

4
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java

@ -16,6 +16,7 @@ import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO;
import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserBindDO;
import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.dal.mysql.permission.UserRoleMapper;
import cn.iocoder.yudao.module.system.dal.mysql.social.SocialClientMapper;
import cn.iocoder.yudao.module.system.dal.mysql.social.SocialUserBindMapper;
import cn.iocoder.yudao.module.system.dal.mysql.social.SocialUserMapper;
@ -324,9 +325,10 @@ public class AdminAuthServiceImpl implements AdminAuthService {
throw exception(INSERT_ERROR);
}
user = userService.autoRegisterUser(authUser);
user = userService.autoRegisterUser(authUser, reqVO.getUserType());
//给一个默认的普通用户的角色
// UserRoleMapper
user.setIsBand(false);

7
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/common/CommonService.java

@ -0,0 +1,7 @@
package cn.iocoder.yudao.module.system.service.common;
import java.util.Map;
public interface CommonService {
Map<String, Object> findById(String tableName, Long id);
}

20
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/common/CommonServiceImpl.java

@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.system.service.common;
import cn.iocoder.yudao.module.system.dal.mysql.common.CommonMapper;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Map;
@Service
public class CommonServiceImpl implements CommonService{
@Resource
private CommonMapper commonMapper;
@Override
public Map<String, Object> findById(String tableName, Long id) {
return commonMapper.selectById(tableName, id);
}
}

3
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseService.java

@ -21,7 +21,7 @@ public interface EnterpriseService {
* @param createReqVO 创建信息
* @return 编号
*/
Long createEnterprise(@Valid EnterpriseSaveReqVO createReqVO);
Long createEnterprise(EnterpriseSaveReqVO createReqVO);
/**
* 更新企业
@ -53,4 +53,5 @@ public interface EnterpriseService {
*/
PageResult<EnterpriseDO> getEnterprisePage(EnterprisePageReqVO pageReqVO);
List<EnterpriseDO> getEnterpriseByUserId(EnterprisePageReqVO pageReqVO);
}

42
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseServiceImpl.java

@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.system.service.enterprise;
import cn.iocoder.yudao.module.system.dal.dataobject.fileInfo.FileInfoDO;
import cn.iocoder.yudao.module.system.dal.mysql.fileInfo.FileInfoMapper;
import cn.iocoder.yudao.module.system.service.fileInfo.FileInfoService;
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.tomcat.jni.FileInfo;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@ -20,6 +22,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.enterprise.EnterpriseMapper;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
/**
@ -37,13 +40,27 @@ public class EnterpriseServiceImpl implements EnterpriseService {
private FileInfoService fileInfoService;
@Resource
private FileInfoMapper fileInfoMapper;
@Resource
private AdminUserService adminUserService;
@Override
@Transactional
public Long createEnterprise(EnterpriseSaveReqVO createReqVO) {
//先查询是否存在
LambdaQueryWrapper<EnterpriseDO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(EnterpriseDO::getEnterprisesName, createReqVO.getEnterprisesName());
final EnterpriseDO enterpriseDO = enterpriseMapper.selectOne(queryWrapper);
if (enterpriseDO != null) {
throw exception(ENTERPRISE_EXISTS);
}
// 插入
EnterpriseDO enterprise = BeanUtils.toBean(createReqVO, EnterpriseDO.class);
enterpriseMapper.insert(enterprise);
//修改企业用户的审核状态为 审核中
if (createReqVO.getFileIds().length > 0) {
for (Long fileId : createReqVO.getFileIds()) {
FileInfoDO fileInfoDO = new FileInfoDO();
@ -63,6 +80,24 @@ public class EnterpriseServiceImpl implements EnterpriseService {
public void updateEnterprise(EnterpriseSaveReqVO updateReqVO) {
// 校验存在
validateEnterpriseExists(updateReqVO.getId());
//如果图片有改变 先删除 在重新添加
if (updateReqVO.getFileIds().length > 0) {
LambdaQueryWrapper<FileInfoDO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(FileInfoDO::getUnitId, updateReqVO.getId().toString());
fileInfoMapper.delete(wrapper);
}
for (Long fileId : updateReqVO.getFileIds()) {
FileInfoDO fileInfoDO = new FileInfoDO();
fileInfoDO.setDictData(1l); //文件类型
fileInfoDO.setDictType(644l);
fileInfoDO.setUnitId(updateReqVO.getId().toString());
fileInfoDO.setInfraFileId(fileId);
fileInfoMapper.insert(fileInfoDO);
}
// 更新
EnterpriseDO updateObj = BeanUtils.toBean(updateReqVO, EnterpriseDO.class);
enterpriseMapper.updateById(updateObj);
@ -92,4 +127,11 @@ public class EnterpriseServiceImpl implements EnterpriseService {
return enterpriseMapper.selectPage(pageReqVO);
}
@Override
public List<EnterpriseDO> getEnterpriseByUserId(EnterprisePageReqVO pageReqVO) {
pageReqVO.setCreate(getLoginUserId().toString());
final PageResult<EnterpriseDO> enterpriseDOPageResult = enterpriseMapper.selectPage(pageReqVO);
return enterpriseDOPageResult.getList();
}
}

56
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fieldchangelog/FieldChangeLogService.java

@ -0,0 +1,56 @@
package cn.iocoder.yudao.module.system.service.fieldchangelog;
import java.util.*;
import cn.iocoder.yudao.module.system.controller.admin.fieldchangelog.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.fieldchangelog.FieldChangeLogDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import javax.validation.Valid;
/**
* 字段变更日志 Service 接口
*
* @author 芋道源码
*/
public interface FieldChangeLogService {
/**
* 创建字段变更日志
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createFieldChangeLog(@Valid FieldChangeLogSaveReqVO createReqVO);
/**
* 更新字段变更日志
*
* @param updateReqVO 更新信息
*/
void updateFieldChangeLog(@Valid FieldChangeLogSaveReqVO updateReqVO);
/**
* 删除字段变更日志
*
* @param id 编号
*/
void deleteFieldChangeLog(Long id);
/**
* 获得字段变更日志
*
* @param id 编号
* @return 字段变更日志
*/
FieldChangeLogDO getFieldChangeLog(Long id);
/**
* 获得字段变更日志分页
*
* @param pageReqVO 分页查询
* @return 字段变更日志分页
*/
PageResult<FieldChangeLogDO> getFieldChangeLogPage(FieldChangeLogPageReqVO pageReqVO);
}

75
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fieldchangelog/FieldChangeLogServiceImpl.java

@ -0,0 +1,75 @@
package cn.iocoder.yudao.module.system.service.fieldchangelog;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import cn.iocoder.yudao.module.system.controller.admin.fieldchangelog.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.fieldchangelog.FieldChangeLogDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.dal.mysql.fieldchangelog.FieldChangeLogMapper;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
/**
* 字段变更日志 Service 实现类
*
* @author 芋道源码
*/
@Service
@Validated
public class FieldChangeLogServiceImpl implements FieldChangeLogService {
@Resource
private FieldChangeLogMapper fieldChangeLogMapper;
@Override
public Long createFieldChangeLog(FieldChangeLogSaveReqVO createReqVO) {
// 插入
FieldChangeLogDO fieldChangeLog = BeanUtils.toBean(createReqVO, FieldChangeLogDO.class);
fieldChangeLogMapper.insert(fieldChangeLog);
// 返回
return fieldChangeLog.getId();
}
@Override
public void updateFieldChangeLog(FieldChangeLogSaveReqVO updateReqVO) {
// 校验存在
validateFieldChangeLogExists(updateReqVO.getId());
// 更新
FieldChangeLogDO updateObj = BeanUtils.toBean(updateReqVO, FieldChangeLogDO.class);
fieldChangeLogMapper.updateById(updateObj);
}
@Override
public void deleteFieldChangeLog(Long id) {
// 校验存在
validateFieldChangeLogExists(id);
// 删除
fieldChangeLogMapper.deleteById(id);
}
private void validateFieldChangeLogExists(Long id) {
if (fieldChangeLogMapper.selectById(id) == null) {
throw exception(FIELD_CHANGE_LOG_NOT_EXISTS);
}
}
@Override
public FieldChangeLogDO getFieldChangeLog(Long id) {
return fieldChangeLogMapper.selectById(id);
}
@Override
public PageResult<FieldChangeLogDO> getFieldChangeLogPage(FieldChangeLogPageReqVO pageReqVO) {
return fieldChangeLogMapper.selectPage(pageReqVO);
}
}

2
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java

@ -226,7 +226,7 @@ public interface AdminUserService {
* @Author djx
* @Date 2025-01-22 上午9:41
**/
AdminUserDO autoRegisterUser(AuthUser authUser);
AdminUserDO autoRegisterUser(AuthUser authUser, int userType);
void userAudit(UserAuditLogSaveReqVO auditLogSaveReqVO);
}

3
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java

@ -548,7 +548,7 @@ public class AdminUserServiceImpl implements AdminUserService {
* @Date 2025-01-22 上午9:40
**/
@Override
public AdminUserDO autoRegisterUser(AuthUser authUser) {
public AdminUserDO autoRegisterUser(AuthUser authUser, int userType) {
// 根据微信用户信息生成用户数据
AdminUserDO user = new AdminUserDO();
// openid.substring(openid.length() - 10)
@ -556,6 +556,7 @@ public class AdminUserServiceImpl implements AdminUserService {
user.setNickname(authUser.getNickname());
user.setAvatar(authUser.getAvatar());
user.setStatus(CommonStatusEnum.ENABLE.getStatus());
user.setUserType(userType);
user.setPassword(encodePassword(authUser.getUuid().substring(authUser.getUuid().length() - 10))); // 随机密码
userMapper.insert(user);
return user;

57
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/util/EntityUtils.java

@ -0,0 +1,57 @@
package cn.iocoder.yudao.module.system.util;
import cn.iocoder.yudao.module.system.annotation.PrimaryKey;
import com.baomidou.mybatisplus.annotation.TableName;
import java.lang.reflect.Field;
public class EntityUtils {
/**
* 获取实体类的主键值
*
* @param entity 实体对象
* @return 主键值
*/
public static Long getPrimaryKeyValue(Object entity) {
for (Field field : entity.getClass().getDeclaredFields()) {
if (field.isAnnotationPresent(PrimaryKey.class)) {
field.setAccessible(true);
try {
return (Long) field.get(entity); // 假设主键类型为 Long
} catch (IllegalAccessException e) {
throw new RuntimeException("无法访问主键字段的值", e);
}
}
}
throw new RuntimeException("实体类中未找到 @PrimaryKey 标记的字段");
}
/**
* 获取实体类对应的表名
*
* @param entity 实体对象
* @return 表名
*/
public static String getTableName(Object entity) {
TableName tableNameAnnotation = entity.getClass().getAnnotation(TableName.class);
return tableNameAnnotation != null ? tableNameAnnotation.value() : entity.getClass().getSimpleName();
}
/**
* 判断实体类是否包含 @PrimaryKey 注解的字段
*
* @param entity 实体对象
* @return 是否包含主键注解
*/
public static boolean hasPrimaryKeyAnnotation(Object entity) {
for (Field field : entity.getClass().getDeclaredFields()) {
if (field.isAnnotationPresent(PrimaryKey.class)) {
return true; // 找到带有 @PrimaryKey 的字段
}
}
return false; // 未找到
}
}
Loading…
Cancel
Save