Quellcode durchsuchen

增加管理授权,修复bug

liliang4869 vor 7 Jahren
Ursprung
Commit
8dfc99d697

+ 1 - 1
src/main/java/com/goafanti/admin/controller/AdminApiController.java

@@ -132,7 +132,7 @@ public class AdminApiController extends CertifyApiController {
 			return res;
 		}
 
-		Admin a = adminService.selectByMobile(admin.getMobile().trim());
+		Admin a = adminService.selectByMobile(admin.getMobile().trim(),null);
 		if (!TokenManager.getAdminId().equals(a.getId())) {
 			res.getError().add(buildError(ErrorConstants.USER_ALREADY_EXIST, "当前用户已注册!"));
 			return res;

+ 343 - 343
src/main/java/com/goafanti/admin/controller/AdminSuperviseApiController.java

@@ -1,343 +1,343 @@
-package com.goafanti.admin.controller;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-import java.util.UUID;
-
-import javax.annotation.Resource;
-
-import org.springframework.beans.BeanUtils;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.goafanti.admin.bo.AdminLocationBo;
-import com.goafanti.admin.service.AdminLocationService;
-import com.goafanti.admin.service.AdminService;
-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;
-import com.goafanti.common.utils.StringUtils;
-import com.goafanti.core.shiro.token.TokenManager;
-import com.goafanti.user.service.UserService;
-
-@Controller
-@RequestMapping(value = "/api/admin/supervise")
-public class AdminSuperviseApiController extends CertifyApiController {
-	@Resource
-	private AdminService			adminService;
-	@Resource(name = "passwordUtil")
-	private PasswordUtil			passwordUtil;
-	@Resource
-	private AdminLocationService	adminLocationService;
-	@Resource
-	private UserService				userService;
-	/**
-	 * 审核人员、客户经理、营销经理检索全部客户名称
-	 */
-	@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;
-		}
-		
-		if (UserType.PERSONAL.getCode().equals(type)){
-			res.setData(userService.findUserNameByNameAndMobile(name, mobile));
-		} else {
-			res.setData(userService.findOrgNameByNameAndMobile(name, mobile));
-		}
-		return res;
-	}
-
-	/**
-	 * 管理员获取自己所在地区(地区管理员)
-	 */
-	@RequestMapping(value = "/adminOwnLocation", method = RequestMethod.GET)
-	public Result adminOwnLocation() {
-		Result res = new Result();
-		if (TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
-			res.setData(AFTConstants.SUPERADMIN);
-			return res;
-		}
-		res.setData(adminLocationService.findLocation(TokenManager.getAdminId()));
-		return res;
-	}
-
-	/**
-	 * 管理员详情获取地区
-	 */
-	@RequestMapping(value = "/adminDetailLocation", method = RequestMethod.GET)
-	public Result adminDetailLocation(String id) {
-		Result res = new Result();
-		if (StringUtils.isBlank(id)) {
-			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户ID", "用户ID"));
-			return res;
-		}
-		res.setData(adminLocationService.findLocation(id));
-		return res;
-	}
-
-	/**
-	 * 管理员下拉列表
-	 */
-	@RequestMapping(value = "/adminSelectList", method = RequestMethod.GET)
-	public Result adminSelectList() {
-		Result res = new Result();
-		res.setData(adminService.listAdminSelect());
-		return res;
-	}
-
-	/**
-	 * 管理员列表
-	 */
-	@RequestMapping(value = "/adminList", method = RequestMethod.GET)
-	public Result adminList(Integer province, Integer number, String mobile, String name, String pageNo,
-			String pageSize) {
-		Result res = new Result();
-		Integer pNo = 1;
-		Integer pSize = 10;
-		if (StringUtils.isNumeric(pageSize)) {
-			pSize = Integer.parseInt(pageSize);
-		}
-		if (StringUtils.isNumeric(pageNo)) {
-			pNo = Integer.parseInt(pageNo);
-		}
-		res.setData(adminService.listAdmin(province, number, mobile, name, pNo, pSize));
-		return res;
-	}
-
-	/**
-	 * 新增管理员
-	 */
-	@RequestMapping(value = "/insertAdmin", method = RequestMethod.POST)
-	public Result insertAdmin(String data) {
-		Result res = new Result();
-		JSONObject jo = (JSONObject) JSON.parse(data);
-		if (null != jo) {
-			Admin admin = jo.toJavaObject(Admin.class);
-
-			if (StringUtils.isBlank(admin.getMobile())) {
-				res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "登录帐号为空", "登录帐号"));
-				return res;
-			}
-
-			if (StringUtils.isBlank(admin.getName())) {
-				res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户名为空", "用户名"));
-				return res;
-			}
-
-			Admin a = adminService.selectByMobile(admin.getMobile().trim());
-			if (null != a) {
-				res.getError().add(buildError(ErrorConstants.USER_ALREADY_EXIST, "当前用户已注册!"));
-				return res;
-			}
-
-			Admin ad = new Admin();
-			BeanUtils.copyProperties(admin, ad);
-			ad.setId(UUID.randomUUID().toString());
-			Calendar now = Calendar.getInstance();
-			now.set(Calendar.MILLISECOND, 0);
-
-			ad.setCreateTime(now.getTime());
-			if (StringUtils.isBlank(ad.getPassword())) {
-				ad.setPassword(AFTConstants.INITIALPASSWORD);
-			}
-			ad.setPassword(passwordUtil.getEncryptPwd(ad));
-			res.setData(adminService.insertNewAdmin(ad));
-		}
-
-		return res;
-	}
-
-	/**
-	 * 修改管理员信息
-	 */
-	@RequestMapping(value = "/updateAdmin", method = RequestMethod.POST)
-	public Result updateAdmin(@RequestParam(value = "roles[]", required = false) String[] roleIds, String data) {
-		Result res = new Result();
-		JSONObject jo = (JSONObject) JSON.parse(data);
-		if (null != jo) {
-			Admin admin = jo.toJavaObject(Admin.class);
-
-			if (null == admin.getId()) {
-				res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "用户id"));
-				return res;
-			}
-
-			if (null == admin.getMobile()) {
-				res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "登录帐号为空", "登录帐号"));
-				return res;
-			}
-
-			if (null == admin.getName()) {
-				res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户名为空", "用户名"));
-				return res;
-			}
-
-			Admin aa = adminService.selectByMobile(admin.getMobile().trim());
-			if (null != aa && !admin.getId().equals(aa.getId())) {
-				res.getError().add(buildError(ErrorConstants.USER_ALREADY_EXIST, "当前用户已注册!"));
-				return res;
-			}
-
-			Admin a = adminService.selectByPrimaryKey(admin.getId());
-			if (null == a) {	
-				res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "用户id"));				
-				return res;
-				
-			}
-			Admin ad = new Admin();
-			BeanUtils.copyProperties(admin, ad);
-			res = disposeAdminLocationList(res, jo, ad);
-			if (!res.getError().isEmpty()) {
-				return res;
-			}
-		
-			List<String> roles = new ArrayList<String>();
-			if (roleIds != null && roleIds.length > 0) {
-				for (String role : roleIds) {
-					roles.add(role);
-				}
-			}
-			res.setData(adminService.updateByPrimaryKeySelective(ad, roles));
-		}
-		return res;
-	}
-
-	/**
-	 * 重置管理员密码
-	 */
-	@RequestMapping(value = "/resetPwd", method = RequestMethod.POST)
-	public Result resetPwd(String id) {
-		Result res = new Result();
-		if (StringUtils.isBlank(id)) {
-			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "用户id"));
-			return res;
-		}
-
-		Admin admin = adminService.selectByPrimaryKey(id);
-		if (null == admin) {
-			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "用户id"));
-			return res;
-		}
-		Admin a = new Admin();
-		a.setId(admin.getId());
-		a.setCreateTime(admin.getCreateTime());
-		a.setPassword(AFTConstants.INITIALPASSWORD);
-		a.setPassword(passwordUtil.getEncryptPwd(a));
-		res.setData(adminService.updateByPrimaryKey(a));
-		return res;
-	}
-
-	private Result disposeAdminLocationList(Result res, JSONObject jo, Admin ad) {
-		JSONArray locations = jo.getJSONArray("locations");
-		if (null == locations || locations.size()<1){
-			return res;
-		}
-		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();
-			String city = alb.getCity();
-			if (null == province) {
-				res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "省份为空", "所在省份"));
-				return res;
-			}
-
-			if (province.intValue() > AFTConstants.PROVINCEMAXNUM) {
-				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) {
-					for (String s : arr) {
-						Integer c = Integer.valueOf(s);
-						if (c.intValue() > AFTConstants.CITYMAXNUM) {
-							res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "所在市"));
-							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;
-	}
-
-	private AdminLocation disposeAdminLocation(AdminLocation al, Admin ad, Integer province, Integer c) {
-		al = new AdminLocation();
-		al.setId(UUID.randomUUID().toString());
-		al.setAdminId(ad.getId());
-		al.setProvince(province);
-		if (null != c) {
-			al.setCity(c);
-		}
-		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;
-	}
-}
+package com.goafanti.admin.controller;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+import java.util.UUID;
+
+import javax.annotation.Resource;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.goafanti.admin.bo.AdminLocationBo;
+import com.goafanti.admin.service.AdminLocationService;
+import com.goafanti.admin.service.AdminService;
+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;
+import com.goafanti.common.utils.StringUtils;
+import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.user.service.UserService;
+
+@Controller
+@RequestMapping(value = "/api/admin/supervise")
+public class AdminSuperviseApiController extends CertifyApiController {
+	@Resource
+	private AdminService			adminService;
+	@Resource(name = "passwordUtil")
+	private PasswordUtil			passwordUtil;
+	@Resource
+	private AdminLocationService	adminLocationService;
+	@Resource
+	private UserService				userService;
+	/**
+	 * 审核人员、客户经理、营销经理检索全部客户名称
+	 */
+	@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;
+		}
+		
+		if (UserType.PERSONAL.getCode().equals(type)){
+			res.setData(userService.findUserNameByNameAndMobile(name, mobile));
+		} else {
+			res.setData(userService.findOrgNameByNameAndMobile(name, mobile));
+		}
+		return res;
+	}
+
+	/**
+	 * 管理员获取自己所在地区(地区管理员)
+	 */
+	@RequestMapping(value = "/adminOwnLocation", method = RequestMethod.GET)
+	public Result adminOwnLocation() {
+		Result res = new Result();
+		if (TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
+			res.setData(AFTConstants.SUPERADMIN);
+			return res;
+		}
+		res.setData(adminLocationService.findLocation(TokenManager.getAdminId()));
+		return res;
+	}
+
+	/**
+	 * 管理员详情获取地区
+	 */
+	@RequestMapping(value = "/adminDetailLocation", method = RequestMethod.GET)
+	public Result adminDetailLocation(String id) {
+		Result res = new Result();
+		if (StringUtils.isBlank(id)) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户ID", "用户ID"));
+			return res;
+		}
+		res.setData(adminLocationService.findLocation(id));
+		return res;
+	}
+
+	/**
+	 * 管理员下拉列表
+	 */
+	@RequestMapping(value = "/adminSelectList", method = RequestMethod.GET)
+	public Result adminSelectList() {
+		Result res = new Result();
+		res.setData(adminService.listAdminSelect());
+		return res;
+	}
+
+	/**
+	 * 管理员列表
+	 */
+	@RequestMapping(value = "/adminList", method = RequestMethod.GET)
+	public Result adminList(Integer province, Integer number, String mobile, String name, String pageNo,
+			String pageSize) {
+		Result res = new Result();
+		Integer pNo = 1;
+		Integer pSize = 10;
+		if (StringUtils.isNumeric(pageSize)) {
+			pSize = Integer.parseInt(pageSize);
+		}
+		if (StringUtils.isNumeric(pageNo)) {
+			pNo = Integer.parseInt(pageNo);
+		}
+		res.setData(adminService.listAdmin(province, number, mobile, name, pNo, pSize));
+		return res;
+	}
+
+	/**
+	 * 新增管理员
+	 */
+	@RequestMapping(value = "/insertAdmin", method = RequestMethod.POST)
+	public Result insertAdmin(String data) {
+		Result res = new Result();
+		JSONObject jo = (JSONObject) JSON.parse(data);
+		if (null != jo) {
+			Admin admin = jo.toJavaObject(Admin.class);
+
+			if (StringUtils.isBlank(admin.getMobile())) {
+				res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "登录帐号为空", "登录帐号"));
+				return res;
+			}
+
+			if (StringUtils.isBlank(admin.getName())) {
+				res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户名为空", "用户名"));
+				return res;
+			}
+
+			Admin a = adminService.selectByMobile(admin.getMobile().trim(),null);
+			if (null != a) {
+				res.getError().add(buildError(ErrorConstants.USER_ALREADY_EXIST, "当前用户已注册!"));
+				return res;
+			}
+
+			Admin ad = new Admin();
+			BeanUtils.copyProperties(admin, ad);
+			ad.setId(UUID.randomUUID().toString());
+			Calendar now = Calendar.getInstance();
+			now.set(Calendar.MILLISECOND, 0);
+
+			ad.setCreateTime(now.getTime());
+			if (StringUtils.isBlank(ad.getPassword())) {
+				ad.setPassword(AFTConstants.INITIALPASSWORD);
+			}
+			ad.setPassword(passwordUtil.getEncryptPwd(ad));
+			res.setData(adminService.insertNewAdmin(ad));
+		}
+
+		return res;
+	}
+
+	/**
+	 * 修改管理员信息
+	 */
+	@RequestMapping(value = "/updateAdmin", method = RequestMethod.POST)
+	public Result updateAdmin(@RequestParam(value = "roles[]", required = false) String[] roleIds, String data) {
+		Result res = new Result();
+		JSONObject jo = (JSONObject) JSON.parse(data);
+		if (null != jo) {
+			Admin admin = jo.toJavaObject(Admin.class);
+
+			if (null == admin.getId()) {
+				res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "用户id"));
+				return res;
+			}
+
+			if (null == admin.getMobile()) {
+				res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "登录帐号为空", "登录帐号"));
+				return res;
+			}
+
+			if (null == admin.getName()) {
+				res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户名为空", "用户名"));
+				return res;
+			}
+
+			Admin aa = adminService.selectByMobile(admin.getMobile().trim(),null);
+			if (null != aa && !admin.getId().equals(aa.getId())) {
+				res.getError().add(buildError(ErrorConstants.USER_ALREADY_EXIST, "当前用户已注册!"));
+				return res;
+			}
+
+			Admin a = adminService.selectByPrimaryKey(admin.getId());
+			if (null == a) {	
+				res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "用户id"));				
+				return res;
+				
+			}
+			Admin ad = new Admin();
+			BeanUtils.copyProperties(admin, ad);
+			res = disposeAdminLocationList(res, jo, ad);
+			if (!res.getError().isEmpty()) {
+				return res;
+			}
+		
+			List<String> roles = new ArrayList<String>();
+			if (roleIds != null && roleIds.length > 0) {
+				for (String role : roleIds) {
+					roles.add(role);
+				}
+			}
+			res.setData(adminService.updateByPrimaryKeySelective(ad, roles));
+		}
+		return res;
+	}
+
+	/**
+	 * 重置管理员密码
+	 */
+	@RequestMapping(value = "/resetPwd", method = RequestMethod.POST)
+	public Result resetPwd(String id) {
+		Result res = new Result();
+		if (StringUtils.isBlank(id)) {
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "用户id"));
+			return res;
+		}
+
+		Admin admin = adminService.selectByPrimaryKey(id);
+		if (null == admin) {
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "用户id"));
+			return res;
+		}
+		Admin a = new Admin();
+		a.setId(admin.getId());
+		a.setCreateTime(admin.getCreateTime());
+		a.setPassword(AFTConstants.INITIALPASSWORD);
+		a.setPassword(passwordUtil.getEncryptPwd(a));
+		res.setData(adminService.updateByPrimaryKey(a));
+		return res;
+	}
+
+	private Result disposeAdminLocationList(Result res, JSONObject jo, Admin ad) {
+		JSONArray locations = jo.getJSONArray("locations");
+		if (null == locations || locations.size()<1){
+			return res;
+		}
+		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();
+			String city = alb.getCity();
+			if (null == province) {
+				res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "省份为空", "所在省份"));
+				return res;
+			}
+
+			if (province.intValue() > AFTConstants.PROVINCEMAXNUM) {
+				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) {
+					for (String s : arr) {
+						Integer c = Integer.valueOf(s);
+						if (c.intValue() > AFTConstants.CITYMAXNUM) {
+							res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "所在市"));
+							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;
+	}
+
+	private AdminLocation disposeAdminLocation(AdminLocation al, Admin ad, Integer province, Integer c) {
+		al = new AdminLocation();
+		al.setId(UUID.randomUUID().toString());
+		al.setAdminId(ad.getId());
+		al.setProvince(province);
+		if (null != c) {
+			al.setCity(c);
+		}
+		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;
+	}
+}

