Browse Source

用户管理模块联调OK

Michael 8 years ago
parent
commit
3830cb3086

+ 12 - 0
src/main/java/com/goafanti/admin/bo/AdminListBo.java

@@ -1,6 +1,7 @@
 package com.goafanti.admin.bo;
 
 import java.util.Date;
+import java.util.List;
 
 import org.apache.commons.lang3.time.DateFormatUtils;
 
@@ -75,6 +76,17 @@ public class AdminListBo {
 	/** 职务 **/
 	private String duty;
 	
+	/** 角色 **/
+	private List<String> roles;
+	
+	public List<String> getRoles() {
+		return roles;
+	}
+
+	public void setRoles(List<String> roles) {
+		this.roles = roles;
+	}
+
 	public String getStatus() {
 		return status;
 	}

+ 260 - 2
src/main/java/com/goafanti/admin/controller/AdminSuperviserApiController.java

@@ -1,23 +1,39 @@
 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 javax.servlet.http.HttpServletRequest;
 
+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.AdminListBo;
+import com.goafanti.admin.bo.AdminLocationBo;
 import com.goafanti.admin.service.AdminLocationService;
-import com.goafanti.admin.service.AdminService;
 import com.goafanti.admin.service.NewAdminService;
 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.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 = "open/api/admin/superviser")
+@RequestMapping(value = "api/admin/superviser")
 public class AdminSuperviserApiController extends CertifyApiController {
 	@Resource
 	private NewAdminService			newAdminService;
@@ -44,4 +60,246 @@ public class AdminSuperviserApiController extends CertifyApiController {
 		return res;
 	}
 	
+	/**
+	 * 新增管理员
+	 */
+	@RequestMapping(value = "/insertAdmin", method = RequestMethod.POST)
+	public Result insertAdmin(@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 (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 = newAdminService.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));
+			List<String> roles = new ArrayList<String>();
+			if (roleIds != null && roleIds.length > 0) {
+				for (String role : roleIds) {
+					roles.add(role);
+				}
+			}
+			res.setData(newAdminService.insertNewAdmin(ad,roles));
+		}
+
+		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 = newAdminService.selectByMobile(admin.getMobile().trim());
+			if (null != aa && !admin.getId().equals(aa.getId())) {
+				res.getError().add(buildError(ErrorConstants.USER_ALREADY_EXIST, "当前用户已注册!"));
+				return res;
+			}
+
+			Admin a = newAdminService.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(newAdminService.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 = newAdminService.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(newAdminService.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;
+	}
+	/** 图片上传 **/
+	@RequestMapping(value = "/uploadAdminImg", method = RequestMethod.POST)
+	public Result uploadCustomerImg(HttpServletRequest req,String sign){
+		Result res = new Result();
+		res.setData(handleFile(res, "/customer_sys_file/", false, req, sign));
+		return res;
+	}
+	
+	/**新增获取ID**/
+	@RequestMapping(value = "/newId", method = RequestMethod.POST)
+	public Result newId(){
+		Result res = new Result();		
+		res.setData(UUID.randomUUID().toString());		
+		return res;
+	}
+	/**编辑页面信息获取**/
+	@RequestMapping(value = "/selectAllByid", method = RequestMethod.POST)
+	public Result selectAllByid(String id){
+		Result res = new Result();
+		res.setData(newAdminService.selectAllByid(id));
+		return res;
+	}
 }

+ 58 - 0
src/main/java/com/goafanti/admin/service/NewAdminService.java

@@ -1,8 +1,66 @@
 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 NewAdminService {
 	Pagination<AdminListBo> listAdmin(AdminListBo alb,String rid,Integer pageNo, Integer pageSize);
+	
+	List<Admin> selectAllAdmin();
+
+	Admin selectByMobile(String username);
+
+	Admin selectByPrimaryKey(String key);
+
+	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, List<String> roleIds);
+
+	Map<String, String> listAdminSelect();
+
+	List<Admin> listAdminByName(String name);
+	
+	Admin selectAllByid(String id);	
+	
 }

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

@@ -1,19 +1,26 @@
 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 {
@@ -37,7 +44,252 @@ public class NewAdminServiceImpl extends BaseMybatisDao<AdminMapper> implements
 		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()));
