From adeaa77864792872f7e39bb9d3560c07d75c1873 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期三, 14 四月 2021 12:01:26 +0800 Subject: [PATCH] update mp化 --- ruoyi-system/src/main/resources/mapper/system/SysDictTypeMapper.xml | 24 ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableColumnMapper.java | 46 - ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java | 60 -- ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableColumnService.java | 13 ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java | 27 ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java | 128 +++- ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableMapper.java | 38 - ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableColumnServiceImpl.java | 81 +- ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java | 70 +- ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml | 89 --- ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java | 155 +++-- ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java | 57 -- ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java | 148 ++--- ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java | 263 +++------ ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml | 75 -- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java | 34 ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml | 88 --- ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java | 15 ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictTypeMapper.java | 34 - ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java | 31 ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml | 65 -- 21 files changed, 473 insertions(+), 1,068 deletions(-) diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java index 53f9f64..03e9344 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java @@ -4,13 +4,13 @@ import com.baomidou.mybatisplus.annotation.*; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.constant.GenConstants; -import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.*; import lombok.experimental.Accessors; import org.apache.commons.lang3.ArrayUtils; import javax.validation.Valid; import javax.validation.constraints.NotBlank; +import java.io.Serializable; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -18,7 +18,7 @@ /** * 涓氬姟琛� gen_table - * + * * @author ruoyi */ @@ -26,75 +26,110 @@ @NoArgsConstructor @Accessors(chain = true) @TableName("gen_table") -public class GenTable -{ +public class GenTable implements Serializable { private static final long serialVersionUID = 1L; - /** 缂栧彿 */ + /** + * 缂栧彿 + */ @TableId(value = "table_id", type = IdType.AUTO) private Long tableId; - /** 琛ㄥ悕绉� */ + /** + * 琛ㄥ悕绉� + */ @NotBlank(message = "琛ㄥ悕绉颁笉鑳戒负绌�") private String tableName; - /** 琛ㄦ弿杩� */ + /** + * 琛ㄦ弿杩� + */ @NotBlank(message = "琛ㄦ弿杩颁笉鑳戒负绌�") private String tableComment; - /** 鍏宠仈鐖惰〃鐨勮〃鍚� */ + /** + * 鍏宠仈鐖惰〃鐨勮〃鍚� + */ private String subTableName; - /** 鏈〃鍏宠仈鐖惰〃鐨勫閿悕 */ + /** + * 鏈〃鍏宠仈鐖惰〃鐨勫閿悕 + */ private String subTableFkName; - /** 瀹炰綋绫诲悕绉�(棣栧瓧姣嶅ぇ鍐�) */ + /** + * 瀹炰綋绫诲悕绉�(棣栧瓧姣嶅ぇ鍐�) + */ @NotBlank(message = "瀹炰綋绫诲悕绉颁笉鑳戒负绌�") private String className; - /** 浣跨敤鐨勬ā鏉匡紙crud鍗曡〃鎿嶄綔 tree鏍戣〃鎿嶄綔 sub涓诲瓙琛ㄦ搷浣滐級 */ + /** + * 浣跨敤鐨勬ā鏉匡紙crud鍗曡〃鎿嶄綔 tree鏍戣〃鎿嶄綔 sub涓诲瓙琛ㄦ搷浣滐級 + */ private String tplCategory; - /** 鐢熸垚鍖呰矾寰� */ + /** + * 鐢熸垚鍖呰矾寰� + */ @NotBlank(message = "鐢熸垚鍖呰矾寰勪笉鑳戒负绌�") private String packageName; - /** 鐢熸垚妯″潡鍚� */ + /** + * 鐢熸垚妯″潡鍚� + */ @NotBlank(message = "鐢熸垚妯″潡鍚嶄笉鑳戒负绌�") private String moduleName; - /** 鐢熸垚涓氬姟鍚� */ + /** + * 鐢熸垚涓氬姟鍚� + */ @NotBlank(message = "鐢熸垚涓氬姟鍚嶄笉鑳戒负绌�") private String businessName; - /** 鐢熸垚鍔熻兘鍚� */ + /** + * 鐢熸垚鍔熻兘鍚� + */ @NotBlank(message = "鐢熸垚鍔熻兘鍚嶄笉鑳戒负绌�") private String functionName; - /** 鐢熸垚浣滆�� */ + /** + * 鐢熸垚浣滆�� + */ @NotBlank(message = "浣滆�呬笉鑳戒负绌�") private String functionAuthor; - /** 鐢熸垚浠g爜鏂瑰紡锛�0zip鍘嬬缉鍖� 1鑷畾涔夎矾寰勶級 */ + /** + * 鐢熸垚浠g爜鏂瑰紡锛�0zip鍘嬬缉鍖� 1鑷畾涔夎矾寰勶級 + */ private String genType; - /** 鐢熸垚璺緞锛堜笉濉粯璁ら」鐩矾寰勶級 */ + /** + * 鐢熸垚璺緞锛堜笉濉粯璁ら」鐩矾寰勶級 + */ private String genPath; - /** 涓婚敭淇℃伅 */ + /** + * 涓婚敭淇℃伅 + */ @TableField(exist = false) private GenTableColumn pkColumn; - /** 瀛愯〃淇℃伅 */ + /** + * 瀛愯〃淇℃伅 + */ @TableField(exist = false) private GenTable subTable; - /** 琛ㄥ垪淇℃伅 */ + /** + * 琛ㄥ垪淇℃伅 + */ @Valid @TableField(exist = false) private List<GenTableColumn> columns; - /** 鍏跺畠鐢熸垚閫夐」 */ + /** + * 鍏跺畠鐢熸垚閫夐」 + */ private String options; /** @@ -132,65 +167,66 @@ @TableField(exist = false) private Map<String, Object> params = new HashMap<>(); - /** 鏍戠紪鐮佸瓧娈� */ + /** + * 鏍戠紪鐮佸瓧娈� + */ @TableField(exist = false) private String treeCode; - /** 鏍戠埗缂栫爜瀛楁 */ + /** + * 鏍戠埗缂栫爜瀛楁 + */ @TableField(exist = false) private String treeParentCode; - /** 鏍戝悕绉板瓧娈� */ + /** + * 鏍戝悕绉板瓧娈� + */ @TableField(exist = false) private String treeName; - /** 涓婄骇鑿滃崟ID瀛楁 */ + /** + * 涓婄骇鑿滃崟ID瀛楁 + */ @TableField(exist = false) private String parentMenuId; - /** 涓婄骇鑿滃崟鍚嶇О瀛楁 */ + /** + * 涓婄骇鑿滃崟鍚嶇О瀛楁 + */ @TableField(exist = false) private String parentMenuName; - public boolean isSub() - { + public boolean isSub() { return isSub(this.tplCategory); } - public static boolean isSub(String tplCategory) - { + public static boolean isSub(String tplCategory) { return tplCategory != null && StrUtil.equals(GenConstants.TPL_SUB, tplCategory); } - public boolean isTree() - { + public boolean isTree() { return isTree(this.tplCategory); } - public static boolean isTree(String tplCategory) - { + public static boolean isTree(String tplCategory) { return tplCategory != null && StrUtil.equals(GenConstants.TPL_TREE, tplCategory); } - public boolean isCrud() - { + public boolean isCrud() { return isCrud(this.tplCategory); } - public static boolean isCrud(String tplCategory) - { + public static boolean isCrud(String tplCategory) { return tplCategory != null && StrUtil.equals(GenConstants.TPL_CRUD, tplCategory); } - public boolean isSuperColumn(String javaField) - { + public boolean isSuperColumn(String javaField) { return isSuperColumn(this.tplCategory, javaField); } - public static boolean isSuperColumn(String tplCategory, String javaField) - { - if (isTree(tplCategory)) - { + public static boolean isSuperColumn(String tplCategory, String javaField) { + if (isTree(tplCategory)) { return StrUtil.equalsAnyIgnoreCase(javaField, ArrayUtils.addAll(GenConstants.TREE_ENTITY, GenConstants.BASE_ENTITY)); } diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java index e04d459..0b63729 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java @@ -3,19 +3,18 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.annotation.*; import com.fasterxml.jackson.annotation.JsonFormat; -import com.ruoyi.common.core.domain.BaseEntity; -import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.*; import lombok.experimental.Accessors; import javax.validation.constraints.NotBlank; +import java.io.Serializable; import java.util.Date; import java.util.HashMap; import java.util.Map; /** * 浠g爜鐢熸垚涓氬姟瀛楁琛� gen_table_column - * + * * @author ruoyi */ @@ -23,64 +22,99 @@ @NoArgsConstructor @Accessors(chain = true) @TableName("gen_table_column") -public class GenTableColumn extends BaseEntity -{ +public class GenTableColumn implements Serializable { private static final long serialVersionUID = 1L; - /** 缂栧彿 */ + /** + * 缂栧彿 + */ @TableId(value = "column_id", type = IdType.AUTO) private Long columnId; - /** 褰掑睘琛ㄧ紪鍙� */ + /** + * 褰掑睘琛ㄧ紪鍙� + */ private Long tableId; - /** 鍒楀悕绉� */ + /** + * 鍒楀悕绉� + */ private String columnName; - /** 鍒楁弿杩� */ + /** + * 鍒楁弿杩� + */ private String columnComment; - /** 鍒楃被鍨� */ + /** + * 鍒楃被鍨� + */ private String columnType; - /** JAVA绫诲瀷 */ + /** + * JAVA绫诲瀷 + */ private String javaType; - /** JAVA瀛楁鍚� */ + /** + * JAVA瀛楁鍚� + */ @NotBlank(message = "Java灞炴�т笉鑳戒负绌�") private String javaField; - /** 鏄惁涓婚敭锛�1鏄級 */ + /** + * 鏄惁涓婚敭锛�1鏄級 + */ private String isPk; - /** 鏄惁鑷锛�1鏄級 */ + /** + * 鏄惁鑷锛�1鏄級 + */ private String isIncrement; - /** 鏄惁蹇呭~锛�1鏄級 */ + /** + * 鏄惁蹇呭~锛�1鏄級 + */ private String isRequired; - /** 鏄惁涓烘彃鍏ュ瓧娈碉紙1鏄級 */ + /** + * 鏄惁涓烘彃鍏ュ瓧娈碉紙1鏄級 + */ private String isInsert; - /** 鏄惁缂栬緫瀛楁锛�1鏄級 */ + /** + * 鏄惁缂栬緫瀛楁锛�1鏄級 + */ private String isEdit; - /** 鏄惁鍒楄〃瀛楁锛�1鏄級 */ + /** + * 鏄惁鍒楄〃瀛楁锛�1鏄級 + */ private String isList; - /** 鏄惁鏌ヨ瀛楁锛�1鏄級 */ + /** + * 鏄惁鏌ヨ瀛楁锛�1鏄級 + */ private String isQuery; - /** 鏌ヨ鏂瑰紡锛圗Q绛変簬銆丯E涓嶇瓑浜庛�丟T澶т簬銆丩T灏忎簬銆丩IKE妯$硦銆丅ETWEEN鑼冨洿锛� */ + /** + * 鏌ヨ鏂瑰紡锛圗Q绛変簬銆丯E涓嶇瓑浜庛�丟T澶т簬銆丩T灏忎簬銆丩IKE妯$硦銆丅ETWEEN鑼冨洿锛� + */ private String queryType; - /** 鏄剧ず绫诲瀷锛坕nput鏂囨湰妗嗐�乼extarea鏂囨湰鍩熴�乻elect涓嬫媺妗嗐�乧heckbox澶嶉�夋銆乺adio鍗曢�夋銆乨atetime鏃ユ湡鎺т欢銆乮mage鍥剧墖涓婁紶鎺т欢銆乽pload鏂囦欢涓婁紶鎺т欢銆乪ditor瀵屾枃鏈帶浠讹級 */ + /** + * 鏄剧ず绫诲瀷锛坕nput鏂囨湰妗嗐�乼extarea鏂囨湰鍩熴�乻elect涓嬫媺妗嗐�乧heckbox澶嶉�夋銆乺adio鍗曢�夋銆乨atetime鏃ユ湡鎺т欢銆乮mage鍥剧墖涓婁紶鎺т欢銆乽pload鏂囦欢涓婁紶鎺т欢銆乪ditor瀵屾枃鏈帶浠讹級 + */ private String htmlType; - /** 瀛楀吀绫诲瀷 */ + /** + * 瀛楀吀绫诲瀷 + */ private String dictType; - /** 鎺掑簭 */ + /** + * 鎺掑簭 + */ private Integer sort; /** @@ -113,88 +147,71 @@ @TableField(exist = false) private Map<String, Object> params = new HashMap<>(); - public String getCapJavaField() - { + public String getCapJavaField() { return StrUtil.upperFirst(javaField); } - public boolean isPk() - { + public boolean isPk() { return isPk(this.isPk); } - public boolean isPk(String isPk) - { + public boolean isPk(String isPk) { return isPk != null && StrUtil.equals("1", isPk); } - public boolean isIncrement() - { + public boolean isIncrement() { return isIncrement(this.isIncrement); } - public boolean isIncrement(String isIncrement) - { + public boolean isIncrement(String isIncrement) { return isIncrement != null && StrUtil.equals("1", isIncrement); } - public boolean isRequired() - { + public boolean isRequired() { return isRequired(this.isRequired); } - public boolean isRequired(String isRequired) - { + public boolean isRequired(String isRequired) { return isRequired != null && StrUtil.equals("1", isRequired); } - public boolean isInsert() - { + public boolean isInsert() { return isInsert(this.isInsert); } - public boolean isInsert(String isInsert) - { + public boolean isInsert(String isInsert) { return isInsert != null && StrUtil.equals("1", isInsert); } - public boolean isEdit() - { + public boolean isEdit() { return isInsert(this.isEdit); } - public boolean isEdit(String isEdit) - { + public boolean isEdit(String isEdit) { return isEdit != null && StrUtil.equals("1", isEdit); } - public boolean isList() - { + public boolean isList() { return isList(this.isList); } - public boolean isList(String isList) - { + public boolean isList(String isList) { return isList != null && StrUtil.equals("1", isList); } - public boolean isQuery() - { + public boolean isQuery() { return isQuery(this.isQuery); } - public boolean isQuery(String isQuery) - { + public boolean isQuery(String isQuery) { return isQuery != null && StrUtil.equals("1", isQuery); } - public boolean isSuperColumn() - { + public boolean isSuperColumn() { return isSuperColumn(this.javaField); } - public static boolean isSuperColumn(String javaField) - { + public static boolean isSuperColumn(String javaField) { return StrUtil.equalsAnyIgnoreCase(javaField, // BaseEntity "createBy", "createTime", "updateBy", "updateTime", "remark", @@ -202,36 +219,28 @@ "parentName", "parentId", "orderNum", "ancestors"); } - public boolean isUsableColumn() - { + public boolean isUsableColumn() { return isUsableColumn(javaField); } - public static boolean isUsableColumn(String javaField) - { + public static boolean isUsableColumn(String javaField) { // isSuperColumn()涓殑鍚嶅崟鐢ㄤ簬閬垮厤鐢熸垚澶氫綑Domain灞炴�э紝鑻ユ煇浜涘睘鎬у湪鐢熸垚椤甸潰鏃堕渶瑕佺敤鍒颁笉鑳藉拷鐣ワ紝鍒欐斁鍦ㄦ澶勭櫧鍚嶅崟 return StrUtil.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark"); } - public String readConverterExp() - { + public String readConverterExp() { String remarks = StrUtil.subBetween(this.columnComment, "锛�", "锛�"); StringBuffer sb = new StringBuffer(); - if (StrUtil.isNotEmpty(remarks)) - { - for (String value : remarks.split(" ")) - { - if (StrUtil.isNotEmpty(value)) - { + if (StrUtil.isNotEmpty(remarks)) { + for (String value : remarks.split(" ")) { + if (StrUtil.isNotEmpty(value)) { Object startStr = value.subSequence(0, 1); String endStr = value.substring(1); sb.append("").append(startStr).append("=").append(endStr).append(","); } } return sb.deleteCharAt(sb.length() - 1).toString(); - } - else - { + } else { return this.columnComment; } } diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableColumnMapper.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableColumnMapper.java index c8df8c7..d3e7e5e 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableColumnMapper.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableColumnMapper.java @@ -7,56 +7,16 @@ /** * 涓氬姟瀛楁 鏁版嵁灞� - * + * * @author ruoyi */ -public interface GenTableColumnMapper extends BaseMapper<GenTableColumn> -{ +public interface GenTableColumnMapper extends BaseMapper<GenTableColumn> { /** * 鏍规嵁琛ㄥ悕绉版煡璇㈠垪淇℃伅 - * + * * @param tableName 琛ㄥ悕绉� * @return 鍒椾俊鎭� */ public List<GenTableColumn> selectDbTableColumnsByName(String tableName); - /** - * 鏌ヨ涓氬姟瀛楁鍒楄〃 - * - * @param tableId 涓氬姟瀛楁缂栧彿 - * @return 涓氬姟瀛楁闆嗗悎 - */ - public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId); - - /** - * 鏂板涓氬姟瀛楁 - * - * @param genTableColumn 涓氬姟瀛楁淇℃伅 - * @return 缁撴灉 - */ - public int insertGenTableColumn(GenTableColumn genTableColumn); - - /** - * 淇敼涓氬姟瀛楁 - * - * @param genTableColumn 涓氬姟瀛楁淇℃伅 - * @return 缁撴灉 - */ - public int updateGenTableColumn(GenTableColumn genTableColumn); - - /** - * 鍒犻櫎涓氬姟瀛楁 - * - * @param genTableColumns 鍒楁暟鎹� - * @return 缁撴灉 - */ - public int deleteGenTableColumns(List<GenTableColumn> genTableColumns); - - /** - * 鎵归噺鍒犻櫎涓氬姟瀛楁 - * - * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁ID - * @return 缁撴灉 - */ - public int deleteGenTableColumnByIds(Long[] ids); } diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableMapper.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableMapper.java index 890a57e..894f689 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableMapper.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableMapper.java @@ -7,14 +7,13 @@ /** * 涓氬姟 鏁版嵁灞� - * + * * @author ruoyi */ -public interface GenTableMapper extends BaseMapper<GenTable> -{ +public interface GenTableMapper extends BaseMapper<GenTable> { /** * 鏌ヨ涓氬姟鍒楄〃 - * + * * @param genTable 涓氬姟淇℃伅 * @return 涓氬姟闆嗗悎 */ @@ -22,7 +21,7 @@ /** * 鏌ヨ鎹簱鍒楄〃 - * + * * @param genTable 涓氬姟淇℃伅 * @return 鏁版嵁搴撹〃闆嗗悎 */ @@ -30,7 +29,7 @@ /** * 鏌ヨ鎹簱鍒楄〃 - * + * * @param tableNames 琛ㄥ悕绉扮粍 * @return 鏁版嵁搴撹〃闆嗗悎 */ @@ -45,7 +44,7 @@ /** * 鏌ヨ琛↖D涓氬姟淇℃伅 - * + * * @param id 涓氬姟ID * @return 涓氬姟淇℃伅 */ @@ -53,33 +52,10 @@ /** * 鏌ヨ琛ㄥ悕绉颁笟鍔′俊鎭� - * + * * @param tableName 琛ㄥ悕绉� * @return 涓氬姟淇℃伅 */ public GenTable selectGenTableByName(String tableName); - /** - * 鏂板涓氬姟 - * - * @param genTable 涓氬姟淇℃伅 - * @return 缁撴灉 - */ - public int insertGenTable(GenTable genTable); - - /** - * 淇敼涓氬姟 - * - * @param genTable 涓氬姟淇℃伅 - * @return 缁撴灉 - */ - public int updateGenTable(GenTable genTable); - - /** - * 鎵归噺鍒犻櫎涓氬姟 - * - * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁ID - * @return 缁撴灉 - */ - public int deleteGenTableByIds(Long[] ids); } diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableColumnServiceImpl.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableColumnServiceImpl.java index 5ff2348..40f0738 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableColumnServiceImpl.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableColumnServiceImpl.java @@ -1,70 +1,65 @@ package com.ruoyi.generator.service; -import java.util.List; - +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import cn.hutool.core.convert.Convert; import com.ruoyi.generator.domain.GenTableColumn; import com.ruoyi.generator.mapper.GenTableColumnMapper; +import org.springframework.stereotype.Service; + +import java.util.Arrays; +import java.util.List; /** * 涓氬姟瀛楁 鏈嶅姟灞傚疄鐜� - * + * * @author ruoyi */ @Service -public class GenTableColumnServiceImpl extends ServiceImpl<GenTableColumnMapper, GenTableColumn> implements IGenTableColumnService -{ - @Autowired - private GenTableColumnMapper genTableColumnMapper; +public class GenTableColumnServiceImpl extends ServiceImpl<GenTableColumnMapper, GenTableColumn> implements IGenTableColumnService { - /** + /** * 鏌ヨ涓氬姟瀛楁鍒楄〃 - * + * * @param tableId 涓氬姟瀛楁缂栧彿 * @return 涓氬姟瀛楁闆嗗悎 */ - @Override - public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId) - { - return genTableColumnMapper.selectGenTableColumnListByTableId(tableId); - } - + @Override + public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId) { + return list(new LambdaQueryWrapper<GenTableColumn>() + .eq(GenTableColumn::getTableId,tableId) + .orderByAsc(GenTableColumn::getSort)); + } + /** * 鏂板涓氬姟瀛楁 - * + * * @param genTableColumn 涓氬姟瀛楁淇℃伅 * @return 缁撴灉 */ - @Override - public int insertGenTableColumn(GenTableColumn genTableColumn) - { - return genTableColumnMapper.insertGenTableColumn(genTableColumn); - } - - /** - * 淇敼涓氬姟瀛楁 - * - * @param genTableColumn 涓氬姟瀛楁淇℃伅 - * @return 缁撴灉 - */ - @Override - public int updateGenTableColumn(GenTableColumn genTableColumn) - { - return genTableColumnMapper.updateGenTableColumn(genTableColumn); - } + @Override + public int insertGenTableColumn(GenTableColumn genTableColumn) { + return baseMapper.insert(genTableColumn); + } - /** + /** + * 淇敼涓氬姟瀛楁 + * + * @param genTableColumn 涓氬姟瀛楁淇℃伅 + * @return 缁撴灉 + */ + @Override + public int updateGenTableColumn(GenTableColumn genTableColumn) { + return baseMapper.updateById(genTableColumn); + } + + /** * 鍒犻櫎涓氬姟瀛楁瀵硅薄 - * + * * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁ID * @return 缁撴灉 */ - @Override - public int deleteGenTableColumnByIds(String ids) - { - return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids)); - } + @Override + public int deleteGenTableColumnByIds(String ids) { + return baseMapper.deleteBatchIds(Arrays.asList(ids.split(","))); + } } diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java index b54f41d..1519f3c 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.GenConstants; @@ -18,12 +19,11 @@ import com.ruoyi.generator.util.GenUtils; import com.ruoyi.generator.util.VelocityInitializer; import com.ruoyi.generator.util.VelocityUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.Velocity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -32,6 +32,7 @@ import java.io.File; import java.io.IOException; import java.io.StringWriter; +import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -41,68 +42,60 @@ /** * 涓氬姟 鏈嶅姟灞傚疄鐜� - * + * * @author ruoyi */ +@Slf4j @Service -public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTable> implements IGenTableService -{ - private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class); - - @Autowired - private GenTableMapper genTableMapper; +public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTable> implements IGenTableService { @Autowired private GenTableColumnMapper genTableColumnMapper; /** * 鏌ヨ涓氬姟淇℃伅 - * + * * @param id 涓氬姟ID * @return 涓氬姟淇℃伅 */ @Override - public GenTable selectGenTableById(Long id) - { - GenTable genTable = genTableMapper.selectGenTableById(id); + public GenTable selectGenTableById(Long id) { + GenTable genTable = baseMapper.selectGenTableById(id); setTableFromOptions(genTable); return genTable; } /** * 鏌ヨ涓氬姟鍒楄〃 - * + * * @param genTable 涓氬姟淇℃伅 * @return 涓氬姟闆嗗悎 */ @Override - public List<GenTable> selectGenTableList(GenTable genTable) - { - return genTableMapper.selectGenTableList(genTable); + public List<GenTable> selectGenTableList(GenTable genTable) { + return baseMapper.selectGenTableList(genTable); } /** * 鏌ヨ鎹簱鍒楄〃 - * + * * @param genTable 涓氬姟淇℃伅 * @return 鏁版嵁搴撹〃闆嗗悎 */ @Override - public List<GenTable> selectDbTableList(GenTable genTable) - { - return genTableMapper.selectDbTableList(genTable); + public List<GenTable> selectDbTableList(GenTable genTable) { + return baseMapper.selectDbTableList(genTable); } /** * 鏌ヨ鎹簱鍒楄〃 - * + * * @param tableNames 琛ㄥ悕绉扮粍 * @return 鏁版嵁搴撹〃闆嗗悎 */ @Override - public List<GenTable> selectDbTableListByNames(String[] tableNames) - { - return genTableMapper.selectDbTableListByNames(tableNames); + public List<GenTable> selectDbTableListByNames(String[] tableNames) { + return baseMapper.selectDbTableListByNames(tableNames); } /** @@ -111,94 +104,82 @@ * @return 琛ㄤ俊鎭泦鍚� */ @Override - public List<GenTable> selectGenTableAll() - { - return genTableMapper.selectGenTableAll(); + public List<GenTable> selectGenTableAll() { + return baseMapper.selectGenTableAll(); } /** * 淇敼涓氬姟 - * + * * @param genTable 涓氬姟淇℃伅 * @return 缁撴灉 */ @Override @Transactional - public void updateGenTable(GenTable genTable) - { + public void updateGenTable(GenTable genTable) { String options = JSON.toJSONString(genTable.getParams()); genTable.setOptions(options); - int row = genTableMapper.updateGenTable(genTable); - if (row > 0) - { - for (GenTableColumn cenTableColumn : genTable.getColumns()) - { - genTableColumnMapper.updateGenTableColumn(cenTableColumn); + int row = baseMapper.updateById(genTable); + if (row > 0) { + for (GenTableColumn cenTableColumn : genTable.getColumns()) { + genTableColumnMapper.updateById(cenTableColumn); } } } /** * 鍒犻櫎涓氬姟瀵硅薄 - * + * * @param tableIds 闇�瑕佸垹闄ょ殑鏁版嵁ID * @return 缁撴灉 */ @Override @Transactional - public void deleteGenTableByIds(Long[] tableIds) - { - genTableMapper.deleteGenTableByIds(tableIds); - genTableColumnMapper.deleteGenTableColumnByIds(tableIds); + public void deleteGenTableByIds(Long[] tableIds) { + List<Long> ids = Arrays.asList(tableIds); + removeByIds(ids); + genTableColumnMapper.delete(new LambdaQueryWrapper<GenTableColumn>().in(GenTableColumn::getTableId, ids)); } /** * 瀵煎叆琛ㄧ粨鏋� - * + * * @param tableList 瀵煎叆琛ㄥ垪琛� */ @Override @Transactional - public void importGenTable(List<GenTable> tableList) - { + public void importGenTable(List<GenTable> tableList) { String operName = SecurityUtils.getUsername(); - try - { - for (GenTable table : tableList) - { + try { + for (GenTable table : tableList) { String tableName = table.getTableName(); GenUtils.initTable(table, operName); - int row = genTableMapper.insertGenTable(table); - if (row > 0) - { + int row = baseMapper.insert(table); + if (row > 0) { // 淇濆瓨鍒椾俊鎭� List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); - for (GenTableColumn column : genTableColumns) - { + for (GenTableColumn column : genTableColumns) { GenUtils.initColumnField(column, table); - genTableColumnMapper.insertGenTableColumn(column); + genTableColumnMapper.insert(column); } } } - } - catch (Exception e) - { + } catch (Exception e) { throw new CustomException("瀵煎叆澶辫触锛�" + e.getMessage()); } } /** * 棰勮浠g爜 - * + * * @param tableId 琛ㄧ紪鍙� * @return 棰勮鏁版嵁鍒楄〃 */ @Override - public Map<String, String> previewCode(Long tableId) - { + public Map<String, String> previewCode(Long tableId) { Map<String, String> dataMap = new LinkedHashMap<>(); // 鏌ヨ琛ㄤ俊鎭� - GenTable table = genTableMapper.selectGenTableById(tableId); + GenTable table = baseMapper.selectGenTableById(tableId); // 璁剧疆涓诲瓙琛ㄤ俊鎭� setSubTable(table); // 璁剧疆涓婚敭鍒椾俊鎭� @@ -209,8 +190,7 @@ // 鑾峰彇妯℃澘鍒楄〃 List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory()); - for (String template : templates) - { + for (String template : templates) { // 娓叉煋妯℃澘 StringWriter sw = new StringWriter(); Template tpl = Velocity.getTemplate(template, Constants.UTF8); @@ -222,13 +202,12 @@ /** * 鐢熸垚浠g爜锛堜笅杞芥柟寮忥級 - * + * * @param tableName 琛ㄥ悕绉� * @return 鏁版嵁 */ @Override - public byte[] downloadCode(String tableName) - { + public byte[] downloadCode(String tableName) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(outputStream); generatorCode(tableName, zip); @@ -238,14 +217,13 @@ /** * 鐢熸垚浠g爜锛堣嚜瀹氫箟璺緞锛� - * + * * @param tableName 琛ㄥ悕绉� */ @Override - public void generatorCode(String tableName) - { + public void generatorCode(String tableName) { // 鏌ヨ琛ㄤ俊鎭� - GenTable table = genTableMapper.selectGenTableByName(tableName); + GenTable table = baseMapper.selectGenTableByName(tableName); // 璁剧疆涓诲瓙琛ㄤ俊鎭� setSubTable(table); // 璁剧疆涓婚敭鍒椾俊鎭� @@ -257,21 +235,16 @@ // 鑾峰彇妯℃澘鍒楄〃 List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory()); - for (String template : templates) - { - if (!StrUtil.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) - { + for (String template : templates) { + if (!StrUtil.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) { // 娓叉煋妯℃澘 StringWriter sw = new StringWriter(); Template tpl = Velocity.getTemplate(template, Constants.UTF8); tpl.merge(context, sw); - try - { + try { String path = getGenPath(table, template); FileUtils.writeStringToFile(new File(path), sw.toString(), Constants.UTF8); - } - catch (IOException e) - { + } catch (IOException e) { throw new CustomException("娓叉煋妯℃澘澶辫触锛岃〃鍚嶏細" + table.getTableName()); } } @@ -280,52 +253,47 @@ /** * 鍚屾鏁版嵁搴� - * + * * @param tableName 琛ㄥ悕绉� */ @Override @Transactional - public void synchDb(String tableName) - { - GenTable table = genTableMapper.selectGenTableByName(tableName); + public void synchDb(String tableName) { + GenTable table = baseMapper.selectGenTableByName(tableName); List<GenTableColumn> tableColumns = table.getColumns(); List<String> tableColumnNames = tableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); - if (Validator.isEmpty(dbTableColumns)) - { + if (Validator.isEmpty(dbTableColumns)) { throw new CustomException("鍚屾鏁版嵁澶辫触锛屽師琛ㄧ粨鏋勪笉瀛樺湪"); } List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); dbTableColumns.forEach(column -> { - if (!tableColumnNames.contains(column.getColumnName())) - { + if (!tableColumnNames.contains(column.getColumnName())) { GenUtils.initColumnField(column, table); - genTableColumnMapper.insertGenTableColumn(column); + genTableColumnMapper.insert(column); } }); List<GenTableColumn> delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList()); - if (CollUtil.isNotEmpty(delColumns)) - { - genTableColumnMapper.deleteGenTableColumns(delColumns); + if (CollUtil.isNotEmpty(delColumns)) { + List<Long> ids = delColumns.stream().map(GenTableColumn::getColumnId).collect(Collectors.toList()); + genTableColumnMapper.deleteBatchIds(ids); } } /** * 鎵归噺鐢熸垚浠g爜锛堜笅杞芥柟寮忥級 - * + * * @param tableNames 琛ㄦ暟缁� * @return 鏁版嵁 */ @Override - public byte[] downloadCode(String[] tableNames) - { + public byte[] downloadCode(String[] tableNames) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(outputStream); - for (String tableName : tableNames) - { + for (String tableName : tableNames) { generatorCode(tableName, zip); } IOUtils.closeQuietly(zip); @@ -335,10 +303,9 @@ /** * 鏌ヨ琛ㄤ俊鎭苟鐢熸垚浠g爜 */ - private void generatorCode(String tableName, ZipOutputStream zip) - { + private void generatorCode(String tableName, ZipOutputStream zip) { // 鏌ヨ琛ㄤ俊鎭� - GenTable table = genTableMapper.selectGenTableByName(tableName); + GenTable table = baseMapper.selectGenTableByName(tableName); // 璁剧疆涓诲瓙琛ㄤ俊鎭� setSubTable(table); // 璁剧疆涓婚敭鍒椾俊鎭� @@ -350,23 +317,19 @@ // 鑾峰彇妯℃澘鍒楄〃 List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory()); - for (String template : templates) - { + for (String template : templates) { // 娓叉煋妯℃澘 StringWriter sw = new StringWriter(); Template tpl = Velocity.getTemplate(template, Constants.UTF8); tpl.merge(context, sw); - try - { + try { // 娣诲姞鍒皕ip zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table))); IOUtils.write(sw.toString(), zip, Constants.UTF8); IOUtils.closeQuietly(sw); - zip.flush(); + zip.flush(); zip.closeEntry(); - } - catch (IOException e) - { + } catch (IOException e) { log.error("娓叉煋妯℃澘澶辫触锛岃〃鍚嶏細" + table.getTableName(), e); } } @@ -374,36 +337,24 @@ /** * 淇敼淇濆瓨鍙傛暟鏍¢獙 - * + * * @param genTable 涓氬姟淇℃伅 */ @Override - public void validateEdit(GenTable genTable) - { - if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) - { + public void validateEdit(GenTable genTable) { + if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) { String options = JSON.toJSONString(genTable.getParams()); JSONObject paramsObj = JSONObject.parseObject(options); - if (Validator.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) - { + if (Validator.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) { throw new CustomException("鏍戠紪鐮佸瓧娈典笉鑳戒负绌�"); - } - else if (Validator.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE))) - { + } else if (Validator.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE))) { throw new CustomException("鏍戠埗缂栫爜瀛楁涓嶈兘涓虹┖"); - } - else if (Validator.isEmpty(paramsObj.getString(GenConstants.TREE_NAME))) - { + } else if (Validator.isEmpty(paramsObj.getString(GenConstants.TREE_NAME))) { throw new CustomException("鏍戝悕绉板瓧娈典笉鑳戒负绌�"); - } - else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory())) - { - if (Validator.isEmpty(genTable.getSubTableName())) - { + } else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory())) { + if (Validator.isEmpty(genTable.getSubTableName())) { throw new CustomException("鍏宠仈瀛愯〃鐨勮〃鍚嶄笉鑳戒负绌�"); - } - else if (Validator.isEmpty(genTable.getSubTableFkName())) - { + } else if (Validator.isEmpty(genTable.getSubTableFkName())) { throw new CustomException("瀛愯〃鍏宠仈鐨勫閿悕涓嶈兘涓虹┖"); } } @@ -412,35 +363,27 @@ /** * 璁剧疆涓婚敭鍒椾俊鎭� - * + * * @param table 涓氬姟琛ㄤ俊鎭� */ - public void setPkColumn(GenTable table) - { - for (GenTableColumn column : table.getColumns()) - { - if (column.isPk()) - { + public void setPkColumn(GenTable table) { + for (GenTableColumn column : table.getColumns()) { + if (column.isPk()) { table.setPkColumn(column); break; } } - if (Validator.isNull(table.getPkColumn())) - { + if (Validator.isNull(table.getPkColumn())) { table.setPkColumn(table.getColumns().get(0)); } - if (GenConstants.TPL_SUB.equals(table.getTplCategory())) - { - for (GenTableColumn column : table.getSubTable().getColumns()) - { - if (column.isPk()) - { + if (GenConstants.TPL_SUB.equals(table.getTplCategory())) { + for (GenTableColumn column : table.getSubTable().getColumns()) { + if (column.isPk()) { table.getSubTable().setPkColumn(column); break; } } - if (Validator.isNull(table.getSubTable().getPkColumn())) - { + if (Validator.isNull(table.getSubTable().getPkColumn())) { table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0)); } } @@ -451,31 +394,27 @@ * * @param table 涓氬姟琛ㄤ俊鎭� */ - public void setSubTable(GenTable table) - { + public void setSubTable(GenTable table) { String subTableName = table.getSubTableName(); - if (Validator.isNotEmpty(subTableName)) - { - table.setSubTable(genTableMapper.selectGenTableByName(subTableName)); + if (Validator.isNotEmpty(subTableName)) { + table.setSubTable(baseMapper.selectGenTableByName(subTableName)); } } /** * 璁剧疆浠g爜鐢熸垚鍏朵粬閫夐」鍊� - * + * * @param genTable 璁剧疆鍚庣殑鐢熸垚瀵硅薄 */ - public void setTableFromOptions(GenTable genTable) - { + public void setTableFromOptions(GenTable genTable) { JSONObject paramsObj = JSONObject.parseObject(genTable.getOptions()); - if (Validator.isNotNull(paramsObj)) - { + if (Validator.isNotNull(paramsObj)) { String treeCode = paramsObj.getString(GenConstants.TREE_CODE); String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE); String treeName = paramsObj.getString(GenConstants.TREE_NAME); String parentMenuId = paramsObj.getString(GenConstants.PARENT_MENU_ID); String parentMenuName = paramsObj.getString(GenConstants.PARENT_MENU_NAME); - + genTable.setTreeCode(treeCode); genTable.setTreeParentCode(treeParentCode); genTable.setTreeName(treeName); @@ -486,16 +425,14 @@ /** * 鑾峰彇浠g爜鐢熸垚鍦板潃 - * - * @param table 涓氬姟琛ㄤ俊鎭� + * + * @param table 涓氬姟琛ㄤ俊鎭� * @param template 妯℃澘鏂囦欢璺緞 * @return 鐢熸垚鍦板潃 */ - public static String getGenPath(GenTable table, String template) - { + public static String getGenPath(GenTable table, String template) { String genPath = table.getGenPath(); - if (StrUtil.equals(genPath, "/")) - { + if (StrUtil.equals(genPath, "/")) { return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table); } return genPath + File.separator + VelocityUtils.getFileName(template, table); diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableColumnService.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableColumnService.java index ae6ecbe..e0111e5 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableColumnService.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableColumnService.java @@ -7,14 +7,13 @@ /** * 涓氬姟瀛楁 鏈嶅姟灞� - * + * * @author ruoyi */ -public interface IGenTableColumnService extends IService<GenTableColumn> -{ +public interface IGenTableColumnService extends IService<GenTableColumn> { /** * 鏌ヨ涓氬姟瀛楁鍒楄〃 - * + * * @param tableId 涓氬姟瀛楁缂栧彿 * @return 涓氬姟瀛楁闆嗗悎 */ @@ -22,7 +21,7 @@ /** * 鏂板涓氬姟瀛楁 - * + * * @param genTableColumn 涓氬姟瀛楁淇℃伅 * @return 缁撴灉 */ @@ -30,7 +29,7 @@ /** * 淇敼涓氬姟瀛楁 - * + * * @param genTableColumn 涓氬姟瀛楁淇℃伅 * @return 缁撴灉 */ @@ -38,7 +37,7 @@ /** * 鍒犻櫎涓氬姟瀛楁淇℃伅 - * + * * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁ID * @return 缁撴灉 */ diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java index f64b55a..c6642ba 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java @@ -8,14 +8,13 @@ /** * 涓氬姟 鏈嶅姟灞� - * + * * @author ruoyi */ -public interface IGenTableService extends IService<GenTable> -{ +public interface IGenTableService extends IService<GenTable> { /** * 鏌ヨ涓氬姟鍒楄〃 - * + * * @param genTable 涓氬姟淇℃伅 * @return 涓氬姟闆嗗悎 */ @@ -23,7 +22,7 @@ /** * 鏌ヨ鎹簱鍒楄〃 - * + * * @param genTable 涓氬姟淇℃伅 * @return 鏁版嵁搴撹〃闆嗗悎 */ @@ -31,7 +30,7 @@ /** * 鏌ヨ鎹簱鍒楄〃 - * + * * @param tableNames 琛ㄥ悕绉扮粍 * @return 鏁版嵁搴撹〃闆嗗悎 */ @@ -46,7 +45,7 @@ /** * 鏌ヨ涓氬姟淇℃伅 - * + * * @param id 涓氬姟ID * @return 涓氬姟淇℃伅 */ @@ -54,7 +53,7 @@ /** * 淇敼涓氬姟 - * + * * @param genTable 涓氬姟淇℃伅 * @return 缁撴灉 */ @@ -62,7 +61,7 @@ /** * 鍒犻櫎涓氬姟淇℃伅 - * + * * @param tableIds 闇�瑕佸垹闄ょ殑琛ㄦ暟鎹甀D * @return 缁撴灉 */ @@ -70,14 +69,14 @@ /** * 瀵煎叆琛ㄧ粨鏋� - * + * * @param tableList 瀵煎叆琛ㄥ垪琛� */ public void importGenTable(List<GenTable> tableList); /** * 棰勮浠g爜 - * + * * @param tableId 琛ㄧ紪鍙� * @return 棰勮鏁版嵁鍒楄〃 */ @@ -85,7 +84,7 @@ /** * 鐢熸垚浠g爜锛堜笅杞芥柟寮忥級 - * + * * @param tableName 琛ㄥ悕绉� * @return 鏁版嵁 */ @@ -93,7 +92,7 @@ /** * 鐢熸垚浠g爜锛堣嚜瀹氫箟璺緞锛� - * + * * @param tableName 琛ㄥ悕绉� * @return 鏁版嵁 */ @@ -101,14 +100,14 @@ /** * 鍚屾鏁版嵁搴� - * + * * @param tableName 琛ㄥ悕绉� */ public void synchDb(String tableName); /** * 鎵归噺鐢熸垚浠g爜锛堜笅杞芥柟寮忥級 - * + * * @param tableNames 琛ㄦ暟缁� * @return 鏁版嵁 */ @@ -116,7 +115,7 @@ /** * 淇敼淇濆瓨鍙傛暟鏍¢獙 - * + * * @param genTable 涓氬姟淇℃伅 */ public void validateEdit(GenTable genTable); diff --git a/ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml b/ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml index 5fa790f..be07a9c 100644 --- a/ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml +++ b/ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml @@ -28,100 +28,11 @@ <result property="updateBy" column="update_by" /> <result property="updateTime" column="update_time" /> </resultMap> - - <sql id="selectGenTableColumnVo"> - select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column - </sql> - - <select id="selectGenTableColumnListByTableId" parameterType="Long" resultMap="GenTableColumnResult"> - <include refid="selectGenTableColumnVo"/> - where table_id = #{tableId} - order by sort - </select> <select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult"> select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName}) order by ordinal_position </select> - - <insert id="insertGenTableColumn" parameterType="GenTableColumn" useGeneratedKeys="true" keyProperty="columnId"> - insert into gen_table_column ( - <if test="tableId != null and tableId != ''">table_id,</if> - <if test="columnName != null and columnName != ''">column_name,</if> - <if test="columnComment != null and columnComment != ''">column_comment,</if> - <if test="columnType != null and columnType != ''">column_type,</if> - <if test="javaType != null and javaType != ''">java_type,</if> - <if test="javaField != null and javaField != ''">java_field,</if> - <if test="isPk != null and isPk != ''">is_pk,</if> - <if test="isIncrement != null and isIncrement != ''">is_increment,</if> - <if test="isRequired != null and isRequired != ''">is_required,</if> - <if test="isInsert != null and isInsert != ''">is_insert,</if> - <if test="isEdit != null and isEdit != ''">is_edit,</if> - <if test="isList != null and isList != ''">is_list,</if> - <if test="isQuery != null and isQuery != ''">is_query,</if> - <if test="queryType != null and queryType != ''">query_type,</if> - <if test="htmlType != null and htmlType != ''">html_type,</if> - <if test="dictType != null and dictType != ''">dict_type,</if> - <if test="sort != null">sort,</if> - <if test="createBy != null and createBy != ''">create_by,</if> - create_time - )values( - <if test="tableId != null and tableId != ''">#{tableId},</if> - <if test="columnName != null and columnName != ''">#{columnName},</if> - <if test="columnComment != null and columnComment != ''">#{columnComment},</if> - <if test="columnType != null and columnType != ''">#{columnType},</if> - <if test="javaType != null and javaType != ''">#{javaType},</if> - <if test="javaField != null and javaField != ''">#{javaField},</if> - <if test="isPk != null and isPk != ''">#{isPk},</if> - <if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if> - <if test="isRequired != null and isRequired != ''">#{isRequired},</if> - <if test="isInsert != null and isInsert != ''">#{isInsert},</if> - <if test="isEdit != null and isEdit != ''">#{isEdit},</if> - <if test="isList != null and isList != ''">#{isList},</if> - <if test="isQuery != null and isQuery != ''">#{isQuery},</if> - <if test="queryType != null and queryType != ''">#{queryType},</if> - <if test="htmlType != null and htmlType != ''">#{htmlType},</if> - <if test="dictType != null and dictType != ''">#{dictType},</if> - <if test="sort != null">#{sort},</if> - <if test="createBy != null and createBy != ''">#{createBy},</if> - sysdate() - ) - </insert> - - <update id="updateGenTableColumn" parameterType="GenTableColumn"> - update gen_table_column - <set> - column_comment = #{columnComment}, - java_type = #{javaType}, - java_field = #{javaField}, - is_insert = #{isInsert}, - is_edit = #{isEdit}, - is_list = #{isList}, - is_query = #{isQuery}, - is_required = #{isRequired}, - query_type = #{queryType}, - html_type = #{htmlType}, - dict_type = #{dictType}, - sort = #{sort}, - update_by = #{updateBy}, - update_time = sysdate() - </set> - where column_id = #{columnId} - </update> - - <delete id="deleteGenTableColumnByIds" parameterType="Long"> - delete from gen_table_column where table_id in - <foreach collection="array" item="tableId" open="(" separator="," close=")"> - #{tableId} - </foreach> - </delete> - - <delete id="deleteGenTableColumns"> - delete from gen_table_column where column_id in - <foreach collection="list" item="item" open="(" separator="," close=")"> - #{item.columnId} - </foreach> - </delete> </mapper> \ No newline at end of file diff --git a/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml b/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml index 528e925..4054dd0 100644 --- a/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml +++ b/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml @@ -133,69 +133,4 @@ order by c.sort </select> - <insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId"> - insert into gen_table ( - <if test="tableName != null">table_name,</if> - <if test="tableComment != null and tableComment != ''">table_comment,</if> - <if test="className != null and className != ''">class_name,</if> - <if test="tplCategory != null and tplCategory != ''">tpl_category,</if> - <if test="packageName != null and packageName != ''">package_name,</if> - <if test="moduleName != null and moduleName != ''">module_name,</if> - <if test="businessName != null and businessName != ''">business_name,</if> - <if test="functionName != null and functionName != ''">function_name,</if> - <if test="functionAuthor != null and functionAuthor != ''">function_author,</if> - <if test="genType != null and genType != ''">gen_type,</if> - <if test="genPath != null and genPath != ''">gen_path,</if> - <if test="remark != null and remark != ''">remark,</if> - <if test="createBy != null and createBy != ''">create_by,</if> - create_time - )values( - <if test="tableName != null">#{tableName},</if> - <if test="tableComment != null and tableComment != ''">#{tableComment},</if> - <if test="className != null and className != ''">#{className},</if> - <if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if> - <if test="packageName != null and packageName != ''">#{packageName},</if> - <if test="moduleName != null and moduleName != ''">#{moduleName},</if> - <if test="businessName != null and businessName != ''">#{businessName},</if> - <if test="functionName != null and functionName != ''">#{functionName},</if> - <if test="functionAuthor != null and functionAuthor != ''">#{functionAuthor},</if> - <if test="genType != null and genType != ''">#{genType},</if> - <if test="genPath != null and genPath != ''">#{genPath},</if> - <if test="remark != null and remark != ''">#{remark},</if> - <if test="createBy != null and createBy != ''">#{createBy},</if> - sysdate() - ) - </insert> - - <update id="updateGenTable" parameterType="GenTable"> - update gen_table - <set> - <if test="tableName != null">table_name = #{tableName},</if> - <if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if> - <if test="subTableName != null">sub_table_name = #{subTableName},</if> - <if test="subTableFkName != null">sub_table_fk_name = #{subTableFkName},</if> - <if test="className != null and className != ''">class_name = #{className},</if> - <if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if> - <if test="genType != null and genType != ''">gen_type = #{genType},</if> - <if test="genPath != null and genPath != ''">gen_path = #{genPath},</if> - <if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if> - <if test="packageName != null and packageName != ''">package_name = #{packageName},</if> - <if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if> - <if test="businessName != null and businessName != ''">business_name = #{businessName},</if> - <if test="functionName != null and functionName != ''">function_name = #{functionName},</if> - <if test="options != null and options != ''">options = #{options},</if> - <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> - <if test="remark != null">remark = #{remark},</if> - update_time = sysdate() - </set> - where table_id = #{tableId} - </update> - - <delete id="deleteGenTableByIds" parameterType="Long"> - delete from gen_table where table_id in - <foreach collection="array" item="tableId" open="(" separator="," close=")"> - #{tableId} - </foreach> - </delete> - </mapper> \ No newline at end of file diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java index 04430a1..b6ae67b 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java @@ -3,64 +3,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.quartz.domain.SysJobLog; -import java.util.List; - /** * 璋冨害浠诲姟鏃ュ織淇℃伅 鏁版嵁灞� - * + * * @author ruoyi */ -public interface SysJobLogMapper extends BaseMapper<SysJobLog> -{ - /** - * 鑾峰彇quartz璋冨害鍣ㄦ棩蹇楃殑璁″垝浠诲姟 - * - * @param jobLog 璋冨害鏃ュ織淇℃伅 - * @return 璋冨害浠诲姟鏃ュ織闆嗗悎 - */ - public List<SysJobLog> selectJobLogList(SysJobLog jobLog); +public interface SysJobLogMapper extends BaseMapper<SysJobLog> { - /** - * 鏌ヨ鎵�鏈夎皟搴︿换鍔℃棩蹇� - * - * @return 璋冨害浠诲姟鏃ュ織鍒楄〃 - */ - public List<SysJobLog> selectJobLogAll(); - - /** - * 閫氳繃璋冨害浠诲姟鏃ュ織ID鏌ヨ璋冨害淇℃伅 - * - * @param jobLogId 璋冨害浠诲姟鏃ュ織ID - * @return 璋冨害浠诲姟鏃ュ織瀵硅薄淇℃伅 - */ - public SysJobLog selectJobLogById(Long jobLogId); - - /** - * 鏂板浠诲姟鏃ュ織 - * - * @param jobLog 璋冨害鏃ュ織淇℃伅 - * @return 缁撴灉 - */ - public int insertJobLog(SysJobLog jobLog); - - /** - * 鎵归噺鍒犻櫎璋冨害鏃ュ織淇℃伅 - * - * @param logIds 闇�瑕佸垹闄ょ殑鏁版嵁ID - * @return 缁撴灉 - */ - public int deleteJobLogByIds(Long[] logIds); - - /** - * 鍒犻櫎浠诲姟鏃ュ織 - * - * @param jobId 璋冨害鏃ュ織ID - * @return 缁撴灉 - */ - public int deleteJobLogById(Long jobId); - - /** - * 娓呯┖浠诲姟鏃ュ織 - */ - public void cleanJobLog(); } diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java index bdada0c..1f814b0 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java @@ -3,67 +3,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.quartz.domain.SysJob; -import java.util.List; - /** * 璋冨害浠诲姟淇℃伅 鏁版嵁灞� - * + * * @author ruoyi */ -public interface SysJobMapper extends BaseMapper<SysJob> -{ - /** - * 鏌ヨ璋冨害浠诲姟鏃ュ織闆嗗悎 - * - * @param job 璋冨害淇℃伅 - * @return 鎿嶄綔鏃ュ織闆嗗悎 - */ - public List<SysJob> selectJobList(SysJob job); +public interface SysJobMapper extends BaseMapper<SysJob> { - /** - * 鏌ヨ鎵�鏈夎皟搴︿换鍔� - * - * @return 璋冨害浠诲姟鍒楄〃 - */ - public List<SysJob> selectJobAll(); - - /** - * 閫氳繃璋冨害ID鏌ヨ璋冨害浠诲姟淇℃伅 - * - * @param jobId 璋冨害ID - * @return 瑙掕壊瀵硅薄淇℃伅 - */ - public SysJob selectJobById(Long jobId); - - /** - * 閫氳繃璋冨害ID鍒犻櫎璋冨害浠诲姟淇℃伅 - * - * @param jobId 璋冨害ID - * @return 缁撴灉 - */ - public int deleteJobById(Long jobId); - - /** - * 鎵归噺鍒犻櫎璋冨害浠诲姟淇℃伅 - * - * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁ID - * @return 缁撴灉 - */ - public int deleteJobByIds(Long[] ids); - - /** - * 淇敼璋冨害浠诲姟淇℃伅 - * - * @param job 璋冨害浠诲姟淇℃伅 - * @return 缁撴灉 - */ - public int updateJob(SysJob job); - - /** - * 鏂板璋冨害浠诲姟淇℃伅 - * - * @param job 璋冨害浠诲姟淇℃伅 - * @return 缁撴灉 - */ - public int insertJob(SysJob job); } diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java index 0ce6908..a95984b 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java @@ -7,14 +7,13 @@ /** * 瀹氭椂浠诲姟璋冨害鏃ュ織淇℃伅淇℃伅 鏈嶅姟灞� - * + * * @author ruoyi */ -public interface ISysJobLogService extends IService<SysJobLog> -{ +public interface ISysJobLogService extends IService<SysJobLog> { /** * 鑾峰彇quartz璋冨害鍣ㄦ棩蹇楃殑璁″垝浠诲姟 - * + * * @param jobLog 璋冨害鏃ュ織淇℃伅 * @return 璋冨害浠诲姟鏃ュ織闆嗗悎 */ @@ -22,7 +21,7 @@ /** * 閫氳繃璋冨害浠诲姟鏃ュ織ID鏌ヨ璋冨害淇℃伅 - * + * * @param jobLogId 璋冨害浠诲姟鏃ュ織ID * @return 璋冨害浠诲姟鏃ュ織瀵硅薄淇℃伅 */ @@ -30,14 +29,14 @@ /** * 鏂板浠诲姟鏃ュ織 - * + * * @param jobLog 璋冨害鏃ュ織淇℃伅 */ public void addJobLog(SysJobLog jobLog); /** * 鎵归噺鍒犻櫎璋冨害鏃ュ織淇℃伅 - * + * * @param logIds 闇�瑕佸垹闄ょ殑鏃ュ織ID * @return 缁撴灉 */ @@ -45,7 +44,7 @@ /** * 鍒犻櫎浠诲姟鏃ュ織 - * + * * @param jobId 璋冨害鏃ュ織ID * @return 缁撴灉 */ diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java index 49b20ef..5bcd9a7 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java @@ -9,14 +9,13 @@ /** * 瀹氭椂浠诲姟璋冨害淇℃伅淇℃伅 鏈嶅姟灞� - * + * * @author ruoyi */ -public interface ISysJobService extends IService<SysJob> -{ +public interface ISysJobService extends IService<SysJob> { /** * 鑾峰彇quartz璋冨害鍣ㄧ殑璁″垝浠诲姟 - * + * * @param job 璋冨害淇℃伅 * @return 璋冨害浠诲姟闆嗗悎 */ @@ -24,7 +23,7 @@ /** * 閫氳繃璋冨害浠诲姟ID鏌ヨ璋冨害淇℃伅 - * + * * @param jobId 璋冨害浠诲姟ID * @return 璋冨害浠诲姟瀵硅薄淇℃伅 */ @@ -32,7 +31,7 @@ /** * 鏆傚仠浠诲姟 - * + * * @param job 璋冨害淇℃伅 * @return 缁撴灉 */ @@ -40,7 +39,7 @@ /** * 鎭㈠浠诲姟 - * + * * @param job 璋冨害淇℃伅 * @return 缁撴灉 */ @@ -48,7 +47,7 @@ /** * 鍒犻櫎浠诲姟鍚庯紝鎵�瀵瑰簲鐨則rigger涔熷皢琚垹闄� - * + * * @param job 璋冨害淇℃伅 * @return 缁撴灉 */ @@ -56,7 +55,7 @@ /** * 鎵归噺鍒犻櫎璋冨害淇℃伅 - * + * * @param jobIds 闇�瑕佸垹闄ょ殑浠诲姟ID * @return 缁撴灉 */ @@ -64,7 +63,7 @@ /** * 浠诲姟璋冨害鐘舵�佷慨鏀� - * + * * @param job 璋冨害淇℃伅 * @return 缁撴灉 */ @@ -72,7 +71,7 @@ /** * 绔嬪嵆杩愯浠诲姟 - * + * * @param job 璋冨害淇℃伅 * @return 缁撴灉 */ @@ -80,7 +79,7 @@ /** * 鏂板浠诲姟 - * + * * @param job 璋冨害淇℃伅 * @return 缁撴灉 */ @@ -88,7 +87,7 @@ /** * 鏇存柊浠诲姟 - * + * * @param job 璋冨害淇℃伅 * @return 缁撴灉 */ @@ -96,7 +95,7 @@ /** * 鏍¢獙cron琛ㄨ揪寮忔槸鍚︽湁鏁� - * + * * @param cronExpression 琛ㄨ揪寮� * @return 缁撴灉 */ diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java index 8556a37..515f403 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java @@ -1,89 +1,95 @@ package com.ruoyi.quartz.service.impl; -import java.util.List; - +import cn.hutool.core.lang.Validator; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; import com.ruoyi.quartz.domain.SysJobLog; import com.ruoyi.quartz.mapper.SysJobLogMapper; import com.ruoyi.quartz.service.ISysJobLogService; +import org.springframework.stereotype.Service; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; /** * 瀹氭椂浠诲姟璋冨害鏃ュ織淇℃伅 鏈嶅姟灞� - * + * * @author ruoyi */ @Service -public class SysJobLogServiceImpl extends ServiceImpl<SysJobLogMapper, SysJobLog> implements ISysJobLogService -{ - @Autowired - private SysJobLogMapper jobLogMapper; +public class SysJobLogServiceImpl extends ServiceImpl<SysJobLogMapper, SysJobLog> implements ISysJobLogService { /** * 鑾峰彇quartz璋冨害鍣ㄦ棩蹇楃殑璁″垝浠诲姟 - * + * * @param jobLog 璋冨害鏃ュ織淇℃伅 * @return 璋冨害浠诲姟鏃ュ織闆嗗悎 */ @Override - public List<SysJobLog> selectJobLogList(SysJobLog jobLog) - { - return jobLogMapper.selectJobLogList(jobLog); + public List<SysJobLog> selectJobLogList(SysJobLog jobLog) { + Map<String, Object> params = jobLog.getParams(); + return list(new LambdaQueryWrapper<SysJobLog>() + .like(StrUtil.isNotBlank(jobLog.getJobName()), SysJobLog::getJobName, jobLog.getJobName()) + .eq(StrUtil.isNotBlank(jobLog.getJobGroup()), SysJobLog::getJobGroup, jobLog.getJobGroup()) + .eq(StrUtil.isNotBlank(jobLog.getStatus()), SysJobLog::getStatus, jobLog.getStatus()) + .like(StrUtil.isNotBlank(jobLog.getInvokeTarget()), SysJobLog::getInvokeTarget, jobLog.getInvokeTarget()) + .apply(Validator.isNotEmpty(params.get("beginTime")), + "date_format(create_time,'%y%m%d') >= date_format({0},'%y%m%d')", + params.get("beginTime")) + .apply(Validator.isNotEmpty(params.get("endTime")), + "date_format(create_time,'%y%m%d') <= date_format({0},'%y%m%d')", + params.get("endTime"))); } /** * 閫氳繃璋冨害浠诲姟鏃ュ織ID鏌ヨ璋冨害淇℃伅 - * + * * @param jobLogId 璋冨害浠诲姟鏃ュ織ID * @return 璋冨害浠诲姟鏃ュ織瀵硅薄淇℃伅 */ @Override - public SysJobLog selectJobLogById(Long jobLogId) - { - return jobLogMapper.selectJobLogById(jobLogId); + public SysJobLog selectJobLogById(Long jobLogId) { + return getById(jobLogId); } /** * 鏂板浠诲姟鏃ュ織 - * + * * @param jobLog 璋冨害鏃ュ織淇℃伅 */ @Override - public void addJobLog(SysJobLog jobLog) - { - jobLogMapper.insertJobLog(jobLog); + public void addJobLog(SysJobLog jobLog) { + baseMapper.insert(jobLog); } /** * 鎵归噺鍒犻櫎璋冨害鏃ュ織淇℃伅 - * + * * @param logIds 闇�瑕佸垹闄ょ殑鏁版嵁ID * @return 缁撴灉 */ @Override - public int deleteJobLogByIds(Long[] logIds) - { - return jobLogMapper.deleteJobLogByIds(logIds); + public int deleteJobLogByIds(Long[] logIds) { + return baseMapper.deleteBatchIds(Arrays.asList(logIds)); } /** * 鍒犻櫎浠诲姟鏃ュ織 - * + * * @param jobId 璋冨害鏃ュ織ID */ @Override - public int deleteJobLogById(Long jobId) - { - return jobLogMapper.deleteJobLogById(jobId); + public int deleteJobLogById(Long jobId) { + return baseMapper.deleteById(jobId); } /** * 娓呯┖浠诲姟鏃ュ織 */ @Override - public void cleanJobLog() - { - jobLogMapper.cleanJobLog(); + public void cleanJobLog() { + remove(new LambdaQueryWrapper<>()); } } diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java index 51688a5..aa6007a 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java @@ -1,16 +1,8 @@ package com.ruoyi.quartz.service.impl; -import java.util.List; -import javax.annotation.PostConstruct; - +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.quartz.JobDataMap; -import org.quartz.JobKey; -import org.quartz.Scheduler; -import org.quartz.SchedulerException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import com.ruoyi.common.constant.ScheduleConstants; import com.ruoyi.common.exception.job.TaskException; import com.ruoyi.quartz.domain.SysJob; @@ -18,74 +10,78 @@ import com.ruoyi.quartz.service.ISysJobService; import com.ruoyi.quartz.util.CronUtils; import com.ruoyi.quartz.util.ScheduleUtils; +import org.quartz.JobDataMap; +import org.quartz.JobKey; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.PostConstruct; +import java.util.List; /** * 瀹氭椂浠诲姟璋冨害淇℃伅 鏈嶅姟灞� - * + * * @author ruoyi */ @Service -public class SysJobServiceImpl extends ServiceImpl<SysJobMapper, SysJob> implements ISysJobService -{ +public class SysJobServiceImpl extends ServiceImpl<SysJobMapper, SysJob> implements ISysJobService { @Autowired private Scheduler scheduler; - - @Autowired - private SysJobMapper jobMapper; /** * 椤圭洰鍚姩鏃讹紝鍒濆鍖栧畾鏃跺櫒 涓昏鏄槻姝㈡墜鍔ㄤ慨鏀规暟鎹簱瀵艰嚧鏈悓姝ュ埌瀹氭椂浠诲姟澶勭悊锛堟敞锛氫笉鑳芥墜鍔ㄤ慨鏀规暟鎹簱ID鍜屼换鍔$粍鍚嶏紝鍚﹀垯浼氬鑷磋剰鏁版嵁锛� */ @PostConstruct - public void init() throws SchedulerException, TaskException - { + public void init() throws SchedulerException, TaskException { scheduler.clear(); - List<SysJob> jobList = jobMapper.selectJobAll(); - for (SysJob job : jobList) - { + List<SysJob> jobList = list(); + for (SysJob job : jobList) { ScheduleUtils.createScheduleJob(scheduler, job); } } /** * 鑾峰彇quartz璋冨害鍣ㄧ殑璁″垝浠诲姟鍒楄〃 - * + * * @param job 璋冨害淇℃伅 * @return */ @Override - public List<SysJob> selectJobList(SysJob job) - { - return jobMapper.selectJobList(job); + public List<SysJob> selectJobList(SysJob job) { + return list(new LambdaQueryWrapper<SysJob>() + .like(StrUtil.isNotBlank(job.getJobName()), SysJob::getJobName, job.getJobName()) + .eq(StrUtil.isNotBlank(job.getJobGroup()), SysJob::getJobGroup, job.getJobGroup()) + .eq(StrUtil.isNotBlank(job.getStatus()), SysJob::getStatus, job.getStatus()) + .like(StrUtil.isNotBlank(job.getInvokeTarget()), SysJob::getInvokeTarget, job.getInvokeTarget())); } /** * 閫氳繃璋冨害浠诲姟ID鏌ヨ璋冨害淇℃伅 - * + * * @param jobId 璋冨害浠诲姟ID * @return 璋冨害浠诲姟瀵硅薄淇℃伅 */ @Override - public SysJob selectJobById(Long jobId) - { - return jobMapper.selectJobById(jobId); + public SysJob selectJobById(Long jobId) { + return getById(jobId); } /** * 鏆傚仠浠诲姟 - * + * * @param job 璋冨害淇℃伅 */ @Override @Transactional - public int pauseJob(SysJob job) throws SchedulerException - { + public int pauseJob(SysJob job) throws SchedulerException { Long jobId = job.getJobId(); String jobGroup = job.getJobGroup(); job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); - int rows = jobMapper.updateJob(job); - if (rows > 0) - { + int rows = baseMapper.updateById(job); + if (rows > 0) { scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup)); } return rows; @@ -93,19 +89,17 @@ /** * 鎭㈠浠诲姟 - * + * * @param job 璋冨害淇℃伅 */ @Override @Transactional - public int resumeJob(SysJob job) throws SchedulerException - { + public int resumeJob(SysJob job) throws SchedulerException { Long jobId = job.getJobId(); String jobGroup = job.getJobGroup(); job.setStatus(ScheduleConstants.Status.NORMAL.getValue()); - int rows = jobMapper.updateJob(job); - if (rows > 0) - { + int rows = baseMapper.updateById(job); + if (rows > 0) { scheduler.resumeJob(ScheduleUtils.getJobKey(jobId, jobGroup)); } return rows; @@ -113,18 +107,16 @@ /** * 鍒犻櫎浠诲姟鍚庯紝鎵�瀵瑰簲鐨則rigger涔熷皢琚垹闄� - * + * * @param job 璋冨害淇℃伅 */ @Override @Transactional - public int deleteJob(SysJob job) throws SchedulerException - { + public int deleteJob(SysJob job) throws SchedulerException { Long jobId = job.getJobId(); String jobGroup = job.getJobGroup(); - int rows = jobMapper.deleteJobById(jobId); - if (rows > 0) - { + int rows = baseMapper.deleteById(jobId); + if (rows > 0) { scheduler.deleteJob(ScheduleUtils.getJobKey(jobId, jobGroup)); } return rows; @@ -132,38 +124,32 @@ /** * 鎵归噺鍒犻櫎璋冨害淇℃伅 - * + * * @param jobIds 闇�瑕佸垹闄ょ殑浠诲姟ID * @return 缁撴灉 */ @Override @Transactional - public void deleteJobByIds(Long[] jobIds) throws SchedulerException - { - for (Long jobId : jobIds) - { - SysJob job = jobMapper.selectJobById(jobId); + public void deleteJobByIds(Long[] jobIds) throws SchedulerException { + for (Long jobId : jobIds) { + SysJob job = getById(jobId); deleteJob(job); } } /** * 浠诲姟璋冨害鐘舵�佷慨鏀� - * + * * @param job 璋冨害淇℃伅 */ @Override @Transactional - public int changeStatus(SysJob job) throws SchedulerException - { + public int changeStatus(SysJob job) throws SchedulerException { int rows = 0; String status = job.getStatus(); - if (ScheduleConstants.Status.NORMAL.getValue().equals(status)) - { + if (ScheduleConstants.Status.NORMAL.getValue().equals(status)) { rows = resumeJob(job); - } - else if (ScheduleConstants.Status.PAUSE.getValue().equals(status)) - { + } else if (ScheduleConstants.Status.PAUSE.getValue().equals(status)) { rows = pauseJob(job); } return rows; @@ -171,13 +157,12 @@ /** * 绔嬪嵆杩愯浠诲姟 - * + * * @param job 璋冨害淇℃伅 */ @Override @Transactional - public void run(SysJob job) throws SchedulerException - { + public void run(SysJob job) throws SchedulerException { Long jobId = job.getJobId(); String jobGroup = job.getJobGroup(); SysJob properties = selectJobById(job.getJobId()); @@ -189,17 +174,15 @@ /** * 鏂板浠诲姟 - * + * * @param job 璋冨害淇℃伅 璋冨害淇℃伅 */ @Override @Transactional - public int insertJob(SysJob job) throws SchedulerException, TaskException - { + public int insertJob(SysJob job) throws SchedulerException, TaskException { job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); - int rows = jobMapper.insertJob(job); - if (rows > 0) - { + int rows = baseMapper.insert(job); + if (rows > 0) { ScheduleUtils.createScheduleJob(scheduler, job); } return rows; @@ -207,17 +190,15 @@ /** * 鏇存柊浠诲姟鐨勬椂闂磋〃杈惧紡 - * + * * @param job 璋冨害淇℃伅 */ @Override @Transactional - public int updateJob(SysJob job) throws SchedulerException, TaskException - { + public int updateJob(SysJob job) throws SchedulerException, TaskException { SysJob properties = selectJobById(job.getJobId()); - int rows = jobMapper.updateJob(job); - if (rows > 0) - { + int rows = baseMapper.updateById(job); + if (rows > 0) { updateSchedulerJob(job, properties.getJobGroup()); } return rows; @@ -225,17 +206,15 @@ /** * 鏇存柊浠诲姟 - * - * @param job 浠诲姟瀵硅薄 + * + * @param job 浠诲姟瀵硅薄 * @param jobGroup 浠诲姟缁勫悕 */ - public void updateSchedulerJob(SysJob job, String jobGroup) throws SchedulerException, TaskException - { + public void updateSchedulerJob(SysJob job, String jobGroup) throws SchedulerException, TaskException { Long jobId = job.getJobId(); // 鍒ゆ柇鏄惁瀛樺湪 JobKey jobKey = ScheduleUtils.getJobKey(jobId, jobGroup); - if (scheduler.checkExists(jobKey)) - { + if (scheduler.checkExists(jobKey)) { // 闃叉鍒涘缓鏃跺瓨鍦ㄦ暟鎹棶棰� 鍏堢Щ闄わ紝鐒跺悗鍦ㄦ墽琛屽垱寤烘搷浣� scheduler.deleteJob(jobKey); } @@ -244,13 +223,12 @@ /** * 鏍¢獙cron琛ㄨ揪寮忔槸鍚︽湁鏁� - * + * * @param cronExpression 琛ㄨ揪寮� * @return 缁撴灉 */ @Override - public boolean checkCronExpressionIsValid(String cronExpression) - { + public boolean checkCronExpressionIsValid(String cronExpression) { return CronUtils.isValid(cronExpression); } } diff --git a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml index 588d177..736a699 100644 --- a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml +++ b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml @@ -14,80 +14,5 @@ <result property="exceptionInfo" column="exception_info" /> <result property="createTime" column="create_time" /> </resultMap> - - <sql id="selectJobLogVo"> - select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time - from sys_job_log - </sql> - - <select id="selectJobLogList" parameterType="SysJobLog" resultMap="SysJobLogResult"> - <include refid="selectJobLogVo"/> - <where> - <if test="jobName != null and jobName != ''"> - AND job_name like concat('%', #{jobName}, '%') - </if> - <if test="jobGroup != null and jobGroup != ''"> - AND job_group = #{jobGroup} - </if> - <if test="status != null and status != ''"> - AND status = #{status} - </if> - <if test="invokeTarget != null and invokeTarget != ''"> - AND invoke_target like concat('%', #{invokeTarget}, '%') - </if> - <if test="params.beginTime != null and params.beginTime != ''"><!-- 寮�濮嬫椂闂存绱� --> - and date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') - </if> - <if test="params.endTime != null and params.endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� --> - and date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') - </if> - </where> - </select> - - <select id="selectJobLogAll" resultMap="SysJobLogResult"> - <include refid="selectJobLogVo"/> - </select> - - <select id="selectJobLogById" parameterType="Long" resultMap="SysJobLogResult"> - <include refid="selectJobLogVo"/> - where job_log_id = #{jobLogId} - </select> - - <delete id="deleteJobLogById" parameterType="Long"> - delete from sys_job_log where job_log_id = #{jobLogId} - </delete> - - <delete id="deleteJobLogByIds" parameterType="Long"> - delete from sys_job_log where job_log_id in - <foreach collection="array" item="jobLogId" open="(" separator="," close=")"> - #{jobLogId} - </foreach> - </delete> - - <update id="cleanJobLog"> - truncate table sys_job_log - </update> - - <insert id="insertJobLog" parameterType="SysJobLog"> - insert into sys_job_log( - <if test="jobLogId != null and jobLogId != 0">job_log_id,</if> - <if test="jobName != null and jobName != ''">job_name,</if> - <if test="jobGroup != null and jobGroup != ''">job_group,</if> - <if test="invokeTarget != null and invokeTarget != ''">invoke_target,</if> - <if test="jobMessage != null and jobMessage != ''">job_message,</if> - <if test="status != null and status != ''">status,</if> - <if test="exceptionInfo != null and exceptionInfo != ''">exception_info,</if> - create_time - )values( - <if test="jobLogId != null and jobLogId != 0">#{jobLogId},</if> - <if test="jobName != null and jobName != ''">#{jobName},</if> - <if test="jobGroup != null and jobGroup != ''">#{jobGroup},</if> - <if test="invokeTarget != null and invokeTarget != ''">#{invokeTarget},</if> - <if test="jobMessage != null and jobMessage != ''">#{jobMessage},</if> - <if test="status != null and status != ''">#{status},</if> - <if test="exceptionInfo != null and exceptionInfo != ''">#{exceptionInfo},</if> - sysdate() - ) - </insert> </mapper> \ No newline at end of file diff --git a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml index 69233bd..0a6342b 100644 --- a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml +++ b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml @@ -19,93 +19,5 @@ <result property="updateTime" column="update_time" /> <result property="remark" column="remark" /> </resultMap> - - <sql id="selectJobVo"> - select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark - from sys_job - </sql> - - <select id="selectJobList" parameterType="SysJob" resultMap="SysJobResult"> - <include refid="selectJobVo"/> - <where> - <if test="jobName != null and jobName != ''"> - AND job_name like concat('%', #{jobName}, '%') - </if> - <if test="jobGroup != null and jobGroup != ''"> - AND job_group = #{jobGroup} - </if> - <if test="status != null and status != ''"> - AND status = #{status} - </if> - <if test="invokeTarget != null and invokeTarget != ''"> - AND invoke_target like concat('%', #{invokeTarget}, '%') - </if> - </where> - </select> - - <select id="selectJobAll" resultMap="SysJobResult"> - <include refid="selectJobVo"/> - </select> - - <select id="selectJobById" parameterType="Long" resultMap="SysJobResult"> - <include refid="selectJobVo"/> - where job_id = #{jobId} - </select> - - <delete id="deleteJobById" parameterType="Long"> - delete from sys_job where job_id = #{jobId} - </delete> - - <delete id="deleteJobByIds" parameterType="Long"> - delete from sys_job where job_id in - <foreach collection="array" item="jobId" open="(" separator="," close=")"> - #{jobId} - </foreach> - </delete> - - <update id="updateJob" parameterType="SysJob"> - update sys_job - <set> - <if test="jobName != null and jobName != ''">job_name = #{jobName},</if> - <if test="jobGroup != null and jobGroup != ''">job_group = #{jobGroup},</if> - <if test="invokeTarget != null and invokeTarget != ''">invoke_target = #{invokeTarget},</if> - <if test="cronExpression != null and cronExpression != ''">cron_expression = #{cronExpression},</if> - <if test="misfirePolicy != null and misfirePolicy != ''">misfire_policy = #{misfirePolicy},</if> - <if test="concurrent != null and concurrent != ''">concurrent = #{concurrent},</if> - <if test="status !=null">status = #{status},</if> - <if test="remark != null and remark != ''">remark = #{remark},</if> - <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> - update_time = sysdate() - </set> - where job_id = #{jobId} - </update> - - <insert id="insertJob" parameterType="SysJob" useGeneratedKeys="true" keyProperty="jobId"> - insert into sys_job( - <if test="jobId != null and jobId != 0">job_id,</if> - <if test="jobName != null and jobName != ''">job_name,</if> - <if test="jobGroup != null and jobGroup != ''">job_group,</if> - <if test="invokeTarget != null and invokeTarget != ''">invoke_target,</if> - <if test="cronExpression != null and cronExpression != ''">cron_expression,</if> - <if test="misfirePolicy != null and misfirePolicy != ''">misfire_policy,</if> - <if test="concurrent != null and concurrent != ''">concurrent,</if> - <if test="status != null and status != ''">status,</if> - <if test="remark != null and remark != ''">remark,</if> - <if test="createBy != null and createBy != ''">create_by,</if> - create_time - )values( - <if test="jobId != null and jobId != 0">#{jobId},</if> - <if test="jobName != null and jobName != ''">#{jobName},</if> - <if test="jobGroup != null and jobGroup != ''">#{jobGroup},</if> - <if test="invokeTarget != null and invokeTarget != ''">#{invokeTarget},</if> - <if test="cronExpression != null and cronExpression != ''">#{cronExpression},</if> - <if test="misfirePolicy != null and misfirePolicy != ''">#{misfirePolicy},</if> - <if test="concurrent != null and concurrent != ''">#{concurrent},</if> - <if test="status != null and status != ''">#{status},</if> - <if test="remark != null and remark != ''">#{remark},</if> - <if test="createBy != null and createBy != ''">#{createBy},</if> - sysdate() - ) - </insert> </mapper> \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictTypeMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictTypeMapper.java index ead5d2d..0c81ddd 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictTypeMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictTypeMapper.java @@ -2,46 +2,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.common.core.domain.entity.SysDictType; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; /** * 瀛楀吀琛� 鏁版嵁灞� * * @author ruoyi */ -@Mapper public interface SysDictTypeMapper extends BaseMapper<SysDictType> { - /** - * 鏍规嵁鎵�鏈夊瓧鍏哥被鍨� - * - * @return 瀛楀吀绫诲瀷闆嗗悎淇℃伅 - */ - public List<SysDictType> selectDictTypeAll(); - - /** - * 鏍规嵁瀛楀吀绫诲瀷ID鏌ヨ淇℃伅 - * - * @param dictId 瀛楀吀绫诲瀷ID - * @return 瀛楀吀绫诲瀷 - */ - public SysDictType selectDictTypeById(Long dictId); - - /** - * 鏍规嵁瀛楀吀绫诲瀷鏌ヨ淇℃伅 - * - * @param dictType 瀛楀吀绫诲瀷 - * @return 瀛楀吀绫诲瀷 - */ - public SysDictType selectDictTypeByType(String dictType); - - /** - * 鏍¢獙瀛楀吀绫诲瀷绉版槸鍚﹀敮涓� - * - * @param dictType 瀛楀吀绫诲瀷 - * @return 缁撴灉 - */ - public SysDictType checkDictTypeUnique(String dictType); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 74c265c..aece9d0 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -16,8 +16,7 @@ import com.ruoyi.system.mapper.*; import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysUserService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -31,12 +30,9 @@ * * @author ruoyi */ +@Slf4j @Service public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService { - private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class); - - @Autowired - private SysUserMapper userMapper; @Autowired private SysRoleMapper roleMapper; @@ -62,7 +58,7 @@ @Override @DataScope(deptAlias = "d", userAlias = "u") public List<SysUser> selectUserList(SysUser user) { - return userMapper.selectUserList(user); + return baseMapper.selectUserList(user); } /** @@ -73,7 +69,7 @@ */ @Override public SysUser selectUserByUserName(String userName) { - return userMapper.selectUserByUserName(userName); + return baseMapper.selectUserByUserName(userName); } /** @@ -84,7 +80,7 @@ */ @Override public SysUser selectUserById(Long userId) { - return userMapper.selectUserById(userId); + return baseMapper.selectUserById(userId); } /** @@ -198,7 +194,7 @@ @Transactional public int insertUser(SysUser user) { // 鏂板鐢ㄦ埛淇℃伅 - int rows = userMapper.insert(user); + int rows = baseMapper.insert(user); // 鏂板鐢ㄦ埛宀椾綅鍏宠仈 insertUserPost(user); // 鏂板鐢ㄦ埛涓庤鑹茬鐞� @@ -224,7 +220,7 @@ userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getUserId,userId)); // 鏂板鐢ㄦ埛涓庡矖浣嶇鐞� insertUserPost(user); - return userMapper.updateById(user); + return baseMapper.updateById(user); } /** @@ -235,7 +231,7 @@ */ @Override public int updateUserStatus(SysUser user) { - return userMapper.updateById(user); + return baseMapper.updateById(user); } /** @@ -246,7 +242,7 @@ */ @Override public int updateUserProfile(SysUser user) { - return userMapper.updateById(user); + return baseMapper.updateById(user); } /** @@ -258,7 +254,7 @@ */ @Override public boolean updateUserAvatar(String userName, String avatar) { - return userMapper.update(null, + return baseMapper.update(null, new LambdaUpdateWrapper<SysUser>() .set(SysUser::getAvatar,avatar) .eq(SysUser::getUserName,userName)) > 0; @@ -272,7 +268,7 @@ */ @Override public int resetPwd(SysUser user) { - return userMapper.updateById(user); + return baseMapper.updateById(user); } /** @@ -284,7 +280,7 @@ */ @Override public int resetUserPwd(String userName, String password) { - return userMapper.update(null, + return baseMapper.update(null, new LambdaUpdateWrapper<SysUser>() .set(SysUser::getPassword,password) .eq(SysUser::getUserName,userName)); @@ -351,7 +347,7 @@ userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId,userId)); // 鍒犻櫎鐢ㄦ埛涓庡矖浣嶈〃 userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getUserId,userId)); - return userMapper.deleteById(userId); + return baseMapper.deleteById(userId); } /** @@ -371,7 +367,7 @@ userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().in(SysUserRole::getUserId,ids)); // 鍒犻櫎鐢ㄦ埛涓庡矖浣嶈〃 userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().in(SysUserPost::getUserId,ids)); - return userMapper.deleteBatchIds(ids); + return baseMapper.deleteBatchIds(ids); } /** @@ -395,7 +391,7 @@ for (SysUser user : userList) { try { // 楠岃瘉鏄惁瀛樺湪杩欎釜鐢ㄦ埛 - SysUser u = userMapper.selectUserByUserName(user.getUserName()); + SysUser u = baseMapper.selectUserByUserName(user.getUserName()); if (Validator.isNull(u)) { user.setPassword(SecurityUtils.encryptPassword(password)); user.setCreateBy(operName); diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDictTypeMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDictTypeMapper.xml index 9778f19..8857f34 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysDictTypeMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysDictTypeMapper.xml @@ -15,28 +15,4 @@ <result property="updateTime" column="update_time"/> </resultMap> - <sql id="selectDictTypeVo"> - select dict_id, dict_name, dict_type, status, create_by, create_time, remark - from sys_dict_type - </sql> - - <select id="selectDictTypeAll" resultMap="SysDictTypeResult"> - <include refid="selectDictTypeVo"/> - </select> - - <select id="selectDictTypeById" parameterType="Long" resultMap="SysDictTypeResult"> - <include refid="selectDictTypeVo"/> - where dict_id = #{dictId} - </select> - - <select id="selectDictTypeByType" parameterType="String" resultMap="SysDictTypeResult"> - <include refid="selectDictTypeVo"/> - where dict_type = #{dictType} - </select> - - <select id="checkDictTypeUnique" parameterType="String" resultMap="SysDictTypeResult"> - <include refid="selectDictTypeVo"/> - where dict_type = #{dictType} limit 1 - </select> - </mapper> \ No newline at end of file -- Gitblit v1.9.3