Commit 5192c828 authored by zjy's avatar zjy

user/role/tright 7.15

parent 9e37b133
package com.pangding.web.authority.dao;
import com.pangding.web.authority.vo.AuthorityVo;
import com.pangding.web.authority.vo.reqvo.AuthorityAfterReqVo;
import com.pangding.web.authority.vo.reqvo.AuthorityGetReqVo;
import com.pangding.web.authority.vo.reqvo.AuthorityListReqVo;
import com.pangding.web.authority.vo.reqvo.ListAuthorityByPageReqVo;
import com.pangding.web.authority.vo.reqvo.*;
import com.yanzuoguang.dao.BaseDao;
import com.yanzuoguang.util.vo.PageSizeData;
......@@ -35,4 +32,8 @@ public interface AuthorityDao extends BaseDao {
List<AuthorityVo> after(AuthorityAfterReqVo afterReqVo);
List<AuthorityVo> listBySort(AuthorityGetReqVo reqVo);
List<AuthorityVo> getLessBetween(AuthorityBetweenSortReqVo reqVo);
List<AuthorityVo> getMoreBetween(AuthorityBetweenSortReqVo reqVo);
}
......@@ -2,10 +2,7 @@ package com.pangding.web.authority.dao.impl;
import com.pangding.web.authority.dao.AuthorityDao;
import com.pangding.web.authority.vo.AuthorityVo;
import com.pangding.web.authority.vo.reqvo.AuthorityAfterReqVo;
import com.pangding.web.authority.vo.reqvo.AuthorityGetReqVo;
import com.pangding.web.authority.vo.reqvo.AuthorityListReqVo;
import com.pangding.web.authority.vo.reqvo.ListAuthorityByPageReqVo;
import com.pangding.web.authority.vo.reqvo.*;
import com.yanzuoguang.dao.impl.BaseDaoImpl;
import com.yanzuoguang.util.vo.PageSizeData;
import org.springframework.stereotype.Component;
......@@ -23,6 +20,8 @@ public class AuthorityDaoImpl extends BaseDaoImpl implements AuthorityDao {
private static final String GET_LEVEL_ONE = "GET_LEVEL_ONE";
private static final String AFTER = "AFTER";
private static final String LIST_BY_SORT = "LIST_BY_SORT";
private static final String GET_LESS_BETWEEN = "GET_LESS_BETWEEN";
private static final String GET_MORE_BETWEEN = "GET_MORE_BETWEEN";
@Override
protected void init() {
......@@ -42,10 +41,23 @@ public class AuthorityDaoImpl extends BaseDaoImpl implements AuthorityDao {
table.add(AFTER,"select * from pd_authority where 1=1 ")
.add("pid","and pid = ? ")
.add("sort","and sort >= ? ");
.add("sort","and sort >= ? ")
.add("attribute","and attribute = ?");
table.add(LIST_BY_SORT,"select * from pd_authority where 1=1 ")
.add("pid","and pid = ? order by sort asc");
table.add(GET_LESS_BETWEEN,"select * from pd_authority where 1=1 ")
.add("pid","and pid = ?")
.add("smallSort","and sort >= ?")
.add("bigSort","and sort < ?")
.add("attribute","and attribute = ?");
table.add(GET_MORE_BETWEEN,"select * from pd_authority where 1=1")
.add("pid","and pid = ?")
.add("smallSort","and sort > ?")
.add("bigSort","and sort <= ?")
.add("attribute","and attribute = ?");
}
/**
......@@ -83,4 +95,14 @@ public class AuthorityDaoImpl extends BaseDaoImpl implements AuthorityDao {
public List<AuthorityVo> listBySort(AuthorityGetReqVo reqVo) {
return this.query(AuthorityVo.class,LIST_BY_SORT,reqVo);
}
@Override
public List<AuthorityVo> getLessBetween(AuthorityBetweenSortReqVo reqVo) {
return this.query(AuthorityVo.class,GET_LESS_BETWEEN,reqVo);
}
@Override
public List<AuthorityVo> getMoreBetween(AuthorityBetweenSortReqVo reqVo) {
return this.query(AuthorityVo.class,GET_MORE_BETWEEN,reqVo);
}
}
......@@ -75,6 +75,7 @@ public class AuthorityServiceImpl implements AuthorityService {
AuthorityGetReqVo reqVo = new AuthorityGetReqVo();
reqVo.setPid(authorityVo.getPid());
reqVo.setSort(authorityVo.getSort());
reqVo.setAttribute(authorityVo.getAttribute());
AuthorityVo authorityVo1 = authorityDao.load(reqVo,AuthorityVo.class);
if (authorityVo1 != null){
AuthorityAfterReqVo afterReqVo = new AuthorityAfterReqVo();
......@@ -119,14 +120,43 @@ public class AuthorityServiceImpl implements AuthorityService {
if (null == authorityVo.getPid() || authorityVo.getPid().isEmpty()){
authorityVo.setPid("");
}
afterSub(authorityVo);
afterPlus(authorityVo);
updateSort(authorityVo);
authorityDao.update(authorityVo);
AuthorityListReqVo reqVo = new AuthorityListReqVo();
reqVo.setLevelOne("levelOne");
return this.getListByLevel(reqVo);
}
private void updateSort(AuthorityVo authorityVo) {
AuthorityGetReqVo authorityGetReqVo = new AuthorityGetReqVo();
authorityGetReqVo.setId(authorityVo.getId());
AuthorityVo old = authorityDao.load(authorityGetReqVo,AuthorityVo.class);
if(old.getSort() > authorityVo.getSort()) {
AuthorityBetweenSortReqVo reqVo = new AuthorityBetweenSortReqVo();
reqVo.setPid(authorityVo.getPid());
reqVo.setSmallSort(authorityVo.getSort());
reqVo.setBigSort(old.getSort());
reqVo.setAttribute(authorityVo.getAttribute());
List<AuthorityVo> authorityVoList = authorityDao.getLessBetween(reqVo);
for (AuthorityVo authorityVo1 : authorityVoList) {
authorityVo1.setSort(authorityVo1.getSort() + 1);
authorityDao.update(authorityVo1);
}
}
if (old.getSort() < authorityVo.getSort()){
AuthorityBetweenSortReqVo reqVo = new AuthorityBetweenSortReqVo();
reqVo.setPid(authorityVo.getPid());
reqVo.setSmallSort(old.getSort());
reqVo.setBigSort(authorityVo.getSort());
reqVo.setAttribute(authorityVo.getAttribute());
List<AuthorityVo> authorityVoList = authorityDao.getMoreBetween(reqVo);
for (AuthorityVo authorityVo1 : authorityVoList) {
authorityVo1.setSort(authorityVo1.getSort() - 1);
authorityDao.update(authorityVo1);
}
}
}
/**
* 检查新建、修改的authorityVo对象是否合法
*
......
......@@ -9,6 +9,16 @@ public class AuthorityAfterReqVo {
private String sort;
private Integer attribute;
public Integer getAttribute() {
return attribute;
}
public void setAttribute(Integer attribute) {
this.attribute = attribute;
}
public String getPid() {
return pid;
}
......
package com.pangding.web.authority.vo.reqvo;
/**
* @Author zhangjinyao
* @create 2019/7/15 16:31
*/
public class AuthorityBetweenSortReqVo {
private String pid;
private Integer smallSort;
private Integer bigSort;
private Integer attribute;
public Integer getAttribute() {
return attribute;
}
public void setAttribute(Integer attribute) {
this.attribute = attribute;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public Integer getSmallSort() {
return smallSort;
}
public void setSmallSort(Integer smallSort) {
this.smallSort = smallSort;
}
public Integer getBigSort() {
return bigSort;
}
public void setBigSort(Integer bigSort) {
this.bigSort = bigSort;
}
}
......@@ -12,6 +12,16 @@ public class AuthorityGetReqVo {
private Integer sort;
private Integer attribute;
public Integer getAttribute() {
return attribute;
}
public void setAttribute(Integer attribute) {
this.attribute = attribute;
}
public String getReqId() {
return reqId;
}
......
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