New file |
| | |
| | | package com.dg.core.controller; |
| | | |
| | | import com.dg.core.ResultData; |
| | | import com.dg.core.db.gen.entity.OrganizationChartEntity; |
| | | import com.dg.core.service.IOrganizationChartService; |
| | | import com.dg.core.util.TableDataInfo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.Assert; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | |
| | | @Api(tags = {"组织架构接口"}) |
| | | @RestController |
| | | @RequestMapping("/organization") |
| | | public class OrganizationController extends BaseController |
| | | { |
| | | |
| | | @Autowired(required = true) |
| | | IOrganizationChartService iOrganizationChartService; |
| | | |
| | | /** |
| | | * 查询机构列表 |
| | | */ |
| | | @ApiOperation("查询机构列表") |
| | | @GetMapping("/getList") |
| | | public TableDataInfo selectConfigList() |
| | | { |
| | | return getDataTable(iOrganizationChartService.selectConfigList("","")); |
| | | } |
| | | |
| | | /** |
| | | * 新增机构 |
| | | */ |
| | | @ApiOperation("新增机构") |
| | | @PostMapping("/add") |
| | | public ResultData insertConfig(@RequestBody OrganizationChartEntity entity) |
| | | { |
| | | Assert.notNull(entity.getGrade(), "等级 grade 不能为空"); |
| | | |
| | | if (StringUtils.equals("1",entity.getGrade())) |
| | | { |
| | | if(!StringUtils.isEmpty(entity.getParentId())) |
| | | { |
| | | return ResultData.error("一级部门不能有父级部门"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if(StringUtils.isEmpty(entity.getParentId())) |
| | | { |
| | | return ResultData.error("非一级部门父级部门不能为空"); |
| | | } |
| | | } |
| | | return toAjax(iOrganizationChartService.insertConfig(entity)); |
| | | } |
| | | |
| | | /** |
| | | * 更新机构 |
| | | */ |
| | | @ApiOperation("更新机构") |
| | | @PostMapping("/update") |
| | | public ResultData updateConfig(@RequestBody OrganizationChartEntity entity) |
| | | { |
| | | return toAjax(iOrganizationChartService.updateConfig(entity)); |
| | | } |
| | | |
| | | /** |
| | | * 删除机构 |
| | | */ |
| | | @ApiOperation("删除机构") |
| | | @DeleteMapping("/delete") |
| | | public ResultData deleteConfigById(@RequestParam(value = "Id",required = false) String Id) |
| | | { |
| | | Assert.notNull(Id, "Id 不能为空"); |
| | | return toAjax(iOrganizationChartService.deleteConfigById(Id)); |
| | | } |
| | | |
| | | /** |
| | | * 查询机构列表(不分级不分页按等级排序) |
| | | */ |
| | | @ApiOperation(value = "查询机构列表(不分级不分页按等级排序)",response = OrganizationChartEntity.class) |
| | | @GetMapping("/selectList") |
| | | public TableDataInfo selectList(){ |
| | | return getDataTable(iOrganizationChartService.selectList()); |
| | | } |
| | | |
| | | /** |
| | | * 根据id查取消组织机构 |
| | | */ |
| | | @ApiOperation(value = "根据id查取消组织机构",response = OrganizationChartEntity.class) |
| | | @GetMapping("/selectById") |
| | | ResultData selectConfigById(@RequestParam("id") String id){ |
| | | return ResultData.success(iOrganizationChartService.selectConfigById(id)); |
| | | } |
| | | |
| | | } |