Merge branch 'dev' of http://blit.7drlb.com:8888/r/moral into dev
	
		
		3 files added
	
		
		26 files modified
	
	
 
	
	
	
	
	
	
	
	
|  |  |  | 
|---|
|  |  |  | <artifactId>screen-common</artifactId> | 
|---|
|  |  |  | <version>1.0-SNAPSHOT</version> | 
|---|
|  |  |  | </dependency> | 
|---|
|  |  |  | <dependency> | 
|---|
|  |  |  | <groupId>javax.persistence</groupId> | 
|---|
|  |  |  | <artifactId>persistence-api</artifactId> | 
|---|
|  |  |  | <version>1.0</version> | 
|---|
|  |  |  | </dependency> | 
|---|
|  |  |  | </dependencies> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <build> | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.moral.api.config.Interceptor; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.springframework.context.annotation.Configuration; | 
|---|
|  |  |  | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | 
|---|
|  |  |  | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.moral.api.interceptor.AuthenticationInterceptor; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Configuration | 
|---|
|  |  |  | public class WebAppConfiguration implements WebMvcConfigurer { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void addInterceptors(InterceptorRegistry registry) { | 
|---|
|  |  |  | registry.addInterceptor(new AuthenticationInterceptor()) | 
|---|
|  |  |  | .addPathPatterns("/**") | 
|---|
|  |  |  | .excludePathPatterns("/**/login/**", "/**/logout/**", "/swagger-ui.html/**", "/swagger-resources/**"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
| 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.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.servlet.http.HttpServletRequest; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.PathVariable; | 
|---|
|  |  |  | 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.ResultMessage; | 
|---|
|  |  |  | import com.moral.redis.RedisUtil; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Api(tags = {"大屏"}) | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping("/api") | 
|---|
|  |  |  | public class WebController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private UserService userService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private GroupService groupService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @param account  账户 | 
|---|
|  |  |  | * @param password 密码 | 
|---|
|  |  |  | * @Auther jinpengyong | 
|---|
|  |  |  | * @Description web登陆 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ApiOperation(value = "登陆", notes = "登陆") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "account", value = "账户", required = true, paramType = "path", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "path", dataType = "String") | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @RequestMapping(value = "login/{account}/{password}", method = RequestMethod.GET) | 
|---|
|  |  |  | public ResultMessage login(@PathVariable("account") String account, @PathVariable("password") String password) { | 
|---|
|  |  |  | if (account == null || password == null) { | 
|---|
|  |  |  | return ResultMessage.fail("账户和密码不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Map<String, Object> map = userService.login(account, password); | 
|---|
|  |  |  | if (map.get("token") == null) { | 
|---|
|  |  |  | return ResultMessage.fail(map.get("msg").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ResultMessage.ok(map.get("token")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "注销", notes = "注销") | 
|---|
|  |  |  | @RequestMapping(value = "logout", method = RequestMethod.POST) | 
|---|
|  |  |  | public ResultMessage logout(HttpServletRequest request) { | 
|---|
|  |  |  | String token = request.getHeader("token"); | 
|---|
|  |  |  | if (token == null) { | 
|---|
|  |  |  | return ResultMessage.fail("未登陆"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | RedisUtil.del(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 = "添加组") | 
|---|
|  |  |  | @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.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime createTime; | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime updateTime; | 
|---|
|  |  |  | private Date updateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 是否删除 | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime createTime; | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime updateTime; | 
|---|
|  |  |  | private Date updateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 是否删除 | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime createTime; | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime updateTime; | 
|---|
|  |  |  | private Date updateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 是否删除 | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime createTime; | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime updateTime; | 
|---|
|  |  |  | private Date updateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 是否删除 | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 操作时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime createTime; | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime createTime; | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime updateTime; | 
|---|
|  |  |  | private Date updateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 是否删除 | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime createTime; | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime updateTime; | 
|---|
|  |  |  | private Date updateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 是否删除 | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime createTime; | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime updateTime; | 
|---|
|  |  |  | private Date updateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 是否删除 | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime createTime; | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime updateTime; | 
|---|
|  |  |  | private Date updateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 是否删除 | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime createTime; | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime updateTime; | 
|---|
|  |  |  | private Date updateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 到期时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime expireTime; | 
|---|
|  |  |  | private Date expireTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 是否删除 | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime createTime; | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime updateTime; | 
|---|
|  |  |  | private Date updateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 是否删除 | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableField; | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime createTime; | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime updateTime; | 
|---|
|  |  |  | private Date updateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 是否删除 | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime createTime; | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime updateTime; | 
|---|
|  |  |  | private Date updateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 是否删除 | 
|---|
|  |  |  | 
|---|
|  |  |  | package com.moral.api.entity; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableField; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.Set; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * <p> | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime createTime; | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime updateTime; | 
|---|
|  |  |  | private Date updateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 过期时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime expireTime; | 
|---|
|  |  |  | private Date expireTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 是否删除 | 
|---|
|  |  |  | 
|---|
|  |  |  | private String isDelete; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @TableField(exist = false) | 
|---|
|  |  |  | private Set<Group> groups; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @TableField(exist = false) | 
|---|
|  |  |  | private Set<Menu> menus; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | protected Serializable pkVal() { | 
|---|
|  |  |  | return this.id; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime createTime; | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime updateTime; | 
|---|
|  |  |  | private Date updateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 是否删除 | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 操作时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LocalDateTime createTime; | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.moral.api.interceptor; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.servlet.http.HttpServletRequest; | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.springframework.stereotype.Component; | 
|---|
|  |  |  | import org.springframework.web.method.HandlerMethod; | 
|---|
|  |  |  | import org.springframework.web.servlet.HandlerInterceptor; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.moral.redis.RedisUtil; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Component | 
|---|
|  |  |  | public class AuthenticationInterceptor implements HandlerInterceptor { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | 
|---|
|  |  |  | request.getSession(); | 
|---|
|  |  |  | if (!(handler instanceof HandlerMethod)) { | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String token = request.getHeader("token"); | 
|---|
|  |  |  | if (token != null) { | 
|---|
|  |  |  | return RedisUtil.hasKey(token); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | package com.moral.api.mapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Set; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Set<Group> selectUserGroup(int userId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Set<Menu> selectUserMenu(int userId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | package com.moral.api.service; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.moral.api.entity.Group; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.service.IService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public interface GroupService extends IService<Group> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Object> addGroup(Group group, String currentUserId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | package com.moral.api.service; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.moral.api.entity.User; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.service.IService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public interface UserService extends IService<User> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Object> login(String account, String password); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Object> addUser(User user, Integer currentUserId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Object> deleteUser(Integer userId, Integer currentUserId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Object> updateUser(User user, Integer currentUserId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<User> getUsersByOrgId(Integer currentUserId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | User getUserById(Integer userId, Integer currentUserId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | package com.moral.api.service.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.moral.api.entity.Group; | 
|---|
|  |  |  | import com.moral.api.entity.User; | 
|---|
|  |  |  | import com.moral.api.mapper.GroupMapper; | 
|---|
|  |  |  | import com.moral.api.mapper.UserMapper; | 
|---|
|  |  |  | import com.moral.api.service.GroupService; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | @Service | 
|---|
|  |  |  | public class GroupServiceImpl extends ServiceImpl<GroupMapper, Group> implements GroupService { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private GroupMapper groupMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private UserMapper userMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Map<String, Object> addGroup(Group group, String currentUserId) { | 
|---|
|  |  |  | Map<String, Object> resultMap = new HashMap<>(); | 
|---|
|  |  |  | User currentUser = userMapper.selectById(currentUserId); | 
|---|
|  |  |  | if (!currentUser.getIsAdmin()) { | 
|---|
|  |  |  | resultMap.put("flag", false); | 
|---|
|  |  |  | resultMap.put("msg", "添加失败,没有权限"); | 
|---|
|  |  |  | return resultMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Integer orgId = currentUser.getOrganizationId(); | 
|---|
|  |  |  | QueryWrapper<Group> queryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | queryWrapper.eq("group_name", group.getGroupName()).eq("organization_id", orgId); | 
|---|
|  |  |  | if (groupMapper.selectOne(queryWrapper) == null) { | 
|---|
|  |  |  | group.setOrganizationId(orgId); | 
|---|
|  |  |  | groupMapper.insert(group); | 
|---|
|  |  |  | resultMap.put("flag", true); | 
|---|
|  |  |  | resultMap.put("msg", "添加成功"); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | resultMap.put("flag", false); | 
|---|
|  |  |  | resultMap.put("msg", "添加失败,组已存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return resultMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | package com.moral.api.service.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import io.swagger.models.auth.In; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  | import java.util.Set; | 
|---|
|  |  |  | import java.util.UUID; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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.User; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.moral.api.mapper.UserMapper; | 
|---|
|  |  |  | import com.moral.api.service.UserService; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
|---|
|  |  |  | import com.moral.redis.RedisUtil; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | @Service | 
|---|
|  |  |  | public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private UserMapper userMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Map<String, Object> login(String account, String password) { | 
|---|
|  |  |  | Map<String, Object> resultMap = new HashMap<>(); | 
|---|
|  |  |  | QueryWrapper<User> queryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | queryWrapper.eq("account", account).eq("password", password).eq("is_Delete", "0"); | 
|---|
|  |  |  | User user = userMapper.selectOne(queryWrapper); | 
|---|
|  |  |  | String msg; | 
|---|
|  |  |  | String token = null; | 
|---|
|  |  |  | if (user == null) { | 
|---|
|  |  |  | msg = "用户名或密码错误"; | 
|---|
|  |  |  | } else if (user.getExpireTime() != null && user.getExpireTime().getTime() < System.currentTimeMillis()) { | 
|---|
|  |  |  | msg = "你的账户已过期"; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | msg = "登陆成功"; | 
|---|
|  |  |  | token = user.getId() + "-" + UUID.randomUUID().toString().replaceAll("-", ""); | 
|---|
|  |  |  | Set<Group> groups = userMapper.selectUserGroup(user.getId()); | 
|---|
|  |  |  | Set<Menu> menus = userMapper.selectUserMenu(user.getId()); | 
|---|
|  |  |  | user.setGroups(groups); | 
|---|
|  |  |  | user.setMenus(menus); | 
|---|
|  |  |  | RedisUtil.set(token, user, 1296000); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | resultMap.put("token", token); | 
|---|
|  |  |  | resultMap.put("msg", msg); | 
|---|
|  |  |  | return resultMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Map<String, Object> addUser(User user, Integer userId) { | 
|---|
|  |  |  | Map<String, Object> resultMap = new HashMap<>(); | 
|---|
|  |  |  | User currentUser = userMapper.selectById(userId); | 
|---|
|  |  |  | if (!currentUser.getIsAdmin()) { | 
|---|
|  |  |  | resultMap.put("flag", false); | 
|---|
|  |  |  | 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", "添加失败,账户名已存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return resultMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Map<String, Object> deleteUser(Integer userId, Integer currentUserId) { | 
|---|
|  |  |  | Map<String, Object> resultMap = new HashMap<>(); | 
|---|
|  |  |  | User currentUser = userMapper.selectById(currentUserId); | 
|---|
|  |  |  | if (!currentUser.getIsAdmin()) { | 
|---|
|  |  |  | resultMap.put("flag", false); | 
|---|
|  |  |  | 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) { | 
|---|
|  |  |  | Map<String, Object> resultMap = new HashMap<>(); | 
|---|
|  |  |  | User currentUser = userMapper.selectById(currentUserId); | 
|---|
|  |  |  | if (!currentUser.getIsAdmin()) { | 
|---|
|  |  |  | resultMap.put("flag", false); | 
|---|
|  |  |  | 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", "修改失败,账户已存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return resultMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<User> getUsersByOrgId(Integer currentUserId) { | 
|---|
|  |  |  | User currentUser = userMapper.selectById(currentUserId); | 
|---|
|  |  |  | if (!currentUser.getIsAdmin()) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Map<String, Object> queryMap = new HashMap<>(); | 
|---|
|  |  |  | queryMap.put("organizationId", currentUser.getOrganizationId()); | 
|---|
|  |  |  | return userMapper.selectByMap(queryMap); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public User getUserById(Integer userId, Integer currentUserId) { | 
|---|
|  |  |  | User currentUser = userMapper.selectById(currentUserId); | 
|---|
|  |  |  | if (!currentUser.getIsAdmin()) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return userMapper.selectById(userId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | #nodes: 47.112.126.78:7001,47.112.126.78:7002,47.112.126.132:7003,47.112.126.132:7004,47.112.132.193:7005,47.112.132.193:7006 | 
|---|
|  |  |  | #password: test | 
|---|
|  |  |  | #timeout: 500 | 
|---|
|  |  |  | host: 127.0.0.1 | 
|---|
|  |  |  | host: 39.97.177.149 | 
|---|
|  |  |  | port: 6379 | 
|---|
|  |  |  | password: 123456 | 
|---|
|  |  |  | password: chenkaiyu111 | 
|---|
|  |  |  | timeout: 30000 | 
|---|
|  |  |  | jedis: | 
|---|
|  |  |  | pool: | 
|---|
|  |  |  | 
|---|
|  |  |  | max-idle: 64 | 
|---|
|  |  |  | max-wait: 30000 | 
|---|
|  |  |  | min-idle: 32 | 
|---|
|  |  |  | tokenRedis: | 
|---|
|  |  |  | host: 39.97.177.149 | 
|---|
|  |  |  | port: 6379 | 
|---|
|  |  |  | password: chenkaiyu111 | 
|---|
|  |  |  | timeout: 30000 | 
|---|
|  |  |  | database: 14 | 
|---|
|  |  |  | pool: | 
|---|
|  |  |  | max-active: 256 | 
|---|
|  |  |  | max-wait: 30000 | 
|---|
|  |  |  | max-idle: 64 | 
|---|
|  |  |  | min-idle: 32 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | datasource: | 
|---|
|  |  |  | minIdle: 1 | 
|---|
|  |  |  | time-between-eviction-runs-millis: 60000 | 
|---|
|  |  |  | 
|---|
|  |  |  | filters: stat | 
|---|
|  |  |  | type: com.alibaba.druid.pool.DruidDataSource | 
|---|
|  |  |  | max-wait: 60000 | 
|---|
|  |  |  | url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC | 
|---|
|  |  |  | password: 123456 | 
|---|
|  |  |  | url: jdbc:mysql://39.97.177.149:3306/moral?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC | 
|---|
|  |  |  | username: root | 
|---|
|  |  |  | password: chenkaiyu111 | 
|---|
|  |  |  | test-on-borrow: false | 
|---|
|  |  |  | sql-script-encoding: utf-8 | 
|---|
|  |  |  | pool-prepared-statements: true | 
|---|
|  |  |  | 
|---|
|  |  |  | driver-class-name: com.mysql.cj.jdbc.Driver | 
|---|
|  |  |  | max-conn-lifetime-millis: 20 | 
|---|
|  |  |  | test-on-return: false | 
|---|
|  |  |  | username: root | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mybatis-plus: | 
|---|
|  |  |  | mapper-locations: classpath:mapper/*.xml | 
|---|
|  |  |  | 
|---|
|  |  |  | commit: false | 
|---|
|  |  |  | group: | 
|---|
|  |  |  | id: test | 
|---|
|  |  |  | servers: 192.168.0.16:9092,192.168.0.17:9092,192.168.0.18:9092 | 
|---|
|  |  |  | servers: 192.168.0.191:9092 | 
|---|
|  |  |  | session: | 
|---|
|  |  |  | timeout: 6000 | 
|---|
|  |  |  | topic: test_topic | 
|---|
|  |  |  | 
|---|
|  |  |  | linger: 1 | 
|---|
|  |  |  | retries: 0 | 
|---|
|  |  |  | servers: 192.168.0.16:9092,192.168.0.17:9092,192.168.0.18:9092 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mvc: | 
|---|
|  |  |  | interceptor: | 
|---|
|  |  |  | exclude: | 
|---|
|  |  |  | - /account/login | 
|---|
|  |  |  | AES: | 
|---|
|  |  |  | KEY: | 
|---|
|  |  |  | AD42F7787B035B7580000EF93BE20BAD | 
|---|
|  |  |  | TOKEN: | 
|---|
|  |  |  | KEY: | 
|---|
|  |  |  | foh3wi2ooghiCh5 | 
|---|
|  |  |  | 
|---|
|  |  |  | <result column="is_delete" property="isDelete" /> | 
|---|
|  |  |  | </resultMap> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectUserGroup" resultType="com.moral.api.entity.Group"> | 
|---|
|  |  |  | SELECT g.* | 
|---|
|  |  |  | FROM `group` g,`user_group` ug | 
|---|
|  |  |  | WHERE ug.user_id = #{userId} | 
|---|
|  |  |  | AND ug.group_id = g.id | 
|---|
|  |  |  | AND g.is_delete = 0 | 
|---|
|  |  |  | AND ug.is_delete = 0 | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectUserMenu" resultType="com.moral.api.entity.Menu"> | 
|---|
|  |  |  | SELECT DISTINCT m.* | 
|---|
|  |  |  | FROM `user_group` ug,`group_menu` gm,`menu` m | 
|---|
|  |  |  | WHERE ug.user_id = #{userId} | 
|---|
|  |  |  | and ug.group_id = gm.group_id | 
|---|
|  |  |  | and gm.menu_id = m.id | 
|---|
|  |  |  | and ug.is_delete = 0 | 
|---|
|  |  |  | and gm.is_delete = 0 | 
|---|
|  |  |  | and m.is_delete = 0 | 
|---|
|  |  |  | ORDER  by m.`order` | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | </mapper> | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.moral.util.SpringContextUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.springframework.data.redis.core.RedisTemplate; | 
|---|
|  |  |  | import org.springframework.util.CollectionUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | private static RedisTemplate redisTemplate = SpringContextUtils.getBeanByName("redisTemplate"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // =============================common============================ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 设置过期时间内的key | 
|---|
|  |  |  | * | 
|---|
|  |  |  | 
|---|
|  |  |  | * @author: wuqp | 
|---|
|  |  |  | * @date: 2021/02/24 9:46 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public boolean hasKey(String key) { | 
|---|
|  |  |  | public static boolean hasKey(String key) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | return redisTemplate.hasKey(key); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | 
|---|
|  |  |  | * @date: 2021/02/24 9:46 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @SuppressWarnings("unchecked") | 
|---|
|  |  |  | public void del(String... key) { | 
|---|
|  |  |  | public static void del(String... key) { | 
|---|
|  |  |  | if (key != null && key.length > 0) { | 
|---|
|  |  |  | if (key.length == 1) { | 
|---|
|  |  |  | redisTemplate.delete(key[0]); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // ============================String============================= | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取string类型的缓存 | 
|---|
|  |  |  | * | 
|---|