| | |
| | | import cn.huge.base.common.utils.ObjectUtils; |
| | | import cn.huge.base.common.utils.ReturnFailUtils; |
| | | import cn.huge.base.common.utils.ReturnSucUtils; |
| | | import cn.huge.base.config.CurrentUser; |
| | | import cn.huge.module.ctuser.domain.po.CtUnit; |
| | | import cn.huge.module.ctuser.domain.po.CtUser; |
| | | import cn.huge.module.ctuser.service.CtUnitService; |
| | | import cn.huge.module.ctuser.service.CtUserService; |
| | | import cn.huge.module.cust.dto.CtUnitDTO; |
| | | import cn.huge.module.cust.dto.CtUserDTO; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private CtUserService ctUserService; |
| | | |
| | | /** |
| | | * 微服务调用-数据迁移-批量新增 |
| | | * @url {ctx}/api/client/ctUnit/saveCtUnitList |
| | | * @param targetCtUnitList 实体对象 |
| | | * @return Object |
| | | */ |
| | | @PostMapping("/saveCtUnitList") |
| | | public Object saveCtUnitList(@RequestBody List<CtUnit> targetCtUnitList) { |
| | | try { |
| | | service.saveBatch(targetCtUnitList,1000); |
| | | return ReturnSucUtils.getRepInfo(); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据id查询组织信息 |
| | | * @url {ctx}/api/client/ctUnit/getUnitById |
| | | * @param unitId 组织编号 |
| | |
| | | return ReturnFailUtils.getRepInfo("查询组织不存在!"); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("Controller接口[CtUnitClientController.getUnitById]请求异常:"+e, e); |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取上级综治中心 |
| | | * @url {ctx}/api/client/ctUnit/getParentZzzxUnit |
| | | * @param unitId 组织编号 |
| | | * @return Object |
| | | */ |
| | | @GetMapping("/getParentZzzxUnit") |
| | | public Object getParentZzzxUnit(@RequestParam(value = "unitId") String unitId) { |
| | | try { |
| | | return ReturnSucUtils.getRepInfo(service.getParentZzzx(unitId)); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取本级综治中心 |
| | | * @url {ctx}/api/client/ctUnit/getBjZzzx |
| | | * @param unitId 组织编号 |
| | | * @return Object |
| | | */ |
| | | @GetMapping("/getBjZzzx") |
| | | public Object getBjZzzx(@RequestParam(value = "unitId") String unitId) { |
| | | try { |
| | | return ReturnSucUtils.getRepInfo(service.getBjZzzx(unitId)); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询用户所在的单位信息 |
| | | * @url {ctx}/api/client/ctUnit/getUnitByUserId |
| | | * @param userId 用户编号 |
| | | * @return Object |
| | | */ |
| | | @GetMapping("/getUnitByUserId") |
| | | public Object getUnitByUserId(@RequestParam(value = "userId") String userId) { |
| | | try { |
| | | CtUser ctUser = ctUserService.getById(userId); |
| | | CtUnit ctUnit = service.getById(ctUser.getUnitId()); |
| | | if (ObjectUtils.isNotEmpty(ctUnit)){ |
| | | CtUnitDTO ctUnitDTO = new CtUnitDTO(); |
| | | BeanUtils.copyProperties(ctUnit, ctUnitDTO); |
| | | return ReturnSucUtils.getRepInfo(ctUnitDTO); |
| | | }else { |
| | | return ReturnFailUtils.getRepInfo("查询组织不存在!"); |
| | | } |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |