| | |
| | | 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.web.bind.annotation.*; |
| | | import com.kidgrow.common.model.PageResult; |
| | | import com.kidgrow.common.model.ResultBody; |
| | | import com.kidgrow.oprationcenter.model.DoctorTemplete; |
| | | import com.kidgrow.oprationcenter.service.IDoctorTempleteService; |
| | | 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.DoctorTemplete; |
| | | import com.kidgrow.oprationcenter.service.IDoctorTempleteService; |
| | | import com.kidgrow.common.model.*; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.validation.ObjectError; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | 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-01 09:37:05 <br> |
| | | * @Project: 运营中心 |
| | | * @CreateDate: Created in 2020-04-02 18:25:34 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | * @version: 1.0 |
| | | */ |
| | |
| | | params.put("limit",10); |
| | | } |
| | | return doctorTempleteService.findList(params); |
| | | } |
| | | /** |
| | | * 医生的模板列表 |
| | | */ |
| | | @ApiOperation(value = "查询列表") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "page", value = "分页起始位置", required = true, dataType = "Integer"), |
| | | @ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer") |
| | | }) |
| | | @GetMapping("/doctorTempleteList") |
| | | public PageResult doctorList(@RequestParam Map<String, Object> params) { |
| | | if(params.size()==0){ |
| | | params.put("page",1); |
| | | params.put("limit",10); |
| | | } |
| | | return doctorTempleteService.findDoctorList(params); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation(value = "保存") |
| | | @PostMapping |
| | | public ResultBody save(@Valid @RequestBody DoctorTemplete doctorTemplete, BindingResult bindingResult) { |
| | | List<String> errMsg= new ArrayList<>(); |
| | | if (bindingResult.hasErrors()) { |
| | | return ResultBody.failed().msg(bindingResult.getFieldError().getDefaultMessage()); |
| | | } else { |
| | | doctorTempleteService.saveOrUpdate(doctorTemplete); |
| | | return ResultBody.ok().data(doctorTemplete).msg("保存成功"); |
| | | for (ObjectError error : bindingResult.getAllErrors()) { |
| | | errMsg.add(error.getDefaultMessage()); |
| | | } |
| | | return ResultBody.failed().msg(errMsg.toString()); |
| | | } else { |
| | | boolean v= doctorTempleteService.saveOrUpdate(doctorTemplete); |
| | | if(v) { |
| | | return ResultBody.ok().data(doctorTemplete.getId()).msg("模板保存成功!"); |
| | | } |
| | | else { |
| | | return ResultBody.failed().msg("模板保存失败,请稍候重试。"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //updateEnabled |
| | | @GetMapping("/updateEnabled") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "用户id", required = true, dataType = "Integer"), |
| | | @ApiImplicitParam(name = "enabled", value = "是否启用", required = true, dataType = "Boolean") |
| | | }) |
| | | public ResultBody updateEnabled(@RequestParam Map<String, Object> params) { |
| | | return doctorTempleteService.updateEnabled(params); |
| | | } |
| | | /** |
| | | * 删除 |
| | | */ |
| | | @ApiOperation(value = "删除") |
| | | @DeleteMapping("/{id}") |
| | | public ResultBody delete(@PathVariable Long id) { |
| | | doctorTempleteService.removeById(id); |
| | | return ResultBody.ok().msg("删除成功"); |
| | | boolean v= doctorTempleteService.removeById(id); |
| | | if(v) { |
| | | return ResultBody.ok().msg("删除成功"); |
| | | } |
| | | else { |
| | | return ResultBody.failed().msg("删除失败"); |
| | | } |
| | | } |
| | | } |