+		}
 		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());
+		}
+		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);
+		}	
+		int count=adminMapper.updateByPrimaryKeySelective(ad);
+		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("0");
+		}
+		return admin;
+	}
 
 }

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

@@ -59,5 +59,19 @@ public interface AdminMapper {
 	List<Admin> listAdminSelectByAreaAdmin(@Param("provinceList")List<Integer> provinceList, @Param("cityList")List<Integer> cityList);
 	
 	List<Admin> listAdminByName(@Param("name")String name);
+	
+	int insertn(Admin record);
+	
+	String selectUserNoBySuperiorId(String superiorId);
+	
+	int selectCountBySuperiorId(String superiorId);
+	
+	String selectIdByUserNo(String userNo);
+	
+	Admin selectAllByid(String id);
+	
+	String selectNameByid(String id);
+	
+	List<String>selectRolesByUid(String id);
 
 }

+ 80 - 2
src/main/java/com/goafanti/common/mapper/AdminMapper.xml

@@ -154,6 +154,21 @@
       <if test="departmentId != null">
      	department_id = #{departmentId,jdbcType=VARCHAR},
       </if>
+      <if test="status != null">
+     	status = #{status,jdbcType=VARCHAR},
+      </if>
+      <if test="userNo != null">
+     	user_no = #{userNo,jdbcType=VARCHAR},
+      </if>
+      <if test="duty != null">
+     	duty = #{duty,jdbcType=VARCHAR},
+      </if>
+      <if test="district != null">
+     	district = #{district,jdbcType=VARCHAR},
+      </if>
+      <if test="headPortraitUrl != null">
+     	head_portrait_url = #{headPortraitUrl,jdbcType=VARCHAR},
+      </if>
     </set>
     where id = #{id,jdbcType=VARCHAR}
   </update>
@@ -389,6 +404,7 @@
     left join department_management dm on a.department_id = dm.id
     left join user_role ur on a.id=ur.uid
     where a.id <![CDATA[ <> ]]> '1'
+    and (a.status !='注销' or a.status is null)
     <if test = "name != null"> 
     	and a.name = #{name,jdbcType=VARCHAR}
     </if>
@@ -412,16 +428,19 @@
     </if>
     <if test = "superiorId != null"> 
    		and a.superior_id = #{superiorId,jdbcType=VARCHAR}
-    </if>    
+    </if>
+    group by a.id
     order by a.number 
     <if test="page_sql!=null">
 			${page_sql}
 	</if>
   </select>
   <select id = "selectAdminCount" parameterType="java.lang.String" resultType="java.lang.Integer">
