| | |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * |
| | | * @Description: 筛查医院信息表-未完待续 |
| | | * @Project: 运营中心 |
| | | * @CreateDate: Created in 2020-04-02 18:25:34 <br> |
| | |
| | | @RestController |
| | | @RequestMapping("/hospitalscreening") |
| | | @Api(tags = "筛查医院信息表-未完待续") |
| | | public class HospitalScreeningController extends BaseController{ |
| | | public class HospitalScreeningController extends BaseController { |
| | | @Autowired |
| | | private IHospitalScreeningService hospitalScreeningService; |
| | | |
| | |
| | | @ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer") |
| | | }) |
| | | @GetMapping |
| | | public PageResult<HospitalScreening> list(@RequestParam Map<String, Object> params) { |
| | | if(params.size()==0){ |
| | | params.put("page",1); |
| | | params.put("limit",10); |
| | | public PageResult<HospitalScreening> list(@RequestParam Map<String, Object> params) { |
| | | if (params.size() == 0) { |
| | | params.put("page", 1); |
| | | params.put("limit", 10); |
| | | } |
| | | return hospitalScreeningService.findList(params); |
| | | } |
| | |
| | | @ApiOperation(value = "保存") |
| | | @PostMapping |
| | | public ResultBody save(@Valid @RequestBody HospitalScreening hospitalScreening, BindingResult bindingResult) { |
| | | List<String> errMsg= new ArrayList<>(); |
| | | List<String> errMsg = new ArrayList<>(); |
| | | if (bindingResult.hasErrors()) { |
| | | for (ObjectError error : bindingResult.getAllErrors()) { |
| | | errMsg.add(error.getDefaultMessage()); |
| | | } |
| | | return ResultBody.failed().msg(errMsg.toString()); |
| | | } else { |
| | | if(hospitalScreening.getId() == null){ |
| | | } else { |
| | | if (hospitalScreening.getId() == null) { |
| | | HospitalScreening hs = new HospitalScreening(); |
| | | hs.setHospitalId(hospitalScreening.getHospitalId()); |
| | | HospitalScreening byObject = hospitalScreeningService.findByObject(hs); |
| | | if(byObject != null){ |
| | | if (byObject != null) { |
| | | return ResultBody.failed().msg("该医院已添加"); |
| | | } |
| | | } |
| | | boolean v= hospitalScreeningService.saveOrUpdate(hospitalScreening); |
| | | if(v) { |
| | | boolean v = hospitalScreeningService.saveOrUpdate(hospitalScreening); |
| | | //更新redis |
| | | hospitalScreeningService.updateRedisById(hospitalScreening); |
| | | |
| | | if (v) { |
| | | return ResultBody.ok().data(hospitalScreening).msg("保存成功"); |
| | | } |
| | | else { |
| | | } else { |
| | | return ResultBody.failed().msg("保存失败"); |
| | | } |
| | | } |
| | |
| | | @ApiOperation(value = "删除") |
| | | @DeleteMapping("/{id}") |
| | | public ResultBody delete(@PathVariable Long id) { |
| | | boolean v= hospitalScreeningService.removeById(id); |
| | | if(v) { |
| | | boolean v = hospitalScreeningService.removeById(id); |
| | | if (v) { |
| | | return ResultBody.ok().msg("删除成功"); |
| | | } |
| | | else { |
| | | } else { |
| | | return ResultBody.failed().msg("删除失败"); |
| | | } |
| | | } |
| | |
| | | |
| | | @ApiOperation(value = "导出") |
| | | @PostMapping("/export") |
| | | public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws IOException { |
| | | public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws IOException { |
| | | List<ScreeningHospitalDataExcel> list = hospitalScreeningService.export(params); |
| | | //导出操作 |
| | | if(list != null && list.size() > 0) { |
| | | String name = MapUtils.getString(params,"hospitalName"); |
| | | if (list != null && list.size() > 0) { |
| | | String name = MapUtils.getString(params, "hospitalName"); |
| | | ExcelUtil.exportExcel(list, null, name, ScreeningHospitalDataExcel.class, name, response); |
| | | } |
| | | } |