Browse Source

科德系统渠道模块开发

anderx 3 years ago
parent
commit
a5fc47e535

+ 13 - 0
src/main/java/com/goafanti/common/utils/Param.java

@@ -0,0 +1,13 @@
+package com.goafanti.common.utils;
+
+import javax.validation.Payload;
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+public @interface Param {
+
+    String name() default "";
+
+
+}

+ 27 - 0
src/main/java/com/goafanti/common/utils/ParamUtils.java

@@ -0,0 +1,27 @@
+package com.goafanti.common.utils;
+
+import java.lang.reflect.Field;
+
+public class ParamUtils {
+
+
+    /**
+     * 根据@Param的字段名称获取name的设置值
+     * @param t 输入参数类型
+     * @param param 字段名称
+     * @param <T>
+     * @return
+     */
+    public static  <T> String  getParamName(T t,String param){
+        Class clazz=t.getClass();
+        for (Field f : clazz.getDeclaredFields()) {
+            System.out.println(f.getName());
+            if (f.getName().equals(param)){
+                Param filedAnno = f.getAnnotation(Param.class);
+//                System.out.println(filedAnno.name());
+                return filedAnno.name();
+            }
+        }
+        return "";
+    }
+}

+ 10 - 0
src/main/java/com/goafanti/customer/bo/InputAddCustomer.java

@@ -1,28 +1,36 @@
 package com.goafanti.customer.bo;
 
 import com.goafanti.common.constant.ErrorConstants;
+import com.goafanti.common.utils.Param;
 
 import javax.validation.constraints.NotNull;
 
 public class InputAddCustomer {
 
     @NotNull(message = "{"+ ErrorConstants.PARAM_EMPTY_ERROR+"}")
+    @Param(name = "名称")
     private String name;
     @NotNull(message = "{"+ ErrorConstants.PARAM_EMPTY_ERROR+"}")
+    @Param(name = "联系人")
     private String contacts;
     @NotNull(message = "{"+ ErrorConstants.PARAM_EMPTY_ERROR+"}")
+    @Param(name = "联系人电话")
     private String contactMobile;
 
     private Integer type;
     @NotNull(message = "{"+ ErrorConstants.PARAM_EMPTY_ERROR+"}")
+    @Param(name = "省")
     private Integer province;
     @NotNull(message = "{"+ ErrorConstants.PARAM_EMPTY_ERROR+"}")
+    @Param(name = "市")
     private Integer city;
     @NotNull(message = "{"+ ErrorConstants.PARAM_EMPTY_ERROR+"}")
+    @Param(name = "区")
     private Integer area;
     private Integer source;
     private String societyTag;
     @NotNull(message = "{"+ ErrorConstants.PARAM_EMPTY_ERROR+"}")
+    @Param(name = "职位")
     private String position;
     private Integer industry;
     private String businessScope;
@@ -33,6 +41,7 @@ public class InputAddCustomer {
      * 简介
      */
     @NotNull(message = "{"+ ErrorConstants.PARAM_EMPTY_ERROR+"}")
+    @Param(name = "简介")
     private String introduction;
 
     /**
@@ -44,6 +53,7 @@ public class InputAddCustomer {
      *  渠道类别:1=政府部门,2=民主党派3=园区,4=民间组织,5=其他战略合作单位
      */
     @NotNull(message = "{"+ ErrorConstants.PARAM_EMPTY_ERROR+"}")
+    @Param(name = "渠道类别")
     private Integer   channelType;
 
 

+ 8 - 6
src/main/java/com/goafanti/customer/controller/AdminCustomerApiController.java

@@ -2,6 +2,7 @@ package com.goafanti.customer.controller;
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.text.DateFormat;
 import java.text.ParseException;
@@ -18,6 +19,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import com.goafanti.common.enums.AchievementFields;
+import com.goafanti.common.utils.*;
 import com.goafanti.customer.bo.*;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Value;
@@ -40,11 +42,6 @@ import com.goafanti.common.error.BusinessException;
 import com.goafanti.common.model.Attachment;
 import com.goafanti.common.model.OrganizationContactBook;
 import com.goafanti.common.model.User;
-import com.goafanti.common.utils.BeanUtilsExt;
-import com.goafanti.common.utils.DateUtils;
-import com.goafanti.common.utils.ExcelUtils;
-import com.goafanti.common.utils.SHA256Util;
-import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.customer.service.CustomerService;
 import com.goafanti.customer.service.impl.AdminOrgAnnualReportServiceImpl;
@@ -346,7 +343,11 @@ public class AdminCustomerApiController extends BaseApiController{
 		Result res = new Result();
 		if (bindingResult.hasErrors()) {
 			res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
-					InputChannelState.getDesc(bindingResult.getFieldError().getField())));
+					ParamUtils.getParamName(in,bindingResult.getFieldError().getField())));
+			return res;
+		}
+		if (customerService.checkUserName(in.getName())){
+			res.getError().add(buildError("客户名称已存在"));
 			return res;
 		}
 		in.setType(1);
@@ -360,6 +361,7 @@ public class AdminCustomerApiController extends BaseApiController{
 
 
 
+
 	/** 单位客户详情信息 **/
 	@RequestMapping(value = "/findOrganizationCustomerDetail", method = RequestMethod.GET)
 	public Result findOrganizationCustomerDetail(String uid){

+ 5 - 5
src/main/resources/props/config_local.properties

@@ -1,12 +1,12 @@
 dev.name=local
 jdbc.driverClassName=com.mysql.jdbc.Driver
-jdbc.url=jdbc\:mysql://localhost:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+#jdbc.url=jdbc\:mysql://localhost:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 #jdbc.url=jdbc\:mysql://localhost:3306/aft20220318?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
-jdbc.username=root
-jdbc.password=123456
-#jdbc.url=jdbc:mysql://101.37.32.31:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 #jdbc.username=root
-#jdbc.password=aftdev
+#jdbc.password=123456
+jdbc.url=jdbc:mysql://101.37.32.31:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+jdbc.username=root
+jdbc.password=aftdev
 jdbc.validationQuery=SELECT 'x'
 jdbc.initialSize=3
 jdbc.maxActive=20