| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.*; |
| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | | import org.springblade.core.log.annotation.ApiLog; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.secure.annotation.PreAuth; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.constant.RoleConstant; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.sxkj.common.constant.WordOrderConstant; |
| | | import org.sxkj.common.node.TreeStringNode; |
| | | import org.sxkj.common.utils.HeaderUtils; |
| | | import org.sxkj.common.utils.OrderNumUtils; |
| | | import org.sxkj.system.cache.DictCache; |
| | | import org.sxkj.system.cache.UserCache; |
| | | import org.sxkj.system.entity.Dept; |
| | | import org.sxkj.system.entity.Region; |
| | | import org.sxkj.system.entity.User; |
| | | import org.sxkj.system.enums.DictEnum; |
| | | import org.sxkj.system.excel.DeptExcel; |
| | | import org.sxkj.system.excel.DeptImporter; |
| | | import org.sxkj.system.excel.RegionExcel; |
| | | import org.sxkj.system.excel.RegionImporter; |
| | | import org.sxkj.system.mapper.DeptMapper; |
| | | import org.sxkj.system.mapper.UserMapper; |
| | | import org.sxkj.system.param.DeptAddParam; |
| | | import org.sxkj.system.param.DeptExportParam; |
| | | import org.sxkj.system.param.DeptPageParam; |
| | | import org.sxkj.system.service.IDeptService; |
| | | import org.sxkj.system.vo.DeptVO; |
| | | import org.sxkj.system.wrapper.DeptWrapper; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
| | |
| | | return R.data(DeptWrapper.build().entityVO(detail)); |
| | | } |
| | | |
| | | /** |
| | | * 机构 自定义分页 |
| | | */ |
| | | @GetMapping("/page") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "分页", notes = " ") |
| | | public R<IPage<DeptVO>> page(DeptPageParam deptPageParam, Query query) { |
| | | IPage<DeptVO> pages = deptService.selectDeptPage(Condition.getPage(query), deptPageParam); |
| | | return R.data(pages); |
| | | } |
| | | /** |
| | | * 列表 |
| | | */ |
| | |
| | | /** |
| | | * 新增或修改 |
| | | */ |
| | | // @PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | @PostMapping("/submit") |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入dept") |
| | | @ApiLog("组织机构信息新增或修改") |
| | | public R submit(@Valid @RequestBody Dept dept) { |
| | | if (deptService.submit(dept)) { |
| | | public R submit(@Valid @RequestBody DeptAddParam dept) { |
| | | Dept deptEntity = Objects.requireNonNull(BeanUtil.copy(dept, Dept.class)); |
| | | String times = OrderNumUtils.initOrderNum2(WordOrderConstant.ORG_CODE); |
| | | String deptCode = WordOrderConstant.ORG_PREFIX + times; |
| | | deptEntity.setDeptCode(deptCode); |
| | | if (deptService.submit(deptEntity)) { |
| | | CacheUtil.clear(SYS_CACHE); |
| | | CacheUtil.clear(SYS_CACHE, Boolean.FALSE); |
| | | List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getDeptId, dept.getId())); |
| | |
| | | */ |
| | | @GetMapping("/getParentDeptInfo") |
| | | @ApiOperationSupport(order = 12) |
| | | @ApiOperation(value = "下拉数据源", notes = "传入id集合") |
| | | @ApiOperation(value = "通过id查询", notes = "传入id集合") |
| | | public R getParentDeptInfo(String deptId) { |
| | | DeptVO list = deptService.getParentDeptInfo(deptId); |
| | | return R.data(list); |
| | |
| | | @ApiOperation(value = "查询机构树(根据区域)") |
| | | public R deptsByAreaCode(@RequestParam(required = false) String areaCode) { |
| | | String areaCodez = HeaderUtils.getAreaCode(); |
| | | if(StringUtils.isNotBlank(areaCode)) { |
| | | areaCodez=areaCode; |
| | | if (StringUtils.isNotBlank(areaCode)) { |
| | | areaCodez = areaCode; |
| | | } |
| | | List<DeptVO> list = deptService.deptsByAreaCode(areaCodez); |
| | | return R.data(list); |
| | | } |
| | | |
| | | /** |
| | | * 导入机构数据 |
| | | */ |
| | | @PostMapping("import-region") |
| | | @ApiOperationSupport(order = 14) |
| | | @ApiOperation(value = "导入机构", notes = "传入excel") |
| | | public R importRegion(MultipartFile file, Integer isCovered) { |
| | | DeptImporter deptImporter = new DeptImporter(deptService, isCovered == 1); |
| | | ExcelUtil.save(file, deptImporter, DeptExcel.class); |
| | | return R.success("操作成功"); |
| | | } |
| | | |
| | | /** |
| | | * 导出机构数据 |
| | | */ |
| | | @GetMapping("export-region") |
| | | @ApiOperationSupport(order = 15) |
| | | @ApiOperation(value = "导出机构", notes = "传入user") |
| | | public void exportRegion(DeptExportParam dept, HttpServletResponse response) { |
| | | List<DeptExcel> list = deptService.exportDept(dept); |
| | | ExcelUtil.export(response, "机构数据" + DateUtil.time(), "机构数据表", list, DeptExcel.class); |
| | | } |
| | | |
| | | /** |
| | | * 导出模板 |
| | | */ |
| | | @GetMapping("export-template") |
| | | @ApiOperationSupport(order = 16) |
| | | @ApiOperation(value = "导出模板") |
| | | public void exportUser(HttpServletResponse response) { |
| | | List<DeptExcel> list = new ArrayList<>(); |
| | | ExcelUtil.export(response, "机构模板", "机构表", list, DeptExcel.class); |
| | | } |
| | | |
| | | } |