diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/service/SysLoginService.java b/ruoyi-admin/src/main/java/com/ruoyi/web/service/SysLoginService.java index 5887eca..7f28f15 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/service/SysLoginService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/service/SysLoginService.java @@ -149,13 +149,15 @@ public class SysLoginService { * 记录登录信息 * * @param userId 用户ID + * @param version 乐观锁 */ - public void recordLoginInfo(Long userId) { + public void recordLoginInfo(Long userId,Integer version) { SysUserBo sysUser = new SysUserBo(); sysUser.setUserId(userId); sysUser.setLoginIp(ServletUtils.getClientIP()); sysUser.setLoginDate(DateUtils.getNowDate()); sysUser.setUpdateBy(userId); + sysUser.setVersion(version); userService.updateUserProfile(sysUser); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/service/impl/PasswordAuthStrategy.java b/ruoyi-admin/src/main/java/com/ruoyi/web/service/impl/PasswordAuthStrategy.java index 4b9e5ec..7037a64 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/service/impl/PasswordAuthStrategy.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/service/impl/PasswordAuthStrategy.java @@ -81,7 +81,7 @@ public class PasswordAuthStrategy implements IAuthStrategy { LoginHelper.login(loginUser, model); loginService.recordLogininfor(loginUser.getTenantId(), username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")); - loginService.recordLoginInfo(user.getUserId()); + loginService.recordLoginInfo(user.getUserId(),user.getVersion()); LoginVo loginVo = new LoginVo(); loginVo.setAccessToken(StpUtil.getTokenValue()); diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/GenConstants.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/GenConstants.java index 1d1b1aa..2357855 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/GenConstants.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/GenConstants.java @@ -98,7 +98,7 @@ public class GenConstants { /** * Entity基类字段 */ - public static final String[] BASE_ENTITY = {"tenantId", "createBy", "createTime", "updateBy", "updateTime"}; + public static final String[] BASE_ENTITY = {"tenantId", "version", "createBy", "createTime", "updateBy", "updateTime"}; /** * Tree基类字段 diff --git a/ruoyi-common/ruoyi-common-orm/src/main/java/com/ruoyi/common/orm/core/domain/BaseEntity.java b/ruoyi-common/ruoyi-common-orm/src/main/java/com/ruoyi/common/orm/core/domain/BaseEntity.java index 8128aa8..3c3d9c5 100644 --- a/ruoyi-common/ruoyi-common-orm/src/main/java/com/ruoyi/common/orm/core/domain/BaseEntity.java +++ b/ruoyi-common/ruoyi-common-orm/src/main/java/com/ruoyi/common/orm/core/domain/BaseEntity.java @@ -27,8 +27,13 @@ public class BaseEntity implements Serializable { /** * 租户编号 */ + @Column(tenantId = true) private Long tenantId; + /** 乐观锁 */ + @Column(version = true) + private Integer version; + /** * 搜索值 */ diff --git a/ruoyi-common/ruoyi-common-orm/src/main/java/com/ruoyi/common/orm/core/domain/TreeEntity.java b/ruoyi-common/ruoyi-common-orm/src/main/java/com/ruoyi/common/orm/core/domain/TreeEntity.java index d06f97f..e7cb550 100644 --- a/ruoyi-common/ruoyi-common-orm/src/main/java/com/ruoyi/common/orm/core/domain/TreeEntity.java +++ b/ruoyi-common/ruoyi-common-orm/src/main/java/com/ruoyi/common/orm/core/domain/TreeEntity.java @@ -1,6 +1,7 @@ package com.ruoyi.common.orm.core.domain; import com.mybatisflex.annotation.Column; +import lombok.Data; import java.io.Serial; import java.util.ArrayList; @@ -10,7 +11,9 @@ import java.util.List; * Tree基类 * * @author ruoyi + * @author 数据小王子 */ +@Data public class TreeEntity extends BaseEntity { @Serial @@ -33,54 +36,4 @@ public class TreeEntity extends BaseEntity /** 子部门 */ @Column(ignore = true) private List children = new ArrayList<>(); - - public String getParentName() - { - return parentName; - } - - public void setParentName(String parentName) - { - this.parentName = parentName; - } - - public Long getParentId() - { - return parentId; - } - - public void setParentId(Long parentId) - { - this.parentId = parentId; - } - - public Integer getOrderNum() - { - return orderNum; - } - - public void setOrderNum(Integer orderNum) - { - this.orderNum = orderNum; - } - - public String getAncestors() - { - return ancestors; - } - - public void setAncestors(String ancestors) - { - this.ancestors = ancestors; - } - - public List getChildren() - { - return children; - } - - public void setChildren(List children) - { - this.children = children; - } } diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/controller/MfProductController.java b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/controller/MfProductController.java index 3749406..5fe6b4c 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/controller/MfProductController.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/controller/MfProductController.java @@ -1,9 +1,9 @@ package com.ruoyi.mf.controller; import java.util.List; - import lombok.RequiredArgsConstructor; import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.constraints.*; import cn.dev33.satoken.annotation.SaCheckPermission; import org.springframework.web.bind.annotation.*; import org.springframework.validation.annotation.Validated; @@ -23,7 +23,7 @@ import com.ruoyi.mf.service.IMfProductService; * 产品树Controller * * @author 数据小王子 - * 2023-11-23 + * 2024-01-06 */ @Validated @RequiredArgsConstructor @@ -94,7 +94,7 @@ public class MfProductController extends BaseController { Boolean updated = mfProductService.update(mfProductBo); if (!updated) { - R.fail("修改产品树记录失败!"); + return R.fail("修改产品树记录失败!"); } return R.ok(); } @@ -109,7 +109,7 @@ public class MfProductController extends BaseController { boolean deleted = mfProductService.deleteByIds(productIds); if (!deleted) { - R.fail("删除产品树记录失败!"); + return R.fail("删除产品树记录失败!"); } return R.ok(); } diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/controller/MfStudentController.java b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/controller/MfStudentController.java index 941d745..0cc85a6 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/controller/MfStudentController.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/controller/MfStudentController.java @@ -1,9 +1,9 @@ package com.ruoyi.mf.controller; import java.util.List; - import lombok.RequiredArgsConstructor; import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.constraints.*; import cn.dev33.satoken.annotation.SaCheckPermission; import org.springframework.web.bind.annotation.*; import org.springframework.validation.annotation.Validated; @@ -24,7 +24,7 @@ import com.ruoyi.common.orm.core.page.TableDataInfo; * 学生信息表Controller * * @author 数据小王子 - * 2023-11-22 + * 2024-01-05 */ @Validated @RequiredArgsConstructor @@ -94,7 +94,7 @@ public class MfStudentController extends BaseController { Boolean updated = mfStudentService.update(mfStudentBo); if (!updated) { - R.fail("修改学生信息表记录失败!"); + return R.fail("修改学生信息表记录失败!"); } return R.ok(); } @@ -109,7 +109,7 @@ public class MfStudentController extends BaseController { boolean deleted = mfStudentService.deleteByIds(studentIds); if (!deleted) { - R.fail("删除学生信息表记录失败!"); + return R.fail("删除学生信息表记录失败!"); } return R.ok(); } diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/Customer.java b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/Customer.java index be34c33..f087a11 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/Customer.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/Customer.java @@ -4,23 +4,28 @@ import java.util.List; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.mf.domain.Goods; +import com.mybatisflex.annotation.Column; import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.Table; import lombok.Data; import lombok.EqualsAndHashCode; +import java.io.Serial; import com.ruoyi.common.orm.core.domain.BaseEntity; /** * 客户主表对象 mf_customer * * @author 数据小王子 - * 2023-12-06 + * 2024-01-06 */ @Data @EqualsAndHashCode(callSuper = true) @Table(value = "mf_customer") public class Customer extends BaseEntity { + @Serial + private static final long serialVersionUID = 1L; + /** 客户id */ @Id private Long customerId; @@ -40,7 +45,11 @@ public class Customer extends BaseEntity /** 客户描述 */ private String remark; - /** 商品子表信息 */ + /** 逻辑删除标志(0代表存在 1代表删除) */ + @Column(isLogicDelete = true) + private Integer delFlag; + + /** 商品子信息 */ private List goodsList; } diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/Goods.java b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/Goods.java index 23823fd..84c848f 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/Goods.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/Goods.java @@ -12,10 +12,10 @@ import java.io.Serializable; import com.ruoyi.common.orm.core.domain.BaseEntity; /** - * 商品子表对象 mf_goods + * 商品子对象 mf_goods * * @author 数据小王子 - * 2023-12-06 + * 2024-01-06 */ @Data @EqualsAndHashCode(callSuper = true) @@ -36,7 +36,7 @@ public class Goods extends BaseEntity private String name; /** 商品重量 */ - private Long weight; + private Integer weight; /** 商品价格 */ private BigDecimal price; diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/MfProduct.java b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/MfProduct.java index 6229ed9..efab9ca 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/MfProduct.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/MfProduct.java @@ -1,22 +1,28 @@ package com.ruoyi.mf.domain; + +import com.mybatisflex.annotation.Column; import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.Table; import lombok.Data; import lombok.EqualsAndHashCode; +import java.io.Serial; import com.ruoyi.common.orm.core.domain.TreeEntity; /** * 产品树对象 mf_product * * @author 数据小王子 - * 2023-11-23 + * 2024-01-06 */ @Data @EqualsAndHashCode(callSuper = true) @Table(value = "mf_product") public class MfProduct extends TreeEntity { + @Serial + private static final long serialVersionUID = 1L; + /** 产品id */ @Id private Long productId; @@ -27,4 +33,9 @@ public class MfProduct extends TreeEntity /** 产品状态(0正常 1停用) */ private String status; + /** 逻辑删除标志(0代表存在 1代表删除) */ + @Column(isLogicDelete = true) + private Integer delFlag; + + } diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/MfStudent.java b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/MfStudent.java index 6f2630d..f9b00be 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/MfStudent.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/MfStudent.java @@ -2,23 +2,29 @@ package com.ruoyi.mf.domain; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; + +import com.mybatisflex.annotation.Column; import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.Table; import lombok.Data; import lombok.EqualsAndHashCode; +import java.io.Serial; import com.ruoyi.common.orm.core.domain.BaseEntity; /** * 学生信息表对象 mf_student * * @author 数据小王子 - * 2023-11-22 + * 2024-01-06 */ @Data @EqualsAndHashCode(callSuper = true) @Table(value = "mf_student") public class MfStudent extends BaseEntity { + @Serial + private static final long serialVersionUID = 1L; + /** 编号 */ @Id private Long studentId; @@ -27,7 +33,7 @@ public class MfStudent extends BaseEntity private String studentName; /** 年龄 */ - private Long studentAge; + private Integer studentAge; /** 爱好(0代码 1音乐 2电影) */ private String studentHobby; @@ -41,4 +47,9 @@ public class MfStudent extends BaseEntity /** 生日 */ private Date studentBirthday; + /** 逻辑删除标志(0代表存在 1代表删除) */ + @Column(isLogicDelete = true) + private Integer delFlag; + + } diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/bo/CustomerBo.java b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/bo/CustomerBo.java index dc5f61e..b70cee7 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/bo/CustomerBo.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/bo/CustomerBo.java @@ -15,7 +15,7 @@ import com.ruoyi.common.orm.core.domain.BaseEntity; * 客户主表业务对象 mf_customer * * @author 数据小王子 - * @date 2023-12-06 + * @date 2024-01-06 */ @Data @EqualsAndHashCode(callSuper = true) @@ -31,30 +31,34 @@ public class CustomerBo extends BaseEntity /** * 客户姓名 */ + @NotBlank(message = "客户姓名不能为空") private String customerName; /** * 手机号码 */ + @NotBlank(message = "手机号码不能为空") private String phonenumber; /** * 客户性别 */ + @NotBlank(message = "客户性别不能为空") private String gender; /** * 客户生日 */ + @NotNull(message = "客户生日不能为空") @JsonFormat(pattern = "yyyy-MM-dd") private Date birthday; /** * 客户描述 */ + @NotBlank(message = "客户描述不能为空") private String remark; - - /** 商品子表信息 */ + /** 商品子信息 */ private List goodsList; } diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/bo/MfProductBo.java b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/bo/MfProductBo.java index d817bf1..91a213b 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/bo/MfProductBo.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/bo/MfProductBo.java @@ -11,7 +11,7 @@ import com.ruoyi.common.orm.core.domain.TreeEntity; * 产品树业务对象 mf_product * * @author 数据小王子 - * @date 2023-11-23 + * @date 2024-01-06 */ @Data @EqualsAndHashCode(callSuper = true) @@ -36,5 +36,4 @@ public class MfProductBo extends TreeEntity @NotBlank(message = "产品状态(0正常 1停用)不能为空") private String status; - } diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/bo/MfStudentBo.java b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/bo/MfStudentBo.java index 7881d0d..9f301c4 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/bo/MfStudentBo.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/bo/MfStudentBo.java @@ -1,24 +1,25 @@ package com.ruoyi.mf.domain.bo; import com.ruoyi.mf.domain.MfStudent; -import com.ruoyi.common.orm.core.domain.BaseEntity; import io.github.linpeilie.annotations.AutoMapper; import lombok.Data; import lombok.EqualsAndHashCode; import jakarta.validation.constraints.*; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.orm.core.domain.BaseEntity; /** * 学生信息表业务对象 mf_student * * @author 数据小王子 - * @date 2023-11-22 + * @date 2024-01-05 */ @Data @EqualsAndHashCode(callSuper = true) @AutoMapper(target = MfStudent.class, reverseConvertGenerate = false) -public class MfStudentBo extends BaseEntity { +public class MfStudentBo extends BaseEntity +{ /** * 编号 @@ -35,7 +36,7 @@ public class MfStudentBo extends BaseEntity { * 年龄 */ @NotNull(message = "年龄不能为空") - private Long studentAge; + private Integer studentAge; /** * 爱好(0代码 1音乐 2电影) @@ -62,5 +63,4 @@ public class MfStudentBo extends BaseEntity { @JsonFormat(pattern = "yyyy-MM-dd") private Date studentBirthday; - } diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/vo/CustomerVo.java b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/vo/CustomerVo.java index 8be307e..13efc74 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/vo/CustomerVo.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/vo/CustomerVo.java @@ -22,7 +22,7 @@ import com.ruoyi.common.orm.core.domain.BaseEntity; * 客户主表视图对象 mf_customer * * @author 数据小王子 - * @date 2023-12-06 + * @date 2024-01-06 */ @Data @ExcelIgnoreUnannotated @@ -59,8 +59,12 @@ public class CustomerVo extends BaseEntity implements Serializable @ExcelProperty(value = "客户描述") private String remark; + /** 逻辑删除标志(0代表存在 1代表删除) */ + @ExcelProperty(value = "逻辑删除标志(0代表存在 1代表删除)") + private Integer delFlag; - /** 商品子表信息 */ + + /** 商品子信息 */ @RelationOneToMany(selfField = "customerId", targetField = "customerId") private List goodsList; diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/vo/MfProductVo.java b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/vo/MfProductVo.java index f3c0c1a..69bee13 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/vo/MfProductVo.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/vo/MfProductVo.java @@ -8,7 +8,6 @@ import com.ruoyi.common.excel.convert.ExcelDictConvert; import io.github.linpeilie.annotations.AutoMapper; import lombok.Data; import lombok.EqualsAndHashCode; - import java.io.Serial; import java.io.Serializable; import java.util.Date; @@ -18,7 +17,7 @@ import com.ruoyi.common.orm.core.domain.TreeEntity; * 产品树视图对象 mf_product * * @author 数据小王子 - * @date 2023-11-23 + * @date 2024-01-06 */ @Data @ExcelIgnoreUnannotated @@ -43,4 +42,8 @@ public class MfProductVo extends TreeEntity implements Serializable @ExcelDictFormat(dictType = "sys_student_status") private String status; + /** 逻辑删除标志(0代表存在 1代表删除) */ + @ExcelProperty(value = "逻辑删除标志(0代表存在 1代表删除)") + private Integer delFlag; + } diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/vo/MfStudentVo.java b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/vo/MfStudentVo.java index e2016c0..ad62a47 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/vo/MfStudentVo.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/domain/vo/MfStudentVo.java @@ -9,19 +9,17 @@ import com.ruoyi.common.excel.annotation.ExcelDictFormat; import com.ruoyi.common.excel.convert.ExcelDictConvert; import io.github.linpeilie.annotations.AutoMapper; import lombok.Data; - +import lombok.EqualsAndHashCode; import java.io.Serial; import java.io.Serializable; import java.util.Date; import com.ruoyi.common.orm.core.domain.BaseEntity; -import lombok.EqualsAndHashCode; - /** * 学生信息表视图对象 mf_student * * @author 数据小王子 - * @date 2023-11-22 + * @date 2024-01-05 */ @Data @ExcelIgnoreUnannotated @@ -43,7 +41,7 @@ public class MfStudentVo extends BaseEntity implements Serializable /** 年龄 */ @ExcelProperty(value = "年龄") - private Long studentAge; + private Integer studentAge; /** 爱好(0代码 1音乐 2电影) */ @ExcelProperty(value = "爱好", converter = ExcelDictConvert.class) @@ -64,4 +62,8 @@ public class MfStudentVo extends BaseEntity implements Serializable @ExcelProperty(value = "生日") private Date studentBirthday; + /** 逻辑删除标志(0代表存在 1代表删除) */ + @ExcelProperty(value = "逻辑删除标志(0代表存在 1代表删除)") + private Integer delFlag; + } diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/mapper/MfProductMapper.java b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/mapper/MfProductMapper.java index 18b39f4..35daf30 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/mapper/MfProductMapper.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/mapper/MfProductMapper.java @@ -8,7 +8,7 @@ import com.ruoyi.mf.domain.MfProduct; * 产品树Mapper接口 * * @author 数据小王子 - * 2023-11-23 + * 2024-01-06 */ @Mapper public interface MfProductMapper extends BaseMapper diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/IMfProductService.java b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/IMfProductService.java index 4fd836d..93a69bb 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/IMfProductService.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/IMfProductService.java @@ -10,7 +10,7 @@ import com.ruoyi.common.orm.core.service.IBaseService; * 产品树Service接口 * * @author 数据小王子 - * 2023-11-23 + * 2024-01-06 */ public interface IMfProductService extends IBaseService { diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/IMfStudentService.java b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/IMfStudentService.java index 098cbc5..0ee1c9b 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/IMfStudentService.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/IMfStudentService.java @@ -11,7 +11,7 @@ import com.ruoyi.common.orm.core.page.TableDataInfo; * 学生信息表Service接口 * * @author 数据小王子 - * 2023-11-22 + * 2024-01-05 */ public interface IMfStudentService extends IBaseService { diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/impl/CustomerServiceImpl.java b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/impl/CustomerServiceImpl.java index ecce1a8..b02349e 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/impl/CustomerServiceImpl.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/impl/CustomerServiceImpl.java @@ -3,42 +3,40 @@ package com.ruoyi.mf.service.impl; import java.util.Arrays; import java.util.List; import java.util.Map; - import cn.hutool.core.util.ObjectUtil; import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.query.QueryWrapper; +import com.mybatisflex.core.relation.RelationManager; import com.ruoyi.common.core.utils.MapstructUtils; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.orm.core.page.PageQuery; import com.ruoyi.common.orm.core.page.TableDataInfo; import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl; +import com.ruoyi.common.core.utils.DateUtils; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; - import java.util.ArrayList; - +import java.util.Arrays; import com.ruoyi.mf.domain.Goods; import com.ruoyi.mf.mapper.GoodsMapper; - import static com.ruoyi.mf.domain.table.GoodsTableDef.GOODS; - import com.ruoyi.mf.mapper.CustomerMapper; import com.ruoyi.mf.domain.Customer; import com.ruoyi.mf.domain.bo.CustomerBo; import com.ruoyi.mf.domain.vo.CustomerVo; import com.ruoyi.mf.service.ICustomerService; - import static com.ruoyi.mf.domain.table.CustomerTableDef.CUSTOMER; /** * 客户主表Service业务层处理 * * @author 数据小王子 - * 2023-12-06 + * 2024-01-06 */ @Service -public class CustomerServiceImpl extends BaseServiceImpl implements ICustomerService { +public class CustomerServiceImpl extends BaseServiceImpl implements ICustomerService +{ @Resource private CustomerMapper customerMapper; @Resource @@ -54,6 +52,7 @@ public class CustomerServiceImpl extends BaseServiceImpl selectList(CustomerBo customerBo) { + public List selectList(CustomerBo customerBo) + { QueryWrapper queryWrapper = buildQueryWrapper(customerBo); return customerMapper.selectListWithRelationsByQueryAs(queryWrapper, CustomerVo.class); } @@ -88,8 +89,11 @@ public class CustomerServiceImpl extends BaseServiceImpl selectPage(CustomerBo customerBo) { + public TableDataInfo selectPage(CustomerBo customerBo) + { QueryWrapper queryWrapper = buildQueryWrapper(customerBo); + //忽略注解,本次不查询子表数据 + RelationManager.addIgnoreRelations("goodsList"); Page page = customerMapper.paginateWithRelationsAs(PageQuery.build(), queryWrapper, CustomerVo.class); return TableDataInfo.build(page); } @@ -102,7 +106,8 @@ public class CustomerServiceImpl extends BaseServiceImpl goodsList = customer.getGoodsList(); Long customerId = customer.getCustomerId(); - if (StringUtils.isNotNull(goodsList)) { + if (StringUtils.isNotNull(goodsList)) + { List list = new ArrayList<>(); - for (Goods goods : goodsList) { + for (Goods goods : goodsList) + { goods.setCustomerId(customerId); list.add(goods); } - if (list.size() > 0) { - return goodsMapper.insertBatch(list) > 0; + if (list.size() > 0) + { + return goodsMapper.insertBatch(list)>0; } } return true; diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/impl/MfProductServiceImpl.java b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/impl/MfProductServiceImpl.java index 1595583..d9a737c 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/impl/MfProductServiceImpl.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/impl/MfProductServiceImpl.java @@ -3,10 +3,15 @@ package com.ruoyi.mf.service.impl; import java.util.Arrays; import java.util.List; import java.util.Map; - +import cn.hutool.core.util.ObjectUtil; +import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.query.QueryWrapper; import com.ruoyi.common.core.utils.MapstructUtils; +import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.common.orm.core.page.PageQuery; +import com.ruoyi.common.orm.core.page.TableDataInfo; import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl; +import com.ruoyi.common.core.utils.DateUtils; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -15,17 +20,17 @@ import com.ruoyi.mf.domain.MfProduct; import com.ruoyi.mf.domain.bo.MfProductBo; import com.ruoyi.mf.domain.vo.MfProductVo; import com.ruoyi.mf.service.IMfProductService; - import static com.ruoyi.mf.domain.table.MfProductTableDef.MF_PRODUCT; /** * 产品树Service业务层处理 * * @author 数据小王子 - * 2023-11-23 + * 2024-01-06 */ @Service -public class MfProductServiceImpl extends BaseServiceImpl implements IMfProductService { +public class MfProductServiceImpl extends BaseServiceImpl implements IMfProductService +{ @Resource private MfProductMapper mfProductMapper; @@ -37,8 +42,9 @@ public class MfProductServiceImpl extends BaseServiceImpl selectList(MfProductBo mfProductBo) { + public List selectList(MfProductBo mfProductBo) + { QueryWrapper queryWrapper = buildQueryWrapper(mfProductBo); return this.listAs(queryWrapper, MfProductVo.class); } @@ -73,7 +82,8 @@ public class MfProductServiceImpl extends BaseServiceImpl implements IMfStudentService { +public class MfStudentServiceImpl extends BaseServiceImpl implements IMfStudentService +{ @Resource private MfStudentMapper mfStudentMapper; @@ -41,6 +43,7 @@ public class MfStudentServiceImpl extends BaseServiceImpl selectList(MfStudentBo mfStudentBo) { + public List selectList(MfStudentBo mfStudentBo) + { QueryWrapper queryWrapper = buildQueryWrapper(mfStudentBo); return this.listAs(queryWrapper, MfStudentVo.class); } @@ -74,8 +80,8 @@ public class MfStudentServiceImpl extends BaseServiceImpl selectPage(MfStudentBo mfStudentBo) { + public TableDataInfo selectPage(MfStudentBo mfStudentBo) + { QueryWrapper queryWrapper = buildQueryWrapper(mfStudentBo); Page page = this.pageAs(PageQuery.build(), queryWrapper, MfStudentVo.class); return TableDataInfo.build(page); @@ -88,7 +94,8 @@ public class MfStudentServiceImpl extends BaseServiceImpl= 500 || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType) ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT; column.setHtmlType(htmlType); - } - else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) - { + } else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) { column.setJavaType(GenConstants.TYPE_DATE); column.setHtmlType(GenConstants.HTML_DATETIME); - } - else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) - { + } else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) { column.setHtmlType(GenConstants.HTML_INPUT); - - // 如果是浮点型 统一用BigDecimal - String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ","); - if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) - { - column.setJavaType(GenConstants.TYPE_BIGDECIMAL); - } - // 如果是整形 - else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10) - { + if (arraysContains(GenConstants.COLUMNTYPE_INTEGER, dataType)) { column.setJavaType(GenConstants.TYPE_INTEGER); - } - // 长整形 - else - { - column.setJavaType(GenConstants.TYPE_LONG); + } else if ("numeric".equals(dataType)) { + column.setJavaType(GenConstants.TYPE_BIGDECIMAL);//为PostgreSQL数据库设置numeric类型 + } else { + // 如果是浮点型 统一用BigDecimal + String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ","); + if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) { + column.setJavaType(GenConstants.TYPE_BIGDECIMAL); + } + // 如果是整形 + else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10) { + column.setJavaType(GenConstants.TYPE_INTEGER); + } + // 长整形 + else { + column.setJavaType(GenConstants.TYPE_LONG); + } } } @@ -105,34 +99,28 @@ public class GenUtils } // 查询字段类型 - if (StringUtils.endsWithIgnoreCase(columnName, "name")) - { + if (StringUtils.endsWithIgnoreCase(columnName, "name")) { column.setQueryType(GenConstants.QUERY_LIKE); } // 状态字段设置单选框 - if (StringUtils.endsWithIgnoreCase(columnName, "status")) - { + if (StringUtils.endsWithIgnoreCase(columnName, "status")) { column.setHtmlType(GenConstants.HTML_RADIO); } // 类型&性别字段设置下拉框 else if (StringUtils.endsWithIgnoreCase(columnName, "type") - || StringUtils.endsWithIgnoreCase(columnName, "gender")) - { + || StringUtils.endsWithIgnoreCase(columnName, "gender")) { column.setHtmlType(GenConstants.HTML_SELECT); } // 图片字段设置图片上传控件 - else if (StringUtils.endsWithIgnoreCase(columnName, "image")) - { + else if (StringUtils.endsWithIgnoreCase(columnName, "image")) { column.setHtmlType(GenConstants.HTML_IMAGE_UPLOAD); } // 文件字段设置文件上传控件 - else if (StringUtils.endsWithIgnoreCase(columnName, "file")) - { + else if (StringUtils.endsWithIgnoreCase(columnName, "file")) { column.setHtmlType(GenConstants.HTML_FILE_UPLOAD); } // 内容字段设置富文本控件 - else if (StringUtils.endsWithIgnoreCase(columnName, "content")) - { + else if (StringUtils.endsWithIgnoreCase(columnName, "content")) { column.setHtmlType(GenConstants.HTML_EDITOR); } } @@ -140,12 +128,11 @@ public class GenUtils /** * 校验数组是否包含指定值 * - * @param arr 数组 + * @param arr 数组 * @param targetValue 值 * @return 是否包含 */ - public static boolean arraysContains(String[] arr, String targetValue) - { + public static boolean arraysContains(String[] arr, String targetValue) { return Arrays.asList(arr).contains(targetValue); } @@ -155,8 +142,7 @@ public class GenUtils * @param packageName 包名 * @return 模块名 */ - public static String getModuleName(String packageName) - { + public static String getModuleName(String packageName) { int lastIndex = packageName.lastIndexOf("."); int nameLength = packageName.length(); return StringUtils.substring(packageName, lastIndex + 1, nameLength); @@ -168,8 +154,7 @@ public class GenUtils * @param tableName 表名 * @return 业务名 */ - public static String getBusinessName(String tableName) - { + public static String getBusinessName(String tableName) { int firstIndex = tableName.indexOf("_"); int nameLength = tableName.length(); String businessName = StringUtils.substring(tableName, firstIndex + 1, nameLength); @@ -183,12 +168,10 @@ public class GenUtils * @param tableName 表名称 * @return 类名 */ - public static String convertClassName(String tableName) - { + public static String convertClassName(String tableName) { boolean autoRemovePre = GenConfig.getAutoRemovePre(); String tablePrefix = GenConfig.getTablePrefix(); - if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) - { + if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) { String[] searchList = StringUtils.split(tablePrefix, ","); tableName = replaceFirst(tableName, searchList); } @@ -199,15 +182,12 @@ public class GenUtils * 批量替换前缀 * * @param replacementm 替换值 - * @param searchList 替换列表 + * @param searchList 替换列表 */ - public static String replaceFirst(String replacementm, String[] searchList) - { + public static String replaceFirst(String replacementm, String[] searchList) { String text = replacementm; - for (String searchString : searchList) - { - if (replacementm.startsWith(searchString)) - { + for (String searchString : searchList) { + if (replacementm.startsWith(searchString)) { text = replacementm.replaceFirst(searchString, ""); break; } @@ -221,8 +201,7 @@ public class GenUtils * @param text 需要被替换的名字 * @return 替换后的名字 */ - public static String replaceText(String text) - { + public static String replaceText(String text) { return RegExUtils.replaceAll(text, "(?:表|若依)", ""); } @@ -232,14 +211,10 @@ public class GenUtils * @param columnType 列类型 * @return 截取后的列类型 */ - public static String getDbType(String columnType) - { - if (StringUtils.indexOf(columnType, "(") > 0) - { + public static String getDbType(String columnType) { + if (StringUtils.indexOf(columnType, "(") > 0) { return StringUtils.substringBefore(columnType, "("); - } - else - { + } else { return columnType; } } @@ -250,15 +225,11 @@ public class GenUtils * @param columnType 列类型 * @return 截取后的列类型 */ - public static Integer getColumnLength(String columnType) - { - if (StringUtils.indexOf(columnType, "(") > 0) - { + public static Integer getColumnLength(String columnType) { + if (StringUtils.indexOf(columnType, "(") > 0) { String length = StringUtils.substringBetween(columnType, "(", ")"); return Integer.valueOf(length); - } - else - { + } else { return 0; } } diff --git a/ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/controller.java.vm b/ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/controller.java.vm index 1ce61c2..5f7a568 100644 --- a/ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/controller.java.vm +++ b/ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/controller.java.vm @@ -105,7 +105,7 @@ public class ${ClassName}Controller extends BaseController { Boolean updated = ${className}Service.update(${className}Bo); if (!updated) { - R.fail("修改${functionName}记录失败!"); + return R.fail("修改${functionName}记录失败!"); } return R.ok(); } @@ -120,7 +120,7 @@ public class ${ClassName}Controller extends BaseController { boolean deleted = ${className}Service.deleteByIds(${pkColumn.javaField}s); if (!deleted) { - R.fail("删除${functionName}记录失败!"); + return R.fail("删除${functionName}记录失败!"); } return R.ok(); } diff --git a/ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/domain.java.vm b/ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/domain.java.vm index 4c52ee7..603e698 100644 --- a/ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/domain.java.vm +++ b/ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/domain.java.vm @@ -6,6 +6,20 @@ import ${import}; #if($table.sub) import ${packageName}.domain.${subClassName}; #end +#set($exitsDelFlagVersionFlag=false) +#foreach ($column in $columns) + #if(!$table.isSuperColumn($column.javaField)) + #if($column.javaField=='delFlag') + #set($exitsDelFlagVersionFlag=true) + #end + #if($column.javaField=='version') + #set($exitsDelFlagVersionFlag=true) + #end + #end +#end +#if($exitsDelFlagVersionFlag) +import com.mybatisflex.annotation.Column; +#end import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.Table; import lombok.Data; diff --git a/ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm b/ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm index b76a28b..5be2a76 100644 --- a/ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm +++ b/ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm @@ -73,6 +73,9 @@ public class ${ClassName}ServiceImpl extends BaseServiceImpl<${ClassName}Mapper, #end #end #end + #if($table.tree) + queryWrapper.orderBy(${CapitalUnderScoreClassName}.ORDER_NUM.asc()); + #end return queryWrapper; } @@ -178,6 +181,8 @@ public class ${ClassName}ServiceImpl extends BaseServiceImpl<${ClassName}Mapper, ${subclassName}Mapper.deleteByQuery(queryWrapper); return insert${subClassName}(${className}); } + #else + return updated; #end } return false; diff --git a/ruoyi-modules/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm b/ruoyi-modules/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm index 680ac3d..50219d4 100644 --- a/ruoyi-modules/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm +++ b/ruoyi-modules/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm @@ -279,7 +279,7 @@ -