Commit 33defe4c authored by tangf's avatar tangf

修改权限管理查询逻辑

修改余额常量字段
parent 12d57f00
package com.pangding.web.authority.dao; package com.pangding.web.authority.dao;
import com.pangding.web.authority.vo.reqvo.RoleAuthorityGetReqVo;
import com.pangding.web.authority.vo.RoleAuthorityVo;
import com.yanzuoguang.dao.BaseDao; import com.yanzuoguang.dao.BaseDao;
import java.util.List;
/** /**
* @author zhangjinyao * @author zhangjinyao
......
...@@ -2,6 +2,7 @@ package com.pangding.web.authority.dao; ...@@ -2,6 +2,7 @@ package com.pangding.web.authority.dao;
import com.pangding.web.authority.vo.reqvo.UserRoleGetReqVo; import com.pangding.web.authority.vo.reqvo.UserRoleGetReqVo;
import com.pangding.web.authority.vo.UserRoleVo; import com.pangding.web.authority.vo.UserRoleVo;
import com.pangding.web.authority.vo.resvo.WebRoleResVo;
import com.yanzuoguang.dao.BaseDao; import com.yanzuoguang.dao.BaseDao;
import java.util.List; import java.util.List;
...@@ -19,4 +20,6 @@ public interface UserRoleDao extends BaseDao { ...@@ -19,4 +20,6 @@ public interface UserRoleDao extends BaseDao {
*/ */
List<UserRoleVo> getUserRoleList(UserRoleGetReqVo reqVo); List<UserRoleVo> getUserRoleList(UserRoleGetReqVo reqVo);
List<WebRoleResVo> getUserNum(UserRoleGetReqVo reqVo);
} }
...@@ -3,6 +3,7 @@ package com.pangding.web.authority.dao.impl; ...@@ -3,6 +3,7 @@ package com.pangding.web.authority.dao.impl;
import com.pangding.web.authority.dao.RoleAuthorityDao; import com.pangding.web.authority.dao.RoleAuthorityDao;
import com.pangding.web.authority.vo.reqvo.RoleAuthorityGetReqVo; import com.pangding.web.authority.vo.reqvo.RoleAuthorityGetReqVo;
import com.pangding.web.authority.vo.RoleAuthorityVo; import com.pangding.web.authority.vo.RoleAuthorityVo;
import com.yanzuoguang.dao.DaoConst;
import com.yanzuoguang.dao.impl.BaseDaoImpl; import com.yanzuoguang.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -16,9 +17,16 @@ public class RoleAuthorityDaoImpl extends BaseDaoImpl implements RoleAuthorityDa ...@@ -16,9 +17,16 @@ public class RoleAuthorityDaoImpl extends BaseDaoImpl implements RoleAuthorityDa
@Override @Override
protected void init() { protected void init() {
register(RoleAuthorityVo.class); register(RoleAuthorityVo.class);
getSql(DaoConst.LOAD).setSql("select ra.role_id,a.* from pd_authority a " +
"LEFT JOIN pd_role_authority ra on ra.authority_id = a.id {INNER} " +
"where 1=1 {WHERE} ORDER BY a.pid,a.sort" )
.add("userId", "AND b.user_id = @userId",
"{INNER}", "INNER JOIN pd_user_role AS b ON ra.role_id = b.role_id")
.add("role", " AND ra.role_id = @role")
;
} }
} }
...@@ -3,6 +3,7 @@ package com.pangding.web.authority.dao.impl; ...@@ -3,6 +3,7 @@ package com.pangding.web.authority.dao.impl;
import com.pangding.web.authority.dao.UserRoleDao; import com.pangding.web.authority.dao.UserRoleDao;
import com.pangding.web.authority.vo.reqvo.UserRoleGetReqVo; import com.pangding.web.authority.vo.reqvo.UserRoleGetReqVo;
import com.pangding.web.authority.vo.UserRoleVo; import com.pangding.web.authority.vo.UserRoleVo;
import com.pangding.web.authority.vo.resvo.WebRoleResVo;
import com.yanzuoguang.dao.impl.BaseDaoImpl; import com.yanzuoguang.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -16,14 +17,20 @@ public class UserRoleDaoImpl extends BaseDaoImpl implements UserRoleDao { ...@@ -16,14 +17,20 @@ public class UserRoleDaoImpl extends BaseDaoImpl implements UserRoleDao {
private static final String GET_USER_ROLE_LIST = "GET_USER_ROLE_LIST"; private static final String GET_USER_ROLE_LIST = "GET_USER_ROLE_LIST";
private static final String GET_ROLE_USER_NUMBER = "GET_ROLE_USER_NUMBER";
@Override @Override
protected void init() { protected void init() {
register(UserRoleVo.class); register(UserRoleVo.class);
table.add(GET_USER_ROLE_LIST,"select * 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("userId","and user_id = ? ")
.add("roleId","and role_id = ?"); .add("roleId","and role_id = ? ");
table.add(GET_ROLE_USER_NUMBER,"select count(*),role_id from pd_user_role where 1=1 {WHERE} group by role_id ")
.add("userId","and user_id = ? ")
.add("roleIds","and role_id in ? ");
} }
...@@ -32,4 +39,9 @@ public class UserRoleDaoImpl extends BaseDaoImpl implements UserRoleDao { ...@@ -32,4 +39,9 @@ public class UserRoleDaoImpl extends BaseDaoImpl implements UserRoleDao {
return this.query(UserRoleVo.class,GET_USER_ROLE_LIST,reqVo); return this.query(UserRoleVo.class,GET_USER_ROLE_LIST,reqVo);
} }
@Override
public List<WebRoleResVo> getUserNum(UserRoleGetReqVo reqVo) {
return this.query(WebRoleResVo.class,GET_ROLE_USER_NUMBER,reqVo);
}
} }
...@@ -9,6 +9,7 @@ import com.pangding.web.authority.vo.resvo.AuthorityListByLevelResVo; ...@@ -9,6 +9,7 @@ import com.pangding.web.authority.vo.resvo.AuthorityListByLevelResVo;
import com.pangding.web.authority.vo.resvo.AuthorityListResVo; import com.pangding.web.authority.vo.resvo.AuthorityListResVo;
import com.pangding.web.authority.vo.resvo.AuthorityResVo; import com.pangding.web.authority.vo.resvo.AuthorityResVo;
import com.pangding.web.authority.vo.resvo.WebAuthorityResVo; import com.pangding.web.authority.vo.resvo.WebAuthorityResVo;
import com.pangding.web.vo.system.res.authority.RoleAuthorityLoadResVo;
import com.yanzuoguang.util.base.ObjectHelper; import com.yanzuoguang.util.base.ObjectHelper;
import com.yanzuoguang.util.exception.CodeException; import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.helper.StringHelper; import com.yanzuoguang.util.helper.StringHelper;
...@@ -48,7 +49,7 @@ public class AuthorityServiceImpl implements AuthorityService { ...@@ -48,7 +49,7 @@ public class AuthorityServiceImpl implements AuthorityService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public AuthorityListResVo save(AuthorityVo authorityVo) { public AuthorityListResVo save(AuthorityVo authorityVo) {
/*this.checkValid(authorityVo);*/ /*this.checkValid(authorityVo);*/
if (null == authorityVo.getPid() || authorityVo.getPid().isEmpty()){ if (null == authorityVo.getPid() || authorityVo.getPid().isEmpty()) {
authorityVo.setPid(""); authorityVo.setPid("");
} }
afterPlus(authorityVo); afterPlus(authorityVo);
...@@ -69,38 +70,39 @@ public class AuthorityServiceImpl implements AuthorityService { ...@@ -69,38 +70,39 @@ public class AuthorityServiceImpl implements AuthorityService {
/** /**
* 将权限新排序后面所有的权限排序+1 * 将权限新排序后面所有的权限排序+1
*
* @param authorityVo 权限对象 * @param authorityVo 权限对象
*/ */
private void afterPlus(AuthorityVo authorityVo){ private void afterPlus(AuthorityVo authorityVo) {
AuthorityGetReqVo reqVo = new AuthorityGetReqVo(); AuthorityGetReqVo reqVo = new AuthorityGetReqVo();
reqVo.setPid(authorityVo.getPid()); reqVo.setPid(authorityVo.getPid());
reqVo.setSort(authorityVo.getSort()); reqVo.setSort(authorityVo.getSort());
reqVo.setAttribute(authorityVo.getAttribute()); reqVo.setAttribute(authorityVo.getAttribute());
AuthorityVo authorityVo1 = authorityDao.load(reqVo,AuthorityVo.class); AuthorityVo authorityVo1 = authorityDao.load(reqVo, AuthorityVo.class);
if (authorityVo1 != null){ if (authorityVo1 != null) {
AuthorityAfterReqVo afterReqVo = new AuthorityAfterReqVo(); AuthorityAfterReqVo afterReqVo = new AuthorityAfterReqVo();
ObjectHelper.writeWithFrom(afterReqVo,authorityVo); ObjectHelper.writeWithFrom(afterReqVo, authorityVo);
List<AuthorityVo> authorityVoList = authorityDao.after(afterReqVo); List<AuthorityVo> authorityVoList = authorityDao.after(afterReqVo);
for (AuthorityVo authorityVo2:authorityVoList) { for (AuthorityVo authorityVo2 : authorityVoList) {
Integer sort = authorityVo2.getSort(); Integer sort = authorityVo2.getSort();
Integer newSort = sort+1; Integer newSort = sort + 1;
authorityVo2.setSort(newSort); authorityVo2.setSort(newSort);
authorityDao.update(authorityVo2); authorityDao.update(authorityVo2);
} }
} }
} }
private void afterSub(AuthorityVo authorityVo){ private void afterSub(AuthorityVo authorityVo) {
AuthorityGetReqVo getReqVo = new AuthorityGetReqVo(); AuthorityGetReqVo getReqVo = new AuthorityGetReqVo();
getReqVo.setId(authorityVo.getId()); getReqVo.setId(authorityVo.getId());
AuthorityVo authorityVo1 = authorityDao.load(getReqVo,AuthorityVo.class); AuthorityVo authorityVo1 = authorityDao.load(getReqVo, AuthorityVo.class);
if (authorityVo1 != null){ if (authorityVo1 != null) {
AuthorityAfterReqVo afterReqVo = new AuthorityAfterReqVo(); AuthorityAfterReqVo afterReqVo = new AuthorityAfterReqVo();
ObjectHelper.writeWithFrom(afterReqVo,authorityVo); ObjectHelper.writeWithFrom(afterReqVo, authorityVo);
List<AuthorityVo> authorityVoList = authorityDao.after(afterReqVo); List<AuthorityVo> authorityVoList = authorityDao.after(afterReqVo);
for (AuthorityVo authorityVo2:authorityVoList) { for (AuthorityVo authorityVo2 : authorityVoList) {
Integer sort = authorityVo2.getSort(); Integer sort = authorityVo2.getSort();
Integer newSort = sort-1; Integer newSort = sort - 1;
authorityVo2.setSort(newSort); authorityVo2.setSort(newSort);
authorityDao.update(authorityVo2); authorityDao.update(authorityVo2);
} }
...@@ -117,7 +119,7 @@ public class AuthorityServiceImpl implements AuthorityService { ...@@ -117,7 +119,7 @@ public class AuthorityServiceImpl implements AuthorityService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public AuthorityListResVo update(AuthorityVo authorityVo) { public AuthorityListResVo update(AuthorityVo authorityVo) {
/*this.checkValid(authorityVo);*/ /*this.checkValid(authorityVo);*/
if (null == authorityVo.getPid() || authorityVo.getPid().isEmpty()){ if (null == authorityVo.getPid() || authorityVo.getPid().isEmpty()) {
authorityVo.setPid(""); authorityVo.setPid("");
} }
updateSort(authorityVo); updateSort(authorityVo);
...@@ -130,8 +132,8 @@ public class AuthorityServiceImpl implements AuthorityService { ...@@ -130,8 +132,8 @@ public class AuthorityServiceImpl implements AuthorityService {
private void updateSort(AuthorityVo authorityVo) { private void updateSort(AuthorityVo authorityVo) {
AuthorityGetReqVo authorityGetReqVo = new AuthorityGetReqVo(); AuthorityGetReqVo authorityGetReqVo = new AuthorityGetReqVo();
authorityGetReqVo.setId(authorityVo.getId()); authorityGetReqVo.setId(authorityVo.getId());
AuthorityVo old = authorityDao.load(authorityGetReqVo,AuthorityVo.class); AuthorityVo old = authorityDao.load(authorityGetReqVo, AuthorityVo.class);
if(old.getSort() > authorityVo.getSort()) { if (old.getSort() > authorityVo.getSort()) {
AuthorityBetweenSortReqVo reqVo = new AuthorityBetweenSortReqVo(); AuthorityBetweenSortReqVo reqVo = new AuthorityBetweenSortReqVo();
reqVo.setPid(authorityVo.getPid()); reqVo.setPid(authorityVo.getPid());
reqVo.setSmallSort(authorityVo.getSort()); reqVo.setSmallSort(authorityVo.getSort());
...@@ -143,7 +145,7 @@ public class AuthorityServiceImpl implements AuthorityService { ...@@ -143,7 +145,7 @@ public class AuthorityServiceImpl implements AuthorityService {
authorityDao.update(authorityVo1); authorityDao.update(authorityVo1);
} }
} }
if (old.getSort() < authorityVo.getSort()){ if (old.getSort() < authorityVo.getSort()) {
AuthorityBetweenSortReqVo reqVo = new AuthorityBetweenSortReqVo(); AuthorityBetweenSortReqVo reqVo = new AuthorityBetweenSortReqVo();
reqVo.setPid(authorityVo.getPid()); reqVo.setPid(authorityVo.getPid());
reqVo.setSmallSort(old.getSort()); reqVo.setSmallSort(old.getSort());
...@@ -178,19 +180,19 @@ public class AuthorityServiceImpl implements AuthorityService { ...@@ -178,19 +180,19 @@ public class AuthorityServiceImpl implements AuthorityService {
public AuthorityResVo getAuthorityById(WebAuthorityReqVo reqVo) { public AuthorityResVo getAuthorityById(WebAuthorityReqVo reqVo) {
AuthorityGetReqVo authorityGetReqVo = new AuthorityGetReqVo(); AuthorityGetReqVo authorityGetReqVo = new AuthorityGetReqVo();
authorityGetReqVo.setId(reqVo.getId()); authorityGetReqVo.setId(reqVo.getId());
AuthorityVo authorityVo = authorityDao.load(authorityGetReqVo,AuthorityVo.class); AuthorityVo authorityVo = authorityDao.load(authorityGetReqVo, AuthorityVo.class);
if (authorityVo == null){ if (authorityVo == null) {
throw new CodeException("该权限不存在"); throw new CodeException("该权限不存在");
} }
AuthorityResVo resVo = new AuthorityResVo(); AuthorityResVo resVo = new AuthorityResVo();
ObjectHelper.writeWithFrom(resVo,authorityVo); ObjectHelper.writeWithFrom(resVo, authorityVo);
if (null != authorityVo.getPid() && !authorityVo.getPid().isEmpty()){ if (null != authorityVo.getPid() && !authorityVo.getPid().isEmpty()) {
AuthorityGetReqVo getReqVo = new AuthorityGetReqVo(); AuthorityGetReqVo getReqVo = new AuthorityGetReqVo();
getReqVo.setId(authorityVo.getPid()); getReqVo.setId(authorityVo.getPid());
AuthorityVo parent = authorityDao.load(getReqVo,AuthorityVo.class); AuthorityVo parent = authorityDao.load(getReqVo, AuthorityVo.class);
if (null != parent){ if (null != parent) {
resVo.setParentName(parent.getName()); resVo.setParentName(parent.getName());
} }
} }
...@@ -210,16 +212,16 @@ public class AuthorityServiceImpl implements AuthorityService { ...@@ -210,16 +212,16 @@ public class AuthorityServiceImpl implements AuthorityService {
/*将该权限排序后的权限排序-1*/ /*将该权限排序后的权限排序-1*/
AuthorityGetReqVo getReqVo = new AuthorityGetReqVo(); AuthorityGetReqVo getReqVo = new AuthorityGetReqVo();
getReqVo.setId(reqVo.getId()); getReqVo.setId(reqVo.getId());
AuthorityVo authority = authorityDao.load(getReqVo,AuthorityVo.class); AuthorityVo authority = authorityDao.load(getReqVo, AuthorityVo.class);
if (null != authority){ if (null != authority) {
afterSub(authority); afterSub(authority);
} }
AuthorityGetReqVo reqVo1 = new AuthorityGetReqVo(); AuthorityGetReqVo reqVo1 = new AuthorityGetReqVo();
reqVo1.setPid(reqVo.getId()); reqVo1.setPid(reqVo.getId());
List<AuthorityVo> childList = authorityDao.loadList(reqVo1,AuthorityVo.class); List<AuthorityVo> childList = authorityDao.loadList(reqVo1, AuthorityVo.class);
if (childList != null && !childList.isEmpty()){ if (childList != null && !childList.isEmpty()) {
for (AuthorityVo child:childList) { for (AuthorityVo child : childList) {
WebAuthorityReqVo reqVo2 = new WebAuthorityReqVo(); WebAuthorityReqVo reqVo2 = new WebAuthorityReqVo();
reqVo2.setId(child.getId()); reqVo2.setId(child.getId());
this.deleteAuthorityById(reqVo2); this.deleteAuthorityById(reqVo2);
...@@ -232,8 +234,8 @@ public class AuthorityServiceImpl implements AuthorityService { ...@@ -232,8 +234,8 @@ public class AuthorityServiceImpl implements AuthorityService {
RoleAuthorityGetReqVo roleAuthorityGetReqVo = new RoleAuthorityGetReqVo(); RoleAuthorityGetReqVo roleAuthorityGetReqVo = new RoleAuthorityGetReqVo();
roleAuthorityGetReqVo.setAuthorityId(reqVo.getId()); roleAuthorityGetReqVo.setAuthorityId(reqVo.getId());
List<RoleAuthorityVo> roleAuthorityList = roleAuthorityDao.loadList(roleAuthorityGetReqVo,RoleAuthorityVo.class); List<RoleAuthorityVo> roleAuthorityList = roleAuthorityDao.loadList(roleAuthorityGetReqVo, RoleAuthorityVo.class);
for (RoleAuthorityVo roleAuthority:roleAuthorityList) { for (RoleAuthorityVo roleAuthority : roleAuthorityList) {
roleAuthorityDao.remove(roleAuthority); roleAuthorityDao.remove(roleAuthority);
} }
} }
...@@ -249,27 +251,27 @@ public class AuthorityServiceImpl implements AuthorityService { ...@@ -249,27 +251,27 @@ public class AuthorityServiceImpl implements AuthorityService {
PageSizeData<AuthorityVo> authorityVoPageSizeData = authorityDao.getAuthorityList(reqVo); PageSizeData<AuthorityVo> authorityVoPageSizeData = authorityDao.getAuthorityList(reqVo);
PageSizeData<WebAuthorityResVo> webAuthorityResVoPageSizeData = new PageSizeData(); PageSizeData<WebAuthorityResVo> webAuthorityResVoPageSizeData = new PageSizeData();
List<AuthorityVo> authorityVoList = authorityVoPageSizeData.getList(); List<AuthorityVo> authorityVoList = authorityVoPageSizeData.getList();
if (authorityVoList == null || authorityVoList.isEmpty()){ if (authorityVoList == null || authorityVoList.isEmpty()) {
throw new CodeException("没有更多权限"); throw new CodeException("没有更多权限");
} }
List<WebAuthorityResVo> webAuthorityResVoList = new ArrayList(authorityVoList.size()); List<WebAuthorityResVo> webAuthorityResVoList = new ArrayList(authorityVoList.size());
for (AuthorityVo authorityVo:authorityVoList) { for (AuthorityVo authorityVo : authorityVoList) {
WebAuthorityResVo resVo = new WebAuthorityResVo(); WebAuthorityResVo resVo = new WebAuthorityResVo();
ObjectHelper.writeWithFrom(resVo,authorityVo); ObjectHelper.writeWithFrom(resVo, authorityVo);
if (null != authorityVo.getPid() && !authorityVo.getPid().isEmpty()){ // if (null != authorityVo.getPid() && !authorityVo.getPid().isEmpty()) {
AuthorityGetReqVo authorityGetReqVo = new AuthorityGetReqVo(); // AuthorityGetReqVo authorityGetReqVo = new AuthorityGetReqVo();
authorityGetReqVo.setId(authorityVo.getPid()); // authorityGetReqVo.setId(authorityVo.getPid());
AuthorityVo parent = authorityDao.load(authorityGetReqVo,AuthorityVo.class); // AuthorityVo parent = authorityDao.load(authorityGetReqVo, AuthorityVo.class);
if(!StringHelper.isEmpty(parent)){ // if (!StringHelper.isEmpty(parent)) {
resVo.setParentName(parent.getName()); // resVo.setParentName(parent.getName());
}else{ // } else {
System.out.println("id:" + authorityVo.getPid()); // System.out.println("id:" + authorityVo.getPid());
} // }
//
} // }
webAuthorityResVoList.add(resVo); webAuthorityResVoList.add(resVo);
} }
ObjectHelper.writeWithFrom(webAuthorityResVoPageSizeData,authorityVoPageSizeData); ObjectHelper.writeWithFrom(webAuthorityResVoPageSizeData, authorityVoPageSizeData);
webAuthorityResVoPageSizeData.setList(webAuthorityResVoList); webAuthorityResVoPageSizeData.setList(webAuthorityResVoList);
return webAuthorityResVoPageSizeData; return webAuthorityResVoPageSizeData;
...@@ -277,12 +279,13 @@ public class AuthorityServiceImpl implements AuthorityService { ...@@ -277,12 +279,13 @@ public class AuthorityServiceImpl implements AuthorityService {
/** /**
* 查询不分页权限列表 * 查询不分页权限列表
*
* @return * @return
*/ */
@Override @Override
public List<AuthorityVo> getAuthorityList(AuthorityListReqVo reqVo) { public List<AuthorityVo> getAuthorityList(AuthorityListReqVo reqVo) {
List<AuthorityVo> authorityVoList = authorityDao.loadList(reqVo,AuthorityVo.class); List<AuthorityVo> authorityVoList = authorityDao.loadList(reqVo, AuthorityVo.class);
if (null == authorityVoList || authorityVoList.isEmpty()){ if (null == authorityVoList || authorityVoList.isEmpty()) {
throw new CodeException("暂无权限,请先添加"); throw new CodeException("暂无权限,请先添加");
} }
return authorityVoList; return authorityVoList;
...@@ -290,91 +293,132 @@ public class AuthorityServiceImpl implements AuthorityService { ...@@ -290,91 +293,132 @@ public class AuthorityServiceImpl implements AuthorityService {
@Override @Override
public AuthorityListResVo getListByLevel(AuthorityListReqVo reqVo) { public AuthorityListResVo getListByLevel(AuthorityListReqVo reqVo) {
AuthorityListResVo authorityListResVo = new AuthorityListResVo();
// 找到该公司管理员角色 // 找到该公司管理员角色
RoleGetReqVo roleGetReqVo = new RoleGetReqVo(); RoleGetReqVo roleGetReqVo = new RoleGetReqVo();
roleGetReqVo.setCompanyId(reqVo.getCompanyId()); roleGetReqVo.setCompanyId(reqVo.getCompanyId());
roleGetReqVo.setIsAdmin(1); roleGetReqVo.setIsAdmin(1);
RoleVo roleVo = roleDaoImpl.load(roleGetReqVo,RoleVo.class); RoleVo roleVo = roleDaoImpl.load(roleGetReqVo, RoleVo.class);
if (StringHelper.isEmpty(roleVo)){ if (StringHelper.isEmpty(roleVo)) {
throw new CodeException("该公司用户未设置管理员角色"); throw new CodeException("该公司用户未设置管理员角色");
} }
Set authorityIdSet = new HashSet();
RoleAuthorityGetReqVo roleAuthorityGetReqVo = new RoleAuthorityGetReqVo(); RoleAuthorityGetReqVo roleAuthorityGetReqVo = new RoleAuthorityGetReqVo();
roleAuthorityGetReqVo.setRoleId(roleVo.getId()); roleAuthorityGetReqVo.setRole(roleVo.getId());
List<RoleAuthorityVo> roleAuthorityVoList = roleAuthorityDao.loadList(roleAuthorityGetReqVo,RoleAuthorityVo.class); List<AuthorityListByLevelResVo> roleAuthorityVoList = roleAuthorityDao.loadList(roleAuthorityGetReqVo, AuthorityListByLevelResVo.class);
for (RoleAuthorityVo roleAuthorityVo:roleAuthorityVoList) { authorityListResVo.setAuthorityListByLevel(getChildList(roleAuthorityVoList, false));
authorityIdSet.add(roleAuthorityVo.getAuthorityId());
}
List<String> authorityIdList = new ArrayList<>(); RoleAuthorityGetReqVo roleAuthorityGetReqVo1 = new RoleAuthorityGetReqVo();
Object[] objs = authorityIdSet.toArray(); roleAuthorityGetReqVo1.setRole(reqVo.getRoleId());
for (Object obj:objs) { List<AuthorityVo> roleAuthorityVoList1 = roleAuthorityDao.loadList(roleAuthorityGetReqVo, AuthorityVo.class);
authorityIdList.add((String) obj); authorityListResVo.setAuthorityListByRole(roleAuthorityVoList1);
}
List<AuthorityVo> levelOneList = new ArrayList(); // for (RoleAuthorityVo roleAuthorityVo:roleAuthorityVoList) {
for (int i = 0; i < authorityIdList.size(); i++) { // authorityIdSet.add(roleAuthorityVo.getAuthorityId());
AuthorityGetReqVo authorityGetReqVo = new AuthorityGetReqVo(); // }
authorityGetReqVo.setId(authorityIdList.get(i));
AuthorityVo authorityVo = authorityDao.load(authorityGetReqVo,AuthorityVo.class); // List<String> authorityIdList = new ArrayList<>();
if (!StringHelper.isEmpty(authorityVo) && StringHelper.isEmpty(authorityVo.getPid())){ // Object[] objs = authorityIdSet.toArray();
levelOneList.add(authorityVo); // for (Object obj:objs) {
authorityIdList.set(i,""); // authorityIdList.add((String) obj);
} // }
} // List<AuthorityVo> levelOneList = new ArrayList();
List<String> authorityIds = new ArrayList<>(); // for (int i = 0; i < authorityIdList.size(); i++) {
for (int i = 0; i < authorityIdList.size(); i++) { // AuthorityGetReqVo authorityGetReqVo = new AuthorityGetReqVo();
if (!"".equals(authorityIdList.get(i))){ // authorityGetReqVo.setId(authorityIdList.get(i));
authorityIds.add(authorityIdList.get(i)); // AuthorityVo authorityVo = authorityDao.load(authorityGetReqVo,AuthorityVo.class);
} // if (!StringHelper.isEmpty(authorityVo) && StringHelper.isEmpty(authorityVo.getPid())){
} // levelOneList.add(authorityVo);
Collections.sort(levelOneList); // authorityIdList.set(i,"");
if (levelOneList.isEmpty()){ // }
throw new CodeException("该用户暂无权限,请添加"); // }
// List<String> authorityIds = new ArrayList<>();
// for (int i = 0; i < authorityIdList.size(); i++) {
// if (!"".equals(authorityIdList.get(i))){
// authorityIds.add(authorityIdList.get(i));
// }
// }
// Collections.sort(levelOneList);
// if (levelOneList.isEmpty()){
// throw new CodeException("该用户暂无权限,请添加");
// }
// List<AuthorityListByLevelResVo> authorityListByLevel = new ArrayList<>();
// for (AuthorityVo authorityVo:levelOneList) {
// AuthorityListByLevelResVo resVo1 = new AuthorityListByLevelResVo();
// ObjectHelper.writeWithFrom(resVo1,authorityVo);
// List<AuthorityListByLevelResVo> childList = registerServiceImpl.getChildList(authorityVo,authorityIds);
// resVo1.setChildList(childList);
// authorityListByLevel.add(resVo1);
// }
// Collections.sort(authorityListByLevel);
// AuthorityListResVo authorityListResVo = new AuthorityListResVo();
// authorityListResVo.setAuthorityListByLevel(authorityListByLevel);
// /*若roleId存在,则需要返回该角色拥有的权限列表*/
// if (null != reqVo.getRoleId() && !reqVo.getRoleId().isEmpty()){
// RoleAuthorityGetReqVo roleAuthorityGetReqVo1 = new RoleAuthorityGetReqVo();
// roleAuthorityGetReqVo1.setRoleId(reqVo.getRoleId());
// List<RoleAuthorityVo> roleAuthorityVos = roleAuthorityDao.loadList(roleAuthorityGetReqVo1,RoleAuthorityVo.class);
// List<AuthorityVo> authorityVoList = new ArrayList<>();
// if (null != roleAuthorityVos && !roleAuthorityVos.isEmpty()){
// for (RoleAuthorityVo roleAuthorityVo:roleAuthorityVos) {
// AuthorityGetReqVo getReqVo = new AuthorityGetReqVo();
// getReqVo.setId(roleAuthorityVo.getAuthorityId());
// AuthorityVo authorityVo = authorityDao.load(getReqVo,AuthorityVo.class);
// if (null != authorityVo){
// authorityVoList.add(authorityVo);
// }
// }
// }
// authorityListResVo.setAuthorityListByRole(authorityVoList);
// }
return authorityListResVo;
}
public static <T extends AuthorityListByLevelResVo> List<T> getChildList(List<T> list, boolean check) {
if (list == null || list.isEmpty()) {
return list;
} }
List<AuthorityListByLevelResVo> authorityListByLevel = new ArrayList<>(); Map<String, T> idMap = new HashMap<>(list.size());
for (AuthorityVo authorityVo:levelOneList) { List<T> root = new ArrayList<>();
AuthorityListByLevelResVo resVo1 = new AuthorityListByLevelResVo(); // 将所有对象进行映射
ObjectHelper.writeWithFrom(resVo1,authorityVo); for (T vo : list) {
List<AuthorityListByLevelResVo> childList = registerServiceImpl.getChildList(authorityVo,authorityIds); String id = vo.getId();
resVo1.setChildList(childList); idMap.put(id, vo);
authorityListByLevel.add(resVo1);
} }
Collections.sort(authorityListByLevel);
AuthorityListResVo authorityListResVo = new AuthorityListResVo(); // 组合成父子级关系
authorityListResVo.setAuthorityListByLevel(authorityListByLevel); for (T vo : list) {
String pid = StringHelper.getFirst(vo.getPid());
/*若roleId存在,则需要返回该角色拥有的权限列表*/ String id = vo.getId();
if (null != reqVo.getRoleId() && !reqVo.getRoleId().isEmpty()){ //当前对象的父对象不存在则创建一个临时的父对象
RoleAuthorityGetReqVo roleAuthorityGetReqVo1 = new RoleAuthorityGetReqVo(); if (StringHelper.isEmpty(pid)) {
roleAuthorityGetReqVo1.setRoleId(reqVo.getRoleId()); root.add(vo);
List<RoleAuthorityVo> roleAuthorityVos = roleAuthorityDao.loadList(roleAuthorityGetReqVo1,RoleAuthorityVo.class); } else if (idMap.containsKey(pid)) {
List<AuthorityVo> authorityVoList = new ArrayList<>(); // List<AuthorityListByLevelResVo> childList = idMap.get(pid).getChildList();
if (null != roleAuthorityVos && !roleAuthorityVos.isEmpty()){ // if (null == childList) {
for (RoleAuthorityVo roleAuthorityVo:roleAuthorityVos) { // childList = new ArrayList<>();
AuthorityGetReqVo getReqVo = new AuthorityGetReqVo(); // }
getReqVo.setId(roleAuthorityVo.getAuthorityId()); // childList.add(vo);
AuthorityVo authorityVo = authorityDao.load(getReqVo,AuthorityVo.class); idMap.get(pid).getChildList().add(vo);
if (null != authorityVo){ } else if (check) {
authorityVoList.add(authorityVo); throw new CodeException(String.format("存在数据不合理,子节点[%s]父id[%s]不存在", id, pid));
}
}
} }
authorityListResVo.setAuthorityListByRole(authorityVoList);
} }
return authorityListResVo; return root;
} }
private List<AuthorityListByLevelResVo> getChildList(String id){ private List<AuthorityListByLevelResVo> getChildList(String id) {
AuthorityGetReqVo reqVo = new AuthorityGetReqVo(); AuthorityGetReqVo reqVo = new AuthorityGetReqVo();
reqVo.setPid(id); reqVo.setPid(id);
List<AuthorityVo> childList = authorityDao.listBySort(reqVo); List<AuthorityVo> childList = authorityDao.listBySort(reqVo);
List<AuthorityListByLevelResVo> childResList = new ArrayList(); List<AuthorityListByLevelResVo> childResList = new ArrayList();
if (null != childList && !childList.isEmpty()){ if (null != childList && !childList.isEmpty()) {
for (AuthorityVo authorityVo:childList) { for (AuthorityVo authorityVo : childList) {
AuthorityListByLevelResVo resVo = new AuthorityListByLevelResVo(); AuthorityListByLevelResVo resVo = new AuthorityListByLevelResVo();
ObjectHelper.writeWithFrom(resVo,authorityVo); ObjectHelper.writeWithFrom(resVo, authorityVo);
List<AuthorityListByLevelResVo> grandchildList = getChildList(authorityVo.getId()); List<AuthorityListByLevelResVo> grandchildList = getChildList(authorityVo.getId());
resVo.setChildList(grandchildList); resVo.setChildList(grandchildList);
childResList.add(resVo); childResList.add(resVo);
...@@ -388,42 +432,42 @@ public class AuthorityServiceImpl implements AuthorityService { ...@@ -388,42 +432,42 @@ public class AuthorityServiceImpl implements AuthorityService {
UserGetReqVo userGetReqVo = new UserGetReqVo(); UserGetReqVo userGetReqVo = new UserGetReqVo();
userGetReqVo.setCompanyId(reqVo.getCompanyId()); userGetReqVo.setCompanyId(reqVo.getCompanyId());
userGetReqVo.setIsFirst(1); userGetReqVo.setIsFirst(1);
UserVo superAdmin = userDaoImpl.load(userGetReqVo,UserVo.class); UserVo superAdmin = userDaoImpl.load(userGetReqVo, UserVo.class);
if (null == superAdmin){ if (null == superAdmin) {
throw new CodeException("暂无超级管理员"); throw new CodeException("暂无超级管理员");
} }
UserRoleGetReqVo getReqVo = new UserRoleGetReqVo(); UserRoleGetReqVo getReqVo = new UserRoleGetReqVo();
getReqVo.setUserId(superAdmin.getId()); getReqVo.setUserId(superAdmin.getId());
List<UserRoleVo> userRoleVoList = userRoleDaoImpl.loadList(getReqVo,UserRoleVo.class); List<UserRoleVo> userRoleVoList = userRoleDaoImpl.loadList(getReqVo, UserRoleVo.class);
if (null == userRoleVoList || userRoleVoList.isEmpty()){ if (null == userRoleVoList || userRoleVoList.isEmpty()) {
throw new CodeException("暂无权限"); throw new CodeException("暂无权限");
} }
List<RoleAuthorityVo> roleAuthorityVoList = new ArrayList(); List<RoleAuthorityVo> roleAuthorityVoList = new ArrayList();
for (UserRoleVo userRoleVo:userRoleVoList) { for (UserRoleVo userRoleVo : userRoleVoList) {
RoleAuthorityGetReqVo roleAuthorityGetReqVo = new RoleAuthorityGetReqVo(); RoleAuthorityGetReqVo roleAuthorityGetReqVo = new RoleAuthorityGetReqVo();
roleAuthorityGetReqVo.setRoleId(userRoleVo.getRoleId()); roleAuthorityGetReqVo.setRoleId(userRoleVo.getRoleId());
List<RoleAuthorityVo> roleAuthorityVos = roleAuthorityDao.loadList(roleAuthorityGetReqVo,RoleAuthorityVo.class); List<RoleAuthorityVo> roleAuthorityVos = roleAuthorityDao.loadList(roleAuthorityGetReqVo, RoleAuthorityVo.class);
roleAuthorityVoList.addAll(roleAuthorityVos); roleAuthorityVoList.addAll(roleAuthorityVos);
} }
if (null == roleAuthorityVoList || roleAuthorityVoList.isEmpty()){ if (null == roleAuthorityVoList || roleAuthorityVoList.isEmpty()) {
throw new CodeException("暂无权限"); throw new CodeException("暂无权限");
} }
List<AuthorityVo> authorityVoList = new ArrayList(); List<AuthorityVo> authorityVoList = new ArrayList();
for (RoleAuthorityVo roleAuthorityVo:roleAuthorityVoList) { for (RoleAuthorityVo roleAuthorityVo : roleAuthorityVoList) {
AuthorityGetReqVo authorityGetReqVo = new AuthorityGetReqVo(); AuthorityGetReqVo authorityGetReqVo = new AuthorityGetReqVo();
authorityGetReqVo.setId(roleAuthorityVo.getAuthorityId()); authorityGetReqVo.setId(roleAuthorityVo.getAuthorityId());
AuthorityVo authorityVo = authorityDao.load(authorityGetReqVo,AuthorityVo.class); AuthorityVo authorityVo = authorityDao.load(authorityGetReqVo, AuthorityVo.class);
if (authorityVo != null){ if (authorityVo != null) {
authorityVoList.add(authorityVo); authorityVoList.add(authorityVo);
} }
} }
if (null == authorityVoList || authorityVoList.isEmpty()){ if (null == authorityVoList || authorityVoList.isEmpty()) {
throw new CodeException("暂无权限"); throw new CodeException("暂无权限");
} }
List<AuthorityListByLevelResVo> resVoList = new ArrayList(); List<AuthorityListByLevelResVo> resVoList = new ArrayList();
for (AuthorityVo authorityVo:authorityVoList) { for (AuthorityVo authorityVo : authorityVoList) {
AuthorityListByLevelResVo resVo = new AuthorityListByLevelResVo(); AuthorityListByLevelResVo resVo = new AuthorityListByLevelResVo();
ObjectHelper.writeWithFrom(resVo,authorityVo); ObjectHelper.writeWithFrom(resVo, authorityVo);
List<AuthorityListByLevelResVo> childList = getChildList(authorityVo.getId()); List<AuthorityListByLevelResVo> childList = getChildList(authorityVo.getId());
resVo.setChildList(childList); resVo.setChildList(childList);
resVoList.add(resVo); resVoList.add(resVo);
......
...@@ -13,6 +13,7 @@ import com.pangding.web.authority.util.RsaConstant; ...@@ -13,6 +13,7 @@ import com.pangding.web.authority.util.RsaConstant;
import com.pangding.web.authority.vo.*; import com.pangding.web.authority.vo.*;
import com.pangding.web.authority.vo.reqvo.*; import com.pangding.web.authority.vo.reqvo.*;
import com.pangding.web.authority.vo.resvo.*; import com.pangding.web.authority.vo.resvo.*;
import com.pangding.web.constant.OrderConstant;
import com.pangding.web.util.RSAUtils; import com.pangding.web.util.RSAUtils;
import com.pangding.web.vo.system.req.company.CompanyMoneyDetailReqVo; import com.pangding.web.vo.system.req.company.CompanyMoneyDetailReqVo;
import com.pangding.web.vo.system.req.company.CompanyMoneyUpdateReqVo; import com.pangding.web.vo.system.req.company.CompanyMoneyUpdateReqVo;
...@@ -977,14 +978,14 @@ public class CompanyServiceImpl implements CompanyService { ...@@ -977,14 +978,14 @@ public class CompanyServiceImpl implements CompanyService {
// req = new UpdateCompanyMoneyReqVo(); // req = new UpdateCompanyMoneyReqVo();
// req.setCompanyId(companyVo.getId()); // req.setCompanyId(companyVo.getId());
if (CompanyConstant.MONEY_TYPE_FZ == req.getMoneyType() if (OrderConstant.CATEGORY_ENTRY == req.getMoneyType()
|| CompanyConstant.MONEY_TYPE_ZZ == req.getMoneyType() || OrderConstant.CATEGORY_DIVIDEND == req.getMoneyType()
|| CompanyConstant.MONEY_TYPE_CZ == req.getMoneyType()) { || OrderConstant.CATEGORY_RECHARGE == req.getMoneyType()) {
// 分账 转账 充值 // 分账 转账 充值
companyMoney += req.getMoney(); companyMoney += req.getMoney();
} }
if (CompanyConstant.MONEY_TYPE_REFUND == req.getMoneyType() if (OrderConstant.CATEGORY_REFUND == req.getMoneyType()
|| CompanyConstant.MONEY_TYPE_TX == req.getMoneyType()) { || OrderConstant.CATEGORY_WITHDRAWAL == req.getMoneyType()) {
// 退款 提现 // 退款 提现
companyMoney -= req.getMoney(); companyMoney -= req.getMoney();
} }
......
...@@ -378,19 +378,14 @@ public class RegisterServiceImpl implements RegisterService { ...@@ -378,19 +378,14 @@ public class RegisterServiceImpl implements RegisterService {
} }
String token = TokenUtil.createToken(reqVo.getAccountOrPhone()); String token = TokenUtil.createToken(reqVo.getAccountOrPhone());
// 登录返回参数
LoginResVo resVo = new LoginResVo(); LoginResVo resVo = new LoginResVo();
resVo.setToken(token); resVo.setToken(token);
userVo.setPassword(""); userVo.setPassword("");
userVo.setRemark(""); userVo.setRemark("");
resVo.setUserVo(userVo); resVo.setUserVo(userVo);
CompanyGetReqVo companyGetReqVo = new CompanyGetReqVo();
companyGetReqVo.setId(userVo.getCompanyId());
CompanyVo companyVo = companyDaoImpl.load(companyGetReqVo,CompanyVo.class);
LoginCompanyResVo loginCompanyResVo = new LoginCompanyResVo();
loginCompanyResVo.setCompanyVo(companyVo);
resVo.setCompanyResVo(loginCompanyResVo);
reqVo.setToken(token);
// 保存登录token
LoginTokenVo loginVo = new LoginTokenVo(); LoginTokenVo loginVo = new LoginTokenVo();
loginVo.setToken(token); loginVo.setToken(token);
loginVo.setDataPwd(token); loginVo.setDataPwd(token);
...@@ -398,39 +393,18 @@ public class RegisterServiceImpl implements RegisterService { ...@@ -398,39 +393,18 @@ public class RegisterServiceImpl implements RegisterService {
loginVo.setExpairTime(DateHelper.getNow()); loginVo.setExpairTime(DateHelper.getNow());
tokenService.save(loginVo); tokenService.save(loginVo);
TokenHelper.write(token,loginVo); TokenHelper.write(token,loginVo);
// TODO
// LoginTokenVo longVo1 = TokenHelper.get(false,LoginTokenVo.class);
// System.out.println("loning=====" + JsonHelper.serialize(longVo1));
CompanyBankCardGetReqVo getReqVo = new CompanyBankCardGetReqVo();
getReqVo.setCompanyId(companyVo.getId());
List<CompanyBankCardVo> companyBankCardVoList = companyBankCardDaoImpl.loadList(getReqVo,CompanyBankCardVo.class);
if (companyBankCardVoList != null && !companyBankCardVoList.isEmpty()){
loginCompanyResVo.setBankCardVoList(companyBankCardVoList);
}
resVo.setCompanyResVo(loginCompanyResVo);
/*获取商家信息*/ // 找到登录用户公司信息
CompanyScenicInfoReqVo companyScenicInfoReqVo = new CompanyScenicInfoReqVo(); CompanyGetReqVo companyGetReqVo = new CompanyGetReqVo();
companyScenicInfoReqVo.setReqId(StringHelper.getNewID()); companyGetReqVo.setId(userVo.getCompanyId());
companyScenicInfoReqVo.setCompanyId(companyVo.getId()); CompanyVo companyVo = companyDaoImpl.load(companyGetReqVo,CompanyVo.class);
companyScenicInfoReqVo.setProductOrInterface(0); // 判断基本信息是否完善,及状态是否为2,且为个人用户,若不完善则跳转个人完善页面
ResponseResult result = new ResponseResult();
try {
result = storeFeign.getCompanyScenicInfo(companyScenicInfoReqVo);
}catch (Exception e){
resVo.setMerchant(null);
}
Merchant merchant = (Merchant) result.getData();
resVo.setMerchant(merchant);
/*判断基本信息是否完善,及状态是否为2,且为个人用户,若不完善则跳转个人完善页面*/
if (companyVo.getStatus() < (CompanyConstant.COMPANY_STATUS_BIND_PHONE) && CompanyConstant.COMPANY_TYPE_PERSON==(companyVo.getCompanyType())){ if (companyVo.getStatus() < (CompanyConstant.COMPANY_STATUS_BIND_PHONE) && CompanyConstant.COMPANY_TYPE_PERSON==(companyVo.getCompanyType())){
resVo.setCode("01"); resVo.setCode("01");
resVo.setMsg("个人基本信息未完善,跳转个人完善页面"); resVo.setMsg("个人基本信息未完善,跳转个人完善页面");
return resVo; return resVo;
} }
/*判断基本信息是否完善,及状态是否为2,且为公司用户,若不完善则跳转个人完善页面*/ // 判断基本信息是否完善,及状态是否为2,且为公司用户,若不完善则跳转个人完善页面
else if (companyVo.getStatus() < (CompanyConstant.COMPANY_STATUS_BIND_PHONE) && (CompanyConstant.COMPANY_TYPE_COMPANY==(companyVo.getCompanyType()))){ else if (companyVo.getStatus() < (CompanyConstant.COMPANY_STATUS_BIND_PHONE) && (CompanyConstant.COMPANY_TYPE_COMPANY==(companyVo.getCompanyType()))){
resVo.setCode("02"); resVo.setCode("02");
resVo.setMsg("公司基本信息未完善,跳转公司完善页面"); resVo.setMsg("公司基本信息未完善,跳转公司完善页面");
...@@ -453,71 +427,100 @@ public class RegisterServiceImpl implements RegisterService { ...@@ -453,71 +427,100 @@ public class RegisterServiceImpl implements RegisterService {
resVo.setUrl(companyReqVo1.getSignUrl()); resVo.setUrl(companyReqVo1.getSignUrl());
return resVo; return resVo;
}*/ }*/
LoginCompanyResVo loginCompanyResVo = new LoginCompanyResVo();
loginCompanyResVo.setCompanyVo(companyVo);
resVo.setCompanyResVo(loginCompanyResVo);
reqVo.setToken(token);
// 找到公司银行信息
CompanyBankCardGetReqVo getReqVo = new CompanyBankCardGetReqVo();
getReqVo.setCompanyId(companyVo.getId());
List<CompanyBankCardVo> companyBankCardVoList = companyBankCardDaoImpl.loadList(getReqVo,CompanyBankCardVo.class);
if (companyBankCardVoList == null || companyBankCardVoList.isEmpty()){ if (companyBankCardVoList == null || companyBankCardVoList.isEmpty()){
/*该公司没有银行卡,需要跳转添加银行卡*/ /*该公司没有银行卡,需要跳转添加银行卡*/
resVo.setCode("03"); resVo.setCode("03");
resVo.setMsg("还未添加银行卡,跳转添加银行卡页面"); resVo.setMsg("还未添加银行卡,跳转添加银行卡页面");
return resVo; return resVo;
} }
/*获取用户权限列表*/ loginCompanyResVo.setBankCardVoList(companyBankCardVoList);
UserRoleGetReqVo userRoleGetReqVo = new UserRoleGetReqVo(); resVo.setCompanyResVo(loginCompanyResVo);
userRoleGetReqVo.setUserId(userVo.getId());
List<UserRoleVo> userRoleVoList = userRoleDaoImpl.loadList(userRoleGetReqVo,UserRoleVo.class); /*获取商家信息*/
if (null != userRoleVoList && !userRoleVoList.isEmpty()){ CompanyScenicInfoReqVo companyScenicInfoReqVo = new CompanyScenicInfoReqVo();
List<String> roleIdList = new ArrayList(); companyScenicInfoReqVo.setReqId(StringHelper.getNewID());
for (UserRoleVo userRoleVo:userRoleVoList) { companyScenicInfoReqVo.setCompanyId(companyVo.getId());
roleIdList.add(userRoleVo.getRoleId()); companyScenicInfoReqVo.setProductOrInterface(0);
} ResponseResult result = new ResponseResult();
Set authorityIdSet = new HashSet(); try {
result = storeFeign.getCompanyScenicInfo(companyScenicInfoReqVo);
for (String roleId:roleIdList) { }catch (Exception e){
RoleAuthorityGetReqVo roleAuthorityGetReqVo = new RoleAuthorityGetReqVo(); resVo.setMerchant(null);
roleAuthorityGetReqVo.setRoleId(roleId);
List<RoleAuthorityVo> roleAuthorityVoList = roleAuthorityDaoImpl.loadList(roleAuthorityGetReqVo,RoleAuthorityVo.class);
if (roleAuthorityVoList != null && !roleAuthorityVoList.isEmpty()){
for (RoleAuthorityVo roleAuthorityVo:roleAuthorityVoList) {
authorityIdSet.add(roleAuthorityVo.getAuthorityId());
}
}
}
List<String> authorityIdList = new ArrayList();
Object[] objs = authorityIdSet.toArray();
for (Object obj:objs) {
authorityIdList.add((String) obj);
}
List<AuthorityVo> levelOneList = new ArrayList();
for (int i = 0; i < authorityIdList.size(); i++) {
AuthorityGetReqVo authorityGetReqVo = new AuthorityGetReqVo();
authorityGetReqVo.setId(authorityIdList.get(i));
AuthorityVo authorityVo = authorityDaoImpl.load(authorityGetReqVo,AuthorityVo.class);
if (!StringHelper.isEmpty(authorityVo) && StringHelper.isEmpty(authorityVo.getPid())){
levelOneList.add(authorityVo);
authorityIdList.set(i,"");
}
}
List<String> authorityIds = new ArrayList<>();
for (int i = 0; i < authorityIdList.size(); i++) {
if (!"".equals(authorityIdList.get(i))){
authorityIds.add(authorityIdList.get(i));
}
}
Collections.sort(levelOneList);
if (null == levelOneList || levelOneList.isEmpty()){
throw new CodeException("该用户暂无权限,请添加");
}
List<AuthorityListByLevelResVo> authorityListByLevel = new ArrayList<>();
for (AuthorityVo authorityVo:levelOneList) {
AuthorityListByLevelResVo resVo1 = new AuthorityListByLevelResVo();
ObjectHelper.writeWithFrom(resVo1,authorityVo);
List<AuthorityListByLevelResVo> childList = getChildList(authorityVo,authorityIds);
resVo1.setChildList(childList);
authorityListByLevel.add(resVo1);
}
Collections.sort(authorityListByLevel);
resVo.setAuthorityListByLevel(authorityListByLevel);
} }
Merchant merchant = (Merchant) result.getData();
resVo.setMerchant(merchant);
/*获取用户权限列表*/
RoleAuthorityGetReqVo roleAuthorityGetReqVo = new RoleAuthorityGetReqVo();
roleAuthorityGetReqVo.setUserId(userVo.getId());
List<AuthorityListByLevelResVo> roleAuthorityVoList = roleAuthorityDaoImpl.loadList(roleAuthorityGetReqVo,AuthorityListByLevelResVo.class);
resVo.setAuthorityListByLevel(AuthorityServiceImpl.getChildList(roleAuthorityVoList, false));
//
// UserRoleGetReqVo userRoleGetReqVo = new UserRoleGetReqVo();
// userRoleGetReqVo.setUserId(userVo.getId());
// List<UserRoleVo> userRoleVoList = userRoleDaoImpl.loadList(userRoleGetReqVo,UserRoleVo.class);
// if (null != userRoleVoList && !userRoleVoList.isEmpty()){
// List<String> roleIdList = new ArrayList();
// for (UserRoleVo userRoleVo:userRoleVoList) {
// roleIdList.add(userRoleVo.getRoleId());
// }
// Set authorityIdSet = new HashSet();
//
// for (String roleId:roleIdList) {
// RoleAuthorityGetReqVo roleAuthorityGetReqVo = new RoleAuthorityGetReqVo();
// roleAuthorityGetReqVo.setRoleId(roleId);
// List<RoleAuthorityVo> roleAuthorityVoList = roleAuthorityDaoImpl.loadList(roleAuthorityGetReqVo,RoleAuthorityVo.class);
// if (roleAuthorityVoList != null && !roleAuthorityVoList.isEmpty()){
// for (RoleAuthorityVo roleAuthorityVo:roleAuthorityVoList) {
// authorityIdSet.add(roleAuthorityVo.getAuthorityId());
// }
// }
// }
// List<String> authorityIdList = new ArrayList();
// Object[] objs = authorityIdSet.toArray();
// for (Object obj:objs) {
// authorityIdList.add((String) obj);
// }
// List<AuthorityVo> levelOneList = new ArrayList();
// for (int i = 0; i < authorityIdList.size(); i++) {
// AuthorityGetReqVo authorityGetReqVo = new AuthorityGetReqVo();
// authorityGetReqVo.setId(authorityIdList.get(i));
// AuthorityVo authorityVo = authorityDaoImpl.load(authorityGetReqVo,AuthorityVo.class);
// if (!StringHelper.isEmpty(authorityVo) && StringHelper.isEmpty(authorityVo.getPid())){
// levelOneList.add(authorityVo);
// authorityIdList.set(i,"");
// }
// }
// List<String> authorityIds = new ArrayList<>();
// for (int i = 0; i < authorityIdList.size(); i++) {
// if (!"".equals(authorityIdList.get(i))){
// authorityIds.add(authorityIdList.get(i));
// }
// }
// Collections.sort(levelOneList);
// if (null == levelOneList || levelOneList.isEmpty()){
// throw new CodeException("该用户暂无权限,请添加");
// }
// List<AuthorityListByLevelResVo> authorityListByLevel = new ArrayList<>();
// for (AuthorityVo authorityVo:levelOneList) {
// AuthorityListByLevelResVo resVo1 = new AuthorityListByLevelResVo();
// ObjectHelper.writeWithFrom(resVo1,authorityVo);
// List<AuthorityListByLevelResVo> childList = getChildList(authorityVo,authorityIds);
// resVo1.setChildList(childList);
// authorityListByLevel.add(resVo1);
// }
// Collections.sort(authorityListByLevel);
// resVo.setAuthorityListByLevel(authorityListByLevel);
// }
resVo.setCode("00"); resVo.setCode("00");
System.out.println(JsonHelper.serialize(resVo)); System.out.println(JsonHelper.serialize(resVo));
return resVo; return resVo;
......
...@@ -178,9 +178,10 @@ public class RoleServiceImpl implements RoleService { ...@@ -178,9 +178,10 @@ public class RoleServiceImpl implements RoleService {
List<WebRoleResVo> webRoleResVoList = new ArrayList(); List<WebRoleResVo> webRoleResVoList = new ArrayList();
for (RoleVo roleVo : roleVoList) { for (RoleVo roleVo : roleVoList) {
WebRoleResVo resVo = new WebRoleResVo(); WebRoleResVo resVo = new WebRoleResVo();
List<AuthorityVo> authorityVoList = this.getAuthorityListByRoleId(roleVo.getId());
ObjectHelper.writeWithFrom(resVo, roleVo); ObjectHelper.writeWithFrom(resVo, roleVo);
resVo.setAuthorityList(authorityVoList);
// List<AuthorityVo> authorityVoList = this.getAuthorityListByRoleId(roleVo.getId());
// resVo.setAuthorityList(authorityVoList);
CountByRoleReqVo countByRoleReqVo = new CountByRoleReqVo(); CountByRoleReqVo countByRoleReqVo = new CountByRoleReqVo();
countByRoleReqVo.setCompanyId(req.getCompanyId()); countByRoleReqVo.setCompanyId(req.getCompanyId());
...@@ -237,17 +238,17 @@ public class RoleServiceImpl implements RoleService { ...@@ -237,17 +238,17 @@ public class RoleServiceImpl implements RoleService {
@Override @Override
public List<AuthorityVo> getAuthorityListByRoleId(String roleId) { public List<AuthorityVo> getAuthorityListByRoleId(String roleId) {
RoleAuthorityGetReqVo reqVo = new RoleAuthorityGetReqVo(); RoleAuthorityGetReqVo reqVo = new RoleAuthorityGetReqVo();
reqVo.setRoleId(roleId); reqVo.setRole(roleId);
List<RoleAuthorityVo> roleAuthorityRelationList = roleAuthorityDaoImpl.loadList(reqVo, RoleAuthorityVo.class); List<AuthorityVo> roleAuthorityRelationList = roleAuthorityDaoImpl.loadList(reqVo, AuthorityVo.class);
if (roleAuthorityRelationList != null && !roleAuthorityRelationList.isEmpty()) { if (roleAuthorityRelationList != null && !roleAuthorityRelationList.isEmpty()) {
List<AuthorityVo> authorityList = new ArrayList(roleAuthorityRelationList.size()); // List<AuthorityVo> authorityList = new ArrayList(roleAuthorityRelationList.size());
for (RoleAuthorityVo roleAuthorityRelation : roleAuthorityRelationList) { // for (RoleAuthorityVo roleAuthorityRelation : roleAuthorityRelationList) {
AuthorityGetReqVo authorityGetReqVo = new AuthorityGetReqVo(); // AuthorityGetReqVo authorityGetReqVo = new AuthorityGetReqVo();
authorityGetReqVo.setId(roleAuthorityRelation.getAuthorityId()); // authorityGetReqVo.setId(roleAuthorityRelation.getAuthorityId());
AuthorityVo authorityVo = authorityDaoImpl.load(authorityGetReqVo, AuthorityVo.class); // AuthorityVo authorityVo = authorityDaoImpl.load(authorityGetReqVo, AuthorityVo.class);
authorityList.add(authorityVo); // authorityList.add(authorityVo);
} // }
return authorityList; return roleAuthorityRelationList;
} }
return null; return null;
} }
......
package com.pangding.web.authority.vo;
import java.util.List;
public interface IRoleAuthorityVo<T extends IRoleAuthorityVo> {
String getId();
String getPid();
List<T> getChildList();
}
...@@ -11,6 +11,18 @@ public class RoleAuthorityGetReqVo { ...@@ -11,6 +11,18 @@ public class RoleAuthorityGetReqVo {
private String roleId; private String roleId;
private String role;
private String userId;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getReqId() { public String getReqId() {
return reqId; return reqId;
} }
...@@ -34,4 +46,12 @@ public class RoleAuthorityGetReqVo { ...@@ -34,4 +46,12 @@ public class RoleAuthorityGetReqVo {
public void setAuthorityId(String authorityId) { public void setAuthorityId(String authorityId) {
this.authorityId = authorityId; this.authorityId = authorityId;
} }
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
} }
package com.pangding.web.authority.vo.reqvo; package com.pangding.web.authority.vo.reqvo;
import java.util.List;
/** /**
* @Author zhangjinyao * @Author zhangjinyao
* @create 2019/5/11 15:37 * @create 2019/5/11 15:37
...@@ -11,6 +13,8 @@ public class UserRoleGetReqVo { ...@@ -11,6 +13,8 @@ public class UserRoleGetReqVo {
private String userId; private String userId;
private List<String> roleIds;
public String getReqId() { public String getReqId() {
return reqId; return reqId;
} }
...@@ -34,4 +38,12 @@ public class UserRoleGetReqVo { ...@@ -34,4 +38,12 @@ public class UserRoleGetReqVo {
public void setRoleId(String roleId) { public void setRoleId(String roleId) {
this.roleId = roleId; this.roleId = roleId;
} }
public List<String> getRoleIds() {
return roleIds;
}
public void setRoleIds(List<String> roleIds) {
this.roleIds = roleIds;
}
} }
package com.pangding.web.authority.vo.resvo; package com.pangding.web.authority.vo.resvo;
import com.pangding.web.authority.vo.AuthorityVo; import com.pangding.web.authority.vo.AuthorityVo;
import com.pangding.web.authority.vo.IRoleAuthorityVo;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -10,7 +12,7 @@ import java.util.List; ...@@ -10,7 +12,7 @@ import java.util.List;
*/ */
public class AuthorityListByLevelResVo extends AuthorityVo { public class AuthorityListByLevelResVo extends AuthorityVo {
List<AuthorityListByLevelResVo> childList; List<AuthorityListByLevelResVo> childList = new ArrayList<>();
public List<AuthorityListByLevelResVo> getChildList() { public List<AuthorityListByLevelResVo> getChildList() {
return childList; return childList;
......
...@@ -28,4 +28,12 @@ public class AuthorityListResVo { ...@@ -28,4 +28,12 @@ public class AuthorityListResVo {
public void setAuthorityListByRole(List<AuthorityVo> authorityListByRole) { public void setAuthorityListByRole(List<AuthorityVo> authorityListByRole) {
this.authorityListByRole = authorityListByRole; this.authorityListByRole = authorityListByRole;
} }
// public List<AuthorityListByLevelResVo> getAuthorityListByRole() {
// return authorityListByRole;
// }
//
// public void setAuthorityListByRole(List<AuthorityListByLevelResVo> authorityListByRole) {
// this.authorityListByRole = authorityListByRole;
// }
} }
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