From 9b811f9e7de77fe31e67df9396734ec9d52cdae1 Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期二, 13 五月 2025 15:13:50 +0800 Subject: [PATCH] 集成内部开发代码生成 --- framework/src/main/java/cn/lili/group/Add.java | 8 + framework/src/main/java/cn/lili/base/AbsForm.java | 20 ++++ framework/src/main/java/cn/lili/base/AbsVo.java | 30 ++++++ config/application.yml | 11 ++ framework/src/main/java/cn/lili/utils/PageUtil.java | 28 +++++ framework/src/main/java/cn/lili/base/Result.java | 121 ++++++++++++++++++++++++ framework/src/main/java/cn/lili/group/Update.java | 8 + framework/src/main/java/cn/lili/base/AbsQuery.java | 26 +++++ 8 files changed, 251 insertions(+), 1 deletions(-) diff --git a/config/application.yml b/config/application.yml index 5f04ee7..762445f 100644 --- a/config/application.yml +++ b/config/application.yml @@ -170,12 +170,21 @@ # Mybatis-plus mybatis-plus: - mapper-locations: classpath*:mapper/*.xml + mapper-locations: classpath*:mapper/**/*.xml configuration: #缂撳瓨寮�鍚� cache-enabled: true + default-enum-type-handler: com.baomidou.mybatisplus.core.handlers.MybatisEnumTypeHandler # 閫氱敤鏋氫妇澶勭悊鍣� #鏃ュ織 # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + global-config: + db-config: + #閫昏緫鍒犻櫎閰嶇疆瀛楁 + logic-delete-field: deleteFlag + #閫昏緫鍒犻櫎閰嶇疆瀛楁 1 鍒犻櫎 + logic-delete-value: 1 + #閫昏緫鍒犻櫎閰嶇疆瀛楁 0 涓嶅垹闄� + logic-not-delete-value: 0 # 鏃ュ織 logging: diff --git a/framework/src/main/java/cn/lili/base/AbsForm.java b/framework/src/main/java/cn/lili/base/AbsForm.java new file mode 100644 index 0000000..4c0e6d2 --- /dev/null +++ b/framework/src/main/java/cn/lili/base/AbsForm.java @@ -0,0 +1,20 @@ +package cn.lili.base; + +import cn.lili.group.Update; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @author xp + * @date 2022/11/29 + */ +@Data +public abstract class AbsForm { + + @ApiModelProperty(value = "id,淇敼蹇呬紶", required = false) + @NotNull(message = "璇烽�夋嫨鏁版嵁", groups = {Update.class}) + private String id; + +} diff --git a/framework/src/main/java/cn/lili/base/AbsQuery.java b/framework/src/main/java/cn/lili/base/AbsQuery.java new file mode 100644 index 0000000..4c17758 --- /dev/null +++ b/framework/src/main/java/cn/lili/base/AbsQuery.java @@ -0,0 +1,26 @@ +package cn.lili.base; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.HashMap; +import java.util.Map; + +/** + * 鍩虹鍒嗛〉鏌ヨ锛岄粯璁ょ涓�椤碉紝姣忛〉10鏉� + * + * @author xp + * @date 2022/11/29 + */ +@Data +public class AbsQuery { + + @ApiModelProperty(value = "褰撳墠椤�", required = true) + private long pageNumber = 1L; + + @ApiModelProperty(value = "姣忛〉鏉℃暟", required = true) + private long pageSize = 10L; + + public Map<String, Object> params = new HashMap<>(2); + +} diff --git a/framework/src/main/java/cn/lili/base/AbsVo.java b/framework/src/main/java/cn/lili/base/AbsVo.java new file mode 100644 index 0000000..a58a36d --- /dev/null +++ b/framework/src/main/java/cn/lili/base/AbsVo.java @@ -0,0 +1,30 @@ +package cn.lili.base; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * @author xp + * @date 2022/11/29 + */ +@Data +public abstract class AbsVo { + + @ApiModelProperty("id") + private String id; + + @ApiModelProperty("鍒涘缓鏃堕棿") + private Date createTime; + + @ApiModelProperty("淇敼鏃堕棿") + private Date updateTime; + + @ApiModelProperty("鍒涘缓浜�") + private String createBy; + + @ApiModelProperty("淇敼浜�") + private String updateBy; + +} diff --git a/framework/src/main/java/cn/lili/base/Result.java b/framework/src/main/java/cn/lili/base/Result.java new file mode 100644 index 0000000..20ab87a --- /dev/null +++ b/framework/src/main/java/cn/lili/base/Result.java @@ -0,0 +1,121 @@ +package cn.lili.base; + +import org.springframework.lang.NonNull; + +import java.util.HashMap; + +/** + * 鎿嶄綔娑堟伅鎻愰啋 + * + * @author ruoyi + */ +public class Result extends HashMap<String, Object> { + + private static final long serialVersionUID = 1L; + + private static final String TOTAL = "total"; + + public static final String DATA = "data"; + + private static final String MSG = "msg"; + + private static final String CODE = "code"; + + public Result() { + put(MSG, "success"); + put(CODE, 200); + } + + /** + * 鎴愬姛锛屽暐涔熶笉鍋� + * @return + */ + public static Result ok() { + return new Result(); + } + + /** + * 鎴愬姛锛岃嚜瀹氫箟鎻愮ず淇℃伅 + * @param msg + * @return + */ + public static Result ok(String msg) { + Result result = new Result(); + result.put(MSG, msg); + return result; + } + + /** + * 澶辫触锛屽暐涔熶笉鍋� + * @return + */ + public static Result error() { + Result result = new Result(); + result.put(CODE, 500); + result.put(MSG, "鎿嶄綔澶辫触"); + return result; + } + + /** + * 澶辫触锛岃嚜瀹氫箟閿欒鎻愮ず + * @param msg + * @return + */ + public static Result error(String msg) { + Result result = new Result(); + result.put(CODE, 500); + result.put(MSG, msg); + return result; + } + + /** + * 澶辫触锛岃嚜瀹氫箟閿欒鐮� + * @param code + * @return + */ + public static Result error(@NonNull Integer code) { + Result result = new Result(); + result.put(CODE, code); + result.put(MSG, "鎿嶄綔澶辫触"); + return result; + } + + /** + * 澶辫触锛岃嚜瀹氫箟閿欒鐮佸拰閿欒鎻愮ず + * @param code + * @param msg + * @return + */ + public static Result error(@NonNull Integer code, String msg) { + Result result = new Result(); + result.put(CODE, code); + result.put(MSG, msg); + return result; + } + + /** + * 娣诲姞鏁版嵁 + * @param data + * @return + */ + public Result data(Object data) { + this.put(DATA, data); + return this; + } + + /** + * 娣诲姞鎬绘潯鏁� + * @param total + * @return + */ + public Result total(long total) { + this.put(TOTAL, total); + return this; + } + + @Override + public Result put(String key, Object value) { + super.put(key, value); + return this; + } +} diff --git a/framework/src/main/java/cn/lili/group/Add.java b/framework/src/main/java/cn/lili/group/Add.java new file mode 100644 index 0000000..55089f1 --- /dev/null +++ b/framework/src/main/java/cn/lili/group/Add.java @@ -0,0 +1,8 @@ +package cn.lili.group; + +/** + * @author锛歺p + * @date锛�2025/5/13 14:10 + */ +public interface Add { +} diff --git a/framework/src/main/java/cn/lili/group/Update.java b/framework/src/main/java/cn/lili/group/Update.java new file mode 100644 index 0000000..4036506 --- /dev/null +++ b/framework/src/main/java/cn/lili/group/Update.java @@ -0,0 +1,8 @@ +package cn.lili.group; + +/** + * @author锛歺p + * @date锛�2025/5/13 14:10 + */ +public interface Update { +} diff --git a/framework/src/main/java/cn/lili/utils/PageUtil.java b/framework/src/main/java/cn/lili/utils/PageUtil.java new file mode 100644 index 0000000..c3d5664 --- /dev/null +++ b/framework/src/main/java/cn/lili/utils/PageUtil.java @@ -0,0 +1,28 @@ +package cn.lili.utils; + +import cn.lili.base.AbsQuery; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +/** + * 鍒嗛〉宸ュ叿绫� + * @author xp + * @date 2022/12/2 + */ +public class PageUtil { + + /** + * 鑾峰彇plus鐨勫垎椤靛璞� + * @param q + * @param <T> 瀹炰綋绫� + * @param <Q> 鏌ヨ绫� + * @return + */ + public static <T, Q extends AbsQuery> IPage<T> getPage(Q q, Class<T> c) { + Page<T> page = new Page<T>() + .setCurrent(q.getPageNumber()) + .setSize(q.getPageSize()); + return page; + } + +} -- Gitblit v1.8.0