添加Tree 树控制器

yun-zuoyi
wei.peng 7 years ago
parent 646a3a5cb2
commit dd58bd9c2e

@ -0,0 +1,77 @@
package cn.estsh.i3plus.core.apiservice.controller.busi;
import cn.estsh.i3plus.core.api.iservice.busi.ICoreTreeService;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.Department;
import cn.estsh.i3plus.pojo.platform.bean.Position;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
import cn.estsh.impp.framework.boot.util.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @Description :
* @Reference :
* @Author : wei.peng
* @Date : 2018-10-29 14:56
* @Modify :
**/
@RestController
@RequestMapping("/tree")
@Api(description = "树服务")
public class TreeController {
public static final Logger LOGGER = LoggerFactory.getLogger(LogSystemController.class);
@Autowired
private ICoreTreeService coreTreeService;
@GetMapping(value="/position/get/{id}")
@ApiOperation(value="查询部门树",notes="通过部门主键获取部门树,-1为根节点")
public ResultBean listPositionTree(@PathVariable("id") long id) {
try {
Position position = coreTreeService.getPositionTreeByParentId(id);
return ResultBean.success("查询部门树成功")
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
.setResultObject(position);
}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());
}
}
@GetMapping(value="/position/list/{parentId}")
@ApiOperation(value="查询部门树",notes="通过部门主键获取部门树,-1为根节点")
public ResultBean listPositionListTree(@PathVariable("parentId") long parentId) {
try {
List<Position> positionList = coreTreeService.findPositionTreeByParentId(parentId);
return ResultBean.success("查询部门树成功")
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
.setResultList(positionList);
}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());
}
}
}
Loading…
Cancel
Save