| | |
| | | package com.kidgrow.usercenter.controller; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import com.kidgrow.common.annotation.LoginUser; |
| | | import com.kidgrow.common.controller.BaseController; |
| | | import com.kidgrow.usercenter.vo.SysDoctorVo; |
| | | import com.kidgrow.common.model.PageResult; |
| | | import com.kidgrow.common.model.ResultBody; |
| | | import com.kidgrow.common.model.SysUser; |
| | | import com.kidgrow.usercenter.model.SysDoctor; |
| | | import com.kidgrow.usercenter.service.ISysDoctorService; |
| | | import com.kidgrow.usercenter.vo.SysDoctorDto; |
| | | import org.apache.commons.collections4.MapUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.ObjectError; |
| | | import org.springframework.web.bind.annotation.*; |
| | | 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.usercenter.model.SysDoctor; |
| | | import com.kidgrow.usercenter.service.ISysDoctorService; |
| | | import com.kidgrow.common.model.*; |
| | | |
| | | import org.apache.commons.collections4.MapUtils; |
| | | 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.servlet.http.HttpServletRequest; |
| | | import javax.validation.Valid; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * @Description: |
| | | * |
| | | * @Description: |
| | | * @Project: 用户中心 |
| | | * @CreateDate: Created in 2020-04-02 18:32:36 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | |
| | | @RestController |
| | | @RequestMapping("/sysdoctor") |
| | | @Api(tags = "医生表") |
| | | public class SysDoctorController extends BaseController{ |
| | | public class SysDoctorController extends BaseController { |
| | | @Autowired |
| | | private ISysDoctorService sysDoctorService; |
| | | |
| | |
| | | @ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer") |
| | | }) |
| | | @GetMapping |
| | | public PageResult<SysDoctorVo> list(@RequestParam Map<String, Object> params,@LoginUser SysUser user) { |
| | | if(params.size()==0){ |
| | | params.put("page",1); |
| | | params.put("limit",10); |
| | | public PageResult<SysDoctorDto> list(@RequestParam Map<String, Object> params, @LoginUser SysUser user) { |
| | | if (params.size() == 0) { |
| | | params.put("page", 1); |
| | | params.put("limit", 10); |
| | | } |
| | | |
| | | return sysDoctorService.findList(params,user); |
| | | return sysDoctorService.findList(params, user); |
| | | } |
| | | |
| | | /** |
| | |
| | | SysDoctor model = sysDoctorService.getById(id); |
| | | return ResultBody.ok().data(model).msg("查询成功"); |
| | | } |
| | | |
| | | /** |
| | | * 判断用户名是否管理员 |
| | | */ |
| | | @ApiOperation(value = "判断用户名是否管理员") |
| | | @GetMapping("/userName") |
| | | public ResultBody findById(@RequestParam String userName) { |
| | | return sysDoctorService.userIsAdmin(userName); |
| | | } |
| | | |
| | | /** |
| | | * 根据 Map 查询 |
| | | */ |
| | | @ApiOperation(value = "查询") |
| | | @PostMapping("/findByMap") |
| | | public ResultBody findByMap(@RequestBody Map<String,Object> map) { |
| | | public ResultBody findByMap(@RequestBody Map<String, Object> map) { |
| | | List<SysDoctor> models = sysDoctorService.findByMap(map); |
| | | return ResultBody.ok().data(models).msg("查询成功"); |
| | | } |
| | | |
| | | /** |
| | | * 根据SysDoctor当做查询条件进行查询 |
| | | */ |
| | |
| | | */ |
| | | @ApiOperation(value = "保存") |
| | | @PostMapping |
| | | public ResultBody save(@Valid @RequestBody SysDoctorDto sysDoctor, BindingResult bindingResult, HttpServletRequest request,@LoginUser SysUser user) { |
| | | List<String> errMsg= new ArrayList<>(); |
| | | public ResultBody save(@Valid @RequestBody SysDoctorDto sysDoctor, BindingResult bindingResult, HttpServletRequest request, @LoginUser SysUser user) { |
| | | 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= sysDoctorService.saveOrUpdateSer(sysDoctor,request,user); |
| | | |
| | | if(v) { |
| | | return ResultBody.ok().data(sysDoctor).msg("保存成功"); |
| | | } |
| | | else { |
| | | return ResultBody.failed().msg("保存失败"); |
| | | } |
| | | return sysDoctorService.saveOrUpdateSer(sysDoctor, request, user); |
| | | } |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "删除") |
| | | @DeleteMapping("/{id}") |
| | | public ResultBody delete(@PathVariable Long id) { |
| | | boolean v= sysDoctorService.delete(id); |
| | | if(v) { |
| | | boolean v = sysDoctorService.delete(id); |
| | | if (v) { |
| | | return ResultBody.ok().msg("删除成功"); |
| | | } |
| | | else { |
| | | } else { |
| | | return ResultBody.failed().msg("删除失败"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 状态 |
| | | */ |
| | |
| | | @PostMapping("enable") |
| | | public ResultBody enable(@RequestBody Map<String, Object> params) { |
| | | Long id = MapUtils.getLong(params, "id"); |
| | | if (id==null) { |
| | | if (id == null) { |
| | | return ResultBody.failed("请选择一条数据"); |
| | | } |
| | | return sysDoctorService.enable(params); |
| | | return sysDoctorService.enable(params); |
| | | } |
| | | |
| | | /** |
| | | * 设为管理 |
| | | */ |
| | | @ApiOperation(value = "设为管理员") |
| | | @PostMapping("setadmin") |
| | | public ResultBody setAdmin(@RequestBody Map<String, Object> params) { |
| | | return sysDoctorService.setAdminDoctor(params); |
| | | } |
| | | |
| | | /** |
| | | * 统计医生的数量 |
| | | * |
| | | * @param datatype 业务类型 |
| | | * 0 自注册医生 |
| | | * 1 签约医生 |
| | | * 2 医答医生 |
| | | * 3 C端医生 |
| | | * 4 H端医生 |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "统计医生的数量") |
| | | @GetMapping("chartDoctor") |
| | | public ResultBody chartDoctor(int datatype) { |
| | | int counts = sysDoctorService.chartDoctor(datatype); |
| | | return ResultBody.ok().data(counts).msg("数据获取成功"); |
| | | } |
| | | |
| | | /** |
| | | * 根据SysDoctor当做查询条件进行查询 |
| | | */ |
| | | @ApiOperation(value = "根据SysDoctor当做查询条件进行查询") |
| | | @PostMapping("/queryDoctorToC") |
| | | public ResultBody queryDoctorToC(@RequestBody Map<String, Object> sysDoctor) { |
| | | List<SysDoctor> model = sysDoctorService.queryDoctorByC(sysDoctor); |
| | | return ResultBody.ok().data(model).msg("查询成功"); |
| | | } |
| | | } |