+ 67 - 67
src/main/java/com/goafanti/admin/service/AdminService.java

@@ -1,67 +1,67 @@
-package com.goafanti.admin.service;
-
-import java.util.List;
-import java.util.Map;
-
-import com.goafanti.admin.bo.AdminDetail;
-import com.goafanti.admin.bo.AdminListBo;
-import com.goafanti.common.model.Admin;
-import com.goafanti.core.mybatis.page.Pagination;
-
-public interface AdminService {
-
-	List<Admin> selectAllAdmin();
-
-	Admin selectByMobile(String username);
-
-	Admin selectByPrimaryKey(String key);
-
-	Pagination<AdminListBo> listAdmin(Integer province, Integer number, String mobile, String name, Integer pNo,
-			Integer pSize);
-
-	int insert(Admin ad);
-
-	int updateByPrimaryKeySelective(Admin ad, List<String> roleIds);
-
-	int updateByPrimaryKey(Admin a);
-
-	AdminDetail selectAdminDetail(String id);
-
-	List<Admin> selectCognizanceConsultant();
-
-	List<Admin> selectPatentAuthor();
-
-	List<Admin> selectPatentPrincipal();
-
-	List<Admin> selectCopyrightConsultant();
-
-	List<Admin> selectCognizancePrincipal();
-
-	List<Admin> selectCopyrightPrincipal();
-
-	List<Admin> selectTechprojectConsultant();
-
-	List<Admin> selectTechprojectPrincipal();
-
-	List<String> selectRoleByPrimaryKey(String aid);
-
-	List<String> listAuditor();
-
-	Map<String, String> selectAccoutManager();
-
-	Map<String, String> selectTechnician();
-
-	Map<String, String> selectSalesman();
-
-	Map<String, String> selectContractManager();
-
-	Map<String, String> selectTechBroder();
-
-	int insertNewAdmin(Admin ad);
-
-	Map<String, String> listAdminSelect();
-
-	List<Admin> listAdminByName(String name);
-
-	List<AdminListBo> selectDepartmentStaff(String departmentId,String name);
-}
+package com.goafanti.admin.service;
+
+import java.util.List;
+import java.util.Map;
+
+import com.goafanti.admin.bo.AdminDetail;
+import com.goafanti.admin.bo.AdminListBo;
+import com.goafanti.common.model.Admin;
+import com.goafanti.core.mybatis.page.Pagination;
+
+public interface AdminService {
+
+	List<Admin> selectAllAdmin();
+
+	Admin selectByMobile(String username,String roleName);
+
+	Admin selectByPrimaryKey(String key);
+
+	Pagination<AdminListBo> listAdmin(Integer province, Integer number, String mobile, String name, Integer pNo,
+			Integer pSize);
+
+	int insert(Admin ad);
+
+	int updateByPrimaryKeySelective(Admin ad, List<String> roleIds);
+
+	int updateByPrimaryKey(Admin a);
+
+	AdminDetail selectAdminDetail(String id);
+
+	List<Admin> selectCognizanceConsultant();
+
+	List<Admin> selectPatentAuthor();
+
+	List<Admin> selectPatentPrincipal();
+
+	List<Admin> selectCopyrightConsultant();
+
+	List<Admin> selectCognizancePrincipal();
+
+	List<Admin> selectCopyrightPrincipal();
+
+	List<Admin> selectTechprojectConsultant();
+
+	List<Admin> selectTechprojectPrincipal();
+
+	List<String> selectRoleByPrimaryKey(String aid);
+
+	List<String> listAuditor();
+
+	Map<String, String> selectAccoutManager();
+
+	Map<String, String> selectTechnician();
+
+	Map<String, String> selectSalesman();
+
+	Map<String, String> selectContractManager();
+
+	Map<String, String> selectTechBroder();
+
+	int insertNewAdmin(Admin ad);
+
+	Map<String, String> listAdminSelect();
+
+	List<Admin> listAdminByName(String name);
+
+	List<AdminListBo> selectDepartmentStaff(String departmentId,String name);
+}