-   	select count(1) from admin a
+   	select count(t.counts) 
+   	from(select id,count(*) counts from admin a
    	left join user_role ur on a.id=ur.uid
     where id <![CDATA[ <> ]]> '1'
+    and (a.status != '注销' or a.status is null)
     <if test = "name != null"> 
     	and a.name = #{name,jdbcType=VARCHAR}
     </if>
@@ -446,5 +465,64 @@
     <if test = "superiorId != null"> 
    		and a.superior_id = #{superiorId,jdbcType=VARCHAR}
     </if>
+    group by a.mobile)t
+  </select>
+  <insert id="insertn" parameterType="com.goafanti.common.model.Admin" >
+    insert into admin (id, mobile, name, 
+      password, email, create_time, 
+      number, province, position, superior_id, city,department_id,status,user_no,duty,district,head_portrait_url)
+    values (#{id,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, 
+      #{password,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
+      #{number,jdbcType=INTEGER}, #{province,jdbcType=INTEGER}, #{position,jdbcType=VARCHAR},
+      #{superiorId,jdbcType=VARCHAR}, #{city,jdbcType=INTEGER},#{departmentId,jdbcType=VARCHAR},
+      #{status,jdbcType=VARCHAR},#{userNo,jdbcType=VARCHAR},#{duty,jdbcType=VARCHAR},#{district,jdbcType=VARCHAR},#{headPortraitUrl,jdbcType=VARCHAR}
+      )
+  </insert>
+  <select id="selectUserNoBySuperiorId" parameterType="java.lang.String" resultType="java.lang.String">
+  	select 
+   		user_no as userNo
+    from admin 
+    where
+    	id=#{superiorId,jdbcType=VARCHAR}
+  </select>
+  <select id="selectCountBySuperiorId" parameterType="java.lang.String" resultType="java.lang.Integer">
+  	select 
+   		count(1)
+    from admin 
+    where
+    	superior_id=#{superiorId,jdbcType=VARCHAR}
+  </select>
+  <select id="selectIdByUserNo" parameterType="java.lang.String" resultType="java.lang.String">
+  		select
+  		id
+  		from admin
+  		where
+  		user_no=#{UserNo,jdbcType=VARCHAR}
+  </select>
+  <select id= "selectAllByid" parameterType="java.lang.String" resultType="com.goafanti.common.model.Admin" >
+  	select 
+   	  id, mobile, name, 
+      password, email, create_time as createTime, 
+      province, position, 
+      superior_id as superiorId,department_id as departmentId,
+      status,user_no as userNo,duty,district,head_portrait_url as headPortraitUrl
+    from admin 
+    where 
+    id=#{id,jdbcType=VARCHAR}
+  </select>
+  <select id= "selectNameByid" parameterType="java.lang.String" resultType="java.lang.String" >
+  	select 
+   	  name
+    from admin 
+    where 
+    id=#{id,jdbcType=VARCHAR}
+  </select>
+  <select id= "selectRolesByUid" parameterType="java.lang.String" resultType="java.lang.String">
+  	select
+  	  r.role_name as roles
+  	from user_role ur
+  	left join role r on r.id = ur.rid
+  	where
+  	uid=#{id,jdbcType=VARCHAR}
   </select>
 </mapper>

+ 1 - 1
src/main/java/com/goafanti/common/mapper/OrganizationManagementMapper.xml

@@ -478,7 +478,7 @@
 	</select>
 	<select id="selectName" resultType="com.goafanti.admin.bo.AdminListBo">
 		select
-		name
+		name,id
 		from admin
 		where
 		name  like concat('%',#{name,jdbcType=VARCHAR},'%')

+ 76 - 1
src/main/java/com/goafanti/common/model/Admin.java

@@ -47,7 +47,7 @@ public class Admin extends BaseModel implements AftUser {
 	 */
 	private Integer				province;
 	/**
-	 * 
+	 * 
 	 */
 	private String				position;
 
@@ -55,6 +55,11 @@ public class Admin extends BaseModel implements AftUser {
 	 * 上级管理用户ID
 	 */
 	private String				superiorId;
+	
+	/**
+	 * 上级管理用户名称
+	 */
+	private String	superior;
 
 	/**
 	 * 所在市
@@ -65,7 +70,77 @@ public class Admin extends BaseModel implements AftUser {
 	 * 部门管理
 	 */
 	private String 				departmentId;
+	/**
+	 * 用户状态
+	 */
+	private String 				status;
+	/**
+	 * 用户编号
+	 */
+	private String 				userNo;
+	/**
+	 * 职务
+	 */
+	private String 				duty;
+	
+	/**
+	 * 地区
+	 */
+	private String 				district;
+	
+	/**
+	 * 用户头像
+	 */
+	private String 				headPortraitUrl;	
 	
+	public String getSuperior() {
+		return superior;
+	}
+
+	public void setSuperior(String superior) {
+		this.superior = superior;
+	}
+
+	public String getHeadPortraitUrl() {
+		return headPortraitUrl;
+	}
+
+	public void setHeadPortraitUrl(String headPortraitUrl) {
+		this.headPortraitUrl = headPortraitUrl;
+	}
+
+	public String getDistrict() {
+		return district;
+	}
+
+	public void setDistrict(String district) {
+		this.district = district;
+	}
+
+	public String getStatus() {
+		return status;
+	}
+
+	public void setStatus(String status) {
+		this.status = status;
+	}
+
+	public String getUserNo() {
+		return userNo;
+	}
+
+	public void setUserNo(String userNo) {
+		this.userNo = userNo;
+	}
+
+	public String getDuty() {
+		return duty;
+	}
+
+	public void setDuty(String duty) {
+		this.duty = duty;
+	}
+
 	public String getSuperiorId() {
 		return superiorId;
 	}