diff --git a/src/main/java/net/wicp/tams/app/duckula/controller/bean/models/SysResource.java b/src/main/java/net/wicp/tams/app/duckula/controller/bean/models/SysResource.java index 8210c97d12d10036f6b41c442ba952054b83639f..88ad399df645ec928fcc18a256a6a986f65db769 100644 --- a/src/main/java/net/wicp/tams/app/duckula/controller/bean/models/SysResource.java +++ b/src/main/java/net/wicp/tams/app/duckula/controller/bean/models/SysResource.java @@ -62,6 +62,11 @@ public class SysResource { * @mbg.generated */ private String remark; + /** + * Database Column Remarks: 是否由程序同否 This field was generated by MyBatis Generator. This field corresponds to the database column sys_resource.is_sync + * @mbg.generated + */ + private String isSync; /** * This field was generated by MyBatis Generator. This field corresponds to the database column sys_resource.bound1 * @mbg.generated @@ -113,8 +118,9 @@ public class SysResource { * @mbg.generated */ public SysResource(Long id, String resCode, String resName, String resValue, String resType, String icon, - Integer resLevel, String isEdit, Long parentId, Long showOrder, String remark, String bound1, String bound2, - String bound3, String bound4, String bound5, String bound6, String bound7, String bound8, String bound9) { + Integer resLevel, String isEdit, Long parentId, Long showOrder, String remark, String isSync, String bound1, + String bound2, String bound3, String bound4, String bound5, String bound6, String bound7, String bound8, + String bound9) { this.id = id; this.resCode = resCode; this.resName = resName; @@ -126,6 +132,7 @@ public class SysResource { this.parentId = parentId; this.showOrder = showOrder; this.remark = remark; + this.isSync = isSync; this.bound1 = bound1; this.bound2 = bound2; this.bound3 = bound3; @@ -343,6 +350,24 @@ public class SysResource { this.remark = remark; } + /** + * This method was generated by MyBatis Generator. This method returns the value of the database column sys_resource.is_sync + * @return the value of sys_resource.is_sync + * @mbg.generated + */ + public String getIsSync() { + return isSync; + } + + /** + * This method was generated by MyBatis Generator. This method sets the value of the database column sys_resource.is_sync + * @param isSync the value for sys_resource.is_sync + * @mbg.generated + */ + public void setIsSync(String isSync) { + this.isSync = isSync; + } + /** * This method was generated by MyBatis Generator. This method returns the value of the database column sys_resource.bound1 * @return the value of sys_resource.bound1 diff --git a/src/main/java/net/wicp/tams/app/duckula/controller/bean/models/SysResourceExample.java b/src/main/java/net/wicp/tams/app/duckula/controller/bean/models/SysResourceExample.java index c1d0b746f06a4ce47c20b2f3444d02829c1a5d3f..3b7d791999809ddff743d455a6a42130295b3b57 100644 --- a/src/main/java/net/wicp/tams/app/duckula/controller/bean/models/SysResourceExample.java +++ b/src/main/java/net/wicp/tams/app/duckula/controller/bean/models/SysResourceExample.java @@ -892,6 +892,76 @@ public class SysResourceExample { return (Criteria) this; } + public Criteria andIsSyncIsNull() { + addCriterion("is_sync is null"); + return (Criteria) this; + } + + public Criteria andIsSyncIsNotNull() { + addCriterion("is_sync is not null"); + return (Criteria) this; + } + + public Criteria andIsSyncEqualTo(String value) { + addCriterion("is_sync =", value, "isSync"); + return (Criteria) this; + } + + public Criteria andIsSyncNotEqualTo(String value) { + addCriterion("is_sync <>", value, "isSync"); + return (Criteria) this; + } + + public Criteria andIsSyncGreaterThan(String value) { + addCriterion("is_sync >", value, "isSync"); + return (Criteria) this; + } + + public Criteria andIsSyncGreaterThanOrEqualTo(String value) { + addCriterion("is_sync >=", value, "isSync"); + return (Criteria) this; + } + + public Criteria andIsSyncLessThan(String value) { + addCriterion("is_sync <", value, "isSync"); + return (Criteria) this; + } + + public Criteria andIsSyncLessThanOrEqualTo(String value) { + addCriterion("is_sync <=", value, "isSync"); + return (Criteria) this; + } + + public Criteria andIsSyncLike(String value) { + addCriterion("is_sync like", value, "isSync"); + return (Criteria) this; + } + + public Criteria andIsSyncNotLike(String value) { + addCriterion("is_sync not like", value, "isSync"); + return (Criteria) this; + } + + public Criteria andIsSyncIn(List values) { + addCriterion("is_sync in", values, "isSync"); + return (Criteria) this; + } + + public Criteria andIsSyncNotIn(List values) { + addCriterion("is_sync not in", values, "isSync"); + return (Criteria) this; + } + + public Criteria andIsSyncBetween(String value1, String value2) { + addCriterion("is_sync between", value1, value2, "isSync"); + return (Criteria) this; + } + + public Criteria andIsSyncNotBetween(String value1, String value2) { + addCriterion("is_sync not between", value1, value2, "isSync"); + return (Criteria) this; + } + public Criteria andBound1IsNull() { addCriterion("bound1 is null"); return (Criteria) this; diff --git a/src/main/java/net/wicp/tams/app/duckula/controller/dao/SysResourceMapper.java b/src/main/java/net/wicp/tams/app/duckula/controller/dao/SysResourceMapper.java index 8fdfb397e2a6a6000588d8a3405fd7c298b97bbc..ef04d0426d1f1ed15457c9fa92d14a3632ca94f2 100644 --- a/src/main/java/net/wicp/tams/app/duckula/controller/dao/SysResourceMapper.java +++ b/src/main/java/net/wicp/tams/app/duckula/controller/dao/SysResourceMapper.java @@ -40,16 +40,17 @@ public interface SysResourceMapper extends BaseMapper{ * @mbg.generated */ @Insert({ "insert into sys_resource (id, res_code, ", "res_name, res_value, ", "res_type, icon, res_level, ", - "is_edit, parent_id, ", "show_order, remark, ", "bound1, bound2, ", "bound3, bound4, ", "bound5, bound6, ", - "bound7, bound8, ", "bound9)", "values (#{id,jdbcType=BIGINT}, #{resCode,jdbcType=VARCHAR}, ", + "is_edit, parent_id, ", "show_order, remark, ", "is_sync, bound1, ", "bound2, bound3, ", "bound4, bound5, ", + "bound6, bound7, ", "bound8, bound9)", "values (#{id,jdbcType=BIGINT}, #{resCode,jdbcType=VARCHAR}, ", "#{resName,jdbcType=VARCHAR}, #{resValue,jdbcType=VARCHAR}, ", "#{resType,jdbcType=VARCHAR}, #{icon,jdbcType=VARCHAR}, #{resLevel,jdbcType=INTEGER}, ", "#{isEdit,jdbcType=VARCHAR}, #{parentId,jdbcType=BIGINT}, ", "#{showOrder,jdbcType=BIGINT}, #{remark,jdbcType=VARCHAR}, ", - "#{bound1,jdbcType=VARCHAR}, #{bound2,jdbcType=VARCHAR}, ", - "#{bound3,jdbcType=VARCHAR}, #{bound4,jdbcType=VARCHAR}, ", - "#{bound5,jdbcType=VARCHAR}, #{bound6,jdbcType=VARCHAR}, ", - "#{bound7,jdbcType=VARCHAR}, #{bound8,jdbcType=VARCHAR}, ", "#{bound9,jdbcType=VARCHAR})" }) + "#{isSync,jdbcType=VARCHAR}, #{bound1,jdbcType=VARCHAR}, ", + "#{bound2,jdbcType=VARCHAR}, #{bound3,jdbcType=VARCHAR}, ", + "#{bound4,jdbcType=VARCHAR}, #{bound5,jdbcType=VARCHAR}, ", + "#{bound6,jdbcType=VARCHAR}, #{bound7,jdbcType=VARCHAR}, ", + "#{bound8,jdbcType=VARCHAR}, #{bound9,jdbcType=VARCHAR})" }) int insert(SysResource record); /** @@ -69,7 +70,7 @@ public interface SysResourceMapper extends BaseMapper{ * @mbg.generated */ @Select({ "select", "id, res_code, res_name, res_value, res_type, icon, res_level, is_edit, parent_id, ", - "show_order, remark, bound1, bound2, bound3, bound4, bound5, bound6, bound7, ", "bound8, bound9", + "show_order, remark, is_sync, bound1, bound2, bound3, bound4, bound5, bound6, ", "bound7, bound8, bound9", "from sys_resource", "where id = #{id,jdbcType=BIGINT}" }) @ResultMap("net.wicp.tams.app.duckula.controller.dao.SysResourceMapper.BaseResultMap") SysResource selectByPrimaryKey(Long id); @@ -101,11 +102,11 @@ public interface SysResourceMapper extends BaseMapper{ "res_type = #{resType,jdbcType=VARCHAR},", "icon = #{icon,jdbcType=VARCHAR},", "res_level = #{resLevel,jdbcType=INTEGER},", "is_edit = #{isEdit,jdbcType=VARCHAR},", "parent_id = #{parentId,jdbcType=BIGINT},", "show_order = #{showOrder,jdbcType=BIGINT},", - "remark = #{remark,jdbcType=VARCHAR},", "bound1 = #{bound1,jdbcType=VARCHAR},", - "bound2 = #{bound2,jdbcType=VARCHAR},", "bound3 = #{bound3,jdbcType=VARCHAR},", - "bound4 = #{bound4,jdbcType=VARCHAR},", "bound5 = #{bound5,jdbcType=VARCHAR},", - "bound6 = #{bound6,jdbcType=VARCHAR},", "bound7 = #{bound7,jdbcType=VARCHAR},", - "bound8 = #{bound8,jdbcType=VARCHAR},", "bound9 = #{bound9,jdbcType=VARCHAR}", - "where id = #{id,jdbcType=BIGINT}" }) + "remark = #{remark,jdbcType=VARCHAR},", "is_sync = #{isSync,jdbcType=VARCHAR},", + "bound1 = #{bound1,jdbcType=VARCHAR},", "bound2 = #{bound2,jdbcType=VARCHAR},", + "bound3 = #{bound3,jdbcType=VARCHAR},", "bound4 = #{bound4,jdbcType=VARCHAR},", + "bound5 = #{bound5,jdbcType=VARCHAR},", "bound6 = #{bound6,jdbcType=VARCHAR},", + "bound7 = #{bound7,jdbcType=VARCHAR},", "bound8 = #{bound8,jdbcType=VARCHAR},", + "bound9 = #{bound9,jdbcType=VARCHAR}", "where id = #{id,jdbcType=BIGINT}" }) int updateByPrimaryKey(SysResource record); } \ No newline at end of file diff --git a/src/main/java/net/wicp/tams/app/duckula/controller/service/cas/impl/MenuService.java b/src/main/java/net/wicp/tams/app/duckula/controller/service/cas/impl/MenuService.java index 9f5c61b539b42ddf6c323387795d45f9a89c108b..94eb532ea14f492f2a92f88ddf8814d3dc52bc76 100644 --- a/src/main/java/net/wicp/tams/app/duckula/controller/service/cas/impl/MenuService.java +++ b/src/main/java/net/wicp/tams/app/duckula/controller/service/cas/impl/MenuService.java @@ -84,7 +84,8 @@ public class MenuService implements IMenuService { // conf.setTextConvert(i18NConvert); conf.setIconClsCol("icon"); - conf.setAttrCols("isEdit","resType", "resLevel", "resCode", "resName", "resValue", "remark", "bound1", "bound2"); + conf.setAttrCols("isEdit", "resType", "resLevel", "resCode", "resName", "resValue", "remark", "bound1", + "bound2"); conf.setIsRoot(new Predicate() { @Override @@ -126,8 +127,7 @@ public class MenuService implements IMenuService { @Override public List findSyncRes() { QueryWrapper queryWrapper = new QueryWrapper(); - queryWrapper.gt("res_level", 1); - queryWrapper.eq("res_type", 3); + queryWrapper.eq("is_sync", "yes"); return sysResourceMapper.selectList(queryWrapper); } diff --git a/src/main/java/net/wicp/tams/duckula/ops/pages/cas/ResManager.java b/src/main/java/net/wicp/tams/duckula/ops/pages/cas/ResManager.java index 5bfdb6102780abdd7bb45c33b1bb86ddc8479116..acc101ec902fd2855c6737463463d14be5b57da6 100644 --- a/src/main/java/net/wicp/tams/duckula/ops/pages/cas/ResManager.java +++ b/src/main/java/net/wicp/tams/duckula/ops/pages/cas/ResManager.java @@ -188,11 +188,13 @@ public class ResManager extends ParentPageBean { hasResList.add(res); } final List dbResList = menuService.findSyncRes();// 查找数据库已有的菜单 + Set synValueList = CollectionUtil.getColSetFromObj(hasResList, "resValue"); // 数据库中有的,但已不存在此页面的,需要删除 List deleteList = (List) CollectionUtils.select(dbResList, new Predicate() { @Override public boolean evaluate(Object object) { - return !hasResList.contains(object); + SysResource temp = (SysResource) object; + return !synValueList.contains(temp.getResValue()); } }); @@ -205,26 +207,23 @@ public class ResManager extends ParentPageBean { @Override public boolean evaluate(Object object) { SysResource tempobj = (SysResource) object; - return hasResList.contains(object); - // && "yes".equals(tempobj.getisEdit()); + return synValueList.contains(tempobj.getResValue()) && "yes".equals(tempobj.getIsEdit()); } }); for (SysResource ca_Resource : updateList) { - SysResource updateObj = hasResList.get(hasResList.indexOf(ca_Resource)); - ca_Resource.setResCode(updateObj.getResCode()); - ca_Resource.setResName(updateObj.getResName()); - ca_Resource.setResValue(updateObj.getResValue()); - ca_Resource.setRemark("程序自动更新"); + ca_Resource.setIsEdit(YesOrNo.yes.name()); + ca_Resource.setRemark("系统自动同步"); + ca_Resource.setIsSync(YesOrNo.yes.name()); + ca_Resource.setBound2(YesOrNo.yes.name()); + sysResourceMapper.updateByPrimaryKeySelective(ca_Resource); } - for (SysResource caResource : updateList) { - sysResourceMapper.updateByPrimaryKey(caResource); - } - + Set dbValueList = CollectionUtil.getColSetFromObj(dbResList, "resValue"); // 数据库没有的,但已存在的、需添加 List addList = (List) CollectionUtils.select(hasResList, new Predicate() { @Override public boolean evaluate(Object object) { - return !dbResList.contains(object); + SysResource tempobj = (SysResource) object; + return !dbValueList.contains(tempobj.getResValue()); } }); @@ -234,9 +233,10 @@ public class ResManager extends ParentPageBean { caResource.setIcon("icon-user"); caResource.setIsEdit(YesOrNo.yes.name()); caResource.setRemark("系统自动同步"); - // caResource.setCaResource(defaulModel); + caResource.setIsSync(YesOrNo.yes.name()); caResource.setResLevel(2); - sysResourceMapper.updateByPrimaryKeySelective(caResource); + caResource.setBound2(YesOrNo.yes.name()); + sysResourceMapper.insert(caResource); } } catch (Exception e) { ret.setMessage(LK("tip.sys.error.sync") + e.getMessage()); diff --git a/src/main/resources/mybatis/primary/sqlmap/SysResourceMapper.xml b/src/main/resources/mybatis/primary/sqlmap/SysResourceMapper.xml index 00ad1ef4723fe0f403020f4fc49a710fd4fc15b1..1b5e8e6ce09c0afa35549c14eaa00dd91e803d07 100644 --- a/src/main/resources/mybatis/primary/sqlmap/SysResourceMapper.xml +++ b/src/main/resources/mybatis/primary/sqlmap/SysResourceMapper.xml @@ -18,6 +18,7 @@ + @@ -101,8 +102,8 @@ This element is automatically generated by MyBatis Generator, do not modify. --> id, res_code, res_name, res_value, res_type, icon, res_level, is_edit, parent_id, - show_order, remark, bound1, bound2, bound3, bound4, bound5, bound6, bound7, bound8, - bound9 + show_order, remark, is_sync, bound1, bound2, bound3, bound4, bound5, bound6, bound7, + bound8, bound9