+ 2 - 2
src/main/java/com/goafanti/admin/service/impl/AdminServiceImpl.java

@@ -36,8 +36,8 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 	}
 	
 	@Override
-	public Admin selectByMobile(String mobile) {
-		return adminMapper.selectByMobile(mobile);
+	public Admin selectByMobile(String mobile,String roleName) {
+		return adminMapper.selectByMobile(mobile,roleName);
 	}
 
 	@Override

+ 352 - 352
src/main/java/com/goafanti/admin/service/impl/NewAdminServiceImpl.java

@@ -1,352 +1,352 @@
-package com.goafanti.admin.service.impl;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import com.goafanti.admin.bo.AdminDetail;
-import com.goafanti.admin.bo.AdminListBo;
-import com.goafanti.admin.service.NewAdminService;
-import com.goafanti.common.constant.AFTConstants;
-import com.goafanti.common.dao.AdminLocationMapper;
-import com.goafanti.common.dao.AdminMapper;
-import com.goafanti.common.dao.UserRoleMapper;
-import com.goafanti.common.model.Admin;
-import com.goafanti.common.utils.StringUtils;
-import com.goafanti.core.mybatis.BaseMybatisDao;
-import com.goafanti.core.mybatis.page.Pagination;
-import com.goafanti.core.shiro.token.TokenManager;
-
-@Service
-public class NewAdminServiceImpl extends BaseMybatisDao<AdminMapper> implements NewAdminService {
-	@Autowired
-	private AdminMapper			adminMapper;
-	@Autowired
-	private UserRoleMapper		userRoleMapper;
-	@Autowired
-	private AdminLocationMapper	adminLocationMapper;
-	
-	@Override
-	public Pagination<AdminListBo> listAdmin(AdminListBo alb, String rid, Integer pageNo, Integer pageSize) {
-		Map<String,Object> params = new HashMap<String, Object>();
-		if(StringUtils.isNotBlank(alb.getName())) params.put("name", alb.getName());
-		if(StringUtils.isNotBlank(alb.getDepartmentId())) params.put("departmentId", alb.getDepartmentId());
-		if(StringUtils.isNotBlank(rid)) params.put("rid", rid);
-		if(StringUtils.isNotBlank(alb.getDuty())) params.put("duty",alb.getDuty());
-		if(StringUtils.isNotBlank(alb.getPosition())) params.put("position", alb.getPosition());
-		if(StringUtils.isNotBlank(alb.getStatus())) params.put("status", alb.getStatus());
-		if(StringUtils.isNotBlank(alb.getMobile())) params.put("mobile", alb.getMobile());
-		if(StringUtils.isNotBlank(alb.getSuperiorId())) params.put("superiorId", alb.getSuperiorId());		
-		@SuppressWarnings("unchecked")
-		Pagination<AdminListBo> p=(Pagination<AdminListBo>)findPage("selectAdminListByPage","selectAdminCount",params,pageNo,pageSize);
-		@SuppressWarnings("unchecked")
-		List<AdminListBo> list=(List<AdminListBo>)p.getList();
-		for(AdminListBo i:list){
-			i.setRoles(adminMapper.selectRolesByUid(i.getId()));
-			i.setRolesId(adminMapper.selectRolesIdByUid(i.getId()));
-		}
-		return p;
-	}
-	
-	@Override
-	public List<Admin> selectAllAdmin() {
-		return adminMapper.selectAllAdmin();
-	}
-
-	@Override
-	public Admin selectByMobile(String mobile) {
-		return adminMapper.selectByMobile(mobile);
-	}
-
-	@Override
-	public Admin selectByPrimaryKey(String key) {
-		return adminMapper.selectByPrimaryKey(key);
-	}
-
-	@Override
-	public int insert(Admin ad) {
-		return adminMapper.insert(ad);
-	}
-
-	@Override
-	public int updateByPrimaryKeySelective(Admin ad, List<String> roleIds) {
-		Map<String, Object> params = new HashMap<>();
-		params.put("uid", ad.getId());
-		params.put("roles", roleIds);
-
-		if (ad.getId() != "1") {
-			userRoleMapper.deleteByUserId(ad.getId());
-			if (!roleIds.isEmpty()) {
-				userRoleMapper.insertBatch(params);
-			}
-			TokenManager.clearUserAuthByUserId(ad.getId());
-		}
-			
-		int count=adminMapper.updateByPrimaryKeySelective(ad);
-		//*******下第一级管理员用户修改
-		String autNo;
-		int n=0;
-		List<Admin> Nos =adminMapper.selectIDNBySuperiorId(ad.getId());
-		for(Admin i:Nos){			
-			autNo=adminMapper.selectUserNoById(i.getSuperiorId());
-			if(n<10){
-				String aut=autNo+"0"+n;			
-				if(n>=10){
-					aut=autNo+n;	
-				}else{
-					aut=autNo+"0"+n;
-				}	
-				i.setUserNo(aut);
-			}
-			if(n>=10){
-				String aut=autNo+n;			
-				aut=autNo+n;	
-				i.setUserNo(aut);
-			}
-			adminMapper.updateByUserNo(i);
-			n++;
-			//*******下第二级管理员用户修改
-			int m=0;
-			List<Admin> Noss =adminMapper.selectIDNBySuperiorId(i.getId());
-			for(Admin o:Noss){			
-				autNo=adminMapper.selectUserNoById(o.getSuperiorId());
-				if(m<10){
-					String aut=autNo+"0"+m;			
-					if(m>=10){
-						aut=autNo+m;	
-					}else{
-						aut=autNo+"0"+m;
-					}	
-					o.setUserNo(aut);
-				}
-				if(m>=10){
-					String aut=autNo+m;			
-					aut=autNo+m;	
-					o.setUserNo(aut);
-				}
-				adminMapper.updateByUserNo(o);
-				m++;
-				//*******下第三级管理员用户修改
-				int z=0;
-				List<Admin> Nosss =adminMapper.selectIDNBySuperiorId(o.getId());
-				for(Admin p:Nosss){			
-					autNo=adminMapper.selectUserNoById(p.getSuperiorId());
-					if(z<10){
-						String aut=autNo+"0"+z;			
-						if(z>=10){
-							aut=autNo+z;	
-						}else{
-							aut=autNo+"0"+z;
-						}	
-						p.setUserNo(aut);
-					}
-					if(z>=10){
-						String aut=autNo+z;			
-						aut=autNo+z;	
-						p.setUserNo(aut);
-					}
-					adminMapper.updateByUserNo(p);
-					z++;
-				}
-			}
-		}
-		return count;
-	}
-
-	@Override
-	public int updateByPrimaryKey(Admin a) {
-		return adminMapper.updateByPrimaryKeySelective(a);
-	}
-
-	@Override
-	public AdminDetail selectAdminDetail(String id) {
-		Admin a = adminMapper.selectByPrimaryKey(id);
-		if (null == a) {
-			return null;
-		}
-
-		AdminDetail ad = new AdminDetail();
-		BeanUtils.copyProperties(a, ad);
-		ad.setRoles(adminMapper.selectRolesByPrimaryKey(id));
-		return null;
-	}
-
-	@Override
-	public List<Admin> selectCognizanceConsultant() {
-		return adminMapper.selectCognizanceConsultant();
-	}
-
-	@Override
-	public List<Admin> selectPatentAuthor() {
-		return adminMapper.selectPatentAuthor();
-	}
-
-	@Override
-	public List<Admin> selectPatentPrincipal() {
-		return adminMapper.selectPatentPrincipal();
-	}
-
-	@Override
-	public List<Admin> selectCopyrightConsultant() {
-		return adminMapper.selectCopyrightConsultant();
-	}
-
-	@Override
-	public List<Admin> selectCognizancePrincipal() {
-		return adminMapper.selectCognizancePrincipal();
-	}
-
-	@Override
-	public List<Admin> selectCopyrightPrincipal() {
-		return adminMapper.selectCopyrightPrincipal();
-	}
-
-	@Override
-	public List<Admin> selectTechprojectConsultant() {
-		return adminMapper.selectTechprojectConsultant();
-	}
-
-	@Override
-	public List<Admin> selectTechprojectPrincipal() {
-		return adminMapper.selectTechprojectPrincipal();
-	}
-
-	@Override
-	public List<String> selectRoleByPrimaryKey(String uid) {
-		return adminMapper.selectRoleByPrimaryKey(uid);
-	}
-
-	@Override
-	public List<String> listAuditor() {
-		return userRoleMapper.listAuditor();
-	}
-
-	@Override
-	public Map<String, String> selectAccoutManager() {
-		return disposeAdminList(adminMapper.selectAccoutManager());
-	}
-
-	@Override
-	public Map<String, String> selectTechnician() {
-		return disposeAdminList(adminMapper.selectTechnician());
-	}
-
-	@Override
-	public Map<String, String> selectSalesman() {
-		return disposeAdminList(adminMapper.selectSalesman());
-	}
-
-	@Override
-	public Map<String, String> selectContractManager() {
-		return disposeAdminList(adminMapper.selectContractManager());
-	}
-
-	@Override
-	public Map<String, String> selectTechBroder() {
-		return disposeAdminList(adminMapper.selectTechBroder());
-	}
-
-	@Override
-	public int insertNewAdmin(Admin ad ,List<String> roleIds) {
-		ad.setStatus("正常");		
-		String sdepNo=adminMapper.selectUserNoBySuperiorId(ad.getSuperiorId());
-		int Count=adminMapper.selectCountBySuperiorId(ad.getSuperiorId());
-		if(Count<10){
-			String dep=sdepNo+"0"+Count;
-			String sid=adminMapper.selectIdByUserNo(dep);
-			while(sid!=null){
-				Count=Count+1;				
-				if(Count>=10){
-					dep=sdepNo+Count;	
-				}else{
-					dep=sdepNo+"0"+Count;
-				}
-				sid=adminMapper.selectIdByUserNo(dep);				
-			}
-			ad.setUserNo(dep);
-		}
-		if(Count>=10){
-			String dep=sdepNo+Count;
-			String sid=adminMapper.selectIdByUserNo(dep);
-			while(sid!=null){
-				Count=Count+1;				
-				dep=sdepNo+Count;
-				sid=adminMapper.selectIdByUserNo(dep);				
-			}
-			ad.setUserNo(dep);
-		}		
-		Map<String, Object> params = new HashMap<>();
-		params.put("uid", ad.getId());
-		params.put("roles", roleIds);
-
-		if (ad.getId() != "1") {
-			userRoleMapper.deleteByUserId(ad.getId());
-			if (!roleIds.isEmpty()) {
-				userRoleMapper.insertBatch(params);
-			}
-			TokenManager.clearUserAuthByUserId(ad.getId());
-		}
-		return adminMapper.insertn(ad);
-	}
-
-	@Override
-	public Map<String, String> listAdminSelect() {
-		if (TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
-			return disposeAdminList(adminMapper.listAdminSelectBySuperAdmin());
-		} else if (TokenManager.hasRole(AFTConstants.AREAADMIN)) {
-			List<Integer> provinceList = adminLocationMapper
-					.selectProvinceWhereCityIsNullByAdminId(TokenManager.getAdminId());
-			List<Integer> cityList = adminLocationMapper.selectCityByAdminId(TokenManager.getAdminId());
-			provinceList.addAll(cityList);
-			return disposeAdminList(adminMapper.listAdminSelectByAreaAdmin(provinceList, cityList));
-		}
-		return null;
-	}
-
-	private Map<String, String> disposeAdminList(List<Admin> list) {
-		Map<String, String> map = new TreeMap<String, String>();
-		for (Admin o : list) {
-			map.put(o.getId(), o.getName() + " " + (StringUtils.isBlank(o.getPosition()) ? "" : o.getPosition()));
-		}
-		return map;
-	}
-
-	@Override
-	public List<Admin> listAdminByName(String name) {
-		
-		return adminMapper.listAdminByName(name);
-	}
-
-	@Override
-	public Admin selectAllByid(String id) {
-		Admin admin=adminMapper.selectAllByid(id);
-		admin.setSuperior(adminMapper.selectNameByid(admin.getSuperiorId()));
-		if(admin.getDistrict()==null){
-			admin.setDistrict(" ");
-		}
-		if(admin.getHeadPortraitUrl()==null){
-			admin.setHeadPortraitUrl("");
-		}
-		return admin;
-	}
-
-	@Override
-	public int deleteById(String id) {
-		adminMapper.deleteById(id);
-		if(id!="1"){
-			userRoleMapper.deleteByUserId(id);
-		}		
-		return 1;
-	}
-
-	@Override
-	public List<AdminListBo> selectAdminByOrg() {
-		return adminMapper.selectSubList(TokenManager.getAdminId());
-	}
-
-}
+package com.goafanti.admin.service.impl;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.goafanti.admin.bo.AdminDetail;
+import com.goafanti.admin.bo.AdminListBo;
+import com.goafanti.admin.service.NewAdminService;
+import com.goafanti.common.constant.AFTConstants;
+import com.goafanti.common.dao.AdminLocationMapper;
+import com.goafanti.common.dao.AdminMapper;
+import com.goafanti.common.dao.UserRoleMapper;
+import com.goafanti.common.model.Admin;
+import com.goafanti.common.utils.StringUtils;
+import com.goafanti.core.mybatis.BaseMybatisDao;
+import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.core.shiro.token.TokenManager;
+
+@Service
+public class NewAdminServiceImpl extends BaseMybatisDao<AdminMapper> implements NewAdminService {
+	@Autowired
+	private AdminMapper			adminMapper;
+	@Autowired
+	private UserRoleMapper		userRoleMapper;
+	@Autowired
+	private AdminLocationMapper	adminLocationMapper;
+	
+	@Override
+	public Pagination<AdminListBo> listAdmin(AdminListBo alb, String rid, Integer pageNo, Integer pageSize) {
+		Map<String,Object> params = new HashMap<String, Object>();
+		if(StringUtils.isNotBlank(alb.getName())) params.put("name", alb.getName());
+		if(StringUtils.isNotBlank(alb.getDepartmentId())) params.put("departmentId", alb.getDepartmentId());
+		if(StringUtils.isNotBlank(rid)) params.put("rid", rid);
+		if(StringUtils.isNotBlank(alb.getDuty())) params.put("duty",alb.getDuty());
+		if(StringUtils.isNotBlank(alb.getPosition())) params.put("position", alb.getPosition());
+		if(StringUtils.isNotBlank(alb.getStatus())) params.put("status", alb.getStatus());
+		if(StringUtils.isNotBlank(alb.getMobile())) params.put("mobile", alb.getMobile());
+		if(StringUtils.isNotBlank(alb.getSuperiorId())) params.put("superiorId", alb.getSuperiorId());		
+		@SuppressWarnings("unchecked")
+		Pagination<AdminListBo> p=(Pagination<AdminListBo>)findPage("selectAdminListByPage","selectAdminCount",params,pageNo,pageSize);
+		@SuppressWarnings("unchecked")
+		List<AdminListBo> list=(List<AdminListBo>)p.getList();
+		for(AdminListBo i:list){
+			i.setRoles(adminMapper.selectRolesByUid(i.getId()));
+			i.setRolesId(adminMapper.selectRolesIdByUid(i.getId()));
+		}
+		return p;
+	}
+	
+	@Override
+	public List<Admin> selectAllAdmin() {
+		return adminMapper.selectAllAdmin();
+	}
+
+	@Override
+	public Admin selectByMobile(String mobile) {
+		return adminMapper.selectByMobile(mobile,null);
+	}
+
+	@Override
+	public Admin selectByPrimaryKey(String key) {
+		return adminMapper.selectByPrimaryKey(key);
+	}
+
+	@Override
+	public int insert(Admin ad) {
+		return adminMapper.insert(ad);
+	}
+
+	@Override
+	public int updateByPrimaryKeySelective(Admin ad, List<String> roleIds) {
+		Map<String, Object> params = new HashMap<>();
+		params.put("uid", ad.getId());
+		params.put("roles", roleIds);
+
+		if (ad.getId() != "1") {
+			userRoleMapper.deleteByUserId(ad.getId());
+			if (!roleIds.isEmpty()) {
+				userRoleMapper.insertBatch(params);
+			}
+			TokenManager.clearUserAuthByUserId(ad.getId());
+		}
+			
+		int count=adminMapper.updateByPrimaryKeySelective(ad);
+		//*******下第一级管理员用户修改
+		String autNo;
+		int n=0;
+		List<Admin> Nos =adminMapper.selectIDNBySuperiorId(ad.getId());
+		for(Admin i:Nos){			
+			autNo=adminMapper.selectUserNoById(i.getSuperiorId());
+			if(n<10){
+				String aut=autNo+"0"+n;			
+				if(n>=10){
+					aut=autNo+n;	
+				}else{
+					aut=autNo+"0"+n;
+				}	
+				i.setUserNo(aut);
+			}
+			if(n>=10){
+				String aut=autNo+n;			
+				aut=autNo+n;	
+				i.setUserNo(aut);
+			}
+			adminMapper.updateByUserNo(i);
+			n++;
+			//*******下第二级管理员用户修改
+			int m=0;
+			List<Admin> Noss =adminMapper.selectIDNBySuperiorId(i.getId());
+			for(Admin o:Noss){			
+				autNo=adminMapper.selectUserNoById(o.getSuperiorId());
+				if(m<10){
+					String aut=autNo+"0"+m;			
+					if(m>=10){
+						aut=autNo+m;	
+					}else{
+						aut=autNo+"0"+m;
+					}	
+					o.setUserNo(aut);
+				}
+				if(m>=10){
+					String aut=autNo+m;			
+					aut=autNo+m;	
+					o.setUserNo(aut);
+				}
+				adminMapper.updateByUserNo(o);
+				m++;
+				//*******下第三级管理员用户修改
+				int z=0;
+				List<Admin> Nosss =adminMapper.selectIDNBySuperiorId(o.getId());
+				for(Admin p:Nosss){			
+					autNo=adminMapper.selectUserNoById(p.getSuperiorId());
+					if(z<10){
+						String aut=autNo+"0"+z;			
+						if(z>=10){
+							aut=autNo+z;	
+						}else{
+							aut=autNo+"0"+z;
+						}	
+						p.setUserNo(aut);
+					}
+					if(z>=10){
+						String aut=autNo+z;			
+						aut=autNo+z;	
+						p.setUserNo(aut);
+					}
+					adminMapper.updateByUserNo(p);
+					z++;
+				}
+			}
+		}
+		return count;
+	}
+
+	@Override
+	public int updateByPrimaryKey(Admin a) {
+		return adminMapper.updateByPrimaryKeySelective(a);
+	}
+
+	@Override
+	public AdminDetail selectAdminDetail(String id) {
+		Admin a = adminMapper.selectByPrimaryKey(id);
+		if (null == a) {
+			return null;
+		}
+
+		AdminDetail ad = new AdminDetail();
+		BeanUtils.copyProperties(a, ad);
+		ad.setRoles(adminMapper.selectRolesByPrimaryKey(id));
+		return null;
+	}
+
+	@Override
+	public List<Admin> selectCognizanceConsultant() {
+		return adminMapper.selectCognizanceConsultant();
+	}
+
+	@Override
+	public List<Admin> selectPatentAuthor() {
+		return adminMapper.selectPatentAuthor();
+	}
+
+	@Override
+	public List<Admin> selectPatentPrincipal() {
+		return adminMapper.selectPatentPrincipal();
+	}
+
+	@Override
+	public List<Admin> selectCopyrightConsultant() {
+		return adminMapper.selectCopyrightConsultant();
+	}
+
+	@Override
+	public List<Admin> selectCognizancePrincipal() {
+		return adminMapper.selectCognizancePrincipal();
+	}
+
+	@Override
+	public List<Admin> selectCopyrightPrincipal() {
+		return adminMapper.selectCopyrightPrincipal();
+	}
+
+	@Override
+	public List<Admin> selectTechprojectConsultant() {
+		return adminMapper.selectTechprojectConsultant();
+	}
+
+	@Override
+	public List<Admin> selectTechprojectPrincipal() {
+		return adminMapper.selectTechprojectPrincipal();
+	}
+
+	@Override
+	public List<String> selectRoleByPrimaryKey(String uid) {
+		return adminMapper.selectRoleByPrimaryKey(uid);
+	}
+
+	@Override
+	public List<String> listAuditor() {
+		return userRoleMapper.listAuditor();
+	}
+
+	@Override
+	public Map<String, String> selectAccoutManager() {
+		return disposeAdminList(adminMapper.selectAccoutManager());
+	}
+
+	@Override
+	public Map<String, String> selectTechnician() {
+		return disposeAdminList(adminMapper.selectTechnician());
+	}
+
+	@Override
+	public Map<String, String> selectSalesman() {
+		return disposeAdminList(adminMapper.selectSalesman());
+	}
+
+	@Override
+	public Map<String, String> selectContractManager() {
+		return disposeAdminList(adminMapper.selectContractManager());
+	}
+
+	@Override
+	public Map<String, String> selectTechBroder() {
+		return disposeAdminList(adminMapper.selectTechBroder());
+	}
+
+	@Override
+	public int insertNewAdmin(Admin ad ,List<String> roleIds) {
+		ad.setStatus("正常");		
+		String sdepNo=adminMapper.selectUserNoBySuperiorId(ad.getSuperiorId());
+		int Count=adminMapper.selectCountBySuperiorId(ad.getSuperiorId());
+		if(Count<10){
+			String dep=sdepNo+"0"+Count;
+			String sid=adminMapper.selectIdByUserNo(dep);
+			while(sid!=null){
+				Count=Count+1;				
+				if(Count>=10){
+					dep=sdepNo+Count;	
+				}else{
+					dep=sdepNo+"0"+Count;
+				}
+				sid=adminMapper.selectIdByUserNo(dep);				
+			}
+			ad.setUserNo(dep);
+		}
+		if(Count>=10){
+			String dep=sdepNo+Count;
+			String sid=adminMapper.selectIdByUserNo(dep);
+			while(sid!=null){
+				Count=Count+1;				
+				dep=sdepNo+Count;
+				sid=adminMapper.selectIdByUserNo(dep);				
+			}
+			ad.setUserNo(dep);
+		}		
+		Map<String, Object> params = new HashMap<>();
+		params.put("uid", ad.getId());
+		params.put("roles", roleIds);
+
+		if (ad.getId() != "1") {
+			userRoleMapper.deleteByUserId(ad.getId());
+			if (!roleIds.isEmpty()) {
+				userRoleMapper.insertBatch(params);
+			}
+			TokenManager.clearUserAuthByUserId(ad.getId());
+		}
+		return adminMapper.insertn(ad);
+	}
+
+	@Override
+	public Map<String, String> listAdminSelect() {
+		if (TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
+			return disposeAdminList(adminMapper.listAdminSelectBySuperAdmin());
+		} else if (TokenManager.hasRole(AFTConstants.AREAADMIN)) {
+			List<Integer> provinceList = adminLocationMapper
+					.selectProvinceWhereCityIsNullByAdminId(TokenManager.getAdminId());
+			List<Integer> cityList = adminLocationMapper.selectCityByAdminId(TokenManager.getAdminId());
+			provinceList.addAll(cityList);
+			return disposeAdminList(adminMapper.listAdminSelectByAreaAdmin(provinceList, cityList));
+		}
+		return null;
+	}
+
+	private Map<String, String> disposeAdminList(List<Admin> list) {
+		Map<String, String> map = new TreeMap<String, String>();
+		for (Admin o : list) {
+			map.put(o.getId(), o.getName() + " " + (StringUtils.isBlank(o.getPosition()) ? "" : o.getPosition()));
+		}
+		return map;
+	}
+
+	@Override
+	public List<Admin> listAdminByName(String name) {
+		
+		return adminMapper.listAdminByName(name);
+	}
+
+	@Override
+	public Admin selectAllByid(String id) {
+		Admin admin=adminMapper.selectAllByid(id);
+		admin.setSuperior(adminMapper.selectNameByid(admin.getSuperiorId()));
+		if(admin.getDistrict()==null){
+			admin.setDistrict(" ");
+		}
+		if(admin.getHeadPortraitUrl()==null){
+			admin.setHeadPortraitUrl("");
+		}
+		return admin;
+	}
+
+	@Override
+	public int deleteById(String id) {
+		adminMapper.deleteById(id);
+		if(id!="1"){
+			userRoleMapper.deleteByUserId(id);
+		}		
+		return 1;
+	}
+
+	@Override
+	public List<AdminListBo> selectAdminByOrg() {
+		return adminMapper.selectSubList(TokenManager.getAdminId());
+	}
+
+}

+ 255 - 249
src/main/java/com/goafanti/business/controller/AdminJtBusinessController.java

@@ -1,249 +1,255 @@
-package com.goafanti.business.controller;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import com.goafanti.business.service.JtBusinessService;
-import com.goafanti.business.service.JtBusinessServiceWithCategoryMapper;
-import com.goafanti.common.bo.Result;
-import com.goafanti.common.constant.ErrorConstants;
-import com.goafanti.common.controller.CertifyApiController;
-import com.goafanti.common.enums.AttachmentType;
-import com.goafanti.common.model.JtBusinessCategory;
-import com.goafanti.common.model.JtBusinessProject;
-
-import okhttp3.Request;
-
-@RestController
-@RequestMapping(value = "/api/admin/jtBusiness")
-public class AdminJtBusinessController extends CertifyApiController{
-	
-	@Resource 
-	private JtBusinessService jtBusinessService;
-	
-	@Resource JtBusinessServiceWithCategoryMapper JtBusinessServiceWithCategoryMapper;
-	
-	/*
-	 * 删除品类
-	 * 
-	 * */
-	@RequestMapping(value="/category/delete",method=RequestMethod.POST)
-	private Result deleteCetegoryById(String id) {
-		Result result=new Result();
-		if(id==null) {result.getError().add(buildError(ErrorConstants.STATUS_ERROR,"","id"));
-		return result;} 
-		int rc=jtBusinessService.deleteCategoryById(id);
-		result.setData(rc);
-		if(rc==-1) {
-			result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","请先删除子项目及子分类,"));
-		}
-		return result;
-		
-	}
-
-	
-	/*
-	 * 
-	 * 品类详情
-	 * */
-	@RequestMapping(value="/category/detail",method=RequestMethod.GET)
-	private Result getCategoryDetailById(String id)
-	{
-		Result result=new Result();
-		if(id==null) {result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","id"));
-		return result;}
-		
-		result.setData(jtBusinessService.getCategoryById(id));
-		return result;
-	}
-	/*
-	 * 
-	 * 新增品類
-	 * 
-	 * */
-	@RequestMapping(value="/category/apply",method=RequestMethod.POST)
-	private Result insertCategory(JtBusinessCategory jtBusinessCategory) {
-		Result result=new Result();
-		disposeCateParam(result, jtBusinessCategory);
-		if(result.getError().size()>0)return result;
-		int rc=jtBusinessService.insertCategory(jtBusinessCategory);
-		if(rc==-1)result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","每层品类不可超过99个,"));
-		if(rc==-2)result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","父类Id与层数需要对应,"));
-		return result;
-	}
-	
-	/*
-	 * 修改
-	 * */
-	@RequestMapping(value="/category/update",method=RequestMethod.POST)
-	private Result updateCategory(JtBusinessCategory jtBusinessCategory) {
-		Result result=new Result();
-		//只允许修改3种字段
-		JtBusinessCategory jtBusinessCategory2=new JtBusinessCategory();
-		jtBusinessCategory2.setId(jtBusinessCategory.getId());
-		jtBusinessCategory2.setImgUrl(jtBusinessCategory.getImgUrl());
-		jtBusinessCategory2.setName(jtBusinessCategory.getName());
-		jtBusinessCategory2.setSummary(jtBusinessCategory.getSummary());
-		 result.setData(jtBusinessService.updateCategory(jtBusinessCategory2));
-		 return result;
-	}
-	
-	/*
-	 * 查询品类
-	 * 
-	 * */
-	@RequestMapping(value="/category/list",method=RequestMethod.GET)
-	private Result getCategoryList(JtBusinessCategory jtBusinessCategory,Integer pageNo,Integer pageSize) {
-		Result result=new Result();
-	
-		 result.setData(JtBusinessServiceWithCategoryMapper.getCategoryListByCondition(jtBusinessCategory,pageNo,pageSize));
-		 return result;
-	}
-	private void disposeCateParam(Result result,JtBusinessCategory jtBusinessCategory ) {
-		if(jtBusinessCategory.getName() == null) {
-			result.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "名称不可为空", "名称"));
-			return ;
-		}
-		if(jtBusinessCategory.getLayer() == null) {
-			result.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "层级不可为空", "层级"));
-			return ;
-		}
-		if(jtBusinessCategory.getLayer()==2 && jtBusinessCategory.getSuperId()==null)
-		{
-			result.getError().add(buildError(ErrorConstants.PARAM_ERROR, "父级品类不可为空", "父级品类"));
-			return ;
-		}
-		if(jtBusinessCategory.getLayer()>3 || jtBusinessCategory.getLayer()<1)
-		{
-			result.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "层级只能为一级或二级")); 
-			return ;
-		}
-	
-		
-		return ;
-	}
-	
-	/*
-	 * 
-	 * 新增项目
-	 * 
-	 * */
-	@RequestMapping(value="/project/apply",method=RequestMethod.POST)
-	private Result insertJtBusinessProject(JtBusinessProject jtBusinessProject) {
-		Result result=new Result();
-		disposeProjectParam(result, jtBusinessProject);
-		if(result.getError().size()<=0) {
-			result.setData(jtBusinessService.insertProject(jtBusinessProject));
-		}
-		return result;
-		
-	}
-	private void disposeProjectParam(Result result,JtBusinessProject jtBusinessProject ) {
-		if(jtBusinessProject.getName() == null) {
-			result.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "名称不可为空", "名称"));
-			return ;
-		}
-		if(jtBusinessProject.getCategoryId() == null) {
-			result.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "品类"));
-			return ;
-		}
-		//todo  判断品类是否存在
-		JtBusinessCategory jtBusinessCategory=jtBusinessService.getCategoryById(jtBusinessProject.getCategoryId());
-		if(jtBusinessCategory==null ||jtBusinessCategory.getLayer()!=2) {
-			result.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "二级品类未找到"));
-			return ;
-		}
-		
-		if(jtBusinessProject.getProvince()==null)
-		{
-			result.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "省份"));
-			return ;
-		}
-	
-		if(jtBusinessProject.getCity()==null)
-		{
-			result.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "城市"));
-			return ;
-		}
-//		if(jtBusinessProject.getPrice()==null)
-//		{
-//			result.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "价格"));
-//			return ;
-//		}
-		return ;
-	}
-	
-	/*
-	 * 项目详情
-	 * 
-	 * */
-	@RequestMapping(value="/project/detail",method=RequestMethod.GET)
-	private Result getProjectDetail(String id) {
-		Result result=new Result();
-		if(id == null) {
-			result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","id不能为空,"));
-			return result;
-		}
-		result.setData(jtBusinessService.getBusinessProjectDetail(id));
-		return result;
-	}
-	
-	/*
-	 * 删除项目
-	 * */
-	@RequestMapping(value="/project/delete",method=RequestMethod.GET)
-	private Result deleteProjecById(String id) {
-		Result result=new Result();
-		if(id == null) {
-			result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","id不能为空,"));
-			return result;
-		}
-		result.setData(jtBusinessService.deleteProjectById(id));
-		return result;
-	}
-	
-	@RequestMapping(value="/project/update",method=RequestMethod.POST)
-	private Result updateProject(JtBusinessProject jtBusinessProject) {
-		Result result=new Result();
-		jtBusinessProject.setCreateTime(null);
-//		jtBusinessProject.setId(null);
-		jtBusinessProject.setNumber(null);
-		jtBusinessService.updateProject(jtBusinessProject);
-		return result;
-	}
-	
-	@RequestMapping(value = "/uploadPicture", method = RequestMethod.POST)
-	public Result uploadPicture(HttpServletRequest req, String sign) {
-		Result res = new Result();
-		AttachmentType attachmentType = AttachmentType.getField(sign);
-
-		if (attachmentType == AttachmentType.JT_BUSINESS_PICTURE
-				) {
-			res.setData(handleFiles(res, "/jtVarieties/", false, req, sign, ""));
-		} else {
-			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "图片"));
-		}
-		return res;
-	}
-	
-	@RequestMapping(value = "/project/uploadPicture", method = RequestMethod.POST)
-	public Result uploadProjectPicture(HttpServletRequest req, String sign) {
-		Result res = new Result();
-		AttachmentType attachmentType = AttachmentType.getField(sign);
-
-		if (attachmentType == AttachmentType.JT_PROJECT_PICTURE
-				) {
-			res.setData(handleFiles(res, "/jtProjects/", false, req, sign, ""));
-		} else {
-			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "图片"));
-		}
-		return res;
-	}
-}
+package com.goafanti.business.controller;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.goafanti.business.service.JtBusinessService;
+import com.goafanti.business.service.JtBusinessServiceWithCategoryMapper;
+import com.goafanti.common.bo.Result;
+import com.goafanti.common.constant.ErrorConstants;
+import com.goafanti.common.controller.CertifyApiController;
+import com.goafanti.common.enums.AttachmentType;
+import com.goafanti.common.model.JtBusinessCategory;
+import com.goafanti.common.model.JtBusinessProject;
+
+import okhttp3.Request;
+
+@RestController
+@RequestMapping(value = "/api/admin/jtBusiness")
+public class AdminJtBusinessController extends CertifyApiController{
+	
+	@Resource 
+	private JtBusinessService jtBusinessService;
+	
+	@Resource JtBusinessServiceWithCategoryMapper JtBusinessServiceWithCategoryMapper;
+	
+	/*
+	 * 删除品类
+	 * 
+	 * */
+	@RequestMapping(value="/category/delete",method=RequestMethod.POST)
+	private Result deleteCetegoryById(String id) {
+		Result result=new Result();
+		if(id==null) {result.getError().add(buildError(ErrorConstants.STATUS_ERROR,"","id"));
+		return result;} 
+		int rc=jtBusinessService.deleteCategoryById(id);
+		result.setData(rc);
+		if(rc==-1) {
+			result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","请先删除子项目及子分类,"));
+		}
+		return result;
+		
+	}
+
+	
+	/*
+	 * 
+	 * 品类详情
+	 * */
+	@RequestMapping(value="/category/detail",method=RequestMethod.GET)
+	private Result getCategoryDetailById(String id)
+	{
+		Result result=new Result();
+		if(id==null) {result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","id"));
+		return result;}
+		
+		result.setData(jtBusinessService.getCategoryById(id));
+		return result;
+	}
+	/*
+	 * 
+	 * 新增品類
+	 * 
+	 * */
+	@RequestMapping(value="/category/apply",method=RequestMethod.POST)
+	private Result insertCategory(JtBusinessCategory jtBusinessCategory) {
+		Result result=new Result();
+		disposeCateParam(result, jtBusinessCategory);
+		if(result.getError().size()>0)return result;
+		int rc=jtBusinessService.insertCategory(jtBusinessCategory);
+		if(rc==-1)result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","每层品类不可超过99个,"));
+		if(rc==-2)result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","父类Id与层数需要对应,"));
+		return result;
+	}
+	
+	/*
+	 * 修改
+	 * */
+	@RequestMapping(value="/category/update",method=RequestMethod.POST)
+	private Result updateCategory(JtBusinessCategory jtBusinessCategory) {
+		Result result=new Result();
+		//只允许修改3种字段
+		JtBusinessCategory jtBusinessCategory2=new JtBusinessCategory();
+		jtBusinessCategory2.setId(jtBusinessCategory.getId());
+		jtBusinessCategory2.setImgUrl(jtBusinessCategory.getImgUrl());
+		jtBusinessCategory2.setName(jtBusinessCategory.getName());
+		jtBusinessCategory2.setSummary(jtBusinessCategory.getSummary());
+		 result.setData(jtBusinessService.updateCategory(jtBusinessCategory2));
+		 return result;
+	}
+	
+	/*
+	 * 查询品类
+	 * 
+	 * */
+	@RequestMapping(value="/category/list",method=RequestMethod.GET)
+	private Result getCategoryList(JtBusinessCategory jtBusinessCategory,Integer pageNo,Integer pageSize) {
+		Result result=new Result();
+	
+		 result.setData(JtBusinessServiceWithCategoryMapper.getCategoryListByCondition(jtBusinessCategory,pageNo,pageSize));
+		 return result;
+	}
+	private void disposeCateParam(Result result,JtBusinessCategory jtBusinessCategory ) {
+		if(jtBusinessCategory.getName() == null) {
+			result.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "名称不可为空", "名称"));
+			return ;
+		}
+		if(jtBusinessCategory.getLayer() == null) {
+			result.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "层级不可为空", "层级"));
+			return ;
+		}
+		if(jtBusinessCategory.getLayer()==2 && jtBusinessCategory.getSuperId()==null)
+		{
+			result.getError().add(buildError(ErrorConstants.PARAM_ERROR, "父级品类不可为空", "父级品类"));
+			return ;
+		}
+		if(jtBusinessCategory.getLayer()>3 || jtBusinessCategory.getLayer()<1)
+		{
+			result.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "层级只能为一级或二级")); 
+			return ;
+		}
+	
+		
+		return ;
+	}
+	
+	/*
+	 * 
+	 * 新增项目
+	 * 
+	 * */
+	@RequestMapping(value="/project/apply",method=RequestMethod.POST)
+	private Result insertJtBusinessProject(JtBusinessProject jtBusinessProject) {
+		Result result=new Result();
+		disposeProjectParam(result, jtBusinessProject);
+		if(result.getError().size()<=0) {
+			result.setData(jtBusinessService.insertProject(jtBusinessProject));
+		}
+		return result;
+		
+	}
+	private void disposeProjectParam(Result result,JtBusinessProject jtBusinessProject ) {
+		if(jtBusinessProject.getName() == null) {
+			result.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "名称不可为空", "名称"));
+			return ;
+		}
+		if(jtBusinessProject.getCategoryId() == null) {
+			result.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "品类"));
+			return ;
+		}
+		//todo  判断品类是否存在
+		JtBusinessCategory jtBusinessCategory=jtBusinessService.getCategoryById(jtBusinessProject.getCategoryId());
+		if(jtBusinessCategory==null ||jtBusinessCategory.getLayer()!=2) {
+			result.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "二级品类未找到"));
+			return ;
+		}
+		
+		if(jtBusinessProject.getProvince()==null)
+		{
+			result.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "省份"));
+			return ;
+		}
+//		if(jtBusinessProject.getCity()==null)
+//		{
+//			result.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "城市"));
+//			return ;
+//		}
+//		if(jtBusinessProject.getPrice()==null)
+//		{
+//			result.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "价格"));
+//			return ;
+//		}
+		return ;
+	}
+	
+	/*
+	 * 项目详情
+	 * 
+	 * */
+	@RequestMapping(value="/project/detail",method=RequestMethod.GET)
+	private Result getProjectDetail(String id) {
+		Result result=new Result();
+		if(id == null) {
+			result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","id不能为空,"));
+			return result;
+		}
+		result.setData(jtBusinessService.getBusinessProjectDetail(id));
+		return result;
+	}
+	
+	/*
+	 * 删除项目
+	 * */
+	@RequestMapping(value="/project/delete",method=RequestMethod.GET)
+	private Result deleteProjecById(String id) {
+		Result result=new Result();
+		if(id == null) {
+			result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","id不能为空,"));
+			return result;
+		}
+		result.setData(jtBusinessService.deleteProjectById(id));
+		return result;
+	}
+	
+	@RequestMapping(value="/project/update",method=RequestMethod.POST)
+	private Result updateProject(JtBusinessProject jtBusinessProject) {
+		Result result=new Result();
+		jtBusinessProject.setCreateTime(null);
+//		jtBusinessProject.setId(null);
+		jtBusinessProject.setNumber(null);
+		disposeProjectParam(result, jtBusinessProject);
+		if(result.getError().size()>0) {
+			return result;
+		}
+		if(jtBusinessProject.getPrice()==null) {
+			result.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "价格不可为空,"));
+		}
+		jtBusinessService.updateProject(jtBusinessProject);
+		return result;
+	}
+	
+	@RequestMapping(value = "/uploadPicture", method = RequestMethod.POST)
+	public Result uploadPicture(HttpServletRequest req, String sign) {
+		Result res = new Result();
+		AttachmentType attachmentType = AttachmentType.getField(sign);
+
+		if (attachmentType == AttachmentType.JT_BUSINESS_PICTURE
+				) {
+			res.setData(handleFiles(res, "/jtVarieties/", false, req, sign, ""));
+		} else {
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "图片"));
+		}
+		return res;
+	}
+	
+	@RequestMapping(value = "/project/uploadPicture", method = RequestMethod.POST)
+	public Result uploadProjectPicture(HttpServletRequest req, String sign) {
+		Result res = new Result();
+		AttachmentType attachmentType = AttachmentType.getField(sign);
+
+		if (attachmentType == AttachmentType.JT_PROJECT_PICTURE
+				) {
+			res.setData(handleFiles(res, "/jtProjects/", false, req, sign, ""));
+		} else {
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "图片"));
+		}
+		return res;
+	}
+}

+ 1 - 1
src/main/java/com/goafanti/common/dao/AdminMapper.java

@@ -25,7 +25,7 @@ public interface AdminMapper {
 
 	List<Admin> selectAllAdmin();
 
-	Admin selectByMobile(String mobile);
+	Admin selectByMobile(String mobile,String roleName);
 
 	List<Role> selectRolesByPrimaryKey(String uid);
 

Datei-Diff unterdrückt, da er zu groß ist
+ 630 - 624
src/main/java/com/goafanti/common/mapper/AdminMapper.xml


+ 1 - 1
src/main/java/com/goafanti/core/shiro/token/UserRealm.java

@@ -51,7 +51,7 @@ public class UserRealm extends AuthorizingRealm {
 
 		ShiroToken token = (ShiroToken) authcToken;
 		if (null == token.getType()) {
-			Admin admin = adminService.selectByMobile(token.getUsername());
+			Admin admin = adminService.selectByMobile(token.getUsername(),"超级管理员");
 			if (null == admin) {
 				throw new UnknownAccountException();
 			}

+ 13 - 5
src/main/webapp/WEB-INF/views/common.html

@@ -28,9 +28,9 @@
 							<a th:href="@{/user/signIn}">注册</a>
 						</li>
 						<li>
-							<a href="javascript:;" class="head_login">登录</a>
+							<a  th:if="!${isLogin}" href="javascript:;" class="head_login">登录</a>
 						</li>
-					<li th:if="${isLogin}">
+					<li th:if="${isLogin}" class="signin">
 						<a th:href="${basePath + (isAdmin? '/admin/index.html':'/user/account/index.html')}"
 							th:text="${#strings.isEmpty(userName)?'个人中心':userName}">个人中心</a>
 						<a th:href="${basePath + '/user/logout'}">退出</a>
@@ -55,19 +55,24 @@
             <div class="nav">
                 <ul>
                     <li th:class="${subM}=='serviceIndex'?active:null">
+                    <div>
                         <a th:href="@{/portal/service/serviceIndex}">科技服务</a>
-                        <img th:src="${portalHost+'/img/hot.png'}">
-                       
+ 
+                       </div>
                     </li>
                     <li th:class="${subM}=='achievement'?active:null">
+                    <div>
                         <a th:href="@{/portal/technologyTrading/achievement}">技术成果</a>
+                        </div>
                     </li>
                     <li th:class="${subM}=='demand'?active:null">
-                        <a th:href="@{/portal/technologyTrading/demand}">技术需求</a>
+                    <div>
+                        <a th:href="@{/portal/technologyTrading/demand}">技术需求</a></div>
                     </li>
                             
                     
                     <li th:class="${subM}=='thinkTankIndex'?active:null">
+                    <div>
                         <a th:href="@{/portal/thinkTank/index.html}">智库咨询</a>
                         <ol class="subnavigation">
                             <li>
@@ -77,15 +82,18 @@
                                 <a th:href="@{/portal/thinkTank/index.html#zizone}">智者</a>
                             </li>
                         </ol>
+                        </div>
                     </li>
 
                     <li th:class="${subM}=='aboutUs'?active:null">
+                    <div>
                         <a th:href="@{/portal/aboutUs}">关于公司</a>
                         <ol class="subnavigation" style="display: none;">
                             <li>
                                 <a th:href="@{/portal/contactUs}">联系我们</a>
                             </li>
                         </ol>
+                        </div>
                     </li>
                 </ul>
             </div>