角色/权限管理
This commit is contained in:
parent
ba1840a752
commit
3284137e68
@ -4,6 +4,9 @@ import lombok.Data;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class ArticleDTO {
|
public class ArticleDTO {
|
||||||
private Integer idArticle;
|
private Integer idArticle;
|
||||||
|
@ -2,8 +2,11 @@ package com.rymcu.vertical.dto;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class TUser {
|
public class TokenUser {
|
||||||
|
|
||||||
private String account;
|
private String account;
|
||||||
|
|
||||||
@ -15,4 +18,6 @@ public class TUser {
|
|||||||
|
|
||||||
private String avatarUrl;
|
private String avatarUrl;
|
||||||
|
|
||||||
|
private Integer weights;
|
||||||
|
|
||||||
}
|
}
|
13
src/main/java/com/rymcu/vertical/dto/admin/UserRoleDTO.java
Normal file
13
src/main/java/com/rymcu/vertical/dto/admin/UserRoleDTO.java
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package com.rymcu.vertical.dto.admin;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UserRoleDTO {
|
||||||
|
private Integer idUser;
|
||||||
|
|
||||||
|
private Integer idRole;
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.rymcu.vertical.entity;
|
package com.rymcu.vertical.entity;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
@ -9,6 +10,9 @@ import javax.persistence.Table;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Table(name = "vertical_role")
|
@Table(name = "vertical_role")
|
||||||
public class Role implements Serializable,Cloneable {
|
public class Role implements Serializable,Cloneable {
|
||||||
@ -29,6 +33,12 @@ public class Role implements Serializable,Cloneable {
|
|||||||
@Column(name = "input_code")
|
@Column(name = "input_code")
|
||||||
private String inputCode;
|
private String inputCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权重
|
||||||
|
* */
|
||||||
|
@Column(name = "weights")
|
||||||
|
private Integer weights;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态
|
* 状态
|
||||||
* */
|
* */
|
||||||
@ -39,11 +49,13 @@ public class Role implements Serializable,Cloneable {
|
|||||||
* 创建时间
|
* 创建时间
|
||||||
* */
|
* */
|
||||||
@Column(name = "created_time")
|
@Column(name = "created_time")
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date createdTime;
|
private Date createdTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新时间
|
* 更新时间
|
||||||
* */
|
* */
|
||||||
@Column(name = "updated_time")
|
@Column(name = "updated_time")
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date updatedTime;
|
private Date updatedTime;
|
||||||
}
|
}
|
@ -12,4 +12,6 @@ public interface RoleMapper extends Mapper<Role> {
|
|||||||
List<Role> selectRoleByIdUser(@Param("id") Integer id);
|
List<Role> selectRoleByIdUser(@Param("id") Integer id);
|
||||||
|
|
||||||
Role selectRoleByInputCode(@Param("inputCode") String inputCode);
|
Role selectRoleByInputCode(@Param("inputCode") String inputCode);
|
||||||
|
|
||||||
|
Integer updateStatus(@Param("idRole") Integer idRole, @Param("status") String status);
|
||||||
}
|
}
|
@ -17,4 +17,10 @@ public interface UserMapper extends Mapper<User> {
|
|||||||
UserDTO selectUserDTOByNickname(@Param("nickname") String nickname);
|
UserDTO selectUserDTOByNickname(@Param("nickname") String nickname);
|
||||||
|
|
||||||
Integer updatePasswordByAccount(@Param("account") String account, @Param("password") String password);
|
Integer updatePasswordByAccount(@Param("account") String account, @Param("password") String password);
|
||||||
|
|
||||||
|
Integer selectRoleWeightsByUser(@Param("idUser") Integer idUser);
|
||||||
|
|
||||||
|
Integer updateUserRole(@Param("idUser") Integer idUser, @Param("idRole") Integer idRole);
|
||||||
|
|
||||||
|
Integer updateStatus(@Param("idUser") Integer idUser, @Param("status") String status);
|
||||||
}
|
}
|
@ -5,6 +5,7 @@ import com.rymcu.vertical.entity.Role;
|
|||||||
import com.rymcu.vertical.entity.User;
|
import com.rymcu.vertical.entity.User;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,4 +14,10 @@ import java.util.List;
|
|||||||
public interface RoleService extends Service<Role> {
|
public interface RoleService extends Service<Role> {
|
||||||
|
|
||||||
List<Role> selectRoleByUser(User sysUser);
|
List<Role> selectRoleByUser(User sysUser);
|
||||||
|
|
||||||
|
List<Role> findByIdUser(Integer idUser);
|
||||||
|
|
||||||
|
Map updateStatus(Integer idRole, String status);
|
||||||
|
|
||||||
|
Map saveRole(Role role);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public interface UserService extends Service<User> {
|
public interface UserService extends Service<User> {
|
||||||
|
|
||||||
|
|
||||||
User findByAccount(String account) throws TooManyResultsException;
|
User findByAccount(String account) throws TooManyResultsException;
|
||||||
|
|
||||||
Map register(String email, String password, String code);
|
Map register(String email, String password, String code);
|
||||||
@ -23,4 +22,8 @@ public interface UserService extends Service<User> {
|
|||||||
UserDTO findUserDTOByNickname(String nickname);
|
UserDTO findUserDTOByNickname(String nickname);
|
||||||
|
|
||||||
Map forgetPassword(String code, String password);
|
Map forgetPassword(String code, String password);
|
||||||
|
|
||||||
|
Map updateUserRole(Integer idUser, Integer idRole);
|
||||||
|
|
||||||
|
Map updateStatus(Integer idUser, String status);
|
||||||
}
|
}
|
||||||
|
@ -9,14 +9,18 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by CodeGenerator on 2018/05/29.
|
*
|
||||||
|
* @author CodeGenerator
|
||||||
|
* @date 2018/05/29
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
|
||||||
public class RoleServiceImpl extends AbstractService<Role> implements RoleService {
|
public class RoleServiceImpl extends AbstractService<Role> implements RoleService {
|
||||||
@Resource
|
@Resource
|
||||||
private RoleMapper roleMapper;
|
private RoleMapper roleMapper;
|
||||||
@ -27,4 +31,41 @@ public class RoleServiceImpl extends AbstractService<Role> implements RoleServic
|
|||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Role> findByIdUser(Integer idUser) {
|
||||||
|
return roleMapper.selectRoleByIdUser(idUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public Map updateStatus(Integer idRole, String status) {
|
||||||
|
Map map = new HashMap(1);
|
||||||
|
Integer result = roleMapper.updateStatus(idRole,status);
|
||||||
|
if(result == 0) {
|
||||||
|
map.put("message","更新失败!");
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map saveRole(Role role) {
|
||||||
|
Integer result = 0;
|
||||||
|
if (role.getIdRole() == null) {
|
||||||
|
role.setStatus("0");
|
||||||
|
role.setCreatedTime(new Date());
|
||||||
|
role.setUpdatedTime(role.getCreatedTime());
|
||||||
|
result = roleMapper.insertSelective(role);
|
||||||
|
} else {
|
||||||
|
role.setCreatedTime(new Date());
|
||||||
|
result = roleMapper.updateByPrimaryKeySelective(role);
|
||||||
|
}
|
||||||
|
Map map = new HashMap(1);
|
||||||
|
if (result == 0) {
|
||||||
|
map.put("message","操作失败!");
|
||||||
|
} else {
|
||||||
|
map.put("role", role);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,13 @@ package com.rymcu.vertical.service.impl;
|
|||||||
|
|
||||||
import com.rymcu.vertical.core.service.AbstractService;
|
import com.rymcu.vertical.core.service.AbstractService;
|
||||||
import com.rymcu.vertical.core.service.redis.RedisService;
|
import com.rymcu.vertical.core.service.redis.RedisService;
|
||||||
import com.rymcu.vertical.dto.TUser;
|
import com.rymcu.vertical.dto.TokenUser;
|
||||||
import com.rymcu.vertical.dto.UserDTO;
|
import com.rymcu.vertical.dto.UserDTO;
|
||||||
import com.rymcu.vertical.entity.Role;
|
import com.rymcu.vertical.entity.Role;
|
||||||
import com.rymcu.vertical.entity.User;
|
import com.rymcu.vertical.entity.User;
|
||||||
import com.rymcu.vertical.jwt.service.TokenManager;
|
import com.rymcu.vertical.jwt.service.TokenManager;
|
||||||
import com.rymcu.vertical.mapper.RoleMapper;
|
import com.rymcu.vertical.mapper.RoleMapper;
|
||||||
import com.rymcu.vertical.mapper.UserMapper;
|
import com.rymcu.vertical.mapper.UserMapper;
|
||||||
import com.rymcu.vertical.service.ArticleService;
|
|
||||||
import com.rymcu.vertical.service.UserService;
|
import com.rymcu.vertical.service.UserService;
|
||||||
import com.rymcu.vertical.util.BeanCopierUtil;
|
import com.rymcu.vertical.util.BeanCopierUtil;
|
||||||
import com.rymcu.vertical.util.Utils;
|
import com.rymcu.vertical.util.Utils;
|
||||||
@ -25,7 +24,9 @@ import java.util.Map;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by CodeGenerator on 2018/05/29.
|
*
|
||||||
|
* @author CodeGenerator
|
||||||
|
* @date 2018/05/29
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class UserServiceImpl extends AbstractService<User> implements UserService {
|
public class UserServiceImpl extends AbstractService<User> implements UserService {
|
||||||
@ -85,10 +86,11 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|||||||
if(Utils.comparePwd(password, user.getPassword())){
|
if(Utils.comparePwd(password, user.getPassword())){
|
||||||
user.setLastLoginTime(new Date());
|
user.setLastLoginTime(new Date());
|
||||||
userMapper.updateByPrimaryKeySelective(user);
|
userMapper.updateByPrimaryKeySelective(user);
|
||||||
TUser tUser = new TUser();
|
TokenUser tokenUser = new TokenUser();
|
||||||
BeanCopierUtil.copy(user,tUser);
|
BeanCopierUtil.copy(user, tokenUser);
|
||||||
tUser.setToken(tokenManager.createToken(account));
|
tokenUser.setToken(tokenManager.createToken(account));
|
||||||
map.put("user",tUser);
|
tokenUser.setWeights(userMapper.selectRoleWeightsByUser(user.getIdUser()));
|
||||||
|
map.put("user", tokenUser);
|
||||||
} else {
|
} else {
|
||||||
map.put("message","密码错误!");
|
map.put("message","密码错误!");
|
||||||
}
|
}
|
||||||
@ -118,4 +120,26 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public Map updateUserRole(Integer idUser, Integer idRole) {
|
||||||
|
Map map = new HashMap(1);
|
||||||
|
Integer result = userMapper.updateUserRole(idUser,idRole);
|
||||||
|
if(result == 0) {
|
||||||
|
map.put("message","更新失败!");
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public Map updateStatus(Integer idUser, String status) {
|
||||||
|
Map map = new HashMap(1);
|
||||||
|
Integer result = userMapper.updateStatus(idUser,status);
|
||||||
|
if(result == 0) {
|
||||||
|
map.put("message","更新失败!");
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.rymcu.vertical.util;
|
package com.rymcu.vertical.util;
|
||||||
|
|
||||||
import com.rymcu.vertical.dto.TUser;
|
import com.rymcu.vertical.dto.TokenUser;
|
||||||
import com.rymcu.vertical.entity.User;
|
import com.rymcu.vertical.entity.User;
|
||||||
import com.rymcu.vertical.jwt.def.JwtConstants;
|
import com.rymcu.vertical.jwt.def.JwtConstants;
|
||||||
import com.rymcu.vertical.jwt.model.TokenModel;
|
import com.rymcu.vertical.jwt.model.TokenModel;
|
||||||
@ -13,6 +13,9 @@ import io.jsonwebtoken.Jwts;
|
|||||||
import io.jsonwebtoken.SignatureException;
|
import io.jsonwebtoken.SignatureException;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
public class UserUtils {
|
public class UserUtils {
|
||||||
|
|
||||||
private static UserMapper userMapper = SpringContextHolder.getBean(UserMapper.class);
|
private static UserMapper userMapper = SpringContextHolder.getBean(UserMapper.class);
|
||||||
@ -46,7 +49,7 @@ public class UserUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TUser getTUser(String token) {
|
public static TokenUser getTokenUser(String token) {
|
||||||
if(StringUtils.isNotBlank(token)){
|
if(StringUtils.isNotBlank(token)){
|
||||||
// 验证token
|
// 验证token
|
||||||
Claims claims = null;
|
Claims claims = null;
|
||||||
@ -61,10 +64,11 @@ public class UserUtils {
|
|||||||
if (tokenManager.checkToken(model)) {
|
if (tokenManager.checkToken(model)) {
|
||||||
User user = userMapper.findByAccount(account.toString());
|
User user = userMapper.findByAccount(account.toString());
|
||||||
if(user != null){
|
if(user != null){
|
||||||
TUser tUser = new TUser();
|
TokenUser tokenUser = new TokenUser();
|
||||||
BeanCopierUtil.copy(user,tUser);
|
BeanCopierUtil.copy(user, tokenUser);
|
||||||
tUser.setToken(token);
|
tokenUser.setToken(token);
|
||||||
return tUser;
|
tokenUser.setWeights(userMapper.selectRoleWeightsByUser(user.getIdUser()));
|
||||||
|
return tokenUser;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,11 @@ import com.github.pagehelper.PageHelper;
|
|||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.rymcu.vertical.core.result.GlobalResult;
|
import com.rymcu.vertical.core.result.GlobalResult;
|
||||||
import com.rymcu.vertical.core.result.GlobalResultGenerator;
|
import com.rymcu.vertical.core.result.GlobalResultGenerator;
|
||||||
import com.rymcu.vertical.dto.admin.TopicDTO;
|
import com.rymcu.vertical.dto.admin.UserRoleDTO;
|
||||||
|
import com.rymcu.vertical.entity.Role;
|
||||||
import com.rymcu.vertical.entity.Topic;
|
import com.rymcu.vertical.entity.Topic;
|
||||||
import com.rymcu.vertical.entity.User;
|
import com.rymcu.vertical.entity.User;
|
||||||
|
import com.rymcu.vertical.service.RoleService;
|
||||||
import com.rymcu.vertical.service.TopicService;
|
import com.rymcu.vertical.service.TopicService;
|
||||||
import com.rymcu.vertical.service.UserService;
|
import com.rymcu.vertical.service.UserService;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@ -27,6 +29,8 @@ public class AdminController {
|
|||||||
@Resource
|
@Resource
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
@Resource
|
@Resource
|
||||||
|
private RoleService roleService;
|
||||||
|
@Resource
|
||||||
private TopicService topicService;
|
private TopicService topicService;
|
||||||
|
|
||||||
@GetMapping("/users")
|
@GetMapping("/users")
|
||||||
@ -44,6 +48,57 @@ public class AdminController {
|
|||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/user/{idUser}/role")
|
||||||
|
public GlobalResult userRole(@PathVariable Integer idUser){
|
||||||
|
List<Role> roles = roleService.findByIdUser(idUser);
|
||||||
|
return GlobalResultGenerator.genSuccessResult(roles);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/roles")
|
||||||
|
public GlobalResult roles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){
|
||||||
|
PageHelper.startPage(page, rows);
|
||||||
|
List<Role> list = roleService.findAll();
|
||||||
|
PageInfo pageInfo = new PageInfo(list);
|
||||||
|
Map map = new HashMap(2);
|
||||||
|
map.put("roles", pageInfo.getList());
|
||||||
|
Map pagination = new HashMap(3);
|
||||||
|
pagination.put("pageSize",pageInfo.getPageSize());
|
||||||
|
pagination.put("total",pageInfo.getTotal());
|
||||||
|
pagination.put("currentPage",pageInfo.getPageNum());
|
||||||
|
map.put("pagination", pagination);
|
||||||
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PatchMapping("/user/update-role")
|
||||||
|
public GlobalResult updateUserRole(@RequestBody UserRoleDTO userRole){
|
||||||
|
Map map = userService.updateUserRole(userRole.getIdUser(),userRole.getIdRole());
|
||||||
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PatchMapping("/user/update-status")
|
||||||
|
public GlobalResult updateUserStatus(@RequestBody User user){
|
||||||
|
Map map = userService.updateStatus(user.getIdUser(),user.getStatus());
|
||||||
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PatchMapping("/role/update-status")
|
||||||
|
public GlobalResult updateRoleStatus(@RequestBody Role role){
|
||||||
|
Map map = roleService.updateStatus(role.getIdRole(),role.getStatus());
|
||||||
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/role/post")
|
||||||
|
public GlobalResult addRole(@RequestBody Role role){
|
||||||
|
Map map = roleService.saveRole(role);
|
||||||
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/role/post")
|
||||||
|
public GlobalResult updateRole(@RequestBody Role role){
|
||||||
|
Map map = roleService.saveRole(role);
|
||||||
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/topics")
|
@GetMapping("/topics")
|
||||||
public GlobalResult topics(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){
|
public GlobalResult topics(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
@ -64,8 +119,8 @@ public class AdminController {
|
|||||||
if (StringUtils.isBlank(topicUri)) {
|
if (StringUtils.isBlank(topicUri)) {
|
||||||
return GlobalResultGenerator.genErrorResult("数据异常!");
|
return GlobalResultGenerator.genErrorResult("数据异常!");
|
||||||
}
|
}
|
||||||
TopicDTO topic = topicService.findTopicByTopicUri(topicUri,page,rows);
|
Map map = topicService.findTopicByTopicUri(topicUri,page,rows);
|
||||||
return GlobalResultGenerator.genSuccessResult();
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,12 @@ package com.rymcu.vertical.web.api.common;
|
|||||||
|
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.rymcu.vertical.core.exception.ServiceException;
|
|
||||||
import com.rymcu.vertical.core.result.GlobalResult;
|
import com.rymcu.vertical.core.result.GlobalResult;
|
||||||
import com.rymcu.vertical.core.result.GlobalResultGenerator;
|
import com.rymcu.vertical.core.result.GlobalResultGenerator;
|
||||||
import com.rymcu.vertical.core.result.GlobalResultMessage;
|
import com.rymcu.vertical.core.result.GlobalResultMessage;
|
||||||
import com.rymcu.vertical.dto.ArticleDTO;
|
import com.rymcu.vertical.dto.ArticleDTO;
|
||||||
import com.rymcu.vertical.dto.ForgetPasswordDTO;
|
import com.rymcu.vertical.dto.ForgetPasswordDTO;
|
||||||
import com.rymcu.vertical.dto.TUser;
|
import com.rymcu.vertical.dto.TokenUser;
|
||||||
import com.rymcu.vertical.entity.User;
|
import com.rymcu.vertical.entity.User;
|
||||||
import com.rymcu.vertical.service.ArticleService;
|
import com.rymcu.vertical.service.ArticleService;
|
||||||
import com.rymcu.vertical.service.JavaMailService;
|
import com.rymcu.vertical.service.JavaMailService;
|
||||||
@ -19,7 +18,6 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.mail.MessagingException;
|
import javax.mail.MessagingException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -121,8 +119,8 @@ public class CommonApiController {
|
|||||||
|
|
||||||
@GetMapping("/token/{token}")
|
@GetMapping("/token/{token}")
|
||||||
public GlobalResult token(@PathVariable String token){
|
public GlobalResult token(@PathVariable String token){
|
||||||
TUser tUser = UserUtils.getTUser(token);
|
TokenUser tokenUser = UserUtils.getTokenUser(token);
|
||||||
return GlobalResultGenerator.genSuccessResult(tUser);
|
return GlobalResultGenerator.genSuccessResult(tokenUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("/forget-password")
|
@PatchMapping("/forget-password")
|
||||||
|
@ -2,7 +2,7 @@ package com.rymcu.vertical.web.api.common;
|
|||||||
|
|
||||||
import com.rymcu.vertical.core.result.GlobalResult;
|
import com.rymcu.vertical.core.result.GlobalResult;
|
||||||
import com.rymcu.vertical.core.result.GlobalResultGenerator;
|
import com.rymcu.vertical.core.result.GlobalResultGenerator;
|
||||||
import com.rymcu.vertical.dto.TUser;
|
import com.rymcu.vertical.dto.TokenUser;
|
||||||
import com.rymcu.vertical.jwt.def.JwtConstants;
|
import com.rymcu.vertical.jwt.def.JwtConstants;
|
||||||
import com.rymcu.vertical.util.FileUtils;
|
import com.rymcu.vertical.util.FileUtils;
|
||||||
import com.rymcu.vertical.util.UserUtils;
|
import com.rymcu.vertical.util.UserUtils;
|
||||||
@ -128,9 +128,9 @@ public class UploadController {
|
|||||||
if(StringUtils.isBlank(authHeader)){
|
if(StringUtils.isBlank(authHeader)){
|
||||||
throw new BaseApiException(ErrorCode.UNAUTHORIZED);
|
throw new BaseApiException(ErrorCode.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
TUser tUser = UserUtils.getTUser(authHeader);
|
TokenUser tokenUser = UserUtils.getTokenUser(authHeader);
|
||||||
Map map = new HashMap(2);
|
Map map = new HashMap(2);
|
||||||
map.put("uploadToken",tUser.getToken());
|
map.put("uploadToken", tokenUser.getToken());
|
||||||
map.put("uploadURL", UPLOAD_URL);
|
map.put("uploadURL", UPLOAD_URL);
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
@ -8,16 +8,14 @@
|
|||||||
<id column="id" jdbcType="INTEGER" property="idRole"/>
|
<id column="id" jdbcType="INTEGER" property="idRole"/>
|
||||||
<result column="name" jdbcType="VARCHAR" property="name"/>
|
<result column="name" jdbcType="VARCHAR" property="name"/>
|
||||||
<result column="input_code" jdbcType="VARCHAR" property="inputCode"/>
|
<result column="input_code" jdbcType="VARCHAR" property="inputCode"/>
|
||||||
|
<result column="weights" jdbcType="TINYINT" property="weights"/>
|
||||||
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
|
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
|
||||||
<result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
|
<result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
|
||||||
<result column="status" jdbcType="INTEGER" property="status"/>
|
<result column="status" jdbcType="INTEGER" property="status"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<resultMap id="RoleDTOResultMap" type="com.rymcu.vertical.dto.RoleDTO">
|
<update id="updateStatus">
|
||||||
<id column="id" property="id"></id>
|
update vertical_role set status = #{status},updated_time = sysdate() where id = #{idRole}
|
||||||
<result column="name" property="name"/>
|
</update>
|
||||||
<result column="input_code" property="inputCode"/>
|
|
||||||
<result column="menu_ids" property="menuIds"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<select id="selectRoleByIdUser" resultMap="BaseResultMap">
|
<select id="selectRoleByIdUser" resultMap="BaseResultMap">
|
||||||
select sr.* from vertical_user_role sur left join vertical_role sr on sur.id_role = sr.id where id_user = #{id}
|
select sr.* from vertical_user_role sur left join vertical_role sr on sur.id_role = sr.id where id_user = #{id}
|
||||||
|
@ -44,6 +44,12 @@
|
|||||||
<update id="updatePasswordByAccount">
|
<update id="updatePasswordByAccount">
|
||||||
update vertical_user set password = #{password} where account = #{account}
|
update vertical_user set password = #{password} where account = #{account}
|
||||||
</update>
|
</update>
|
||||||
|
<update id="updateUserRole">
|
||||||
|
update vertical_user_role set id_role = #{idRole},created_time = sysdate() where id_user = #{idUser}
|
||||||
|
</update>
|
||||||
|
<update id="updateStatus">
|
||||||
|
update vertical_user set status = #{status} where id = #{idUser}
|
||||||
|
</update>
|
||||||
|
|
||||||
<select id="findByAccount" resultMap="BaseResultMap">
|
<select id="findByAccount" resultMap="BaseResultMap">
|
||||||
select id, nickname, account, password, status from vertical_user where account = #{account} AND status = 0
|
select id, nickname, account, password, status from vertical_user where account = #{account} AND status = 0
|
||||||
@ -54,5 +60,8 @@
|
|||||||
<select id="selectUserDTOByNickname" resultMap="DTOResultMapper">
|
<select id="selectUserDTOByNickname" resultMap="DTOResultMapper">
|
||||||
select id, nickname, avatar_type, avatar_url, account from vertical_user where nickname = #{nickname} and status = 0
|
select id, nickname, avatar_type, avatar_url, account from vertical_user where nickname = #{nickname} and status = 0
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectRoleWeightsByUser" resultType="java.lang.Integer">
|
||||||
|
select vr.weights from vertical_role vr left join vertical_user_role vur on vr.id = vur.id_role where vur.id_user = #{idUser}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
Loading…
Reference in New Issue
Block a user