From 36f6c79e66205bb7153036e172bf4a1a55a857d5 Mon Sep 17 00:00:00 2001 From: alwaysfrin <39822157+alwaysfrin@users.noreply.github.com> Date: Tue, 30 Oct 2018 19:43:57 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=9B=BD=E5=AE=B6=E5=8C=96=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/estsh/i3plus/pojo/base/enumutil/CommonEnumUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/enumutil/CommonEnumUtil.java b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/enumutil/CommonEnumUtil.java index f1f9201..ca0decd 100644 --- a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/enumutil/CommonEnumUtil.java +++ b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/enumutil/CommonEnumUtil.java @@ -141,7 +141,7 @@ public class CommonEnumUtil { * 处理标识 */ public enum SYS_LOCALE_RESOURCE_TYPE { - COMMON(1, "通用"), + COMMON(1, "通用"),EXCEPTION(2, "异常"), MODULE(10, "模块"), METHOD(11, "功能"), BUTTON(12, "按钮"); private int value; From 44ea78b93a85888e6c65858ec5deb5244ad9c800 Mon Sep 17 00:00:00 2001 From: "wei.peng" Date: Tue, 30 Oct 2018 21:27:30 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E5=88=A0=E9=99=A4=20=E6=B7=BB=E5=8A=A0=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/i3plus-pojo-base/pom.xml | 5 ++ .../i3plus/pojo/base/enumutil/CommonEnumUtil.java | 37 +++++++++++++- .../i3plus/pojo/base/jpa/dao/BaseRepository.java | 24 +++++++++ .../pojo/base/jpa/daoimpl/BaseRepositoryImpl.java | 57 ++++++++++++++++++++-- .../cn/estsh/i3plus/pojo/base/tool/HqlPack.java | 2 - 5 files changed, 117 insertions(+), 8 deletions(-) diff --git a/modules/i3plus-pojo-base/pom.xml b/modules/i3plus-pojo-base/pom.xml index a397cee..c5bfff4 100644 --- a/modules/i3plus-pojo-base/pom.xml +++ b/modules/i3plus-pojo-base/pom.xml @@ -23,6 +23,11 @@ com.fasterxml.jackson.core jackson-databind + + org.apache.commons + commons-lang3 + + diff --git a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/enumutil/CommonEnumUtil.java b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/enumutil/CommonEnumUtil.java index f1f9201..3163fd9 100644 --- a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/enumutil/CommonEnumUtil.java +++ b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/enumutil/CommonEnumUtil.java @@ -388,7 +388,6 @@ public class CommonEnumUtil { } } - /** * 是否有效 */ @@ -422,7 +421,6 @@ public class CommonEnumUtil { } } - /** * 排序方式 */ @@ -455,4 +453,39 @@ public class CommonEnumUtil { return tmp; } } + + /** + * 父节点配置 + */ + public enum PARENT{ + + DEFAULT(-1L,"根节点"); + + private Long value = -1L; + private String description = null; + + public Long getValue() { + return value; + } + + public String getDescription() { + return description; + } + + private PARENT(Long value, String description) { + this.value = value; + this.description = description; + } + + public static String valueOf(int val) { + String tmp = null; + for (int i = 0; i < values().length; i++) { + if (values()[i].value == val) { + tmp = values()[i].description; + } + } + return tmp; + } + } + } diff --git a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/jpa/dao/BaseRepository.java b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/jpa/dao/BaseRepository.java index ed8613c..32b769b 100644 --- a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/jpa/dao/BaseRepository.java +++ b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/jpa/dao/BaseRepository.java @@ -77,6 +77,12 @@ public interface BaseRepository extends JpaReposito public void deleteByProperties(String[] propName, Object[] propValue); /** + * 通过 in 批量删除 + * @param ids 熟悉值数组 + */ + public void deleteByIdIn(Long[] ids); + + /** * 通过多单属性进行单个值更新 * @param conditionName * @param conditionValue @@ -112,6 +118,24 @@ public interface BaseRepository extends JpaReposito */ public int updateByProperties(String[] conditionName, Object[] conditionValue, String[] propertyName, Object[] propertyValue); + /** + * 根据 hqlWhere 批量修改制定字段 + * @param hqlWhere + * @param propertyName 修改的字段名称 + * @param propertyValue 修改后的值 + * @return + */ + public int updateByHqlWhere(String hqlWhere,String propertyName, Object propertyValue); + + /** + * 批量修改数据熟悉 + * @param hqlWhere HQL where 语句 + * @param propertyName 修改的字段名称 + * @param propertyValue 修改后的值 + * @return + */ + public int updateByHqlWhere(String hqlWhere,String[] propertyName, Object[] propertyValue); + public T getById(long id); public List list(); diff --git a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/jpa/daoimpl/BaseRepositoryImpl.java b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/jpa/daoimpl/BaseRepositoryImpl.java index 333cb8b..712bd20 100644 --- a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/jpa/daoimpl/BaseRepositoryImpl.java +++ b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/jpa/daoimpl/BaseRepositoryImpl.java @@ -1,14 +1,15 @@ package cn.estsh.i3plus.pojo.base.jpa.daoimpl; +import cn.estsh.i3plus.pojo.base.common.Pager; import cn.estsh.i3plus.pojo.base.jpa.dao.BaseRepository; import cn.estsh.i3plus.pojo.base.tool.SnowflakeIdMaker; -import cn.estsh.i3plus.pojo.base.common.Pager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.data.jpa.repository.support.SimpleJpaRepository; import javax.persistence.EntityManager; import javax.persistence.Id; import javax.persistence.Query; -import javax.persistence.TypedQuery; import java.io.Serializable; import java.lang.reflect.Field; import java.util.*; @@ -22,6 +23,8 @@ import java.util.*; **/ public class BaseRepositoryImpl extends SimpleJpaRepository implements BaseRepository { + public static final Logger LOGGER = LoggerFactory.getLogger(BaseRepositoryImpl.class); + /** * 持久化上下文 */ @@ -141,6 +144,19 @@ public class BaseRepositoryImpl extends SimpleJpaRep } @Override + public void deleteByIdIn(Long[] ids) { + if(ids != null && ids.length > 0){ + String hql = "delete from " + persistentClass.getName() + " o where o.id in(:ids) "; + Query query = entityManager.createQuery(hql); + query.setParameter("ids", Arrays.asList(ids)); + + query.executeUpdate(); + }else{ + throw new IllegalArgumentException("Method deleteByPropertiesIn argument is illegal! ids:" + ids); + } + } + + @Override public int updateByProperties(String conditionName, Object conditionValue, String propertyName, Object propertyValue) { return updateByProperties(new String[] { conditionName }, new Object[] { conditionValue }, new String[] { propertyName }, new Object[] { propertyValue }); } @@ -161,17 +177,20 @@ public class BaseRepositoryImpl extends SimpleJpaRep && (propertyValue.length > 0) && (propertyName.length == propertyValue.length) && (conditionValue != null) && (conditionValue.length > 0)) { StringBuffer sb = new StringBuffer(); + sb.append("update " + persistentClass.getName() + " o set "); for (int i = 0; i < propertyName.length; i++) { sb.append(propertyName[i] + " = :p_" + propertyName[i] + ","); } sb.deleteCharAt(sb.length() - 1); + sb.append(" where 1=1 "); appendQL(sb, conditionName, conditionValue); Query query = entityManager.createQuery(sb.toString()); for (int i = 0; i < propertyName.length; i++) { query.setParameter("p_" + propertyName[i], propertyValue[i]); } + setParameter(query, conditionName, conditionValue); return query.executeUpdate(); } else { @@ -181,6 +200,36 @@ public class BaseRepositoryImpl extends SimpleJpaRep } @Override + public int updateByHqlWhere(String hqlWhere, String propertyName, Object propertyValue) { + return updateByHqlWhere(hqlWhere, new String[]{propertyName}, new Object[]{propertyValue}); + } + + @Override + public int updateByHqlWhere(String hqlWhere, String[] propertyName, Object[] propertyValue) { + if ((propertyName != null) && (propertyName.length > 0) && (propertyValue != null) + && (propertyValue.length > 0) && (propertyName.length == propertyValue.length)) { + StringBuffer sb = new StringBuffer(); + + sb.append("update " + persistentClass.getName() + " o set "); + for (int i = 0; i < propertyName.length; i++) { + sb.append(propertyName[i] + " = :p_" + propertyName[i] + ","); + } + sb.deleteCharAt(sb.length() - 1); + + sb.append(" where 1=1 "); + sb.append(hqlWhere); + Query query = entityManager.createQuery(sb.toString()); + for (int i = 0; i < propertyName.length; i++) { + query.setParameter("p_" + propertyName[i], propertyValue[i]); + } + + return query.executeUpdate(); + } else { + throw new IllegalArgumentException("Method updateByProperties argument is illegal! propertyName:" + propertyName + ",propertyValue:" + propertyValue); + } + } + + @Override public T getById(long id) { return this.getOne(id); } @@ -292,7 +341,6 @@ public class BaseRepositoryImpl extends SimpleJpaRep return queryObject.getResultList(); } - @Override public T getByProperty(String propertyName, Object value) { String queryString = "from " + persistentClass.getSimpleName() + " as model where model." + propertyName + "= :" + propertyName; @@ -548,7 +596,8 @@ public class BaseRepositoryImpl extends SimpleJpaRep queryString.append(hqlWhere); } - return entityManager.createQuery(queryString.toString(),Integer.class).getSingleResult(); + Long count = entityManager.createQuery(queryString.toString(), Long.class).getSingleResult(); + return count == null ? 0 : count.intValue(); } @Override diff --git a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/tool/HqlPack.java b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/tool/HqlPack.java index f3902c5..6698784 100644 --- a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/tool/HqlPack.java +++ b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/tool/HqlPack.java @@ -1,7 +1,5 @@ package cn.estsh.i3plus.pojo.base.tool; -import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; - import java.text.SimpleDateFormat; import java.util.Date; From ffb0d1fd832e98b461f6c903a18c18105e802f56 Mon Sep 17 00:00:00 2001 From: "wei.peng" Date: Tue, 30 Oct 2018 21:28:41 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E5=B2=97=E4=BD=8DTree?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=20=E9=83=A8=E9=97=A8Tree=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20=E7=BB=84=E7=BB=87Tree=20=E6=B7=BB=E5=8A=A0=20?= =?UTF-8?q?=E5=8A=9F=E8=83=BDTree?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../i3plus/pojo/base/enumutil/CommonEnumUtil.java | 1 - .../i3plus/pojo/platform/bean/Department.java | 6 +++--- .../estsh/i3plus/pojo/platform/bean/Organize.java | 3 +++ .../estsh/i3plus/pojo/platform/bean/Position.java | 4 ++-- .../i3plus/pojo/platform/bean/SessionUser.java | 4 ++-- .../estsh/i3plus/pojo/platform/bean/SysMenu.java | 4 ++++ .../i3plus/pojo/platform/sqlpack/CoreHqlPack.java | 22 ++++++++++++++++++---- 7 files changed, 32 insertions(+), 12 deletions(-) diff --git a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/enumutil/CommonEnumUtil.java b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/enumutil/CommonEnumUtil.java index 3163fd9..b720989 100644 --- a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/enumutil/CommonEnumUtil.java +++ b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/enumutil/CommonEnumUtil.java @@ -285,7 +285,6 @@ public class CommonEnumUtil { } } - /** * 数据状态 * 1 启用 diff --git a/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/bean/Department.java b/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/bean/Department.java index b46579f..e49698b 100644 --- a/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/bean/Department.java +++ b/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/bean/Department.java @@ -55,9 +55,6 @@ public class Department extends BaseBean { } } - @ApiParam(value ="子部门列表") - private transient List childList; - @Column(name="RED_ORGANIZATION_NAME") @ApiParam(value ="所属组织名称" , access ="所属组织名称") private String redOrganizeName; @@ -71,4 +68,7 @@ public class Department extends BaseBean { @ApiParam(value ="排序" , example ="1" , access ="排序") private Integer departmentSort; + @ApiParam(value ="子集列表") + private transient List childList; + } diff --git a/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/bean/Organize.java b/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/bean/Organize.java index 7689cbf..fcb5770 100644 --- a/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/bean/Organize.java +++ b/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/bean/Organize.java @@ -13,6 +13,7 @@ import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; import java.text.DecimalFormat; +import java.util.List; /** * @Description : 组织 @@ -71,4 +72,6 @@ public class Organize extends BaseBean { @ApiParam(value ="组织状态(枚举:1.正常,2.禁用)" , example ="1") private Integer organizeStatus; + @ApiParam(value ="子集列表") + private transient List childList; } diff --git a/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/bean/Position.java b/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/bean/Position.java index 72135d4..683e624 100644 --- a/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/bean/Position.java +++ b/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/bean/Position.java @@ -37,11 +37,11 @@ public class Position extends BaseBean { @Column(name="POSITION_CODE") @ApiParam(value ="岗位代码" , access ="岗位代码") private String positionCode; - + + // 默认值 -1 @Column(name="PARENT_ID") @ApiParam(value ="上级岗位" , example ="-1" , access ="上级岗位") @JsonSerialize(using = ToStringSerializer.class) - // 默认值 -1 private Long parentId; public Long getParentId() { diff --git a/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/bean/SessionUser.java b/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/bean/SessionUser.java index f527e84..5b8fb4a 100644 --- a/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/bean/SessionUser.java +++ b/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/bean/SessionUser.java @@ -29,7 +29,7 @@ public class SessionUser implements Serializable { @ApiParam("用户类型") //CommonEnumUtil.USER_TYPE.xxx.getCode() - private Integer userTypeId; + private String userTypeId; @ApiParam("用户信息") private SysUser user; @@ -61,7 +61,7 @@ public class SessionUser implements Serializable { } - public SessionUser(String userCode, String userName, String siteCode, String languageCode, Integer userTypeId) { + public SessionUser(String userCode, String userName, String siteCode, String languageCode, String userTypeId) { this.userCode = userCode; this.userName = userName; this.languageCode = languageCode; diff --git a/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/bean/SysMenu.java b/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/bean/SysMenu.java index 655171b..b7d1ac0 100644 --- a/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/bean/SysMenu.java +++ b/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/bean/SysMenu.java @@ -13,6 +13,7 @@ import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; import java.text.DecimalFormat; +import java.util.List; /** * @Description : 系统功能 @@ -79,4 +80,7 @@ public class SysMenu extends BaseBean { @ApiParam(value ="功能状态(1.正常,2.禁用)" , example ="1" , access ="功能状态(1.正常,2.禁用)",defaultValue="1") private Integer menuStatus = 1; + @ApiParam(value ="子集列表") + private transient List childList; + } diff --git a/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/sqlpack/CoreHqlPack.java b/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/sqlpack/CoreHqlPack.java index 987f5b0..c916584 100644 --- a/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/sqlpack/CoreHqlPack.java +++ b/modules/i3plus-pojo-platform/src/main/java/cn/estsh/i3plus/pojo/platform/sqlpack/CoreHqlPack.java @@ -60,7 +60,7 @@ public class CoreHqlPack { * @param position * @return */ - public static String packHqlPosition(Position position) { + public static String packHqlDepartment(Position position) { StringBuffer result = new StringBuffer(); // 岗位名称 @@ -73,7 +73,6 @@ public class CoreHqlPack { return result.toString(); } - /** * In 参数封装 * @param columnName @@ -87,13 +86,12 @@ public class CoreHqlPack { return result.toString(); } - /** * 部门复杂查询 * @param department * @return */ - public static String packHqlPosition(Department department) { + public static String packHqlDepartment(Department department) { StringBuffer result = new StringBuffer(); // 部门名称 @@ -107,4 +105,20 @@ public class CoreHqlPack { return result.toString(); } + + /** + * 岗位复杂查询 + * @param position + * @return + */ + public static String packHqlPosition(Position position){ + StringBuffer result = new StringBuffer(); + + // 查询参数封装 + HqlPack.getNumEqualPack(position.getParentId(),"parentId",result); + HqlPack.getStringLikerPack(position.getName(),"name",result); + HqlPack.getStringLikerPack(position.getPositionCode(),"positionCode",result); + + return result.toString(); + } }