|
|
@@ -23,6 +23,7 @@ import com.goafanti.common.bo.Result;
|
|
|
import com.goafanti.common.constant.AFTConstants;
|
|
|
import com.goafanti.common.constant.ErrorConstants;
|
|
|
import com.goafanti.common.controller.CertifyApiController;
|
|
|
+import com.goafanti.common.enums.UserType;
|
|
|
import com.goafanti.common.model.Admin;
|
|
|
import com.goafanti.common.model.AdminLocation;
|
|
|
import com.goafanti.common.utils.PasswordUtil;
|
|
|
@@ -40,15 +41,38 @@ public class AdminSuperviseApiController extends CertifyApiController {
|
|
|
private AdminLocationService adminLocationService;
|
|
|
|
|
|
/**
|
|
|
+ * 审核人员、客户经理、营销经理检索全部客户名称
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/findUser", method = RequestMethod.GET)
|
|
|
+ public Result findUser(String name, String mobile, Integer type){
|
|
|
+ Result res = new Result();
|
|
|
+ if (null == type){
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户类型", "用户类型"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ if (!UserType.PERSONAL.getCode().equals(type) && !UserType.ORGANIZATION.getCode().equals(type)){
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "用户类型", "用户类型"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(name) && StringUtils.isBlank(mobile)){
|
|
|
+ res.getError().add(buildError("", "查询条件不能为空!"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 管理员获取自己所在地区(地区管理员)
|
|
|
*/
|
|
|
@RequestMapping(value = "/adminOwnLocation", method = RequestMethod.GET)
|
|
|
- public Result adminOwnLocation(){
|
|
|
+ public Result adminOwnLocation() {
|
|
|
Result res = new Result();
|
|
|
- if (TokenManager.hasRole(AFTConstants.SUPERADMIN)){
|
|
|
+ /*if (TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
|
|
|
res.setData(AFTConstants.SUPERADMIN);
|
|
|
return res;
|
|
|
- }
|
|
|
+ }*/
|
|
|
res.setData(adminLocationService.findLocation(TokenManager.getAdminId()));
|
|
|
return res;
|
|
|
}
|
|
|
@@ -232,6 +256,12 @@ public class AdminSuperviseApiController extends CertifyApiController {
|
|
|
JSONArray locations = jo.getJSONArray("locations");
|
|
|
List<AdminLocation> adminLocationList = new ArrayList<>();
|
|
|
AdminLocation al = null;
|
|
|
+ Boolean areaAdminFlag = false;
|
|
|
+ List<Integer> locationList = null;
|
|
|
+ if (TokenManager.hasRole(AFTConstants.AREAADMIN)) {
|
|
|
+ locationList = new ArrayList<>();
|
|
|
+ areaAdminFlag = true;
|
|
|
+ }
|
|
|
for (int i = 0; i < locations.size(); i++) {
|
|
|
AdminLocationBo alb = locations.getJSONObject(i).toJavaObject(AdminLocationBo.class);
|
|
|
Integer province = alb.getProvince();
|
|
|
@@ -245,7 +275,9 @@ public class AdminSuperviseApiController extends CertifyApiController {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "所在省份"));
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+ if (areaAdminFlag) {
|
|
|
+ locationList.add(province);
|
|
|
+ }
|
|
|
if (!StringUtils.isBlank(city)) {
|
|
|
String[] arr = city.trim().split(",|,");
|
|
|
if (null != arr && arr.length > 0) {
|
|
|
@@ -256,12 +288,22 @@ public class AdminSuperviseApiController extends CertifyApiController {
|
|
|
return res;
|
|
|
}
|
|
|
adminLocationList.add(disposeAdminLocation(al, ad, province, c));
|
|
|
+ if (areaAdminFlag){
|
|
|
+ locationList.add(c);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
adminLocationList.add(disposeAdminLocation(al, ad, province, null));
|
|
|
}
|
|
|
}
|
|
|
+ if (areaAdminFlag){
|
|
|
+ List<Integer> albList = disposeAdminLocationBo();
|
|
|
+ if (!albList.containsAll(locationList)){
|
|
|
+ res.getError().add(buildError("","所选所在地区域不在负责区域,无法添加或修改"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ }
|
|
|
res.setData(adminLocationList);
|
|
|
return res;
|
|
|
}
|
|
|
@@ -276,4 +318,26 @@ public class AdminSuperviseApiController extends CertifyApiController {
|
|
|
}
|
|
|
return al;
|
|
|
}
|
|
|
+
|
|
|
+ private List<Integer> disposeAdminLocationBo(){
|
|
|
+ List<AdminLocationBo> alb = adminLocationService.findLocation(TokenManager.getAdminId());
|
|
|
+ List<Integer> albList = null;
|
|
|
+ if (!alb.isEmpty()){
|
|
|
+ Integer albProvince = null;
|
|
|
+ albList = new ArrayList<>();
|
|
|
+ for (AdminLocationBo bo : alb){
|
|
|
+ albProvince = bo.getProvince();
|
|
|
+ albList.add(albProvince);
|
|
|
+ if (!StringUtils.isBlank(bo.getCity())){
|
|
|
+ String[] albArr = bo.getCity().trim().split(",|,");
|
|
|
+ if (null != albArr && albArr.length > 0){
|
|
|
+ for (String ss : albArr){
|
|
|
+ albList.add(Integer.valueOf(ss));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return albList;
|
|
|
+ }
|
|
|
}
|