From 26c7992abd62b73840ff073b450d5672f6ade712 Mon Sep 17 00:00:00 2001 From: "youHong.ai" <774495953@qq.com> Date: Mon, 5 Dec 2022 15:09:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9F=A5=E8=AF=A2=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E6=98=A0=E5=B0=84boolean=E7=B1=BB=E5=9E=8B=EF=BC=8C?= =?UTF-8?q?=E4=BF=9D=E6=97=B6=E6=8D=B7=E4=BA=BA=E5=91=98=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E6=9E=B6=E6=9E=84=E5=9B=BE=E9=BB=98=E8=AE=A4=E5=85=A8=E9=83=A8?= =?UTF-8?q?=E5=B1=95=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/recordset/BooleanTypeHandler.java | 49 ++++++++++++++++++- .../orgchart/mapper/OrgChartMapper.java | 33 +++++++++++-- .../orgchart/pojo/ShowPointOrAll.java | 34 +++++++++++++ .../orgchart/service/OrgChartService.java | 42 +++++++++++++--- 4 files changed, 145 insertions(+), 13 deletions(-) create mode 100644 src/main/java/com/api/youhong/ai/pcn/organization/orgchart/pojo/ShowPointOrAll.java diff --git a/src/main/java/aiyh/utils/recordset/BooleanTypeHandler.java b/src/main/java/aiyh/utils/recordset/BooleanTypeHandler.java index dfc688a..5c018f3 100644 --- a/src/main/java/aiyh/utils/recordset/BooleanTypeHandler.java +++ b/src/main/java/aiyh/utils/recordset/BooleanTypeHandler.java @@ -1,5 +1,10 @@ package aiyh.utils.recordset; +import aiyh.utils.annotation.BooleanConverter; +import aiyh.utils.annotation.BooleanConverterEnum; +import aiyh.utils.excention.CustomerException; +import com.google.common.base.Strings; +import org.jetbrains.annotations.NotNull; import weaver.conn.RecordSet; import java.lang.reflect.Field; @@ -13,11 +18,51 @@ import java.lang.reflect.Field; public class BooleanTypeHandler implements TypeHandler{ @Override public Object getValue(RecordSet rs, String fieldName, Field declaredField) { - return rs.getBoolean(fieldName); + return getBoolean(declaredField, rs.getString(fieldName)); } @Override public Object getValue(RecordSet rs, int index,Field declaredField) { - return rs.getBoolean(index); + return getBoolean(declaredField, rs.getString(index)); + } + + @NotNull + private Object getBoolean(Field declaredField, String fieldValue) { + try { + BooleanConverter annotation = declaredField.getAnnotation(BooleanConverter.class); + BooleanConverterEnum value = annotation.value(); + String trueStr = annotation.trueStr(); + String falseStr = annotation.falseStr(); + String trueInteger = annotation.trueInteger(); + String falseInteger = annotation.falseInteger(); + boolean defaultValue = annotation.defaultValue(); + String booleanVal = null; + try { + booleanVal = fieldValue; + } catch (Exception ignored) { + } + boolean hasValueTrue = annotation.hasValueTrue(); + if (value == BooleanConverterEnum.STRING) { + if (booleanVal == null || booleanVal.equals(falseStr)) { + return false; + } else if ((hasValueTrue && !Strings.isNullOrEmpty(booleanVal)) || booleanVal.equals(trueStr)) { + return true; + } else { + return defaultValue; + } + } else if (value == BooleanConverterEnum.INTEGER) { + if (booleanVal == null || booleanVal.equals(falseInteger)) { + return false; + } else if ((hasValueTrue && !Strings.isNullOrEmpty(booleanVal)) || booleanVal.equals(trueInteger)) { + return true; + } else { + return defaultValue; + } + }else { + return defaultValue; + } + } catch (Exception e) { + throw new CustomerException("不支持的类型转换!"); + } } } diff --git a/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/mapper/OrgChartMapper.java b/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/mapper/OrgChartMapper.java index ecd7da2..f5f9551 100644 --- a/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/mapper/OrgChartMapper.java +++ b/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/mapper/OrgChartMapper.java @@ -4,6 +4,7 @@ import aiyh.utils.annotation.recordset.ParamMapper; import aiyh.utils.annotation.recordset.Select; import aiyh.utils.annotation.recordset.SqlMapper; import com.api.youhong.ai.pcn.organization.orgchart.pojo.HrmResource; +import com.api.youhong.ai.pcn.organization.orgchart.pojo.ShowPointOrAll; import java.util.List; @@ -19,9 +20,19 @@ import java.util.List; public interface OrgChartMapper { + /** + *
create: 2022-12-05 10:51
+ * + * @author youHong.ai + */ + +@Getter +@Setter +@ToString +public class ShowPointOrAll { + /** id */ + private Integer id; + + /** 多人力资源的人员id */ + private String resources; + + /** 是否全部展开 */ + @BooleanConverter(BooleanConverterEnum.INTEGER) + private boolean showAll; + + /** 是否显示不同的人员标识 */ + @BooleanConverter(BooleanConverterEnum.INTEGER) + private boolean showType; +} diff --git a/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/service/OrgChartService.java b/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/service/OrgChartService.java index c122d01..e2745d6 100644 --- a/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/service/OrgChartService.java +++ b/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/service/OrgChartService.java @@ -6,6 +6,7 @@ import com.api.youhong.ai.pcn.organization.orgchart.dto.HrmResourceDto; import com.api.youhong.ai.pcn.organization.orgchart.mapper.OrgChartMapper; import com.api.youhong.ai.pcn.organization.orgchart.mapstruct.OrgChartMapStruct; import com.api.youhong.ai.pcn.organization.orgchart.pojo.HrmResource; +import com.api.youhong.ai.pcn.organization.orgchart.pojo.ShowPointOrAll; import com.api.youhong.ai.pcn.organization.orgchart.vo.OrgChartNodeVo; import ebu7common.youhong.ai.bean.Builder; import weaver.hrm.User; @@ -41,7 +42,9 @@ public class OrgChartService { int userId = logInUser.getUID(); String typeOfEmploymentField = Util.getCusConfigValue("typeOfEmploymentField"); Assert.notBlank(typeOfEmploymentField, "config [typeOfEmploymentField] is null or blank!"); - List