| | |
| | | |
| | | import java.util.Map; |
| | | import com.kidgrow.common.controller.BaseController; |
| | | import com.kidgrow.usercenter.vo.SysDoctorVo; |
| | | 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 com.kidgrow.common.model.*; |
| | | |
| | | import org.springframework.validation.BindingResult; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | 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; |
| | | |
| | | |
| | | /** |
| | |
| | | @ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer") |
| | | }) |
| | | @GetMapping |
| | | public ResultBody<PageResult> list(@RequestParam Map<String, Object> params) { |
| | | public PageResult<SysDoctorVo> list(@RequestParam Map<String, Object> params) { |
| | | if(params.size()==0){ |
| | | params.put("page",1); |
| | | params.put("limit",10); |
| | | } |
| | | return ResultBody.ok().data(sysDoctorService.findList(params)); |
| | | return sysDoctorService.findList(params); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ApiOperation(value = "保存") |
| | | @PostMapping |
| | | public ResultBody save(@Valid @RequestBody SysDoctor sysDoctor, BindingResult bindingResult) { |
| | | public ResultBody save(@Valid @RequestBody SysDoctorDto sysDoctor, BindingResult bindingResult, HttpServletRequest request) { |
| | | List<String> errMsg= new ArrayList<>(); |
| | | if (bindingResult.hasErrors()) { |
| | | for (ObjectError error : bindingResult.getAllErrors()) { |
| | |
| | | } |
| | | return ResultBody.failed().msg(errMsg.toString()); |
| | | } else { |
| | | boolean v= sysDoctorService.saveOrUpdate(sysDoctor); |
| | | boolean v= sysDoctorService.saveOrUpdateSer(sysDoctor,request); |
| | | |
| | | if(v) { |
| | | return ResultBody.ok().data(sysDoctor).msg("保存成功"); |
| | | } |
| | |
| | | @ApiOperation(value = "删除") |
| | | @DeleteMapping("/{id}") |
| | | public ResultBody delete(@PathVariable Long id) { |
| | | boolean v= sysDoctorService.removeById(id); |
| | | boolean v= sysDoctorService.delete(id); |
| | | if(v) { |
| | | return ResultBody.ok().msg("删除成功"); |
| | | } |
| | |
| | | return ResultBody.failed().msg("删除失败"); |
| | | } |
| | | } |
| | | /** |
| | | * 状态 |
| | | */ |
| | | @ApiOperation(value = "修改状态") |
| | | @PostMapping("enable") |
| | | public ResultBody enable(@RequestBody Map<String, Object> params) { |
| | | Long id = MapUtils.getLong(params, "id"); |
| | | if (id==null) { |
| | | return ResultBody.failed("请选择一条数据"); |
| | | } |
| | | return sysDoctorService.enable(params); |
| | | } |
| | | |
| | | } |