Commit 13496897 authored by zjy's avatar zjy

user/role/tright 5.10 20:33

parent 5ba6bd1c
# 参数请符合实体,而不是单独的参数,专注于参数内容,专注于参数顺序
``` java
{
id: "1"
}
```
如:
```java
public List<String> getRoleTrightPKListByRoleId(String roleId) {
return this.query(String.class,GET_ROLE_TRIGHT_PKLIST_BY_ROLEID,roleId);
}
```
# RoleDaoImpl
## 夏敏的函数请用load,可以删除
``` java
@Override
public RoleVo getRoleById(String id) {
return this.queryFirst(RoleVo.class,GET_ROLE_BY_ID,id);
}
@Override
public RoleVo getRoleByName(String name) {
return this.queryFirst(RoleVo.class,GET_ROLE_BY_NAME,name);
}
```
参见如下代码:
``` java
dao.load({id:"1"})
dao.load({name:"1"})
```
## 检测语句
``` java
table.add(CHECK_NAME_EXIST,"select count(r.id) from pd_role r where 1=1 ")
.add("name","and r.name = ? ")
.add("id","and r.id <> ?");
```
改成
```java
table.addExist(CHECK_NAME_EXIST,"name");
```
调用时
``` java
this.checkExist(CHECK_NAME_EXIST,roleVo,"橘色名称已经存在");
```
# 请确定语句主表,比如说和 pd_role_authority表和pd_authority表的查询,请另外新建dao层,符合三层架构规范
``` java
table.add(GET_TRIGHTID_LIST,"select authority_id from pd_role_authority where 1=1 ")
.add("roleId","and role_id = ?");
table.add(GET_TRIGHTNAME_BY_TRIGHTID,"select name from pd_authority where 1=1 ")
.add("trightId","and id = ?");
```
# SQL语句合并
```java
table.add(GET_ROLE_TRIGHT_PKLIST_BY_ROLEID,"select id from pd_role_authority where 1=1 ")
.add("roleId","and role_id = ?");
table.add(GET_ROLE_TRIGHT_PKLIST_BY_TRIGHTID,"select id from pd_role_authority where 1=1 ")
.add("trightId","and tright_id = ?");
```
可以合并为
```java
table.add(GET_ROLE_TRIGHT_PKLIST_BY_ROLEID,"select id from pd_role_authority where 1=1 ")
.add("roleId","and role_id = ?");
.add("trightId","and tright_id = ?");
```
# 更爱SQL语句
```java
table.add(CHECK_VALID,"select count(a.id) from pd_authority a where 1=1 ")
.add("name","and a.name = ? ")
.add("url","and a.url = ? ")
.add("id","and a.id <> ?");
```
改为:
``` java
table.addExist(CHECK_VALID,"name","url");
```
# 将如下SQL语句合并
``` java
table.add(GET_TRIGHT_BY_ID,"select * from pd_authority where 1=1 ")
.add("id","and id = ?");
table.add(LIST_ALL,"select * from pd_authority where 1=1");
table.add(LIST_LEVEL_ONE,"select * from pd_authority where pid=null");
// 这句SQL语句可以去掉,本身没有意义
table.add(CHECK_CHILD,"select count(id) from pd_authority where 1=1 ")
.add("id","and pid = ?");
table.add(GET_CHILDID_LIST,"select id from pd_authority where 1=1 ")
.add("id","and pid = ?");
```
如:
is null, is not null , ifnull(field,'')=''
```java
table.add(GET_TRIGHT_BY_ID,"select * from pd_authority where 1=1 ")
.add("id","and id = ?")
.add("top","and ifnull(pid,'')= ''")
.add("pid","and pid = ?");
```
# 将如下SQL语句合并
``` java
table.add(GET_USER, "SELECT id,account,phone,status,remark,create_time,creator FROM pd_user WHERE 1=1 ")
.add("account", " AND account = ?");
table.add(GET_ALL_USERS,"select id,account,phone,status,remark,create_time,creator from pd_user where 1=1");
table.add(GET_ROLE_IDS,"select role_id from pd_user_role where 1=1 ")
.add("userId","and user_id = ?");
table.add(GET_USER_BY_ID,"select id,account,phone,status,remark,create_time,creator from pd_user where 1=1 ")
.add("userId","and user_id = ?");
table.add(GET_ROLE_BY_ROLEID,"select name from pd_role where 1=1 ")
.add("roleId","and id = ?");
```
# 如下语句可以删除
``` java
table.add(DELETE_USER_ROLE,"delete from pd_user_role_relation where 1=1 ")
.add("userId","and user_id = ?");
```
直接调用:
```
dao.remove({userId:"1"})
```
\ No newline at end of file
...@@ -2,17 +2,16 @@ package com.pangding.web.tright.controller; ...@@ -2,17 +2,16 @@ package com.pangding.web.tright.controller;
import com.pangding.web.tright.currency.Result; import com.pangding.web.tright.currency.Result;
import com.pangding.web.tright.dao.RoleDao;
import com.pangding.web.tright.dto.RoleDto; import com.pangding.web.tright.dto.RoleDto;
import com.pangding.web.tright.service.RoleService; import com.pangding.web.tright.service.RoleService;
import com.pangding.web.tright.vo.RoleVo; import com.pangding.web.tright.vo.RoleVo;
import com.yanzuoguang.util.helper.CheckerHelper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID;
/** /**
* @author zhangjinyao * @author zhangjinyao
...@@ -23,8 +22,7 @@ public class RoleController { ...@@ -23,8 +22,7 @@ public class RoleController {
@Autowired @Autowired
RoleService roleServiceImpl; RoleService roleServiceImpl;
@Autowired
RoleDao roleDao;
/** /**
* 新增角色 * 新增角色
* @param roleDto * @param roleDto
...@@ -32,16 +30,13 @@ public class RoleController { ...@@ -32,16 +30,13 @@ public class RoleController {
*/ */
@RequestMapping(value = "/save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "/save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public Object saveRole(@RequestBody RoleDto roleDto){ public Object saveRole(@RequestBody RoleDto roleDto){
String id = roleDto.getId();
String name = roleDto.getName(); String name = roleDto.getName();
if (roleServiceImpl.getRoleById(id) != null){
return new Result(4001, "该角色ID已存在", null);
}
if (roleServiceImpl.getRoleByName(name) != null){ if (roleServiceImpl.getRoleByName(name) != null){
return new Result(4001, "该角色名已存在", null); return new Result(4001, "该角色名已存在", null);
} }
roleServiceImpl.saveRole((RoleVo)roleDto); roleDto.setId(UUID.randomUUID().toString().replace("-",""));
roleServiceImpl.roleAndTright(roleDto); roleServiceImpl.saveRole(roleDto);
return new Result(0,"SUCCESS",null); return new Result(0,"SUCCESS",null);
} }
...@@ -56,8 +51,7 @@ public class RoleController { ...@@ -56,8 +51,7 @@ public class RoleController {
if (!roleServiceImpl.checkNameExist(roleVo)){ if (!roleServiceImpl.checkNameExist(roleVo)){
return new Result(4001,"该角色名已存在",null); return new Result(4001,"该角色名已存在",null);
} }
roleServiceImpl.saveRole(roleVo); roleServiceImpl.updateRole(roleDto);
roleServiceImpl.roleAndTright(roleDto);
Result result = new Result(0,"SUCCESS",null); Result result = new Result(0,"SUCCESS",null);
return result; return result;
} }
...@@ -116,15 +110,6 @@ public class RoleController { ...@@ -116,15 +110,6 @@ public class RoleController {
@RequestMapping(value = "/delete/{roleId}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "/delete/{roleId}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public Object delete(@PathVariable String roleId){ public Object delete(@PathVariable String roleId){
roleServiceImpl.deleteRole(roleId); roleServiceImpl.deleteRole(roleId);
List<String> roleUserList = roleServiceImpl.getRoleUserPKListByRoleId(roleId);
for (String roleUserId:roleUserList) {
roleServiceImpl.deleteRoleUser(roleUserId);
}
List<String> roleTrightList = roleServiceImpl.getRoleTrightPKListByRoleId(roleId);
for (String roleTrightId:roleTrightList) {
roleServiceImpl.deleteRoleTright(roleTrightId);
}
Result result = new Result(0,"SUCCESS",null); Result result = new Result(0,"SUCCESS",null);
return result; return result;
} }
......
package com.pangding.web.tright.controller; package com.pangding.web.tright.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.pangding.web.tright.currency.Result; import com.pangding.web.tright.currency.Result;
import com.pangding.web.tright.dao.TrightDao;
import com.pangding.web.tright.service.TrightService; import com.pangding.web.tright.service.TrightService;
import com.pangding.web.tright.vo.TrightVo; import com.pangding.web.tright.vo.TrightVo;
import org.bouncycastle.jcajce.provider.digest.MD5;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -24,8 +19,6 @@ public class TrightController { ...@@ -24,8 +19,6 @@ public class TrightController {
@Autowired @Autowired
TrightService trightServiceImpl; TrightService trightServiceImpl;
@Autowired
TrightDao trightDao;
/** /**
* 新增权限 * 新增权限
...@@ -113,7 +106,7 @@ public class TrightController { ...@@ -113,7 +106,7 @@ public class TrightController {
} }
/** /**
* 删除权限 * 删除权限及其子权限
* @param id * @param id
* @return * @return
*/ */
...@@ -126,11 +119,6 @@ public class TrightController { ...@@ -126,11 +119,6 @@ public class TrightController {
} }
} }
trightServiceImpl.deleteTrightById(id); trightServiceImpl.deleteTrightById(id);
List<String> roleTrightList = trightServiceImpl.getRoleTrightPKListByTrightId(id);
for (String roleTrightId:roleTrightList) {
trightServiceImpl.deleteRoleTright(roleTrightId);
}
return new Result(0,"SUCCESS",null); return new Result(0,"SUCCESS",null);
} }
} }
......
...@@ -2,18 +2,16 @@ package com.pangding.web.tright.controller; ...@@ -2,18 +2,16 @@ package com.pangding.web.tright.controller;
import com.pangding.web.tright.currency.Result; import com.pangding.web.tright.currency.Result;
import com.pangding.web.tright.dao.UserDao;
import com.pangding.web.tright.dto.UserDto; import com.pangding.web.tright.dto.UserDto;
import com.pangding.web.tright.service.UserService; import com.pangding.web.tright.service.UserService;
import com.pangding.web.tright.vo.UserVo; import com.pangding.web.tright.vo.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID;
/** /**
* @author zhangjinyao * @author zhangjinyao
...@@ -24,8 +22,7 @@ public class UserController { ...@@ -24,8 +22,7 @@ public class UserController {
@Autowired @Autowired
UserService userServiceImpl; UserService userServiceImpl;
@Autowired
private UserDao userDao;
/** /**
* 新增用户 * 新增用户
* @param userDto * @param userDto
...@@ -37,18 +34,13 @@ public class UserController { ...@@ -37,18 +34,13 @@ public class UserController {
UserVo u = userServiceImpl.getUser(userDto); UserVo u = userServiceImpl.getUser(userDto);
if (u != null) { if (u != null) {
return new Result(4001,"该用户已存在",null); return new Result(4001,"该用户已存在",null);
} }
String saltPassword = userServiceImpl.passwordEncoder(userDto.getPassword()); String saltPassword = userServiceImpl.passwordEncoder(userDto.getPassword());
userDto.setPassword(saltPassword); userDto.setPassword(saltPassword);
userDao.create(userDto); userDto.setId(UUID.randomUUID().toString().replace("-",""));
if (userDto.getRoleIds()!=null&&userDto.getRoleIds().size()!=0){ userServiceImpl.saveUser(userDto);
userServiceImpl.userAndRole(userDto);
}
Result result = new Result(0,"SUCCESS",null); Result result = new Result(0,"SUCCESS",null);
return result; return result;
} }
...@@ -59,10 +51,12 @@ public class UserController { ...@@ -59,10 +51,12 @@ public class UserController {
*/ */
@RequestMapping(value = "/update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "/update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public Object updateUser(@RequestBody UserDto userDto){ public Object updateUser(@RequestBody UserDto userDto){
UserVo u = userDto; UserVo u = userServiceImpl.getUser(userDto);
u.setPassword(userServiceImpl.passwordEncoder(u.getPassword())); if (u != null && !u.getId().equals(userDto.getId())) {
userDao.update(u); return new Result(4001,"该用户名已存在",null);
userServiceImpl.userAndRole(userDto); }
userDto.setPassword(userServiceImpl.passwordEncoder(userDto.getPassword()));
userServiceImpl.updateUser(userDto);
Result result = new Result(0,"SUCCESS",null); Result result = new Result(0,"SUCCESS",null);
return result; return result;
} }
...@@ -77,15 +71,23 @@ public class UserController { ...@@ -77,15 +71,23 @@ public class UserController {
List<UserVo> userVoList = userServiceImpl.listUserVo(); List<UserVo> userVoList = userServiceImpl.listUserVo();
List<UserDto> userDtoList = new ArrayList(userVoList.size()); List<UserDto> userDtoList = new ArrayList(userVoList.size());
for (int var1 = 0;var1 < userVoList.size();var1++){ for (int index1 = 0;index1 < userVoList.size();index1++){
UserVo userVo = userVoList.get(var1); UserVo userVo = userVoList.get(index1);
List<String> roleIdList = userServiceImpl.listRoleIdList(userVo); GetUserRoleListByUserIdReqVo reqVo = new GetUserRoleListByUserIdReqVo();
List<String> roleList = new ArrayList(roleIdList.size()); reqVo.setUserId(userVo.getId());
for (int var2 = 0;var2 < roleIdList.size();++var2){ List<UserRoleRelation> userRole = userServiceImpl.listUserRoleListByUserId(reqVo);
String role = userServiceImpl.getRoleNameByRoleId(roleIdList.get(var2)); List<String> roleIdList = new ArrayList(userRole.size());
roleList.add(role); for (UserRoleRelation userRoleRelation:userRole) {
roleIdList.add(userRoleRelation.getRoleId());
}
List<String> roleNameList = new ArrayList(roleIdList.size());
for (int index2 = 0;index2 < roleIdList.size();index2++){
GetRoleByRoleIdReqVo getRoleByRoleIdReqVo = new GetRoleByRoleIdReqVo();
getRoleByRoleIdReqVo.setId(roleIdList.get(index2));
RoleVo role = userServiceImpl.getRoleByRoleId(getRoleByRoleIdReqVo);
roleNameList.add(role.getName());
} }
UserDto userDto = userServiceImpl.makeUserDto(userVo,roleIdList,roleList); UserDto userDto = userServiceImpl.makeUserDto(userVo,roleIdList,roleNameList);
userDtoList.add(userDto); userDtoList.add(userDto);
} }
...@@ -98,22 +100,29 @@ public class UserController { ...@@ -98,22 +100,29 @@ public class UserController {
* @param //id * @param //id
* @return * @return
*/ */
@RequestMapping(value = "/user", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "/user/{userId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public Object user(String userId){//@PathVariable Long id public Object user(@PathVariable String userId){
UserVo userVo = userServiceImpl.getUserById(userId); UserVo userVo = userServiceImpl.getUserById(userId);
if(userVo == null){ if(userVo == null){
return new Result(4001,"该用户不存在",null); return new Result(4001,"该用户不存在",null);
} }
List<String> roleIdList = userServiceImpl.listRoleIdList(userVo); GetUserRoleListByUserIdReqVo reqVo = new GetUserRoleListByUserIdReqVo();
List<String> roleList = new ArrayList(roleIdList.size()); reqVo.setUserId(userVo.getId());
for (int var2 = 0;var2 < roleIdList.size();var2++){ List<UserRoleRelation> userRole = userServiceImpl.listUserRoleListByUserId(reqVo);
String role = userServiceImpl.getRoleNameByRoleId(roleIdList.get(var2)); List<String> roleIdList = new ArrayList(userRole.size());
roleList.add(role); for (UserRoleRelation userRoleRelation:userRole) {
roleIdList.add(userRoleRelation.getRoleId());
} }
UserDto userDto = userServiceImpl.makeUserDto(userVo,roleIdList,roleList); List<String> roleNameList = new ArrayList(roleIdList.size());
Result result = new Result(0,"SUCCESS",userDto); for (int index2 = 0;index2 < roleIdList.size();index2++){
return result; GetRoleByRoleIdReqVo getRoleByRoleIdReqVo = new GetRoleByRoleIdReqVo();
getRoleByRoleIdReqVo.setId(roleIdList.get(index2));
RoleVo role = userServiceImpl.getRoleByRoleId(getRoleByRoleIdReqVo);
roleNameList.add(role.getName());
}
UserDto userDto = userServiceImpl.makeUserDto(userVo,roleIdList,roleNameList);
return new Result(0,"SUCCESS",userDto);
} }
} }
package com.pangding.web.tright.dao; package com.pangding.web.tright.dao;
import com.pangding.web.tright.dto.RoleDto; import com.pangding.web.tright.vo.GetRoleByRoleIdReqVo;
import com.pangding.web.tright.vo.RoleTrightRelation; import com.pangding.web.tright.vo.GetRoleByRoleNameReqVo;
import com.pangding.web.tright.vo.RoleVo; import com.pangding.web.tright.vo.RoleVo;
import com.yanzuoguang.dao.BaseDao; import com.yanzuoguang.dao.BaseDao;
...@@ -15,18 +15,18 @@ public interface RoleDao extends BaseDao { ...@@ -15,18 +15,18 @@ public interface RoleDao extends BaseDao {
/** /**
* 通过主键id获取RoleVo对象 * 通过主键id获取RoleVo对象
* *
* @param id 主键 * @param getRoleByRoleIdReqVo getRoleByRoleIdReqVo对象
* @return RoleVo对象 * @return RoleVo对象
*/ */
RoleVo getRoleById(String id); RoleVo getRoleById(GetRoleByRoleIdReqVo getRoleByRoleIdReqVo);
/** /**
* 通过角色名查询RoleVo对象 * 通过角色名查询RoleVo对象
* *
* @param name 角色名 * @param getRoleByRoleNameReqVo 角色名
* @return RoleVo对象 * @return RoleVo对象
*/ */
RoleVo getRoleByName(String name); RoleVo getRoleByRoleName(GetRoleByRoleNameReqVo getRoleByRoleNameReqVo);
/** /**
* 检查用户名是否已存在 * 检查用户名是否已存在
......
package com.pangding.web.tright.dao; package com.pangding.web.tright.dao;
import com.pangding.web.tright.dto.UserDto; import com.pangding.web.tright.vo.GetUserByAccountReqVo;
import com.pangding.web.tright.vo.UserRoleRelation; import com.pangding.web.tright.vo.GetUserByIdReqVo;
import com.pangding.web.tright.vo.UserVo; import com.pangding.web.tright.vo.UserVo;
import com.yanzuoguang.dao.BaseDao; import com.yanzuoguang.dao.BaseDao;
...@@ -14,12 +14,12 @@ public interface UserDao extends BaseDao { ...@@ -14,12 +14,12 @@ public interface UserDao extends BaseDao {
/** /**
* 通过UserVo对象获取相同的UserVo对象 * 通过账户名获取相同的UserVo对象
* *
* @param userVo UserVo对象 * @param account 账户名
* @return UserVo对象 * @return UserVo对象
*/ */
UserVo getUser(UserVo userVo); UserVo getUserByAccount(GetUserByAccountReqVo account);
/** /**
* 获取UserVo对象列表 * 获取UserVo对象列表
...@@ -50,5 +50,5 @@ public interface UserDao extends BaseDao { ...@@ -50,5 +50,5 @@ public interface UserDao extends BaseDao {
* @param userId 用户id * @param userId 用户id
* @return UserVo对象 * @return UserVo对象
*/ */
UserVo getUserById(String userId); UserVo getUserById(GetUserByIdReqVo id);
} }
package com.pangding.web.tright.dao; package com.pangding.web.tright.dao;
import com.pangding.web.tright.vo.GetUserRoleListByUserIdReqVo;
import com.pangding.web.tright.vo.UserRoleRelation;
import com.yanzuoguang.dao.BaseDao; import com.yanzuoguang.dao.BaseDao;
import java.util.List; import java.util.List;
...@@ -10,10 +12,10 @@ import java.util.List; ...@@ -10,10 +12,10 @@ import java.util.List;
public interface UserRoleDao extends BaseDao { public interface UserRoleDao extends BaseDao {
/** /**
* 通过角色id获取角色用户表主键列表 * 通过userId查询用户角色对应关系列表
* *
* @param roleId 角色id * @param userId 用户id
* @return 角色用户表主键列表 * @return user和role对应关系对象列表
*/ */
List<String> getRoleUserPKListByRoleId(String roleId); List<UserRoleRelation> getUserRoleListByUserId(GetUserRoleListByUserIdReqVo userId);
} }
package com.pangding.web.tright.dao.impl; package com.pangding.web.tright.dao.impl;
import com.pangding.web.tright.dao.RoleDao; import com.pangding.web.tright.dao.RoleDao;
import com.pangding.web.tright.vo.GetRoleByRoleIdReqVo;
import com.pangding.web.tright.vo.GetRoleByRoleNameReqVo;
import com.pangding.web.tright.vo.RoleVo; import com.pangding.web.tright.vo.RoleVo;
import com.yanzuoguang.dao.impl.BaseDaoImpl; import com.yanzuoguang.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.management.relation.Role;
import java.util.List; import java.util.List;
/** /**
...@@ -24,12 +27,6 @@ public class RoleDaoImpl extends BaseDaoImpl implements RoleDao { ...@@ -24,12 +27,6 @@ public class RoleDaoImpl extends BaseDaoImpl implements RoleDao {
protected void init() { protected void init() {
register(RoleVo.class); register(RoleVo.class);
table.add(GET_ROLE_BY_ID,"select r.* from pd_role r where 1=1 ")
.add("id","and r.id = ?");
table.add(GET_ROLE_BY_NAME,"select r.* from pd_role r where 1=1 ")
.add("name","and r.name = ?");
table.add(CHECK_NAME_EXIST,"select count(r.id) from pd_role r where 1=1 ") table.add(CHECK_NAME_EXIST,"select count(r.id) from pd_role r where 1=1 ")
.add("name","and r.name = ? ") .add("name","and r.name = ? ")
.add("id","and r.id <> ?"); .add("id","and r.id <> ?");
...@@ -45,13 +42,13 @@ public class RoleDaoImpl extends BaseDaoImpl implements RoleDao { ...@@ -45,13 +42,13 @@ public class RoleDaoImpl extends BaseDaoImpl implements RoleDao {
} }
@Override @Override
public RoleVo getRoleById(String id) { public RoleVo getRoleById(GetRoleByRoleIdReqVo getRoleByRoleIdReqVo) {
return this.queryFirst(RoleVo.class,GET_ROLE_BY_ID,id); return this.load(getRoleByRoleIdReqVo,RoleVo.class);
} }
@Override @Override
public RoleVo getRoleByName(String name) { public RoleVo getRoleByRoleName(GetRoleByRoleNameReqVo getRoleByRoleNameReqVo) {
return this.queryFirst(RoleVo.class,GET_ROLE_BY_NAME,name); return this.load(getRoleByRoleNameReqVo, RoleVo.class);
} }
@Override @Override
......
package com.pangding.web.tright.dao.impl; package com.pangding.web.tright.dao.impl;
import com.pangding.web.tright.dao.UserDao; import com.pangding.web.tright.dao.UserDao;
import com.pangding.web.tright.dto.UserDto; import com.pangding.web.tright.vo.GetUserByAccountReqVo;
import com.pangding.web.tright.vo.UserRoleRelation; import com.pangding.web.tright.vo.GetUserByIdReqVo;
import com.pangding.web.tright.vo.UserVo; import com.pangding.web.tright.vo.UserVo;
import com.yanzuoguang.dao.DaoConst;
import com.yanzuoguang.dao.impl.BaseDaoImpl; import com.yanzuoguang.dao.impl.BaseDaoImpl;
import com.yanzuoguang.util.vo.MapRow;
import com.yanzuoguang.util.vo.PageSizeData;
import com.yanzuoguang.util.vo.PageSizeReqVo;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.UUID;
/** /**
* @author zhangjinyao * @author zhangjinyao
...@@ -22,7 +16,7 @@ import java.util.UUID; ...@@ -22,7 +16,7 @@ import java.util.UUID;
public class UserDaoImpl extends BaseDaoImpl implements UserDao { public class UserDaoImpl extends BaseDaoImpl implements UserDao {
private static final String GET_USER = "GET_USER"; private static final String SELECT = "SELECT";
private static final String DELETE_USER_ROLE="deleteUserRole"; private static final String DELETE_USER_ROLE="deleteUserRole";
private static final String SAVE_USER_ROLE = "saveUserRoles"; private static final String SAVE_USER_ROLE = "saveUserRoles";
private static final String GET_ALL_USERS = "GET_ALL_USERS"; private static final String GET_ALL_USERS = "GET_ALL_USERS";
...@@ -34,28 +28,13 @@ public class UserDaoImpl extends BaseDaoImpl implements UserDao { ...@@ -34,28 +28,13 @@ public class UserDaoImpl extends BaseDaoImpl implements UserDao {
protected void init() { protected void init() {
register(UserVo.class); register(UserVo.class);
table.add(GET_USER, "SELECT id,account,phone,status,remark,create_time,creator FROM pd_user WHERE 1=1 ")
.add("account", " AND account = ?");
table.add(DELETE_USER_ROLE,"delete from pd_user_role_relation where 1=1 ")
.add("userId","and user_id = ?");
table.add(GET_ALL_USERS,"select id,account,phone,status,remark,create_time,creator from pd_user where 1=1"); table.add(GET_ALL_USERS,"select id,account,phone,status,remark,create_time,creator from pd_user where 1=1");
table.add(GET_ROLE_IDS,"select role_id from pd_user_role where 1=1 ")
.add("userId","and user_id = ?");
table.add(GET_USER_BY_ID,"select id,account,phone,status,remark,create_time,creator from pd_user where 1=1 ")
.add("userId","and user_id = ?");
table.add(GET_ROLE_BY_ROLEID,"select name from pd_role where 1=1 ")
.add("roleId","and id = ?");
} }
@Override @Override
public UserVo getUser(UserVo userVo) { public UserVo getUserByAccount(GetUserByAccountReqVo account) {
return this.queryFirst(UserVo.class, GET_USER, userVo); return this.load(account,UserVo.class);
} }
...@@ -77,7 +56,7 @@ public class UserDaoImpl extends BaseDaoImpl implements UserDao { ...@@ -77,7 +56,7 @@ public class UserDaoImpl extends BaseDaoImpl implements UserDao {
} }
@Override @Override
public UserVo getUserById(String userId) { public UserVo getUserById(GetUserByIdReqVo id) {
return this.queryFirst(UserVo.class,GET_USER_BY_ID,userId); return this.load(id,UserVo.class);
} }
} }
package com.pangding.web.tright.dao.impl; package com.pangding.web.tright.dao.impl;
import com.pangding.web.tright.dao.UserRoleDao; import com.pangding.web.tright.dao.UserRoleDao;
import com.pangding.web.tright.vo.GetUserRoleListByUserIdReqVo;
import com.pangding.web.tright.vo.UserRoleRelation; import com.pangding.web.tright.vo.UserRoleRelation;
import com.yanzuoguang.dao.impl.BaseDaoImpl; import com.yanzuoguang.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -13,20 +14,21 @@ import java.util.List; ...@@ -13,20 +14,21 @@ import java.util.List;
@Component @Component
public class UserRoleDaoImpl extends BaseDaoImpl implements UserRoleDao { public class UserRoleDaoImpl extends BaseDaoImpl implements UserRoleDao {
private static final String GET_ROLE_USER_PK_BY_ROLEID = "GET_ROLE_USER_PK_BY_ROLEID"; private static final String GET_USER_ROLE_LIST = "GET_USER_ROLE_LIST";
@Override @Override
protected void init() { protected void init() {
register(UserRoleRelation.class); register(UserRoleRelation.class);
table.add(GET_ROLE_USER_PK_BY_ROLEID,"select id from pd_user_role where 1=1 ") table.add(GET_USER_ROLE_LIST,"select * from pd_user_role where 1=1 ")
.add("userId","and user_id = ?")
.add("roleId","and role_id = ?"); .add("roleId","and role_id = ?");
} }
@Override @Override
public List<String> getRoleUserPKListByRoleId(String roleId) { public List<UserRoleRelation> getUserRoleListByUserId(GetUserRoleListByUserIdReqVo userId) {
return this.query(String.class,GET_ROLE_USER_PK_BY_ROLEID,roleId); return this.query(UserRoleRelation.class,GET_USER_ROLE_LIST,userId);
} }
} }
...@@ -11,11 +11,18 @@ import java.util.List; ...@@ -11,11 +11,18 @@ import java.util.List;
public interface RoleService { public interface RoleService {
/** /**
* 保存RoleVo对象 * 保存RoleDto对象,并保存角色权限的对应关系
* *
* @param roleVo RoleVo对象 * @param roleDto RoleDto对象
*/
void saveRole(RoleDto roleDto);
/**
* 更新RoleDto对象,并更新角色权限的对应关系
*
* @param roleDto RoleDto对象
*/ */
void saveRole(RoleVo roleVo); void updateRole(RoleDto roleDto);
/** /**
* 通过主键id查询RoleVo对象 * 通过主键id查询RoleVo对象
...@@ -33,13 +40,6 @@ public interface RoleService { ...@@ -33,13 +40,6 @@ public interface RoleService {
*/ */
RoleVo getRoleByName(String name); RoleVo getRoleByName(String name);
/**
* 保存角色与权限的对应关系
*
* @param roleDto RoleDto对象
*/
void roleAndTright(RoleDto roleDto);
/** /**
* 检查角色名是否已存在 * 检查角色名是否已存在
* *
...@@ -82,39 +82,10 @@ public interface RoleService { ...@@ -82,39 +82,10 @@ public interface RoleService {
RoleDto makeRoleDto(RoleVo roleVo,List<String> trightIdList,List<String> trightNameList); RoleDto makeRoleDto(RoleVo roleVo,List<String> trightIdList,List<String> trightNameList);
/** /**
* 通过角色id删除角色 * 通过角色id删除角色,并删除角色和用户的对应关系一级角色和权限的对应关系
* *
* @param roleId 角色id * @param roleId 角色id
*/ */
void deleteRole(String roleId); void deleteRole(String roleId);
/**
* 通过角色id删除角色与用户的对应关系
*
* @param roleId 角色id
*/
void deleteRoleUser(String roleId);
/**
* 通过角色id删除角色权限的对应关系
*
* @param roleId 角色id
*/
void deleteRoleTright(String roleId);
/**
* 通过角色id获取角色用户关系表主键列表
*
* @param roleId 角色id
* @return 角色用户关系表主键列表
*/
List<String> getRoleUserPKListByRoleId(String roleId);
/**
* 通过角色id获取角色权限主键列表
*
* @param roleId 角色id
* @return 角色权限主键列表
*/
List<String> getRoleTrightPKListByRoleId(String roleId);
} }
...@@ -31,7 +31,7 @@ public interface TrightService { ...@@ -31,7 +31,7 @@ public interface TrightService {
TrightVo getTrightById(String id); TrightVo getTrightById(String id);
/** /**
* 通过权限表主键删除TrightVo对象 * 通过权限表主键删除TrightVo对象,并删除权限和角色的对应关系
* *
* @param id 主键 * @param id 主键
*/ */
...@@ -75,18 +75,4 @@ public interface TrightService { ...@@ -75,18 +75,4 @@ public interface TrightService {
*/ */
List<String> getChildIdList(String id); List<String> getChildIdList(String id);
/**
* 通过权限id获取角色权限表主键列表
*
* @param id 权限id
* @return 角色权限表主键列表
*/
List<String> getRoleTrightPKListByTrightId(String id);
/**
* 通过角色权限表主键删除角色权限对应关系
*
* @param roleTrightId 角色权限表主键
*/
void deleteRoleTright(String roleTrightId);
} }
package com.pangding.web.tright.service; package com.pangding.web.tright.service;
import com.pangding.web.tright.dto.UserDto; import com.pangding.web.tright.dto.UserDto;
import com.pangding.web.tright.vo.UserVo; import com.pangding.web.tright.vo.*;
import java.lang.reflect.Array;
import java.util.List; import java.util.List;
/** /**
...@@ -12,11 +11,18 @@ import java.util.List; ...@@ -12,11 +11,18 @@ import java.util.List;
public interface UserService { public interface UserService {
/** /**
* 保存用户和角色的对应关系 * 保存用户信息,并保存用户和角色的对应关系
* *
* @param userDto UserDto对象 * @param userDto UserDto对象
*/ */
void userAndRole(UserDto userDto); void saveUser(UserDto userDto);
/**
* 保存更新后的用户信息,并更新用户和角色的对应关系
*
* @param userDto UserDto对象
*/
void updateUser(UserDto userDto);
/** /**
* 通过UserVo对象获取相同的UserVo对象 * 通过UserVo对象获取相同的UserVo对象
...@@ -41,22 +47,6 @@ public interface UserService { ...@@ -41,22 +47,6 @@ public interface UserService {
*/ */
List<UserVo> listUserVo(); List<UserVo> listUserVo();
/**
* 通过UserVo对象获取该用户的角色ID列表
*
* @param userVo UserVo对象
* @return 角色id列表
*/
List<String> listRoleIdList(UserVo userVo);
/**
* 通过角色id获取角色名
*
* @param roleId 角色id
* @return 角色名
*/
String getRoleNameByRoleId(String roleId);
/** /**
* 将UserVo对象添加角色id列表和角色名列表封装成UserDto对象 * 将UserVo对象添加角色id列表和角色名列表封装成UserDto对象
* *
...@@ -74,4 +64,20 @@ public interface UserService { ...@@ -74,4 +64,20 @@ public interface UserService {
* @return UserVo对象 * @return UserVo对象
*/ */
UserVo getUserById(String userId); UserVo getUserById(String userId);
/**
* 通过userId查询user和role对应关系对象列表
*
* @param reqVo GetUserRoleListByUserIdReqVo对象
* @return UserRole对应关系对象列表
*/
List<UserRoleRelation> listUserRoleListByUserId(GetUserRoleListByUserIdReqVo reqVo);
/**
* 根据roleId查询RoleVo对象
*
* @param getRoleByRoleIdReqVo GetRoleByRoleIdReqVo对象
* @return RoleVo对象
*/
RoleVo getRoleByRoleId(GetRoleByRoleIdReqVo getRoleByRoleIdReqVo);
} }
...@@ -5,15 +5,13 @@ import com.pangding.web.tright.dao.RoleTrightDao; ...@@ -5,15 +5,13 @@ import com.pangding.web.tright.dao.RoleTrightDao;
import com.pangding.web.tright.dao.UserRoleDao; import com.pangding.web.tright.dao.UserRoleDao;
import com.pangding.web.tright.dto.RoleDto; import com.pangding.web.tright.dto.RoleDto;
import com.pangding.web.tright.service.RoleService; import com.pangding.web.tright.service.RoleService;
import com.pangding.web.tright.vo.GetRoleByRoleNameReqVo;
import com.pangding.web.tright.vo.RoleTrightRelation; import com.pangding.web.tright.vo.RoleTrightRelation;
import com.pangding.web.tright.vo.RoleVo; import com.pangding.web.tright.vo.RoleVo;
import com.pangding.web.tright.vo.UserRoleRelation;
import com.yanzuoguang.util.helper.CheckerHelper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
...@@ -33,32 +31,53 @@ public class RoleServiceImpl implements RoleService { ...@@ -33,32 +31,53 @@ public class RoleServiceImpl implements RoleService {
RoleTrightDao roleTrightDaoImpl; RoleTrightDao roleTrightDaoImpl;
@Override @Override
public void saveRole(RoleVo roleVo) { @Transactional(rollbackFor = Exception.class)
public void saveRole(RoleDto roleDto) {
RoleVo roleVo = roleDto;
roleDao.create(roleVo); roleDao.create(roleVo);
List<String> trightIds = roleDto.getTrightIds();
for (String trightId : trightIds) {
RoleTrightRelation roleTrightRelation = new RoleTrightRelation();
roleTrightRelation.setTrightId(trightId);
roleTrightRelation.setRoleId(roleDto.getId());
roleTrightRelation.setId(UUID.randomUUID().toString().replace("-",""));
roleTrightDaoImpl.create(roleTrightRelation);
}
} }
@Override @Override
public RoleVo getRoleById(String id) { @Transactional(rollbackFor = Exception.class)
return roleDao.getRoleById(id); public void updateRole(RoleDto roleDto) {
} RoleVo roleVo = roleDto;
roleDao.update(roleVo);
@Override List<String> roleTrightIdList = roleTrightDaoImpl.getRoleTrightPKListByRoleId(roleDto.getId());
public RoleVo getRoleByName(String name) { if (roleTrightIdList != null && roleTrightIdList.size() != 0){
return roleDao.getRoleByName(name); for (String roleTrightId:roleTrightIdList) {
} roleTrightDaoImpl.remove(roleTrightId);
}
@Override }
public void roleAndTright(RoleDto roleDto) {
List<String> trightIds = roleDto.getTrightIds(); List<String> trightIds = roleDto.getTrightIds();
for (String trightId : trightIds) { for (String trightId : trightIds) {
RoleTrightRelation roleTrightRelation = new RoleTrightRelation(); RoleTrightRelation roleTrightRelation = new RoleTrightRelation();
roleTrightRelation.setTrightId(trightId); roleTrightRelation.setTrightId(trightId);
roleTrightRelation.setRoleId(roleDto.getId()); roleTrightRelation.setRoleId(roleDto.getId());
roleTrightRelation.setId(UUID.randomUUID().toString()); roleTrightRelation.setId(UUID.randomUUID().toString().replace("-",""));
roleTrightDaoImpl.create(roleTrightRelation); roleTrightDaoImpl.update(roleTrightRelation);
} }
} }
@Override
public RoleVo getRoleById(String id) {
return roleDao.getRoleById(id);
}
@Override
public RoleVo getRoleByName(String name) {
GetRoleByRoleNameReqVo getRoleByRoleNameReqVo = new GetRoleByRoleNameReqVo();
getRoleByRoleNameReqVo.setName(name);
return roleDao.getRoleByRoleName(getRoleByRoleNameReqVo);
}
@Override @Override
public Boolean checkNameExist(RoleVo roleVo) { public Boolean checkNameExist(RoleVo roleVo) {
if (roleDao.checkNameExist(roleVo) > 0){return false;} if (roleDao.checkNameExist(roleVo) > 0){return false;}
...@@ -89,32 +108,21 @@ public class RoleServiceImpl implements RoleService { ...@@ -89,32 +108,21 @@ public class RoleServiceImpl implements RoleService {
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void deleteRole(String roleId) { public void deleteRole(String roleId) {
roleDao.remove(roleId);
}
@Override roleDao.remove(roleId);
public void deleteRoleUser(String id) { List<String> roleUserList = userRoleDaoImpl.getRoleUserPKListByRoleId(roleId);
if (id != null && id != "") { for (String roleUserId:roleUserList) {
userRoleDaoImpl.remove(id); if (roleUserId != null && roleUserId != "") {
userRoleDaoImpl.remove(roleUserId);
}
} }
} List<String> roleTrightList = roleTrightDaoImpl.getRoleTrightPKListByRoleId(roleId);
for (String roleTrightId:roleTrightList) {
@Override if (roleTrightId != null && roleTrightId != "") {
public void deleteRoleTright(String id) { roleTrightDaoImpl.remove(roleTrightId);
if (id != null && id != "") { }
roleTrightDaoImpl.remove(id);
} }
} }
@Override
public List<String> getRoleUserPKListByRoleId(String roleId) {
return userRoleDaoImpl.getRoleUserPKListByRoleId(roleId);
}
@Override
public List<String> getRoleTrightPKListByRoleId(String roleId) {
return roleTrightDaoImpl.getRoleTrightPKListByRoleId(roleId);
}
} }
...@@ -6,8 +6,10 @@ import com.pangding.web.tright.service.TrightService; ...@@ -6,8 +6,10 @@ import com.pangding.web.tright.service.TrightService;
import com.pangding.web.tright.vo.TrightVo; import com.pangding.web.tright.vo.TrightVo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
import java.util.UUID;
/** /**
* @author zhangjinyao * @author zhangjinyao
...@@ -23,6 +25,7 @@ public class TrightServiceImpl implements TrightService { ...@@ -23,6 +25,7 @@ public class TrightServiceImpl implements TrightService {
@Override @Override
public void save(TrightVo trightVo) { public void save(TrightVo trightVo) {
trightVo.setId(UUID.randomUUID().toString().replace("-",""));
trightDao.create(trightVo); trightDao.create(trightVo);
} }
...@@ -45,8 +48,13 @@ public class TrightServiceImpl implements TrightService { ...@@ -45,8 +48,13 @@ public class TrightServiceImpl implements TrightService {
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void deleteTrightById(String id) { public void deleteTrightById(String id) {
trightDao.remove(id); trightDao.remove(id);
List<String> roleTrightList = roleTrightDao.getRoleTrightPKListByTrightId(id);
for (String roleTrightId:roleTrightList) {
roleTrightDao.remove(roleTrightId);
}
} }
@Override @Override
...@@ -72,16 +80,4 @@ public class TrightServiceImpl implements TrightService { ...@@ -72,16 +80,4 @@ public class TrightServiceImpl implements TrightService {
return trightDao.getChildIdList(id); return trightDao.getChildIdList(id);
} }
@Override
public List<String> getRoleTrightPKListByTrightId(String id) {
return roleTrightDao.getRoleTrightPKListByTrightId(id);
}
@Override
public void deleteRoleTright(String roleTrightId) {
roleTrightDao.remove(roleTrightId);
}
} }
package com.pangding.web.tright.service.impl; package com.pangding.web.tright.service.impl;
import com.pangding.web.tright.dao.RoleDao;
import com.pangding.web.tright.dao.UserDao; import com.pangding.web.tright.dao.UserDao;
import com.pangding.web.tright.dao.UserRoleDao;
import com.pangding.web.tright.dto.UserDto; import com.pangding.web.tright.dto.UserDto;
import com.pangding.web.tright.service.UserService; import com.pangding.web.tright.service.UserService;
import com.pangding.web.tright.utils.Md5AndSalt; import com.pangding.web.tright.utils.Md5AndSalt;
import com.pangding.web.tright.vo.UserRoleRelation; import com.pangding.web.tright.vo.*;
import com.pangding.web.tright.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -23,56 +24,107 @@ public class UserServiceImpl implements UserService { ...@@ -23,56 +24,107 @@ public class UserServiceImpl implements UserService {
@Autowired @Autowired
UserDao userDao; UserDao userDao;
@Override @Autowired
public List<UserVo> listUserVo() { UserRoleDao userRoleDao;
return userDao.listUserVo(); @Autowired
} RoleDao roleDao;
@Override @Override
public void userAndRole(UserDto userDto) { @Transactional(rollbackFor = Exception.class)
public void saveUser(UserDto userDto) {
List<String> roleIds = userDto.getRoleIds(); UserVo userVo = userDto;
userDao.create(userVo);
for (String roleId : roleIds) { if (userDto.getRoleIds()!=null&&userDto.getRoleIds().size()!=0){
UserRoleRelation userRoleRelation = new UserRoleRelation(); List<String> roleIds = userDto.getRoleIds();
userRoleRelation.setRoleId(roleId); for (String roleId : roleIds) {
userRoleRelation.setUserId(userDto.getId()); UserRoleRelation userRoleRelation = new UserRoleRelation();
userRoleRelation.setId(UUID.randomUUID().toString()); userRoleRelation.setRoleId(roleId);
userDao.create(userRoleRelation); userRoleRelation.setUserId(userDto.getId());
userRoleRelation.setId(UUID.randomUUID().toString().replace("-",""));
userRoleDao.create(userRoleRelation);
}
} }
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateUser(UserDto userDto) {
UserVo userVo = userDto;
userDao.update(userVo);
GetUserRoleListByUserIdReqVo userId = new GetUserRoleListByUserIdReqVo();
userId.setUserId(userDto.getId());
List<UserRoleRelation> userRoleList = userRoleDao.getUserRoleListByUserId(userId);
List<String> userRoleIdList = new ArrayList(userRoleList.size());
for (UserRoleRelation userRole:userRoleList) {
userRoleIdList.add(userRole.getId());
}
if (userRoleIdList != null && userRoleIdList.size() != 0){
for (String userRoleId:userRoleIdList){
UserRoleDaoRemoveReqVo userRole = new UserRoleDaoRemoveReqVo();
userRole.setId(userRoleId);
userRoleDao.remove(userRole);
}
}
if (userDto.getRoleIds()!=null&&userDto.getRoleIds().size()!=0){
List<String> roleIds = userDto.getRoleIds();
for (String roleId : roleIds) {
UserRoleRelation userRoleRelation = new UserRoleRelation();
userRoleRelation.setRoleId(roleId);
userRoleRelation.setUserId(userDto.getId());
userRoleRelation.setId(UUID.randomUUID().toString().replace("-",""));
userRoleDao.create(userRoleRelation);
}
}
} }
@Override
public List<UserVo> listUserVo() {
return userDao.listUserVo();
}
@Override @Override
public UserVo getUser(UserVo userVo) { public UserVo getUser(UserVo userVo) {
return userDao.getUser(userVo); GetUserByAccountReqVo account = new GetUserByAccountReqVo();
account.setAccount(userVo.getAccount());
return userDao.getUserByAccount(account);
} }
@Override @Override
public String passwordEncoder(String password) { return Md5AndSalt.generate(password); } public String passwordEncoder(String password) { return Md5AndSalt.generate(password); }
@Override
public List<String> listRoleIdList(UserVo userVo) {
return userDao.getRoleIdList(userVo);
}
@Override @Override
public UserDto makeUserDto(UserVo userVo, List<String> roleIdList, List<String> roleList) { public UserDto makeUserDto(UserVo userVo, List<String> roleIdList, List<String> roleNameList) {
UserDto userDto = (UserDto) userVo; UserDto userDto = new UserDto();
userDto.setPassword(userVo.getPassword());
userDto.setAccount(userVo.getAccount());
userDto.setCreateTime(userVo.getCreateTime());
userDto.setCreator(userVo.getCreator());
userDto.setId(userVo.getId());
userDto.setPhone(userVo.getPhone());
userDto.setRemark(userVo.getRemark());
userDto.setStatus(userVo.getStatus());
userDto.setRoleIds(roleIdList); userDto.setRoleIds(roleIdList);
userDto.setRoles(roleList); userDto.setRoles(roleNameList);
return userDto; return userDto;
} }
@Override @Override
public String getRoleNameByRoleId(String roleId) { public UserVo getUserById(String userId) {
return userDao.getRoleNameByRoleId(roleId); GetUserByIdReqVo id = new GetUserByIdReqVo();
id.setId(userId);
return userDao.getUserById(id);
} }
@Override @Override
public UserVo getUserById(String userId) { public List<UserRoleRelation> listUserRoleListByUserId(GetUserRoleListByUserIdReqVo reqVo) {
return userDao.getUserById(userId); return userRoleDao.getUserRoleListByUserId(reqVo);
}
@Override
public RoleVo getRoleByRoleId(GetRoleByRoleIdReqVo getRoleByRoleIdReqVo) {
return roleDao.getRoleById(getRoleByRoleIdReqVo);
} }
} }
package com.pangding.web.tright.vo;
/**
* @Author zhangjinyao
* @create 2019/5/10 20:09
*/
public class GetRoleByRoleIdReqVo {
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
package com.pangding.web.tright.vo;
/**
* @Author zhangjinyao
* @create 2019/5/10 20:27
*/
public class GetRoleByRoleNameReqVo {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package com.pangding.web.tright.vo;
import org.springframework.context.annotation.Bean;
/**
* @Author zhangjinyao
* @create 2019/5/10 17:17
*/
public class GetUserByAccountReqVo {
private String account;
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
}
package com.pangding.web.tright.vo;
/**
* @Author zhangjinyao
* @create 2019/5/10 17:21
*/
public class GetUserByIdReqVo {
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
package com.pangding.web.tright.vo;
/**
* @Author zhangjinyao
* @create 2019/5/10 19:34
*/
public class GetUserRoleListByUserIdReqVo {
private String userId;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
}
package com.pangding.web.tright.vo;
/**
* @Author zhangjinyao
* @create 2019/5/10 19:47
*/
public class UserRoleDaoRemoveReqVo {
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment