添加 岗位Tree

添加 部门Tree
添加 组织Tree
添加 功能Tree
岗位功能模块 开发完成
yun-zuoyi
wei.peng 7 years ago
parent 8d8cd35235
commit 64b4ce2200

@ -1,7 +1,9 @@
package cn.estsh.i3plus.core.api.iservice.busi;
import cn.estsh.i3plus.pojo.platform.bean.Department;
import cn.estsh.i3plus.pojo.platform.bean.Organize;
import cn.estsh.i3plus.pojo.platform.bean.Position;
import cn.estsh.i3plus.pojo.platform.bean.SysMenu;
import java.util.List;
@ -14,7 +16,40 @@ import java.util.List;
**/
public interface ICoreTreeService {
Department getDepartmentTreeByParentId(long depParentId);
/**
*
* @param parentId
* @return
*/
List<Position> findPositionTreeByParentId(long parentId);
/**
*
* @param id
* @return
*/
Position getPositionTreeByParentId(long id);
/**
*
* @param parent
* @param step
*/
void findPositionChildrenTreePack(Position parent,int step);
/**
*
* @param parentId
* @return
*/
List<Department> findDepartmentTreeByParentId(long parentId);
/**
*
* @param id
* @return
*/
Department getDepartmentTreeByParentId(long id);
/**
*
@ -24,24 +59,45 @@ public interface ICoreTreeService {
void findDepartmentChildrenTreePack(Department parent,int step);
/**
*
*
* @param parentId
* @return
*/
List<Position> findPositionTreeByParentId(long parentId);
List<Organize> findOrganizeTreeByParentId(long parentId);
/**
*
*
* @param id
* @return
*/
Position getPositionTreeByParentId(long id);
Organize getOrganizeTreeByParentId(long id);
/**
*
* @param parent
* @param step
*/
void findPositionChildrenTreePack(Position parent,int step);
void findOrganizeChildrenTreePack(Organize parent,int step);
/**
*
* @param parentId
* @return
*/
List<SysMenu> findSysMenuTreeByParentId(long parentId);
/**
*
* @param id
* @return
*/
SysMenu getSysMenuTreeByParentId(long id);
/**
*
* @param parent
* @param step
*/
void findSysMenuChildrenTreePack(SysMenu parent, int step);
}

@ -28,6 +28,13 @@ public interface IDepartmentService {
void deleteDepartmentById(String id);
/**
* id
* @param ids id
* @return
*/
void deleteDepartmentByIds(String[] ids);
/**
*
* @param department
*/

@ -36,6 +36,13 @@ public interface IOrganizeService {
void deleteOrganizeById(String id);
/**
* id
* @param ids id
* @return
*/
void deleteOrganizeByIds(String[] ids);
/**
*
* @param organize
* @return

@ -3,6 +3,7 @@ package cn.estsh.i3plus.core.api.iservice.busi;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.platform.bean.Position;
import org.springframework.data.domain.Page;
import java.util.List;
@ -30,6 +31,13 @@ public interface IPositionService {
void deletePositionById(String id);
/**
* id
* @param ids id
* @return
*/
void deletePositionByIds(String[] ids);
/**
*
*
* @param position
@ -45,6 +53,14 @@ public interface IPositionService {
List listPosition();
/**
*
* @param position
* @param pager
* @return
*/
ListPager<Position> queryPosition(Position position, Pager pager);
/**
* Key
*
* @param id
@ -60,10 +76,5 @@ public interface IPositionService {
*/
ListPager findPositionByPager(Position position, Pager pager);
/**
* id
* @param ids id
* @return
*/
void deletePositionByIds(String[] ids);
}

@ -32,6 +32,14 @@ public interface ISysMenuService {
void updateSysMenuStatus(String id, int status, SessionUser user);
/**
*
* @param ids
* @param status
* @param user
*/
void updateSysMenuStatusByIds(String[] ids, int status, SessionUser user);
/**
* Key
* @param id
* @return

@ -4,11 +4,13 @@ import cn.estsh.i3plus.core.api.iservice.busi.IDepartmentService;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.Department;
import cn.estsh.i3plus.pojo.platform.bean.SessionUser;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
import cn.estsh.impp.framework.boot.util.ResultBean;
import cn.estsh.impp.framework.boot.util.ValidatorBean;
@ -38,7 +40,6 @@ public class DepartmentController {
@Autowired
public IDepartmentService departmentService;
@PostMapping(value = "/insert")
@ApiOperation(value = "添加部门", notes = "返回内容添加部门")
public ResultBean insertDepartment(Department department) {
@ -48,7 +49,7 @@ public class DepartmentController {
//条件验证
ValidatorBean.beginValid(department)
.notNull("departmentName", department.getName())
.notNull("name", department.getName())
.notNull("departmentCode", department.getDepartmentCode())
.checkNotZero("organizeId",department.getOrganizeId());
@ -168,17 +169,23 @@ public class DepartmentController {
@DeleteMapping(value = "/batch-delete")
@ApiOperation(value = "根据id批量删除", notes = "根据id批量删除")
public ResultBean deleteDepartmentByIds(@RequestBody String[] ids) {
try {
// TODO 集合校验
// departmentService.(ids);
public ResultBean deleteDepartmentByIds(String[] ids){
try{
if(ids.length == 0){
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("请选择需要删除的资源。")
.build();
}
departmentService.deleteDepartmentByIds(ids);
return ResultBean.success("删除成功")
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
} catch (ImppBusiException busExcep) {
LOGGER.error(busExcep.getErrorMsg() + "{}", busExcep.getErrorDetail(), busExcep);
}catch(ImppBusiException busExcep){
LOGGER.error(busExcep.getErrorMsg() + "{}",busExcep.getErrorDetail(),busExcep);
return ResultBean.fail(busExcep.getErrorShow());
} catch (Exception e) {
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + "{}", e.getMessage(), e);
}catch(Exception e){
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + "{}",e.getMessage(),e);
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
}
}

@ -2,10 +2,12 @@ package cn.estsh.i3plus.core.apiservice.controller.busi;
import cn.estsh.i3plus.core.api.iservice.busi.IOrganizeService;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.Organize;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
import cn.estsh.impp.framework.boot.util.ResultBean;
import cn.estsh.impp.framework.boot.util.ValidatorBean;
@ -154,4 +156,27 @@ public class OrganizeController {
return ResultBean.fail().setCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode());
}
}
@DeleteMapping(value = "/batch-delete")
@ApiOperation(value = "根据id批量删除", notes = "根据id批量删除")
public ResultBean deleteOrganizeByIds(String[] ids){
try{
if(ids.length == 0){
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("请选择需要删除的资源。")
.build();
}
organizeService.deleteOrganizeByIds(ids);
return ResultBean.success("删除成功")
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}catch(ImppBusiException busExcep){
LOGGER.error(busExcep.getErrorMsg() + "{}",busExcep.getErrorDetail(),busExcep);
return ResultBean.fail(busExcep.getErrorShow());
}catch(Exception e){
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + "{}",e.getMessage(),e);
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
}
}
}

@ -21,7 +21,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.websocket.server.PathParam;
import java.util.List;
/**
@ -52,8 +51,10 @@ public class PositionController {
.notNull("name",position.getName())
.notNull("positionCode",position.getPositionCode());
//新增初始化
ConvertBean.modelInitialize(position,user);
if(position.getParentId() == null || position.getParentId().intValue() == 0){
position.setParentId(CommonEnumUtil.PARENT.DEFAULT.getValue());
}
positionService.insertPosition(position);
return ResultBean.success("添加成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
@ -127,13 +128,12 @@ public class PositionController {
}
}
@GetMapping(value="/get/{id}")
@ApiOperation(value="根据id查询岗位",notes="根据id查询岗位")
public ResultBean getPositionById(@PathVariable("id") String id){
@GetMapping(value="/query")
@ApiOperation(value="查询所有岗位",notes="查询所有岗位")
public ResultBean queryPosition(Position position,Pager pager){
try{
Position position = positionService.getPositionById(id);
return ResultBean.success("查询成功")
.setResultObject(position)
ListPager<Position> listPager = positionService.queryPosition(position, pager);
return ResultBean.success("操作成功").setListPager(listPager)
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}catch(ImppBusiException busExcep){
LOGGER.error(busExcep.getErrorMsg() + "{}",busExcep.getErrorDetail(),busExcep);
@ -144,14 +144,14 @@ public class PositionController {
}
}
@GetMapping(value="/query")
@ApiOperation(value="根据名称和代码查询岗位",notes="根据名称和代码查询岗位")
public ResultBean queryPositionByPager(Position position, Pager pager){
@GetMapping(value="/get/{id}")
@ApiOperation(value="根据id查询岗位",notes="根据id查询岗位")
public ResultBean getPositionById(@PathVariable("id") String id){
try{
ListPager positionListPager = positionService.findPositionByPager(position,pager);
Position position = positionService.getPositionById(id);
return ResultBean.success("查询成功")
.setListPager(positionListPager)
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
.setResultObject(position)
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}catch(ImppBusiException busExcep){
LOGGER.error(busExcep.getErrorMsg() + "{}",busExcep.getErrorDetail(),busExcep);
return ResultBean.fail(busExcep.getErrorShow());

@ -155,5 +155,24 @@ public class SysMenuController {
}
}
@PutMapping(value = "/batch-status")
@ApiOperation(value = "批量修改系统功能状态", notes = "根据ID修改系统功能状态")
public ResultBean updateBatchStatus(String[] ids,int status) {
try {
// 数据校验
ValidatorBean.checkNotNull(ids, "功能id 不能为空");
ValidatorBean.checkNotZero(status, "功能状态不能为空");
sysMenuService.updateSysMenuStatusByIds(ids,status,AuthUtil.getSessionUser());
return new ResultBean(true);
} catch(ImppBusiException busExcep){
LOGGER.error(busExcep.getErrorMsg() + "{}",busExcep.getErrorDetail(),busExcep);
return ResultBean.fail(busExcep.getErrorShow());
}catch(Exception e){
LOGGER.error(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getDescription() + "{}",e.getMessage(),e);
return ResultBean.fail().setCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode());
}
}
}

@ -1,10 +1,11 @@
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.core.api.iservice.busi.ICoreTreeService;
import cn.estsh.i3plus.pojo.platform.bean.Department;
import cn.estsh.i3plus.pojo.platform.bean.Position;
import cn.estsh.i3plus.pojo.platform.bean.*;
import cn.estsh.i3plus.pojo.platform.repository.DepartmentRepository;
import cn.estsh.i3plus.pojo.platform.repository.OrganizeRepository;
import cn.estsh.i3plus.pojo.platform.repository.PositionRepository;
import cn.estsh.i3plus.pojo.platform.repository.SysMenuRepository;
import cn.estsh.impp.framework.boot.util.ValidatorBean;
import javafx.scene.layout.VBox;
import org.slf4j.Logger;
@ -15,7 +16,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Description :
* @Description : Core
* @Reference :
* @Author : wei.peng
* @Date : 2018-10-24 11:17
@ -32,35 +33,11 @@ public class CoreTreeServiceImpl implements ICoreTreeService {
@Autowired
private PositionRepository positionRDao;
@Override
public Department getDepartmentTreeByParentId(long depParentId) {
Department depParent = departmentRDao.getById(depParentId);
//封装子集
findDepartmentChildrenTreePack(depParent, 0);
return depParent;
}
/**
*
*
* @param parent
*/
@Override
public void findDepartmentChildrenTreePack(Department parent, int step) {
++step;
List<Department> childDepList = departmentRDao.findByProperty("parentId", parent.getId());
if (childDepList.size() > 0) {
//说明有子集
for (Department depChild : childDepList) {
findDepartmentChildrenTreePack(depChild, step);
}
}
LOGGER.info("【{}】包含子集:{},步长:{}", parent.getName(), childDepList.size(), step);
parent.setChildList(childDepList);
}
@Autowired
private OrganizeRepository organizeRDao;
@Autowired
private SysMenuRepository menuRDao;
@Override
public List<Position> findPositionTreeByParentId(long parentId) {
@ -68,7 +45,6 @@ public class CoreTreeServiceImpl implements ICoreTreeService {
// 循环设置子集
if(result != null && result.size() > 0){
result.stream().forEach(position -> findPositionChildrenTreePack(position,0));
}
@ -102,4 +78,122 @@ public class CoreTreeServiceImpl implements ICoreTreeService {
LOGGER.info("【{}】包含子集:{},步长:{}", parent.getName(), childList.size(), step);
parent.setChildList(childList);
}
@Override
public List<Department> findDepartmentTreeByParentId(long parentId) {
List<Department> result = departmentRDao.findByProperty("parentId", parentId);
// 循环设置子集
if(result != null && result.size() > 0){
result.stream().forEach(department -> findDepartmentChildrenTreePack(department,0));
}
return result;
}
@Override
public Department getDepartmentTreeByParentId(long id) {
// 查找数据
Department department = departmentRDao.getById(id);
// 数据是否真实存在
ValidatorBean.checkNotNull(department,"不存在的部门信息");
// 递归查询子集
findDepartmentChildrenTreePack(department, 0);
return department;
}
@Override
public void findDepartmentChildrenTreePack(Department parent, int step) {
++step;
List<Department> childList = departmentRDao.findByProperty("parentId", parent.getId());
if (childList.size() > 0) {
//说明有子集
for (Department child : childList) {
findDepartmentChildrenTreePack(child, step);
}
}
LOGGER.info("【{}】包含子集:{},步长:{}", parent.getName(), childList.size(), step);
parent.setChildList(childList);
}
@Override
public List<Organize> findOrganizeTreeByParentId(long parentId) {
List<Organize> result = organizeRDao.findByProperty("parentId", parentId);
// 循环设置子集
if(result != null && result.size() > 0){
result.stream().forEach(organize -> findOrganizeChildrenTreePack(organize,0));
}
return result;
}
@Override
public Organize getOrganizeTreeByParentId(long id) {
// 查找数据
Organize organize = organizeRDao.getById(id);
// 数据是否真实存在
ValidatorBean.checkNotNull(organize,"不存在的组织信息");
// 递归查询子集
findOrganizeChildrenTreePack(organize, 0);
return organize;
}
@Override
public void findOrganizeChildrenTreePack(Organize parent, int step) {
++step;
List<Organize> childList = organizeRDao.findByProperty("parentId", parent.getId());
if (childList.size() > 0) { //说明有子集
for (Organize child : childList) {
findOrganizeChildrenTreePack(child, step);
}
}
LOGGER.info("【{}】包含子集:{},步长:{}", parent.getName(), childList.size(), step);
parent.setChildList(childList);
}
@Override
public List<SysMenu> findSysMenuTreeByParentId(long parentId) {
List<SysMenu> result = menuRDao.findByProperty("parentId", parentId);
// 循环设置子集
if(result != null && result.size() > 0){
result.stream().forEach(menu -> findSysMenuChildrenTreePack(menu,0));
}
return result;
}
@Override
public SysMenu getSysMenuTreeByParentId(long id) {
// 查找数据
SysMenu menu = menuRDao.getById(id);
// 数据是否真实存在
ValidatorBean.checkNotNull(menu,"不存在的组织信息");
// 递归查询子集
findSysMenuChildrenTreePack(menu, 0);
return menu;
}
@Override
public void findSysMenuChildrenTreePack(SysMenu parent, int step) {
++step;
List<SysMenu> childList = menuRDao.findByProperty("parentId", parent.getId());
if (childList.size() > 0) { //说明有子集
for (SysMenu child : childList) {
findSysMenuChildrenTreePack(child, step);
}
}
LOGGER.info("【{}】包含子集:{},步长:{}", parent.getName(), childList.size(), step);
parent.setChildList(childList);
}
}

@ -18,7 +18,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
/**
@ -80,6 +79,25 @@ public class DepartmentServiceImpl implements IDepartmentService {
}
@Override
public void deleteDepartmentByIds(String[] ids) {
long positionCount = departmentRDao.findByHqlWhereCount(CoreHqlPack.packHqlIds("parentId",ids));
if (positionCount >= 1) {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("存在子节点无法删除!")
.setErrorSolution("请重新操作")
.build();
}else {
Long[] array = new Long[ids.length];
for (int i = 0; i < ids.length; i++) {
array[i] = Long.parseLong(ids[i]);
}
departmentRDao.deleteByIdIn(array);
}
}
@Override
public void updateDepartment(Department department) {
// 查询父级部门名称
if (department.getParentId() != null && department.getParentId() > 0) {
@ -121,7 +139,7 @@ public class DepartmentServiceImpl implements IDepartmentService {
// TODO 分页日志格式 排序
return new ListPager(departmentRDao.listPager(pager),pager);
} else {
String hqlPack = CoreHqlPack.packHqlPosition(department);
String hqlPack = CoreHqlPack.packHqlDepartment(department);
pager = PagerHelper.getPager(pager, departmentRDao.findByHqlWhereCount(hqlPack));
// TODO 分页日志格式 排序
return new ListPager(departmentRDao.findByHqlWherePage(hqlPack + department.getOrderByParam(),pager),pager);

@ -2,14 +2,13 @@ package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.core.api.iservice.busi.IOrganizeService;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.Organize;
import cn.estsh.i3plus.pojo.platform.bean.SessionUser;
import cn.estsh.i3plus.pojo.platform.repository.OrganizeRepository;
import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
import cn.estsh.impp.framework.boot.util.ValidatorBean;
import org.aspectj.weaver.ast.Or;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -50,7 +49,7 @@ public class OrganizeServiceImpl implements IOrganizeService {
public void updateOrganizeStatus(String id, int status, SessionUser user) {
LOGGER.info("组织 ORGANIZE id:{} status:{} user:{}", id,status,user);
Organize organize = organizeRDao.getById(Long.parseLong(id));
organize.setOrganizeStatusId(status);
organize.setOrganizeStatus(status);
organize.setModifyUser(user.getUserName());
organizeRDao.update(organize);
}
@ -70,6 +69,24 @@ public class OrganizeServiceImpl implements IOrganizeService {
organizeRDao.deleteById(Long.parseLong(id));
}
@Override
public void deleteOrganizeByIds(String[] ids) {
long positionCount = organizeRDao.findByHqlWhereCount(CoreHqlPack.packHqlIds("parentId",ids));
if (positionCount >= 1) {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("存在子节点无法删除!")
.setErrorSolution("请重新操作")
.build();
}else {
Long[] array = new Long[ids.length];
for (int i = 0; i < ids.length; i++) {
array[i] = Long.parseLong(ids[i]);
}
organizeRDao.deleteByIdIn(array);
}
}
@Override
public Organize insertOrganize(Organize organize) {

@ -16,11 +16,13 @@ import cn.estsh.impp.framework.boot.util.ValidatorBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -43,9 +45,9 @@ public class PositionServiceImpl implements IPositionService {
// 查询父级岗位名称
if (position.getParentId() != null && position.getParentId() > 0) {
LOGGER.info("岗位信息 POSITION parentId:{}", position.getParentId());
Position parentPosition = positionRDao.getById(position.getParentId());
ValidatorBean.checkNotNull(parentPosition);
position.setRedParentName(parentPosition.getName());
}
@ -90,12 +92,48 @@ public class PositionServiceImpl implements IPositionService {
}
@Override
public void deletePositionByIds(String[] ids) {
long positionCount = positionRDao.findByHqlWhereCount(CoreHqlPack.packHqlIds("parentId",ids));
if (positionCount >= 1) {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("存在子节点无法删除!")
.setErrorSolution("请重新操作")
.build();
}else {
Long[] array = new Long[ids.length];
for (int i = 0; i < ids.length; i++) {
array[i] = Long.parseLong(ids[i]);
}
positionRDao.deleteByIdIn(array);
}
}
@Override
public List listPosition() {
LOGGER.info("岗位信息 Position list");
return positionRDao.list();
}
@Override
public ListPager<Position> queryPosition(Position position, Pager pager) {
LOGGER.info("岗位信息 Position find Position page");
if(position == null){
//不传入实体对象,查询所有
int count = positionRDao.listCount();
pager = PagerHelper.getPager(pager,count);
return new ListPager(positionRDao.listPager(pager),pager);
}else {
//生成hql查询语句
String hqlPack = CoreHqlPack.packHqlPosition(position);
pager = PagerHelper.getPager(pager,positionRDao.findByHqlWhereCount(hqlPack));
return new ListPager(positionRDao.findByHqlWherePage(hqlPack + position.orderBy(), pager),pager);
}
}
@Override
public Position getPositionById(String id) {
LOGGER.info("岗位信息 根据Id查询岗位信息 id:{}", id);
return positionRDao.getById(Long.parseLong(id));
@ -113,21 +151,6 @@ public class PositionServiceImpl implements IPositionService {
}
}
@Override
public void deletePositionByIds(String[] ids) {
long positionCount = positionRDao.findByHqlCount(CoreHqlPack.packHqlIds("id",ids));
if (positionCount >= 1) {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("存在子节点无法删除!")
.setErrorSolution("请重新操作")
.build();
}else {
for(String idStr : ids){
positionRDao.deleteById(Long.parseLong(idStr));
}
}
}
}

@ -2,6 +2,7 @@ package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.core.api.iservice.busi.ISysMenuService;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.HqlPack;
import cn.estsh.i3plus.pojo.platform.bean.SessionUser;
import cn.estsh.i3plus.pojo.platform.bean.SysMenu;
import cn.estsh.i3plus.pojo.platform.repository.SysMenuRepository;
@ -45,6 +46,15 @@ public class SysMenuServiceImpl implements ISysMenuService {
}
@Override
public void updateSysMenuStatusByIds(String[] ids, int status, SessionUser user) {
LOGGER.info("系统功能 SYS_MENU ids:{} status:{} user:{}", ids, status, user);
StringBuffer where = new StringBuffer();
HqlPack.getInPack(String.join(",", ids), "id", where);
sysMenuRDao.updateByHqlWhere(where.toString(), "status", status);
}
@Override
public void deleteSysMenuById(String id) {
LOGGER.info("系统功能 SYS_MENU Key:{}", id);
long count = sysMenuRDao.findByPropertyCount("parentId",Long.parseLong(id));

@ -1,18 +1,14 @@
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.core.api.iservice.busi.IPositionService;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.junit.runners.MethodSorters;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import java.util.List;
/**
* @Description :
@ -21,12 +17,10 @@ import java.util.List;
* @Date : 2018-10-29 19:12
* @Modify :
**/
//@SpringBootTest
//@RunWith(SpringRunner.class)
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
@FixMethodOrder(value = MethodSorters.DEFAULT) // <<--- I will change here for testing ...
public class TestBase {
@Before

@ -1,10 +1,14 @@
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.core.api.iservice.busi.IPositionService;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.platform.bean.Position;
import com.alibaba.fastjson.JSON;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.test.annotation.Rollback;
import javax.transaction.Transactional;
import java.util.List;
@ -22,57 +26,91 @@ public class TestPositionServiceImpl extends TestBase {
private IPositionService positionService;
/**
*
*
*/
@Test
@Transactional
public void testListPosition() {
List list = positionService.listPosition();
System.out.println(JSON.toJSONString(list));
@Rollback(false)
public void testInsertPosition(){
for(int i = 0 ; i < 50 ; i++ ){
Position position = new Position();
position.setName("Junit Test " + i);
position.setPositionCode("TEST_JUNIT " + i);
position = positionService.insertPosition(position);
System.out.println(JSON.toJSONString(position));
}
}
/**
*
* Key
* @return
*/
@Test
@Transactional
public void testGetPositionById() {
Position position = positionService.getPositionById("1056796316849541120");
System.out.println(JSON.toJSONString(position));
public void testGetPositionById(){
Position pos = positionService.getPositionById("1057108589715525632");
System.out.println(JSON.toJSONString(pos));
}
/**
*
*
*
* @return
*/
@Test
@Transactional
public void testInsertPosition() {
Position position = new Position();
position.setName("张三的岗位");
position.setPositionCode("ZS_CODE");
position.setPositionDescription("描述该岗位的信息");
Position pos = positionService.insertPosition(position);
System.out.println(JSON.toJSONString(pos));
public void testListPosition(){
List list = positionService.listPosition();
System.out.println(JSON.toJSONString(list));
}
/**
*
*
* @return
*/
@Test
@Transactional
public void testDeletePositionById() {
positionService.deletePositionById("105605611393555");
public void testFindPositionByPager(){
Position position = new Position();
Pager pager = new Pager();
pager.setPageSize(10);
pager.setCurrentPage(1);
ListPager list = positionService.findPositionByPager(null, pager);
System.out.println(JSON.toJSONString(list));
}
/**
*
*
*/
@Test
@Transactional
public void testUpdatePosition(){
Position position = positionService.getPositionById("1056878692237709312");
position.setName("===>> 改动后的名称");
Position position = positionService.getPositionById("1057108586410414080");
position.setName("Junit update Name ");
positionService.updatePosition(position);
System.out.println(JSON.toJSONString(position));
}
/**
* Key
*/
@Test
@Transactional
public void testDeletePositionById(){
positionService.deletePositionById("1057108585240203264");
}
/**
* id
* @return
*/
@Test
@Transactional
public void deletePositionByIds(){
positionService.deletePositionByIds(new String[]{"1057108585445724160","1057108585760296960"});
}

Loading…
Cancel
Save