Merge branch 'feature/easy-trans' of https://gitee.com/zhijiantianya/yudao-cloud
# Conflicts: # yudao-dependencies/pom.xml # yudao-framework/yudao-common/pom.xml # yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/logger/OperateLogApiImpl.java # yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/logger/OperateLogController.java # yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/logger/vo/operatelog/OperateLogRespVO.javapull/107/head
commit
3e8e3374f9
|
@ -0,0 +1,59 @@
|
||||||
|
package com.fhs.trans.service;
|
||||||
|
|
||||||
|
import com.fhs.core.trans.vo.VO;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 只有实现了这个接口的才能自动翻译
|
||||||
|
*
|
||||||
|
* 为什么要赋值粘贴到 yudao-common 包下?
|
||||||
|
* 因为 AutoTransable 属于 easy-trans-service 下,无法方便的在 yudao-module-xxx-api 模块下使用
|
||||||
|
*
|
||||||
|
* @author jackwang
|
||||||
|
* @since 2020-05-19 10:26:15
|
||||||
|
*/
|
||||||
|
public interface AutoTransable<V extends VO> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 ids 查询数据列表
|
||||||
|
*
|
||||||
|
* 改方法已过期啦,请使用 selectByIds
|
||||||
|
*
|
||||||
|
* @param ids 编号数组
|
||||||
|
* @return 数据列表
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default List<V> findByIds(List<? extends Object> ids){
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 ids 查询
|
||||||
|
*
|
||||||
|
* @param ids 编号数组
|
||||||
|
* @return 数据列表
|
||||||
|
*/
|
||||||
|
default List<V> selectByIds(List<? extends Object> ids){
|
||||||
|
return this.findByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 db 中所有的数据
|
||||||
|
*
|
||||||
|
* @return db 中所有的数据
|
||||||
|
*/
|
||||||
|
default List<V> select(){
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 id 获取 vo
|
||||||
|
*
|
||||||
|
* @param primaryValue id
|
||||||
|
* @return vo
|
||||||
|
*/
|
||||||
|
V selectById(Object primaryValue);
|
||||||
|
|
||||||
|
}
|
|
@ -71,6 +71,15 @@
|
||||||
<groupId>com.github.yulichang</groupId>
|
<groupId>com.github.yulichang</groupId>
|
||||||
<artifactId>mybatis-plus-join-boot-starter</artifactId> <!-- MyBatis 联表查询 -->
|
<artifactId>mybatis-plus-join-boot-starter</artifactId> <!-- MyBatis 联表查询 -->
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fhs-opensource</groupId> <!-- VO 数据翻译 -->
|
||||||
|
<artifactId>easy-trans-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fhs-opensource</groupId>
|
||||||
|
<artifactId>easy-trans-mybatis-plus-extend</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -3,6 +3,8 @@ package cn.iocoder.yudao.framework.mybatis.core.dataobject;
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fhs.core.trans.vo.TransPojo;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.apache.ibatis.type.JdbcType;
|
import org.apache.ibatis.type.JdbcType;
|
||||||
|
|
||||||
|
@ -12,10 +14,14 @@ import java.time.LocalDateTime;
|
||||||
/**
|
/**
|
||||||
* 基础实体对象
|
* 基础实体对象
|
||||||
*
|
*
|
||||||
|
* 为什么实现 {@link TransPojo} 接口?
|
||||||
|
* 因为使用 Easy-Trans TransType.SIMPLE 模式,集成 MyBatis Plus 查询
|
||||||
|
*
|
||||||
* @author 芋道源码
|
* @author 芋道源码
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public abstract class BaseDO implements Serializable {
|
@JsonIgnoreProperties(value = "transMap") // 由于 Easy-Trans 会添加 transMap 属性,避免 Jackson 在 Spring Cache 反序列化报错
|
||||||
|
public abstract class BaseDO implements Serializable, TransPojo {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package cn.iocoder.yudao.framework.translate.config;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.translate.core.TranslateUtils;
|
||||||
|
import com.fhs.trans.service.impl.TransService;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
||||||
|
@AutoConfiguration
|
||||||
|
public class YudaoTranslateAutoConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@SuppressWarnings({"InstantiationOfUtilityClass", "SpringJavaInjectionPointsAutowiringInspection"})
|
||||||
|
public TranslateUtils translateUtils(TransService transService) {
|
||||||
|
TranslateUtils.init(transService);
|
||||||
|
return new TranslateUtils();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package cn.iocoder.yudao.framework.translate.core;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.fhs.core.trans.vo.VO;
|
||||||
|
import com.fhs.trans.service.impl.TransService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VO 数据翻译 Utils
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public class TranslateUtils {
|
||||||
|
|
||||||
|
private static TransService transService;
|
||||||
|
|
||||||
|
public static void init(TransService transService) {
|
||||||
|
TranslateUtils.transService = transService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据翻译
|
||||||
|
*
|
||||||
|
* 使用场景:无法使用 @TransMethodResult 注解的场景,只能通过手动触发翻译
|
||||||
|
*
|
||||||
|
* @param data 数据
|
||||||
|
* @return 翻译结果
|
||||||
|
*/
|
||||||
|
public static <T extends VO> List<T> translate(List<T> data) {
|
||||||
|
if (CollUtil.isNotEmpty((data))) {
|
||||||
|
transService.transBatch(data);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
/**
|
||||||
|
* 使用 Easy-Trans 提升使用 VO 数据翻译的开发效率
|
||||||
|
*/
|
||||||
|
package cn.iocoder.yudao.framework.translate;
|
|
@ -1,2 +1,3 @@
|
||||||
cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration
|
cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration
|
||||||
cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration
|
cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration
|
||||||
|
cn.iocoder.yudao.framework.translate.config.YudaoTranslateAutoConfiguration
|
|
@ -1,23 +1,19 @@
|
||||||
package cn.iocoder.yudao.module.crm.controller.admin.product;
|
package cn.iocoder.yudao.module.crm.controller.admin.product;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||||
|
import cn.iocoder.yudao.framework.translate.core.TranslateUtils;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductRespVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductRespVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductSaveReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO;
|
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO;
|
||||||
import cn.iocoder.yudao.module.crm.enums.product.CrmProductStatusEnum;
|
import cn.iocoder.yudao.module.crm.enums.product.CrmProductStatusEnum;
|
||||||
import cn.iocoder.yudao.module.crm.service.product.CrmProductCategoryService;
|
|
||||||
import cn.iocoder.yudao.module.crm.service.product.CrmProductService;
|
import cn.iocoder.yudao.module.crm.service.product.CrmProductService;
|
||||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
@ -29,15 +25,11 @@ import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||||
import static java.util.Collections.singletonList;
|
|
||||||
|
|
||||||
@Tag(name = "管理后台 - CRM 产品")
|
@Tag(name = "管理后台 - CRM 产品")
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -47,9 +39,6 @@ public class CrmProductController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CrmProductService productService;
|
private CrmProductService productService;
|
||||||
@Resource
|
|
||||||
private CrmProductCategoryService productCategoryService;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private AdminUserApi adminUserApi;
|
private AdminUserApi adminUserApi;
|
||||||
|
|
||||||
|
@ -83,14 +72,7 @@ public class CrmProductController {
|
||||||
@PreAuthorize("@ss.hasPermission('crm:product:query')")
|
@PreAuthorize("@ss.hasPermission('crm:product:query')")
|
||||||
public CommonResult<CrmProductRespVO> getProduct(@RequestParam("id") Long id) {
|
public CommonResult<CrmProductRespVO> getProduct(@RequestParam("id") Long id) {
|
||||||
CrmProductDO product = productService.getProduct(id);
|
CrmProductDO product = productService.getProduct(id);
|
||||||
return success(buildProductDetail(product));
|
return success(BeanUtils.toBean(product, CrmProductRespVO.class));
|
||||||
}
|
|
||||||
|
|
||||||
private CrmProductRespVO buildProductDetail(CrmProductDO product) {
|
|
||||||
if (product == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return buildProductDetailList(singletonList(product)).get(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/simple-list")
|
@GetMapping("/simple-list")
|
||||||
|
@ -106,7 +88,7 @@ public class CrmProductController {
|
||||||
@PreAuthorize("@ss.hasPermission('crm:product:query')")
|
@PreAuthorize("@ss.hasPermission('crm:product:query')")
|
||||||
public CommonResult<PageResult<CrmProductRespVO>> getProductPage(@Valid CrmProductPageReqVO pageVO) {
|
public CommonResult<PageResult<CrmProductRespVO>> getProductPage(@Valid CrmProductPageReqVO pageVO) {
|
||||||
PageResult<CrmProductDO> pageResult = productService.getProductPage(pageVO);
|
PageResult<CrmProductDO> pageResult = productService.getProductPage(pageVO);
|
||||||
return success(new PageResult<>(buildProductDetailList(pageResult.getList()), pageResult.getTotal()));
|
return success(BeanUtils.toBean(pageResult, CrmProductRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/export-excel")
|
@GetMapping("/export-excel")
|
||||||
|
@ -119,27 +101,7 @@ public class CrmProductController {
|
||||||
List<CrmProductDO> list = productService.getProductPage(exportReqVO).getList();
|
List<CrmProductDO> list = productService.getProductPage(exportReqVO).getList();
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
ExcelUtils.write(response, "产品.xls", "数据", CrmProductRespVO.class,
|
ExcelUtils.write(response, "产品.xls", "数据", CrmProductRespVO.class,
|
||||||
buildProductDetailList(list));
|
TranslateUtils.translate(BeanUtils.toBean(list, CrmProductRespVO.class)));
|
||||||
}
|
|
||||||
|
|
||||||
private List<CrmProductRespVO> buildProductDetailList(List<CrmProductDO> list) {
|
|
||||||
if (CollUtil.isEmpty(list)) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
// 1.1 获得用户信息
|
|
||||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
|
|
||||||
convertSetByFlatMap(list, user -> Stream.of(Long.valueOf(user.getCreator()), user.getOwnerUserId())));
|
|
||||||
// 1.2 获得分类信息
|
|
||||||
Map<Long, CrmProductCategoryDO> categoryMap = productCategoryService.getProductCategoryMap(
|
|
||||||
convertSet(list, CrmProductDO::getCategoryId));
|
|
||||||
// 2. 拼接数据
|
|
||||||
return BeanUtils.toBean(list, CrmProductRespVO.class, productVO -> {
|
|
||||||
// 2.1 设置用户信息
|
|
||||||
MapUtils.findAndThen(userMap, productVO.getOwnerUserId(), user -> productVO.setOwnerUserName(user.getNickname()));
|
|
||||||
MapUtils.findAndThen(userMap, Long.valueOf(productVO.getCreator()), user -> productVO.setCreatorName(user.getNickname()));
|
|
||||||
// 2.2 设置分类名称
|
|
||||||
MapUtils.findAndThen(categoryMap, productVO.getCategoryId(), category -> productVO.setCategoryName(category.getName()));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,14 @@ package cn.iocoder.yudao.module.crm.controller.admin.product.vo.product;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO;
|
||||||
import cn.iocoder.yudao.module.crm.enums.DictTypeConstants;
|
import cn.iocoder.yudao.module.crm.enums.DictTypeConstants;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import com.fhs.core.trans.anno.Trans;
|
||||||
|
import com.fhs.core.trans.constant.TransType;
|
||||||
|
import com.fhs.core.trans.vo.VO;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
@ -14,7 +19,7 @@ import java.time.LocalDateTime;
|
||||||
@Schema(description = "管理后台 - CRM 产品 Response VO")
|
@Schema(description = "管理后台 - CRM 产品 Response VO")
|
||||||
@Data
|
@Data
|
||||||
@ExcelIgnoreUnannotated
|
@ExcelIgnoreUnannotated
|
||||||
public class CrmProductRespVO {
|
public class CrmProductRespVO implements VO {
|
||||||
|
|
||||||
@Schema(description = "产品编号", example = "20529")
|
@Schema(description = "产品编号", example = "20529")
|
||||||
@ExcelProperty("产品编号")
|
@ExcelProperty("产品编号")
|
||||||
|
@ -43,6 +48,7 @@ public class CrmProductRespVO {
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
@Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||||
|
@Trans(type = TransType.SIMPLE, target = CrmProductCategoryDO.class, fields = "name", ref = "categoryName")
|
||||||
private Long categoryId;
|
private Long categoryId;
|
||||||
@Schema(description = "产品分类名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "衣服")
|
@Schema(description = "产品分类名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "衣服")
|
||||||
@ExcelProperty("产品分类")
|
@ExcelProperty("产品分类")
|
||||||
|
@ -53,12 +59,16 @@ public class CrmProductRespVO {
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31926")
|
@Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31926")
|
||||||
|
@Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX,
|
||||||
|
fields = "nickname", ref = "ownerUserName")
|
||||||
private Long ownerUserId;
|
private Long ownerUserId;
|
||||||
@Schema(description = "负责人的用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
|
@Schema(description = "负责人的用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
|
||||||
@ExcelProperty("负责人")
|
@ExcelProperty("负责人")
|
||||||
private String ownerUserName;
|
private String ownerUserName;
|
||||||
|
|
||||||
@Schema(description = "创建人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "创建人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
|
@Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX,
|
||||||
|
fields = "nickname", ref = "creatorName")
|
||||||
private String creator;
|
private String creator;
|
||||||
@Schema(description = "创建人名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
|
@Schema(description = "创建人名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
|
||||||
@ExcelProperty("创建人")
|
@ExcelProperty("创建人")
|
||||||
|
|
|
@ -70,6 +70,11 @@ spring:
|
||||||
repositories:
|
repositories:
|
||||||
enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度
|
enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度
|
||||||
|
|
||||||
|
# VO 转换(数据翻译)相关
|
||||||
|
easy-trans:
|
||||||
|
is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口
|
||||||
|
is-enable-cloud: false # 禁用 TransType.RPC 微服务模式
|
||||||
|
|
||||||
--- #################### MQ 消息队列相关配置 ####################
|
--- #################### MQ 消息队列相关配置 ####################
|
||||||
|
|
||||||
--- #################### 定时任务相关配置 ####################
|
--- #################### 定时任务相关配置 ####################
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package cn.iocoder.yudao.module.system.api.logger.dto;
|
package cn.iocoder.yudao.module.system.api.logger.dto;
|
||||||
|
|
||||||
|
import com.fhs.core.trans.anno.Trans;
|
||||||
|
import com.fhs.core.trans.constant.TransType;
|
||||||
|
import com.fhs.core.trans.vo.VO;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
@ -7,11 +10,16 @@ import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Schema(name = "RPC 服务 - 系统操作日志 Response DTO")
|
@Schema(name = "RPC 服务 - 系统操作日志 Response DTO")
|
||||||
@Data
|
@Data
|
||||||
public class OperateLogV2RespDTO {
|
public class OperateLogV2RespDTO implements VO {
|
||||||
|
|
||||||
|
@Schema(description = "日志编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "链路追踪编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "89aca178-a370-411c-ae02-3f0d672be4ab")
|
@Schema(description = "链路追踪编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "89aca178-a370-411c-ae02-3f0d672be4ab")
|
||||||
private String traceId;
|
private String traceId;
|
||||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
|
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
|
||||||
|
@Trans(type = TransType.RPC, targetClassName = "cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO",
|
||||||
|
fields = "nickname", ref = "userName")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
@Schema(description = "用户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
@Schema(description = "用户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
package cn.iocoder.yudao.module.system.api.user;
|
package cn.iocoder.yudao.module.system.api.user;
|
||||||
|
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||||
import cn.iocoder.yudao.module.system.enums.ApiConstants;
|
import cn.iocoder.yudao.module.system.enums.ApiConstants;
|
||||||
|
import com.fhs.core.trans.anno.AutoTrans;
|
||||||
|
import com.fhs.trans.service.AutoTransable;
|
||||||
|
import feign.FeignIgnore;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
@ -13,9 +17,12 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.module.system.api.user.AdminUserApi.PREFIX;
|
||||||
|
|
||||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||||
@Tag(name = "RPC 服务 - 管理员用户")
|
@Tag(name = "RPC 服务 - 管理员用户")
|
||||||
public interface AdminUserApi {
|
@AutoTrans(namespace = PREFIX, fields = {"nickname"})
|
||||||
|
public interface AdminUserApi extends AutoTransable<AdminUserRespDTO> {
|
||||||
|
|
||||||
String PREFIX = ApiConstants.PREFIX + "/user";
|
String PREFIX = ApiConstants.PREFIX + "/user";
|
||||||
|
|
||||||
|
@ -71,4 +78,16 @@ public interface AdminUserApi {
|
||||||
@Parameter(name = "ids", description = "用户编号数组", example = "3,5", required = true)
|
@Parameter(name = "ids", description = "用户编号数组", example = "3,5", required = true)
|
||||||
CommonResult<Boolean> validateUserList(@RequestParam("ids") Collection<Long> ids);
|
CommonResult<Boolean> validateUserList(@RequestParam("ids") Collection<Long> ids);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@FeignIgnore
|
||||||
|
default List<AdminUserRespDTO> selectByIds(List<?> ids) {
|
||||||
|
return getUserList(Convert.toList(Long.class, ids)).getCheckedData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@FeignIgnore
|
||||||
|
default AdminUserRespDTO selectById(Object id) {
|
||||||
|
return getUser(Convert.toLong(id)).getCheckedData();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.iocoder.yudao.module.system.api.user.dto;
|
package cn.iocoder.yudao.module.system.api.user.dto;
|
||||||
|
|
||||||
|
import com.fhs.core.trans.vo.VO;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
@ -7,7 +8,7 @@ import java.util.Set;
|
||||||
|
|
||||||
@Schema(description = "RPC 服务 - Admin 用户 Response DTO")
|
@Schema(description = "RPC 服务 - Admin 用户 Response DTO")
|
||||||
@Data
|
@Data
|
||||||
public class AdminUserRespDTO {
|
public class AdminUserRespDTO implements VO {
|
||||||
|
|
||||||
@Schema(description = "用户 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "用户 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
|
@ -1,26 +1,19 @@
|
||||||
package cn.iocoder.yudao.module.system.api.logger;
|
package cn.iocoder.yudao.module.system.api.logger;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
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.module.system.api.logger.dto.OperateLogCreateReqDTO;
|
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2CreateReqDTO;
|
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2CreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2PageReqDTO;
|
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2PageReqDTO;
|
||||||
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2RespDTO;
|
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2RespDTO;
|
||||||
import cn.iocoder.yudao.module.system.convert.logger.OperateLogConvert;
|
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogV2DO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogV2DO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
|
||||||
import cn.iocoder.yudao.module.system.service.logger.OperateLogService;
|
import cn.iocoder.yudao.module.system.service.logger.OperateLogService;
|
||||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
||||||
|
|
||||||
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||||
@Validated
|
@Validated
|
||||||
|
@ -28,8 +21,6 @@ public class OperateLogApiImpl implements OperateLogApi {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private OperateLogService operateLogService;
|
private OperateLogService operateLogService;
|
||||||
@Resource
|
|
||||||
private AdminUserService adminUserService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommonResult<Boolean> createOperateLog(OperateLogCreateReqDTO createReqDTO) {
|
public CommonResult<Boolean> createOperateLog(OperateLogCreateReqDTO createReqDTO) {
|
||||||
|
@ -46,14 +37,7 @@ public class OperateLogApiImpl implements OperateLogApi {
|
||||||
@Override
|
@Override
|
||||||
public CommonResult<PageResult<OperateLogV2RespDTO>> getOperateLogPage(OperateLogV2PageReqDTO pageReqVO) {
|
public CommonResult<PageResult<OperateLogV2RespDTO>> getOperateLogPage(OperateLogV2PageReqDTO pageReqVO) {
|
||||||
PageResult<OperateLogV2DO> operateLogPage = operateLogService.getOperateLogPage(pageReqVO);
|
PageResult<OperateLogV2DO> operateLogPage = operateLogService.getOperateLogPage(pageReqVO);
|
||||||
if (CollUtil.isEmpty(operateLogPage.getList())) {
|
return success(BeanUtils.toBean(operateLogPage, OperateLogV2RespDTO.class));
|
||||||
return success(PageResult.empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取用户
|
|
||||||
List<AdminUserDO> userList = adminUserService.getUserList(
|
|
||||||
convertSet(operateLogPage.getList(), OperateLogV2DO::getUserId));
|
|
||||||
return success(OperateLogConvert.INSTANCE.convertPage(operateLogPage, userList));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
### 请求 /system/operate-log/demo 接口 => 成功
|
### 请求 /system/operate-log/page 接口 => 成功
|
||||||
GET {{baseUrl}}/system/operate-log/demo
|
GET {{systemBaseUrl}}/system/operate-log/page
|
||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
tenant-id: {{adminTenentId}}
|
tenant-id: {{adminTenentId}}
|
||||||
|
|
|
@ -3,32 +3,29 @@ package cn.iocoder.yudao.module.system.controller.admin.logger;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
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.excel.core.util.ExcelUtils;
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||||
|
import cn.iocoder.yudao.framework.translate.core.TranslateUtils;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.logger.vo.operatelog.OperateLogPageReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.logger.vo.operatelog.OperateLogPageReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.logger.vo.operatelog.OperateLogRespVO;
|
import cn.iocoder.yudao.module.system.controller.admin.logger.vo.operatelog.OperateLogRespVO;
|
||||||
import cn.iocoder.yudao.module.system.convert.logger.OperateLogConvert;
|
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
|
||||||
import cn.iocoder.yudao.module.system.service.logger.OperateLogService;
|
import cn.iocoder.yudao.module.system.service.logger.OperateLogService;
|
||||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
|
||||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 操作日志")
|
@Tag(name = "管理后台 - 操作日志")
|
||||||
|
@ -39,19 +36,13 @@ public class OperateLogController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private OperateLogService operateLogService;
|
private OperateLogService operateLogService;
|
||||||
@Resource
|
|
||||||
private AdminUserService userService;
|
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "查看操作日志分页列表")
|
@Operation(summary = "查看操作日志分页列表")
|
||||||
@PreAuthorize("@ss.hasPermission('system:operate-log:query')")
|
@PreAuthorize("@ss.hasPermission('system:operate-log:query')")
|
||||||
public CommonResult<PageResult<OperateLogRespVO>> pageOperateLog(@Valid OperateLogPageReqVO pageReqVO) {
|
public CommonResult<PageResult<OperateLogRespVO>> pageOperateLog(@Valid OperateLogPageReqVO pageReqVO) {
|
||||||
PageResult<OperateLogDO> pageResult = operateLogService.getOperateLogPage(pageReqVO);
|
PageResult<OperateLogDO> pageResult = operateLogService.getOperateLogPage(pageReqVO);
|
||||||
// 获得拼接需要的数据
|
return success(BeanUtils.toBean(pageResult, OperateLogRespVO.class));
|
||||||
Map<Long, AdminUserDO> userMap = userService.getUserMap(
|
|
||||||
convertList(pageResult.getList(), OperateLogDO::getUserId));
|
|
||||||
return success(new PageResult<>(OperateLogConvert.INSTANCE.convertList(pageResult.getList(), userMap),
|
|
||||||
pageResult.getTotal()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "导出操作日志")
|
@Operation(summary = "导出操作日志")
|
||||||
|
@ -61,11 +52,8 @@ public class OperateLogController {
|
||||||
public void exportOperateLog(HttpServletResponse response, @Valid OperateLogPageReqVO exportReqVO) throws IOException {
|
public void exportOperateLog(HttpServletResponse response, @Valid OperateLogPageReqVO exportReqVO) throws IOException {
|
||||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
List<OperateLogDO> list = operateLogService.getOperateLogPage(exportReqVO).getList();
|
List<OperateLogDO> list = operateLogService.getOperateLogPage(exportReqVO).getList();
|
||||||
// 输出
|
|
||||||
Map<Long, AdminUserDO> userMap = userService.getUserMap(
|
|
||||||
convertList(list, OperateLogDO::getUserId));
|
|
||||||
ExcelUtils.write(response, "操作日志.xls", "数据列表", OperateLogRespVO.class,
|
ExcelUtils.write(response, "操作日志.xls", "数据列表", OperateLogRespVO.class,
|
||||||
OperateLogConvert.INSTANCE.convertList(list, userMap));
|
TranslateUtils.translate(BeanUtils.toBean(list, OperateLogRespVO.class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,20 +2,24 @@ package cn.iocoder.yudao.module.system.controller.admin.logger.vo.operatelog;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import com.fhs.core.trans.anno.Trans;
|
||||||
|
import com.fhs.core.trans.constant.TransType;
|
||||||
|
import com.fhs.core.trans.vo.VO;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 操作日志 Response VO")
|
@Schema(description = "管理后台 - 操作日志 Response VO")
|
||||||
@Data
|
@Data
|
||||||
@ExcelIgnoreUnannotated
|
@ExcelIgnoreUnannotated
|
||||||
public class OperateLogRespVO {
|
public class OperateLogRespVO implements VO {
|
||||||
|
|
||||||
@Schema(description = "日志编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "日志编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
@ExcelProperty("日志编号")
|
@ExcelProperty("日志编号")
|
||||||
|
@ -25,6 +29,7 @@ public class OperateLogRespVO {
|
||||||
private String traceId;
|
private String traceId;
|
||||||
|
|
||||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
|
@Trans(type = TransType.SIMPLE, target = AdminUserDO.class, fields = "nickname", ref = "userNickname")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
package cn.iocoder.yudao.module.system.convert.logger;
|
|
||||||
|
|
||||||
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.MapUtils;
|
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
||||||
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2RespDTO;
|
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.logger.vo.operatelog.OperateLogRespVO;
|
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogDO;
|
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogV2DO;
|
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface OperateLogConvert {
|
|
||||||
|
|
||||||
OperateLogConvert INSTANCE = Mappers.getMapper(OperateLogConvert.class);
|
|
||||||
|
|
||||||
default List<OperateLogRespVO> convertList(List<OperateLogDO> list, Map<Long, AdminUserDO> userMap) {
|
|
||||||
return CollectionUtils.convertList(list, log -> {
|
|
||||||
OperateLogRespVO logVO = BeanUtils.toBean(log, OperateLogRespVO.class);
|
|
||||||
MapUtils.findAndThen(userMap, log.getUserId(), user -> logVO.setUserNickname(user.getNickname()));
|
|
||||||
return logVO;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
default PageResult<OperateLogV2RespDTO> convertPage(PageResult<OperateLogV2DO> operateLogPage, List<AdminUserDO> userList) {
|
|
||||||
return BeanUtils.toBean(operateLogPage, OperateLogV2RespDTO.class).setList(setUserInfo(operateLogPage.getList(), userList));
|
|
||||||
}
|
|
||||||
|
|
||||||
OperateLogV2RespDTO convert(OperateLogV2DO operateLogV2DO);
|
|
||||||
|
|
||||||
default List<OperateLogV2RespDTO> setUserInfo(List<OperateLogV2DO> logList, List<AdminUserDO> userList) {
|
|
||||||
Map<Long, AdminUserDO> userMap = convertMap(userList, AdminUserDO::getId);
|
|
||||||
return CollectionUtils.convertList(logList, item -> {
|
|
||||||
OperateLogV2RespDTO respDTO = convert(item);
|
|
||||||
findAndThen(userMap, item.getUserId(), user -> respDTO.setUserName(user.getNickname()));
|
|
||||||
return respDTO;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -70,6 +70,11 @@ spring:
|
||||||
repositories:
|
repositories:
|
||||||
enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度
|
enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度
|
||||||
|
|
||||||
|
# VO 转换(数据翻译)相关
|
||||||
|
easy-trans:
|
||||||
|
is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口
|
||||||
|
is-enable-cloud: false # 禁用 TransType.RPC 微服务模式
|
||||||
|
|
||||||
--- #################### RPC 远程调用相关配置 ####################
|
--- #################### RPC 远程调用相关配置 ####################
|
||||||
|
|
||||||
--- #################### 消息队列相关 ####################
|
--- #################### 消息队列相关 ####################
|
||||||
|
|
Loading…
Reference in New Issue