Merge remote-tracking branch 'origin/dev' into dev
# Conflicts:
#	screen-common/src/main/java/com/moral/constant/ResponseCodeEnum.java
	
		
		1 files deleted
	
		
		1 files added
	
		
		10 files modified
	
	
 
	
	
	
	
	
	
	
	
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.moral.api.controller; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParam; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParams; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.servlet.http.HttpServletRequest; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Value; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestMethod; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RestController; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.moral.api.entity.Group; | 
|---|
|  |  |  | import com.moral.api.entity.User; | 
|---|
|  |  |  | import com.moral.api.service.GroupService; | 
|---|
|  |  |  | import com.moral.api.service.UserService; | 
|---|
|  |  |  | import com.moral.constant.ResponseCodeEnum; | 
|---|
|  |  |  | import com.moral.constant.ResultMessage; | 
|---|
|  |  |  | import com.moral.util.AESUtils; | 
|---|
|  |  |  | import com.moral.util.MD5Utils; | 
|---|
|  |  |  | import com.moral.util.TokenUtils; | 
|---|
|  |  |  | import com.moral.util.WebUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Api(tags = {"登陆"}) | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | public class LoginController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private UserService userService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private GroupService groupService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${AES.KEY}") | 
|---|
|  |  |  | private String AESKey; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "登陆", notes = "登陆") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "account", value = "账户", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "password", value = "密码", required = false, paramType = "query", dataType = "String") | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @RequestMapping(value = "login", method = RequestMethod.POST) | 
|---|
|  |  |  | public ResultMessage login(HttpServletRequest request) { | 
|---|
|  |  |  | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); | 
|---|
|  |  |  | if (!(parameters.containsKey("account") && parameters.containsKey("password"))) { | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //接收参数 | 
|---|
|  |  |  | String password = parameters.get("password").toString(); | 
|---|
|  |  |  | //密码解密 | 
|---|
|  |  |  | password = AESUtils.decrypt(password, AESKey); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | User user = userService.selectUserInfo(parameters); | 
|---|
|  |  |  | //校验账户 | 
|---|
|  |  |  | if (user == null) { | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getCode(), ResponseCodeEnum.ACCOUNT_NOT_EXIST.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //校验密码 | 
|---|
|  |  |  | if (!MD5Utils.saltMD5Verify(password, user.getPassword())) { | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.PASSWORD_INVALID.getCode(), ResponseCodeEnum.PASSWORD_INVALID.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //校验是否删除 | 
|---|
|  |  |  | if ("1".equals(user.getIsDelete())) { | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.ACCOUNT_IS_DELETE.getCode(), ResponseCodeEnum.ACCOUNT_IS_DELETE.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //校验是否过期 | 
|---|
|  |  |  | if (user.getExpireTime() != null && user.getExpireTime().getTime() < System.currentTimeMillis()) { | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.ACCOUNT_IS_EXPIRE.getCode(), ResponseCodeEnum.ACCOUNT_IS_EXPIRE.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Map<String, Object> result = userService.login(user); | 
|---|
|  |  |  | if (!result.containsKey("token")) { | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.TOKEN_CREATE_ERROR.getCode(), ResponseCodeEnum.TOKEN_CREATE_ERROR.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ResultMessage.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "注销", notes = "注销") | 
|---|
|  |  |  | @RequestMapping(value = "logout", method = RequestMethod.POST) | 
|---|
|  |  |  | public ResultMessage logout(HttpServletRequest request) { | 
|---|
|  |  |  | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); | 
|---|
|  |  |  | if (!parameters.containsKey("uid")) { | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String userId = request.getParameter("uid"); | 
|---|
|  |  |  | String token = request.getHeader("token"); | 
|---|
|  |  |  | TokenUtils.destoryToken(userId, token); | 
|---|
|  |  |  | return ResultMessage.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "添加组", notes = "添加组") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "groupName", value = "组名", required = true, paramType = "query", dataType = "String") | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @RequestMapping(value = "addGroup", method = RequestMethod.POST) | 
|---|
|  |  |  | private ResultMessage addGroup(Group group, HttpServletRequest request) { | 
|---|
|  |  |  | String currentUserId = request.getHeader("uid"); | 
|---|
|  |  |  | Map<String, Object> map = groupService.addGroup(group, currentUserId); | 
|---|
|  |  |  | String msg = map.get("msg").toString(); | 
|---|
|  |  |  | boolean flag = Boolean.parseBoolean(map.get("flag").toString()); | 
|---|
|  |  |  | if (flag) { | 
|---|
|  |  |  | return ResultMessage.ok(msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ResultMessage.fail(msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.moral.api.entity.User; | 
|---|
|  |  |  | import com.moral.api.service.UserService; | 
|---|
|  |  |  | import com.moral.constant.ResponseCodeEnum; | 
|---|
|  |  |  | import com.moral.constant.ResultMessage; | 
|---|
|  |  |  | import com.moral.util.WebUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | public ResultMessage addUser(User user, HttpServletRequest request) { | 
|---|
|  |  |  | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); | 
|---|
|  |  |  | if (!(parameters.containsKey("account") && parameters.containsKey("password"))) { | 
|---|
|  |  |  | return ResultMessage.fail("账户及密码不允许为空!"); | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String token = request.getHeader("token"); | 
|---|
|  |  |  | Map<String, Object> map = userService.addUser(user, token); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (map.containsKey("msg")) { | 
|---|
|  |  |  | return ResultMessage.fail(map.get("msg").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Set; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.persistence.Transient; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String isDelete; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transient | 
|---|
|  |  |  | private Organization organization; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transient | 
|---|
|  |  |  | private List<Group> groups; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | protected Serializable pkVal() { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | 
|---|
|  |  |  | /*if (!(handler instanceof HandlerMethod)) { | 
|---|
|  |  |  | if (!(handler instanceof HandlerMethod)) { | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String token = form.getHeader("token"); | 
|---|
|  |  |  | String token = request.getHeader("token"); | 
|---|
|  |  |  | if (token == null) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | TokenUtils.extendTokenTime(token); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | }*/ | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public interface GroupMapper extends BaseMapper<Group> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Map<String, Object>> selectUserGroup(int userId); | 
|---|
|  |  |  | List<Map<String, Object>> selectUserGroup(Map<String, Object> parameters); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | public interface UserMapper extends BaseMapper<User> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Map<String, Object>> selectUsers(Map<String, Object> parameters); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | User selectUserInfo(Map<String, Object> parameters); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public interface UserService extends IService<User> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Object> login(Map<String, Object> parameters); | 
|---|
|  |  |  | Map<String, Object> login(User user); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Object> addUser(User user, String token); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Object> getUsers(Map<String, Object> parameters); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | User selectUserInfo(Map<String, Object> parameters); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.moral.api.entity.Group; | 
|---|
|  |  |  | import com.moral.api.entity.Menu; | 
|---|
|  |  |  | import com.moral.api.entity.Organization; | 
|---|
|  |  |  | import com.moral.api.entity.User; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.moral.api.mapper.GroupMapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | private UserMapper userMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private GroupMapper groupMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MenuMapper menuMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrganizationMapper organizationMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${AES.KEY}") | 
|---|
|  |  |  | private String AESKey; | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public User selectUserInfo(Map<String, Object> parameters) { | 
|---|
|  |  |  | return userMapper.selectUserInfo(parameters); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Map<String, Object> login(Map<String, Object> parameters) { | 
|---|
|  |  |  | public Map<String, Object> login(User user) { | 
|---|
|  |  |  | Map<String, Object> resultMap = new LinkedHashMap<>(); | 
|---|
|  |  |  | //接收参数 | 
|---|
|  |  |  | String account = parameters.get("account").toString(); | 
|---|
|  |  |  | String password = parameters.get("password").toString(); | 
|---|
|  |  |  | //解密 | 
|---|
|  |  |  | /*account = AESUtils.decrypt(account, AESKey); | 
|---|
|  |  |  | password = AESUtils.decrypt(password, AESKey);*/ | 
|---|
|  |  |  | QueryWrapper<User> queryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | //校验账户 | 
|---|
|  |  |  | queryWrapper.eq("account", account); | 
|---|
|  |  |  | User user = userMapper.selectOne(queryWrapper); | 
|---|
|  |  |  | String msg; | 
|---|
|  |  |  | if (user == null) { | 
|---|
|  |  |  | msg = "用户名不存在"; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | if (!MD5Utils.saltMD5Verify(password, user.getPassword())) {//校验密码 | 
|---|
|  |  |  | msg = "密码错误"; | 
|---|
|  |  |  | } else if ("1".equals(user.getIsDelete())) { | 
|---|
|  |  |  | msg = "账户已被删除"; | 
|---|
|  |  |  | } else if (user.getExpireTime() != null && user.getExpireTime().getTime() < System.currentTimeMillis()) { | 
|---|
|  |  |  | msg = "你的账户已过期"; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | int userId = user.getId(); | 
|---|
|  |  |  | //查询地图等级 | 
|---|
|  |  |  | Map<String, Object> orgMap = organizationMapper.selectOrganizationById(user.getOrganizationId()); | 
|---|
|  |  |  | String locationCode = orgMap.get(orgMap.get("location_level").toString()).toString(); | 
|---|
|  |  |  | //封装用户信息 | 
|---|
|  |  |  | Map<String, Object> userInfo = new LinkedHashMap<>(); | 
|---|
|  |  |  | userInfo.put("userId", userId); | 
|---|
|  |  |  | userInfo.put("account", user.getAccount()); | 
|---|
|  |  |  | userInfo.put("userName", user.getUserName()); | 
|---|
|  |  |  | userInfo.put("organizationId", user.getOrganizationId()); | 
|---|
|  |  |  | userInfo.put("locationCode", locationCode); | 
|---|
|  |  |  | userInfo.put("expireTime", user.getExpireTime()); | 
|---|
|  |  |  | userInfo.put("isAdmin", user.getIsAdmin()); | 
|---|
|  |  |  | List<Map<String, Object>> groups = groupMapper.selectUserGroup(userId); | 
|---|
|  |  |  | userInfo.put("groups", groups); | 
|---|
|  |  |  | userInfo.putAll(getMenus(userId)); | 
|---|
|  |  |  | //生成token,并存入redis | 
|---|
|  |  |  | String token = TokenUtils.getToken(user.getId().toString(), userInfo); | 
|---|
|  |  |  | resultMap.put("token", token); | 
|---|
|  |  |  | resultMap.putAll(userInfo); | 
|---|
|  |  |  | return resultMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //封装用户信息 | 
|---|
|  |  |  | Map<String, Object> userInfo = new LinkedHashMap<>(); | 
|---|
|  |  |  | List<Map<String, Object>> groups = new ArrayList<>(); | 
|---|
|  |  |  | for (Group group : user.getGroups()) { | 
|---|
|  |  |  | HashMap<String, Object> groupMap = new HashMap<>(); | 
|---|
|  |  |  | groupMap.put("groupId", group.getId()); | 
|---|
|  |  |  | groupMap.put("groupName", group.getGroupName()); | 
|---|
|  |  |  | groups.add(groupMap); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | resultMap.put("msg", msg); | 
|---|
|  |  |  | Organization organization = user.getOrganization(); | 
|---|
|  |  |  | userInfo.put("userId", user.getId()); | 
|---|
|  |  |  | userInfo.put("account", user.getAccount()); | 
|---|
|  |  |  | userInfo.put("userName", user.getUserName()); | 
|---|
|  |  |  | userInfo.put("expireTime", user.getExpireTime()); | 
|---|
|  |  |  | userInfo.put("isAdmin", user.getIsAdmin()); | 
|---|
|  |  |  | userInfo.put("organizationId", user.getOrganizationId()); | 
|---|
|  |  |  | userInfo.put("organizationName", organization.getName()); | 
|---|
|  |  |  | userInfo.put("locationLevel", organization.getLocationLevel()); | 
|---|
|  |  |  | userInfo.put("groups", groups); | 
|---|
|  |  |  | userInfo.putAll(getMenus(user.getId())); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | //生成token,并存入redis | 
|---|
|  |  |  | String token = TokenUtils.getToken(user.getId().toString(), userInfo); | 
|---|
|  |  |  | resultMap.put("token", token); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("token生成异常:"+e.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | resultMap.putAll(userInfo); | 
|---|
|  |  |  | return resultMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | Map<String, Object> resultMap = new HashMap<>(); | 
|---|
|  |  |  | Map<String, Object> currentUserInfo = (Map<String, Object>) TokenUtils.getUserInfoByToken(token); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!(boolean) currentUserInfo.get("isAdmin")) { | 
|---|
|  |  |  | resultMap.put("msg", "没有权限"); | 
|---|
|  |  |  | return resultMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | QueryWrapper<User> queryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | queryWrapper.eq("account", user.getAccount()); | 
|---|
|  |  |  | userMapper.selectOne(queryWrapper); | 
|---|
|  |  |  | if (userMapper.selectOne(queryWrapper) != null) { | 
|---|
|  |  |  | resultMap.put("msg", "账户名已存在"); | 
|---|
|  |  |  | return resultMap; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return msgs; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | <resultMap id="GroupResultMap" type="java.util.LinkedHashMap"> | 
|---|
|  |  |  | <id column="id" property="id"/> | 
|---|
|  |  |  | <result column="group_name" property="groupName"/> | 
|---|
|  |  |  | <result column="organization_id" property="organizationId"/> | 
|---|
|  |  |  | </resultMap> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectUserGroup" resultMap="GroupResultMap"> | 
|---|
|  |  |  | 
|---|
|  |  |  | <result column="update_time" property="updateTime"/> | 
|---|
|  |  |  | <result column="expire_time" property="expireTime"/> | 
|---|
|  |  |  | <result column="is_delete" property="isDelete"/> | 
|---|
|  |  |  | <!--用户组织--> | 
|---|
|  |  |  | <association property="organization" javaType="com.moral.api.entity.Organization"> | 
|---|
|  |  |  | <result column="id" property="id" jdbcType="INTEGER"/> | 
|---|
|  |  |  | <result column="name" property="name" jdbcType="VARCHAR"/> | 
|---|
|  |  |  | <result column="location_level" property="locationLevel"/> | 
|---|
|  |  |  | </association> | 
|---|
|  |  |  | <!--用户组--> | 
|---|
|  |  |  | <collection property="groups" ofType="com.moral.api.entity.Group" javaType = "java.util.ArrayList"> | 
|---|
|  |  |  | <id column="groupId" property="id" jdbcType="INTEGER"/> | 
|---|
|  |  |  | <result column="group_name" property="groupName" jdbcType="VARCHAR"/> | 
|---|
|  |  |  | </collection> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </resultMap> | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectUserInfo" resultMap="BaseResultMap"> | 
|---|
|  |  |  | SELECT u.id,u.account,u.password,u.user_name,u.organization_id,u.expire_time,u.is_delete, | 
|---|
|  |  |  | o.name,u.is_admin,o.location_level, | 
|---|
|  |  |  | g.id groupId,g.group_name | 
|---|
|  |  |  | FROM `user` u, | 
|---|
|  |  |  | `organization` o, | 
|---|
|  |  |  | `user_group` ug, | 
|---|
|  |  |  | `group` g | 
|---|
|  |  |  | WHERE u.account = #{account} | 
|---|
|  |  |  | AND u.organization_id=o.id | 
|---|
|  |  |  | AND  u.id = ug.user_id | 
|---|
|  |  |  | AND ug.group_id = g.id | 
|---|
|  |  |  | AND g.is_delete = 0 | 
|---|
|  |  |  | AND ug.is_delete = 0 | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectUsers" resultType="java.util.Map"> | 
|---|
|  |  |  | SELECT id,account,user_name userName,email,mobile,wechat FROM `user` WHERE | 
|---|
|  |  |  | <if test="orgId!=null"> | 
|---|
|  |  |  | 
|---|
|  |  |  | MOBILE_INVALID(-9,"手机号无效"), | 
|---|
|  |  |  | EMAIL_INVALID(-10,"邮箱无效"), | 
|---|
|  |  |  | ACCOUNT_INVALID(-11,"用户名无效"), | 
|---|
|  |  |  | PASSWORD_INVALID(-12,"密码无效") | 
|---|
|  |  |  | PASSWORD_INVALID(-12,"密码无效"), | 
|---|
|  |  |  | ACCOUNT_IS_EXPIRE(-13,"用户已过期") | 
|---|
|  |  |  | ; | 
|---|
|  |  |  | private final Integer code; | 
|---|
|  |  |  | private final String  msg; | 
|---|