| | |
| | | package com.kidgrow.oprationcenter.controller; |
| | | |
| | | import java.util.Map; |
| | | import com.kidgrow.common.controller.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.ObjectError; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.kidgrow.common.model.PageResult; |
| | | import com.kidgrow.common.model.ResultBody; |
| | | import com.kidgrow.common.utils.ExcelUtil; |
| | | import com.kidgrow.oprationcenter.model.HospitalScreening; |
| | | import com.kidgrow.oprationcenter.model.ScreeningHospitalDataExcel; |
| | | import com.kidgrow.oprationcenter.service.IHospitalScreeningService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import com.kidgrow.oprationcenter.model.HospitalScreening; |
| | | import com.kidgrow.oprationcenter.service.IHospitalScreeningService; |
| | | import com.kidgrow.common.model.*; |
| | | |
| | | import org.apache.commons.collections4.MapUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.BindingResult; |
| | | import javax.validation.Valid; |
| | | import org.springframework.validation.ObjectError; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © 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 ResultBody<PageResult> 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 ResultBody.ok().data(hospitalScreeningService.findList(params)); |
| | | 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 { |
| | | boolean v= hospitalScreeningService.saveOrUpdate(hospitalScreening); |
| | | if(v) { |
| | | return ResultBody.ok().data(hospitalScreening).msg("保存成功"); |
| | | } else { |
| | | if (hospitalScreening.getId() == null) { |
| | | HospitalScreening hs = new HospitalScreening(); |
| | | hs.setHospitalId(hospitalScreening.getHospitalId()); |
| | | HospitalScreening byObject = hospitalScreeningService.findByObject(hs); |
| | | if (byObject != null) { |
| | | return ResultBody.failed().msg("该医院已添加"); |
| | | } |
| | | } |
| | | else { |
| | | boolean v = hospitalScreeningService.saveOrUpdate(hospitalScreening); |
| | | //更新redis |
| | | hospitalScreeningService.updateRedisById(hospitalScreening); |
| | | |
| | | if (v) { |
| | | return ResultBody.ok().data(hospitalScreening).msg("保存成功"); |
| | | } 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("删除失败"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改状态 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "修改反馈数据状态") |
| | | @GetMapping("/updateEnabled") |
| | | public ResultBody updateEnabled(@RequestParam Map<String, Object> params) { |
| | | if (params.size() == 0) { |
| | | return ResultBody.failed().msg("参数异常!"); |
| | | } |
| | | return hospitalScreeningService.updateEnabled(params); |
| | | } |
| | | |
| | | /** |
| | | * 查询 |
| | | */ |
| | | @ApiOperation(value = "查询") |
| | | @GetMapping("/findByName") |
| | | public ResultBody findByName(@RequestParam String hospitalName) { |
| | | if (!hospitalName.isEmpty()) { |
| | | return ResultBody.ok().data(hospitalScreeningService.findByName(hospitalName).getData()).msg("查询成功"); |
| | | } else { |
| | | return ResultBody.ok().data(null).msg(""); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "导出") |
| | | @PostMapping("/export") |
| | | 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"); |
| | | ExcelUtil.exportExcel(list, null, name, ScreeningHospitalDataExcel.class, name, response); |
| | | } |
| | | } |
| | | } |