Skip to content

Commit

Permalink
refactor: 适配 Crane4j 条件注解
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Mar 8, 2024
1 parent 89546de commit bf00747
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import cn.crane4j.annotation.Assemble;
import cn.crane4j.annotation.Mapping;
import cn.crane4j.annotation.condition.ConditionOnPropertyNotNull;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
Expand Down Expand Up @@ -49,6 +50,7 @@ public class LogResp implements Serializable {
* 创建人
*/
@JsonIgnore
@ConditionOnPropertyNotNull
@Assemble(container = ContainerConstants.USER_NICKNAME, props = @Mapping(ref = "createUserString"))
private Long createUser;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
import cn.crane4j.annotation.AssembleMethod;
import cn.crane4j.annotation.ContainerMethod;
import cn.crane4j.annotation.Mapping;
import cn.crane4j.annotation.condition.ConditionOnExpression;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import top.charles7c.continew.admin.common.enums.DisEnableStatusEnum;
import top.charles7c.continew.admin.system.service.DeptService;
import top.charles7c.continew.starter.extension.crud.model.resp.BaseDetailResp;
import top.charles7c.continew.starter.extension.crud.converter.ExcelBaseEnumConverter;
import top.charles7c.continew.starter.extension.crud.model.resp.BaseDetailResp;

import java.io.Serial;

Expand Down Expand Up @@ -55,6 +56,7 @@ public class DeptDetailResp extends BaseDetailResp {
* 上级部门 ID
*/
@Schema(description = "上级部门 ID", example = "2")
@ConditionOnExpression(value = "#target.parentId != 0")
@AssembleMethod(targetType = DeptService.class, method = @ContainerMethod(bindMethod = "get", resultType = DeptDetailResp.class), props = @Mapping(src = "name", ref = "parentName"))
private Long parentId;

Expand Down

0 comments on commit bf00747

Please sign in to comment.