2 files added
	
		
		7 files modified
	
	
 
	
	
	
	
	
	
	
	
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Api(tags = {"大屏"}) | 
|---|
|  |  |  | @Api(tags = {"测试"}) | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping("/api") | 
|---|
|  |  |  | @RequestMapping("/test") | 
|---|
|  |  |  | public class TestController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
| 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.web.bind.annotation.RequestMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestMethod; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RestController; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.moral.api.entity.User; | 
|---|
|  |  |  | import com.moral.api.service.UserService; | 
|---|
|  |  |  | import com.moral.constant.ResultMessage; | 
|---|
|  |  |  | import com.moral.util.WebUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Api(tags = {"用户"}) | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping("/user") | 
|---|
|  |  |  | public class UserController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private UserService userService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "添加账户", notes = "添加账户") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "account", value = "账户,长度6-10", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "password", value = "密码,长度6-20", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "userName", value = "账户名称", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "email", value = "邮箱,格式123456@qq.com", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "mobile", value = "手机号,1开头11为数字", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "wechat", value = "微信", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @RequestMapping(value = "addUser", method = RequestMethod.POST) | 
|---|
|  |  |  | 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("账户及密码不允许为空!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String token = request.getHeader("token"); | 
|---|
|  |  |  | Map<String, Object> map = userService.addUser(user, token); | 
|---|
|  |  |  | if (map.containsKey("msg")) { | 
|---|
|  |  |  | return ResultMessage.fail(map.get("msg").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ResultMessage.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "删除账户", notes = "删除账户") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "userId", value = "用户id", required = true, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @RequestMapping(value = "deleteUser", method = RequestMethod.POST) | 
|---|
|  |  |  | public ResultMessage deleteUser(String userId, HttpServletRequest request) { | 
|---|
|  |  |  | if (userId == null) { | 
|---|
|  |  |  | return ResultMessage.fail("请求参数错误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String token = request.getHeader("token"); | 
|---|
|  |  |  | Map<String, Object> map = userService.deleteUser(Integer.parseInt(userId), token); | 
|---|
|  |  |  | if (map.containsKey("msg")) { | 
|---|
|  |  |  | return ResultMessage.fail(map.get("msg").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ResultMessage.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "修改账户信息", notes = "修改账户信息") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "account", value = "账户,长度6-10", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "password", value = "密码,长度6-20", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "userName", value = "账户名称", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "email", value = "邮箱,格式123456@qq.com", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "mobile", value = "手机号,1开头11位数字", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "wechat", value = "微信", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @RequestMapping(value = "updateUser", method = RequestMethod.POST) | 
|---|
|  |  |  | public ResultMessage updateUser(User user, HttpServletRequest request) { | 
|---|
|  |  |  | String token = request.getHeader("token"); | 
|---|
|  |  |  | Map<String, Object> map = userService.updateUser(user, token); | 
|---|
|  |  |  | if (map.containsKey("msg")) { | 
|---|
|  |  |  | return ResultMessage.fail(map.get("msg").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ResultMessage.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "查询账户信息", notes = "查询账户信息") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "userId", value = "用户id", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @RequestMapping(value = "getUserInfo", method = RequestMethod.POST) | 
|---|
|  |  |  | public ResultMessage getUserInfo(HttpServletRequest request) { | 
|---|
|  |  |  | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); | 
|---|
|  |  |  | parameters.put("token", request.getHeader("token")); | 
|---|
|  |  |  | Map<String, Object> users = userService.getUsers(parameters); | 
|---|
|  |  |  | if (users.containsKey("msg")) { | 
|---|
|  |  |  | return ResultMessage.fail(users.get("msg").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ResultMessage.ok(users.get("users")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | 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.ResultMessage; | 
|---|
|  |  |  | import com.moral.redis.RedisUtil; | 
|---|
|  |  |  | import com.moral.util.TokenUtils; | 
|---|
|  |  |  | import com.moral.util.WebUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "登陆", notes = "登陆") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "account", value = "账户", required = true, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "query", dataType = "String") | 
|---|
|  |  |  | @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("用户名及密码不允许为空!"); | 
|---|
|  |  |  | return ResultMessage.fail("账户及密码不允许为空!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Map<String, Object> map = userService.login(parameters); | 
|---|
|  |  |  | if (map.get("token") == null) { | 
|---|
|  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "注销", notes = "注销") | 
|---|
|  |  |  | @RequestMapping(value = "logout", method = RequestMethod.POST) | 
|---|
|  |  |  | public ResultMessage logout(HttpServletRequest request) { | 
|---|
|  |  |  | String userId = request.getHeader("uid"); | 
|---|
|  |  |  | String token = request.getHeader("token"); | 
|---|
|  |  |  | if (token == null) { | 
|---|
|  |  |  | return ResultMessage.fail("未登陆"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | RedisUtil.del(token); | 
|---|
|  |  |  | TokenUtils.destoryToken(userId, token); | 
|---|
|  |  |  | return ResultMessage.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "添加账户", notes = "添加账户") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "account", value = "账户", required = true, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "userName", value = "账户名称", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "email", value = "邮箱", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "mobile", value = "手机号", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "wechat", value = "微信", required = false, paramType = "query", dataType = "String") | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @RequestMapping(value = "addUser", method = RequestMethod.POST) | 
|---|
|  |  |  | public ResultMessage addUser(User user, HttpServletRequest request) { | 
|---|
|  |  |  | Integer currentUserId = Integer.parseInt(request.getHeader("uid")); | 
|---|
|  |  |  | Map<String, Object> map = userService.addUser(user, 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "删除账户", notes = "删除账户") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "userId", value = "用户id", required = true, paramType = "path", dataType = "String") | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @RequestMapping(value = "deleteUser/{userId}", method = RequestMethod.GET) | 
|---|
|  |  |  | public ResultMessage deleteUser(@PathVariable("userId") String userId, HttpServletRequest request) { | 
|---|
|  |  |  | Integer currentUserId = Integer.parseInt(request.getHeader("uid")); | 
|---|
|  |  |  | Map<String, Object> map = userService.deleteUser(Integer.parseInt(userId), 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "修改用户信息", notes = "修改用户信息") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "account", value = "账户", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "password", value = "密码", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "userName", value = "账户名称", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "email", value = "邮箱", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "mobile", value = "手机号", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "wechat", value = "微信", required = false, paramType = "query", dataType = "String") | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @RequestMapping(value = "updateUser", method = RequestMethod.POST) | 
|---|
|  |  |  | public ResultMessage updateUser(User user, HttpServletRequest request) { | 
|---|
|  |  |  | Integer currentUserId = Integer.parseInt(request.getHeader("uid")); | 
|---|
|  |  |  | Map<String, Object> map = userService.updateUser(user, 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "查询用户信息", notes = "查询用户信息") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "userId", value = "用户id", required = false, paramType = "path", dataType = "String") | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @RequestMapping(value = "getUserInfo/{userId}", method = RequestMethod.GET) | 
|---|
|  |  |  | public ResultMessage getUserInfo(@PathVariable("userId") String userId, HttpServletRequest request) { | 
|---|
|  |  |  | Integer currentUserId = Integer.parseInt(request.getHeader("uid")); | 
|---|
|  |  |  | if (userId == null) { | 
|---|
|  |  |  | List<User> users = userService.getUsersByOrgId(currentUserId); | 
|---|
|  |  |  | return ResultMessage.ok(users); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | User user = userService.getUserById(Integer.parseInt(userId), currentUserId); | 
|---|
|  |  |  | return ResultMessage.ok(user); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "添加组", notes = "添加组") | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.web.servlet.HandlerInterceptor; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.moral.redis.RedisUtil; | 
|---|
|  |  |  | import com.moral.util.TokenUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Component | 
|---|
|  |  |  | public class AuthenticationInterceptor implements HandlerInterceptor { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | 
|---|
|  |  |  | request.getSession(); | 
|---|
|  |  |  | if (!(handler instanceof HandlerMethod)) { | 
|---|
|  |  |  | /*if (!(handler instanceof HandlerMethod)) { | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String token = request.getHeader("token"); | 
|---|
|  |  |  | if (token != null) { | 
|---|
|  |  |  | return RedisUtil.hasKey(token); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (token == null) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | //校验token | 
|---|
|  |  |  | TokenUtils.checkToken(token); | 
|---|
|  |  |  | //延长token | 
|---|
|  |  |  | TokenUtils.extendTokenTime(token); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | }*/ | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | package com.moral.api.mapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Set; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.moral.api.entity.Group; | 
|---|
|  |  |  | import com.moral.api.entity.Menu; | 
|---|
|  |  |  | import com.moral.api.entity.User; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public interface UserMapper extends BaseMapper<User> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Map<String, Object>> selectUsers(Map<String, Object> parameters); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Object> login(Map<String,Object> parameters); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Object> addUser(User user, Integer currentUserId); | 
|---|
|  |  |  | Map<String, Object> addUser(User user, String token); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Object> deleteUser(Integer userId, Integer currentUserId); | 
|---|
|  |  |  | Map<String, Object> deleteUser(int userId, String token); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Object> updateUser(User user, Integer currentUserId); | 
|---|
|  |  |  | Map<String, Object> updateUser(User user, String token); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<User> getUsersByOrgId(Integer currentUserId); | 
|---|
|  |  |  | Map<String, Object> getUsers(Map<String, Object> parameters); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | User getUserById(Integer userId, Integer currentUserId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Comparator; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.LinkedHashMap; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
|---|
|  |  |  | import com.moral.util.AESUtils; | 
|---|
|  |  |  | import com.moral.util.MD5Utils; | 
|---|
|  |  |  | import com.moral.util.RegexUtils; | 
|---|
|  |  |  | import com.moral.util.TokenUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | 
|---|
|  |  |  | String account = parameters.get("account").toString(); | 
|---|
|  |  |  | String password = parameters.get("password").toString(); | 
|---|
|  |  |  | //解密 | 
|---|
|  |  |  | account = AESUtils.decrypt(account, AESKey); | 
|---|
|  |  |  | password = AESUtils.decrypt(password, AESKey); | 
|---|
|  |  |  | /*account = AESUtils.decrypt(account, AESKey); | 
|---|
|  |  |  | password = AESUtils.decrypt(password, AESKey);*/ | 
|---|
|  |  |  | QueryWrapper<User> queryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | //校验账户 | 
|---|
|  |  |  | queryWrapper.eq("account", account); | 
|---|
|  |  |  | 
|---|
|  |  |  | 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)); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Map<String, Object> addUser(User user, Integer userId) { | 
|---|
|  |  |  | public Map<String, Object> addUser(User user, String token) { | 
|---|
|  |  |  | Map<String, Object> resultMap = new HashMap<>(); | 
|---|
|  |  |  | User currentUser = userMapper.selectById(userId); | 
|---|
|  |  |  | if (!currentUser.getIsAdmin()) { | 
|---|
|  |  |  | resultMap.put("flag", false); | 
|---|
|  |  |  | resultMap.put("msg", "添加失败,没有权限"); | 
|---|
|  |  |  | 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) { | 
|---|
|  |  |  | user.setOrganizationId(currentUser.getOrganizationId()); | 
|---|
|  |  |  | user.setExpireTime(currentUser.getExpireTime()); | 
|---|
|  |  |  | userMapper.insert(user); | 
|---|
|  |  |  | resultMap.put("flag", true); | 
|---|
|  |  |  | resultMap.put("msg", "添加成功"); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | resultMap.put("flag", false); | 
|---|
|  |  |  | resultMap.put("msg", "添加失败,账户名已存在"); | 
|---|
|  |  |  | if (userMapper.selectOne(queryWrapper) != null) { | 
|---|
|  |  |  | resultMap.put("msg", "账户名已存在"); | 
|---|
|  |  |  | return resultMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //校验用户信息是否符合规则 | 
|---|
|  |  |  | List<String> msgs = checkUserInfo(user); | 
|---|
|  |  |  | if (!msgs.isEmpty()) { | 
|---|
|  |  |  | resultMap.put("msg", msgs); | 
|---|
|  |  |  | return resultMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //密码加密 | 
|---|
|  |  |  | String password = MD5Utils.saltMD5(user.getPassword()); | 
|---|
|  |  |  | user.setPassword(password); | 
|---|
|  |  |  | user.setIsAdmin(false); | 
|---|
|  |  |  | user.setOrganizationId(Integer.parseInt(currentUserInfo.get("organizationId").toString())); | 
|---|
|  |  |  | //新增账户的过期时间 | 
|---|
|  |  |  | Date userExpireTime = user.getExpireTime(); | 
|---|
|  |  |  | //当前账户的过期时间 | 
|---|
|  |  |  | Date expireTime = (Date) currentUserInfo.get("expireTime"); | 
|---|
|  |  |  | if (userExpireTime == null || userExpireTime.getTime() > expireTime.getTime()) { | 
|---|
|  |  |  | user.setExpireTime(expireTime); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | userMapper.insert(user); | 
|---|
|  |  |  | return resultMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Map<String, Object> deleteUser(Integer userId, Integer currentUserId) { | 
|---|
|  |  |  | public Map<String, Object> deleteUser(int userId, String token) { | 
|---|
|  |  |  | Map<String, Object> resultMap = new HashMap<>(); | 
|---|
|  |  |  | User currentUser = userMapper.selectById(currentUserId); | 
|---|
|  |  |  | if (!currentUser.getIsAdmin()) { | 
|---|
|  |  |  | resultMap.put("flag", false); | 
|---|
|  |  |  | resultMap.put("msg", "删除失败,没有权限"); | 
|---|
|  |  |  | Map<String, Object> currentUserInfo = (Map<String, Object>) TokenUtils.getUserInfoByToken(token); | 
|---|
|  |  |  | if (!(boolean) currentUserInfo.get("isAdmin")) { | 
|---|
|  |  |  | resultMap.put("msg", "没有权限"); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | User user = new User(); | 
|---|
|  |  |  | user.setId(userId); | 
|---|
|  |  |  | user.setIsDelete("1"); | 
|---|
|  |  |  | userMapper.updateById(user); | 
|---|
|  |  |  | resultMap.put("flag", true); | 
|---|
|  |  |  | resultMap.put("msg", "删除成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return resultMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Map<String, Object> updateUser(User user, Integer currentUserId) { | 
|---|
|  |  |  | public Map<String, Object> updateUser(User user, String token) { | 
|---|
|  |  |  | Map<String, Object> resultMap = new HashMap<>(); | 
|---|
|  |  |  | User currentUser = userMapper.selectById(currentUserId); | 
|---|
|  |  |  | if (!currentUser.getIsAdmin()) { | 
|---|
|  |  |  | resultMap.put("flag", false); | 
|---|
|  |  |  | resultMap.put("msg", "修改失败,没有权限"); | 
|---|
|  |  |  | 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()); | 
|---|
|  |  |  | if (userMapper.selectOne(queryWrapper) == null) { | 
|---|
|  |  |  | userMapper.updateById(user); | 
|---|
|  |  |  | resultMap.put("flag", true); | 
|---|
|  |  |  | resultMap.put("msg", "修改成功"); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | resultMap.put("flag", false); | 
|---|
|  |  |  | resultMap.put("msg", "修改失败,账户已存在"); | 
|---|
|  |  |  | if (userMapper.selectOne(queryWrapper) != null) { | 
|---|
|  |  |  | resultMap.put("msg", "账户已存在"); | 
|---|
|  |  |  | return resultMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //校验用户信息是否符合规则 | 
|---|
|  |  |  | List<String> msgs = checkUserInfo(user); | 
|---|
|  |  |  | if (!msgs.isEmpty()) { | 
|---|
|  |  |  | resultMap.put("msg", msgs); | 
|---|
|  |  |  | return resultMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //密码Md5加密 | 
|---|
|  |  |  | user.setPassword(MD5Utils.saltMD5(user.getPassword())); | 
|---|
|  |  |  | userMapper.updateById(user); | 
|---|
|  |  |  | return resultMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<User> getUsersByOrgId(Integer currentUserId) { | 
|---|
|  |  |  | User currentUser = userMapper.selectById(currentUserId); | 
|---|
|  |  |  | if (!currentUser.getIsAdmin()) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | public Map<String, Object> getUsers(Map<String, Object> parameters) { | 
|---|
|  |  |  | Map<String, Object> resultMap = new HashMap<>(); | 
|---|
|  |  |  | Map<String, Object> currentUserInfo = (Map<String, Object>) TokenUtils.getUserInfoByToken(parameters.get("token").toString()); | 
|---|
|  |  |  | if (!(boolean) currentUserInfo.get("isAdmin")) { | 
|---|
|  |  |  | resultMap.put("msg", "没有权限"); | 
|---|
|  |  |  | return resultMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Map<String, Object> queryMap = new HashMap<>(); | 
|---|
|  |  |  | queryMap.put("organizationId", currentUser.getOrganizationId()); | 
|---|
|  |  |  | return userMapper.selectByMap(queryMap); | 
|---|
|  |  |  | if (!parameters.containsKey("userId")) { | 
|---|
|  |  |  | parameters.put("orgId", currentUserInfo.get("organizationId")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Map<String, Object>> users = userMapper.selectUsers(parameters); | 
|---|
|  |  |  | resultMap.put("users", users); | 
|---|
|  |  |  | return resultMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public User getUserById(Integer userId, Integer currentUserId) { | 
|---|
|  |  |  | User currentUser = userMapper.selectById(currentUserId); | 
|---|
|  |  |  | if (!currentUser.getIsAdmin()) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | private List<String> checkUserInfo(User user) { | 
|---|
|  |  |  | List<String> msgs = new ArrayList<>(); | 
|---|
|  |  |  | //验证账户 | 
|---|
|  |  |  | if (!RegexUtils.checkAccount(user.getAccount())) { | 
|---|
|  |  |  | msgs.add("账户格式不正确"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return userMapper.selectById(userId); | 
|---|
|  |  |  | //验证密码 | 
|---|
|  |  |  | if (!RegexUtils.checkPassword(user.getPassword())) { | 
|---|
|  |  |  | msgs.add("密码格式不正确"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //验证邮箱 | 
|---|
|  |  |  | if (user.getEmail() != null) { | 
|---|
|  |  |  | if (!RegexUtils.checkEmail(user.getEmail())) { | 
|---|
|  |  |  | msgs.add("邮箱格式不正确"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //验证手机号 | 
|---|
|  |  |  | if (user.getMobile() != null) { | 
|---|
|  |  |  | if (!RegexUtils.checkMobile(user.getMobile())) { | 
|---|
|  |  |  | msgs.add("手机号格式不正确"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return msgs; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | <result column="is_delete" property="isDelete"/> | 
|---|
|  |  |  | </resultMap> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectUsers" resultType="java.util.Map"> | 
|---|
|  |  |  | SELECT id,account,user_name userName,email,mobile,wechat FROM `user` WHERE | 
|---|
|  |  |  | <if test="orgId!=null"> | 
|---|
|  |  |  | organization_id = #{orgId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="userId!=null"> | 
|---|
|  |  |  | id = #{userId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | </mapper> | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.moral.util; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.regex.Matcher; | 
|---|
|  |  |  | import java.util.regex.Pattern; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class RegexUtils { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 验证账户名 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param account 账户必须以字母开头,只能包括 字母 , 下划线 , 数字,长度必须在3 到 20 之间 | 
|---|
|  |  |  | * @return 证成功返回true,验证失败返回false | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static boolean checkAccount(String account) { | 
|---|
|  |  |  | String regex = "[a-zA-Z]\\w{3,19}"; | 
|---|
|  |  |  | return account.matches(regex); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 验证密码 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param password 密码只能包含 字母 , 下划线 , 数字,长度必须在3 到 20 之间 | 
|---|
|  |  |  | * @return 证成功返回true,验证失败返回false | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static boolean checkPassword(String password) { | 
|---|
|  |  |  | String regex = "[0-9a-zA-Z_]\\w{3,19}"; | 
|---|
|  |  |  | return password.matches(regex); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 验证Email | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param email email地址,格式:zhangsan@zuidaima.com,zhangsan@xxx.com.cn,xxx代表邮件服务商 | 
|---|
|  |  |  | * @return 验证成功返回true,验证失败返回false | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static boolean checkEmail(String email) { | 
|---|
|  |  |  | String regex = "\\w+@\\w+\\.[a-z]+(\\.[a-z]+)?"; | 
|---|
|  |  |  | return Pattern.matches(regex, email); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 验证身份证号码 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param idCard 居民身份证号码15位或18位,最后一位可能是数字或字母 | 
|---|
|  |  |  | * @return 验证成功返回true,验证失败返回false | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static boolean checkIdCard(String idCard) { | 
|---|
|  |  |  | String regex = "[1-9]\\d{13,16}[a-zA-Z0-9]{1}"; | 
|---|
|  |  |  | return Pattern.matches(regex, idCard); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 验证手机号码 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param mobile 手机号,11位,1开头 | 
|---|
|  |  |  | * @return 验证成功返回true,验证失败返回false | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static boolean checkMobile(String mobile) { | 
|---|
|  |  |  | String regex = "^1[0-9]{10}$"; | 
|---|
|  |  |  | return Pattern.matches(regex, mobile); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 验证固定电话号码 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param phone 电话号码,格式:国家(地区)电话代码 + 区号(城市代码) + 电话号码,如:+8602085588447 | 
|---|
|  |  |  | *              <p><b>国家(地区) 代码 :</b>标识电话号码的国家(地区)的标准国家(地区)代码。它包含从 0 到 9 的一位或多位数字, | 
|---|
|  |  |  | *              数字之后是空格分隔的国家(地区)代码。</p> | 
|---|
|  |  |  | *              <p><b>区号(城市代码):</b>这可能包含一个或多个从 0 到 9 的数字,地区或城市代码放在圆括号—— | 
|---|
|  |  |  | *              对不使用地区或城市代码的国家(地区),则省略该组件。</p> | 
|---|
|  |  |  | *              <p><b>电话号码:</b>这包含从 0 到 9 的一个或多个数字 </p> | 
|---|
|  |  |  | * @return 验证成功返回true,验证失败返回false | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static boolean checkPhone(String phone) { | 
|---|
|  |  |  | String regex = "(\\+\\d+)?(\\d{3,4}\\-?)?\\d{7,8}$"; | 
|---|
|  |  |  | return Pattern.matches(regex, phone); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 验证整数(正整数和负整数) | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param digit 一位或多位0-9之间的整数 | 
|---|
|  |  |  | * @return 验证成功返回true,验证失败返回false | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static boolean checkDigit(String digit) { | 
|---|
|  |  |  | String regex = "\\-?[1-9]\\d+"; | 
|---|
|  |  |  | return Pattern.matches(regex, digit); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 验证整数和浮点数(正负整数和正负浮点数) | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param decimals 一位或多位0-9之间的浮点数,如:1.23,233.30 | 
|---|
|  |  |  | * @return 验证成功返回true,验证失败返回false | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static boolean checkDecimals(String decimals) { | 
|---|
|  |  |  | String regex = "\\-?[1-9]\\d+(\\.\\d+)?"; | 
|---|
|  |  |  | return Pattern.matches(regex, decimals); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 验证空白字符 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param blankSpace 空白字符,包括:空格、\t、\n、\r、\f、\x0B | 
|---|
|  |  |  | * @return 验证成功返回true,验证失败返回false | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static boolean checkBlankSpace(String blankSpace) { | 
|---|
|  |  |  | String regex = "\\s+"; | 
|---|
|  |  |  | return Pattern.matches(regex, blankSpace); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 验证中文 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param chinese 中文字符 | 
|---|
|  |  |  | * @return 验证成功返回true,验证失败返回false | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static boolean checkChinese(String chinese) { | 
|---|
|  |  |  | String regex = "^[\u4E00-\u9FA5]+$"; | 
|---|
|  |  |  | return Pattern.matches(regex, chinese); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 验证日期(年月日) | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param birthday 日期,格式:1992-09-03,或1992.09.03 | 
|---|
|  |  |  | * @return 验证成功返回true,验证失败返回false | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static boolean checkBirthday(String birthday) { | 
|---|
|  |  |  | String regex = "[1-9]{4}([-./])\\d{1,2}\\1\\d{1,2}"; | 
|---|
|  |  |  | return Pattern.matches(regex, birthday); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 验证URL地址 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param url 格式:http://blog.csdn.net:80/xyang81/article/details/7705960? 或 http://www.csdn.net:80 | 
|---|
|  |  |  | * @return 验证成功返回true,验证失败返回false | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static boolean checkURL(String url) { | 
|---|
|  |  |  | String regex = "(https?://(w{3}\\.)?)?\\w+\\.\\w+(\\.[a-zA-Z]+)*(:\\d{1,5})?(/\\w*)*(\\??(.+=.*)?(&.+=.*)?)?"; | 
|---|
|  |  |  | return Pattern.matches(regex, url); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * <pre> | 
|---|
|  |  |  | * 获取网址 URL 的一级域 | 
|---|
|  |  |  | * </pre> | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param url | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static String getDomain(String url) { | 
|---|
|  |  |  | Pattern p = Pattern.compile("(?<=http://|\\.)[^.]*?\\.(com|cn|net|org|biz|info|cc|tv)", Pattern.CASE_INSENSITIVE); | 
|---|
|  |  |  | // 获取完整的域名 | 
|---|
|  |  |  | // Pattern p=Pattern.compile("[^//]*?\\.(com|cn|net|org|biz|info|cc|tv)", Pattern.CASE_INSENSITIVE); | 
|---|
|  |  |  | Matcher matcher = p.matcher(url); | 
|---|
|  |  |  | matcher.find(); | 
|---|
|  |  |  | return matcher.group(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 匹配中国邮政编码 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param postcode 邮政编码 | 
|---|
|  |  |  | * @return 验证成功返回true,验证失败返回false | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static boolean checkPostcode(String postcode) { | 
|---|
|  |  |  | String regex = "[1-9]\\d{5}"; | 
|---|
|  |  |  | return Pattern.matches(regex, postcode); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 匹配IP地址(简单匹配,格式,如:192.168.1.1,127.0.0.1,没有匹配IP段的大小) | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param ipAddress IPv4标准地址 | 
|---|
|  |  |  | * @return 验证成功返回true,验证失败返回false | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static boolean checkIpAddress(String ipAddress) { | 
|---|
|  |  |  | String regex = "[1-9](\\d{1,2})?\\.(0|([1-9](\\d{1,2})?))\\.(0|([1-9](\\d{1,2})?))\\.(0|([1-9](\\d{1,2})?))"; | 
|---|
|  |  |  | return Pattern.matches(regex, ipAddress); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|