| | |
| | | package com.kidgrow.usercenter.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.kidgrow.common.annotation.LoginUser; |
| | | import com.kidgrow.common.controller.BaseController; |
| | | import com.kidgrow.common.model.PageResult; |
| | | import com.kidgrow.common.model.ResultBody; |
| | | import com.kidgrow.common.model.SysOrganization; |
| | | import com.kidgrow.common.utils.StringUtils; |
| | | import com.kidgrow.common.model.SysUser; |
| | | import com.kidgrow.usercenter.model.SysDepartment; |
| | | import com.kidgrow.usercenter.service.ISysDepartmentService; |
| | | import com.kidgrow.usercenter.service.ISysOrganizationService; |
| | |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | SysDepartment model = sysDepartmentService.getById(id); |
| | | return ResultBody.ok().data(model).msg("查询成功"); |
| | | } |
| | | |
| | | /** |
| | | * 查询 |
| | | */ |
| | | @ApiOperation(value = "更新支付功能的开通状态") |
| | | @GetMapping("/updatePay") |
| | | public ResultBody updatePay(Long departmentId,Boolean isPay) { |
| | | boolean isPays = sysDepartmentService.updatePay(departmentId,isPay); |
| | | return ResultBody.ok().data(isPays).msg("操作成功"); |
| | | } |
| | | /** |
| | | * 查询 |
| | | */ |
| | | @ApiOperation(value = "查看支付功能的开通状态") |
| | | @GetMapping("/getPayMes") |
| | | public ResultBody getPayMes(Long departmentId) { |
| | | SysDepartment model = sysDepartmentService.getById(departmentId); |
| | | return ResultBody.ok().data(model.getIsPay()).msg("操作成功"); |
| | | } |
| | | /** |
| | | * 根据SysDepartment当做查询条件进行查询 |
| | | */ |
| | |
| | | */ |
| | | @ApiOperation(value = "检查科室名是否存在") |
| | | @GetMapping("/checkName") |
| | | public ResultBody checkDepName(@RequestParam Map<String, Object> params) { |
| | | params.put("page", 1); |
| | | params.put("limit", 1); |
| | | if (sysDepartmentService.findList(params).getData().size() > 0) { |
| | | return ResultBody.failed().msg(String.format("该医院下已经存在科室 %s", params.get("departmentName"))); |
| | | public ResultBody checkDepName(Long hospitalId,String departmentName) { |
| | | if (departMentNameIsUsed(hospitalId,departmentName)) { |
| | | return ResultBody.failed().msg(String.format("该医院下已经存在科室 %s", departmentName)); |
| | | } |
| | | return ResultBody.ok().msg(""); |
| | | } |
| | | |
| | | /** |
| | | * 检查科室名是否存在 |
| | | * @param hosId |
| | | * @param departmentName |
| | | * @return |
| | | */ |
| | | private Boolean departMentNameIsUsed(Long hosId,String departmentName) |
| | | { |
| | | String departName=sysDepartmentService.checkDepartmentName(hosId,departmentName); |
| | | return StringUtils.isNotBlank(departName); |
| | | } |
| | | /** |
| | | * 新增or更新 |
| | | */ |
| | | @ApiOperation(value = "保存") |
| | | @PostMapping |
| | | @PostMapping("/{hosId}") |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public ResultBody save(@Valid @RequestBody SysDepartment sysDepartment, BindingResult bindingResult) { |
| | | public ResultBody save(@Valid @RequestBody SysDepartment sysDepartment,@PathVariable Long hosId, BindingResult bindingResult,@LoginUser SysUser sysUser) { |
| | | List<String> errMsg = new ArrayList<>(); |
| | | if (bindingResult.hasErrors()) { |
| | | for (ObjectError error : bindingResult.getAllErrors()) { |
| | |
| | | } else { |
| | | //先检查该医院该科室是否已经存在 |
| | | if (sysDepartment.getId() == null) { |
| | | Map<String, Object> checkDepartment = new HashMap<String, Object>(); |
| | | checkDepartment.put("page", 1); |
| | | checkDepartment.put("limit", 1); |
| | | checkDepartment.put("departmentName", sysDepartment.getDepartmentName()); |
| | | if (sysDepartmentService.findList(checkDepartment).getData().size() > 0) { |
| | | |
| | | if (departMentNameIsUsed(hosId,sysDepartment.getDepartmentName())) { |
| | | return ResultBody.failed().msg(String.format("该医院下已经存在科室 %s", sysDepartment.getDepartmentName())); |
| | | } |
| | | } |
| | |
| | | sysOrganization.setOrgLevel(2); |
| | | //临时暂用其它字段承载数据 |
| | | sysOrganization.setOrgParentId(sysDepartment.getUpdateUserId()); |
| | | if(!sysUser.getOrganizations().isEmpty()){ |
| | | sysOrganization.setCreateUserOrgCode(sysUser.getOrganizations().get(1).getOrgCode()); |
| | | } |
| | | } else { |
| | | sysOrganization.setOrgName(sysDepartment.getDepartmentName()); |
| | | } |
| | |
| | | public ResultBody findListByHospitalId(@RequestParam Map<String, Object> params) { |
| | | return sysDepartmentService.findListByHospitalId(params); |
| | | } |
| | | @PostMapping |
| | | public ResultBody update(@RequestBody SysDepartment sysDepartment){ |
| | | if(sysDepartment.getId()==null){ |
| | | return ResultBody.failed("请输入id"); |
| | | } |
| | | QueryWrapper queryWrapper =new QueryWrapper(); |
| | | queryWrapper.eq("id",sysDepartment.getId()); |
| | | boolean update = sysDepartmentService.update(sysDepartment, queryWrapper); |
| | | if(update){ |
| | | return ResultBody.ok(); |
| | | }else { |
| | | return ResultBody.failed("更新数据失败"); |
| | | } |
| | | } |
| | | /** |
| | | *运动处方调用 是否开通服务 |
| | | */ |
| | | |
| | | @PostMapping("getHealth") |
| | | public ResultBody getHealth(@RequestBody SysDepartment sysDepartment){ |
| | | if(sysDepartment.getId()==null){ |
| | | return ResultBody.failed("请输入id"); |
| | | } |
| | | return sysDepartmentService.getHealth(sysDepartment); |
| | | } |
| | | |
| | | } |