|
@ -1,21 +1,22 @@
|
|
|
package com.yihu.jw.base.endpoint.doctor;
|
|
|
|
|
|
import com.yihu.jw.base.service.doctor.BaseDoctorRoleService;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.area.service.BaseInpatientAreaService;
|
|
|
import com.yihu.jw.contant.CommonContant;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorRoleDao;
|
|
|
import com.yihu.jw.doctor.service.BaseDoctorRoleService;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
|
|
|
import com.yihu.jw.restmodel.base.doctor.BaseDoctorRoleVO;
|
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
|
import com.yihu.jw.restmodel.web.ListEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.ObjEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
|
|
|
import com.yihu.jw.rm.base.BaseRequestMapping;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
*
|
|
@ -34,70 +35,120 @@ import java.util.List;
|
|
|
@Api(value = "医生与业务模块角色关联信息管理", description = "医生与业务模块角色关联信息管理服务接口", tags = {"wlyy基础服务 - 医生与业务模块角色关联信息管理服务接口"})
|
|
|
public class BaseDoctorRoleEndpoint extends EnvelopRestEndpoint {
|
|
|
|
|
|
@Autowired
|
|
|
private BaseDoctorRoleService baseDoctorRoleService;
|
|
|
@Autowired
|
|
|
private BaseDoctorRoleService baseDoctorRoleService;
|
|
|
@Autowired
|
|
|
private BaseDoctorRoleDao doctorRoleDao;
|
|
|
@Autowired
|
|
|
private BaseInpatientAreaService inpatientAreaService;
|
|
|
|
|
|
@PostMapping(value = BaseRequestMapping.BaseDoctorRole.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
@ApiOperation(value = "创建")
|
|
|
public ObjEnvelop<BaseDoctorRoleVO> create (
|
|
|
@ApiParam(name = "json_data", value = "Json数据", required = true)
|
|
|
@RequestBody String jsonData) throws Exception {
|
|
|
BaseDoctorRoleDO baseDoctorRole = toEntity(jsonData, BaseDoctorRoleDO.class);
|
|
|
baseDoctorRole = baseDoctorRoleService.save(baseDoctorRole);
|
|
|
return success(baseDoctorRole, BaseDoctorRoleVO.class);
|
|
|
|
|
|
@PostMapping(value = BaseRequestMapping.BaseDoctorRole.CREATE)
|
|
|
@ApiOperation(value = "创建")
|
|
|
public Envelop create (
|
|
|
@ApiParam(name = "jsonData", value = "Json数据", required = true)
|
|
|
@RequestBody String jsonData){
|
|
|
try {
|
|
|
JSONObject json = JSON.parseObject(jsonData);
|
|
|
String roleCode = json.getString("roleCode");
|
|
|
if(CommonContant.DR_INPATIENTAREA.equals(roleCode)){
|
|
|
//住院病区审核员处理
|
|
|
return ObjEnvelop.getSuccess("保存成功", inpatientAreaService.addAreaDoctor(json,roleCode));
|
|
|
}else{
|
|
|
BaseDoctorRoleDO baseDoctorRole = toEntity(jsonData, BaseDoctorRoleDO.class);
|
|
|
baseDoctorRole.setDel(1);
|
|
|
baseDoctorRole = baseDoctorRoleService.save(baseDoctorRole);
|
|
|
return success(baseDoctorRole, BaseDoctorRoleVO.class);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return Envelop.getError("保存失败");
|
|
|
}
|
|
|
|
|
|
@PostMapping(value = "updDel")
|
|
|
@ApiOperation(value = "生效/失效")
|
|
|
public Envelop updStatus(
|
|
|
@ApiParam(name = "id", value = "id", required = true)
|
|
|
@RequestParam(value = "id") String id,
|
|
|
@ApiParam(name = "del", value = "1生效,0失效", required = true)
|
|
|
@RequestParam(value = "del") Integer del,
|
|
|
@ApiParam(name = "roleCode", value = "角色编码", required = true)
|
|
|
@RequestParam(value = "roleCode") String roleCode) {
|
|
|
try {
|
|
|
if(CommonContant.DR_INPATIENTAREA.equals(roleCode)){
|
|
|
inpatientAreaService.updDel(id,del);
|
|
|
}else {
|
|
|
BaseDoctorRoleDO roleDO = doctorRoleDao.findById(Integer.parseInt(id)).orElse(null);
|
|
|
if(roleDO!=null){
|
|
|
roleDO.setDel(del);
|
|
|
doctorRoleDao.save(roleDO);
|
|
|
}
|
|
|
}
|
|
|
return Envelop.getSuccess("修改成功");
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return Envelop.getError("修改失败");
|
|
|
}
|
|
|
|
|
|
@PostMapping(value = BaseRequestMapping.BaseDoctorRole.DELETE)
|
|
|
@ApiOperation(value = "删除")
|
|
|
public Envelop delete(
|
|
|
@ApiParam(name = "ids", value = "id串,中间用,分隔", required = true)
|
|
|
@RequestParam(value = "ids") String ids) {
|
|
|
baseDoctorRoleService.delete(ids.split(","));
|
|
|
return success("删除成功");
|
|
|
@ApiParam(name = "id", value = "id", required = true)
|
|
|
@RequestParam(value = "id") String id,
|
|
|
@ApiParam(name = "roleCode", value = "角色编码", required = true)
|
|
|
@RequestParam(value = "roleCode") String roleCode) {
|
|
|
try {
|
|
|
if(CommonContant.DR_INPATIENTAREA.equals(roleCode)){
|
|
|
inpatientAreaService.delAreaDoctor(id);
|
|
|
}else {
|
|
|
doctorRoleDao.deleteById(Integer.parseInt(id));
|
|
|
}
|
|
|
return success("删除成功");
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return Envelop.getError("删除失败");
|
|
|
}
|
|
|
|
|
|
@PostMapping(value = BaseRequestMapping.BaseDoctorRole.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
@PostMapping(value = BaseRequestMapping.BaseDoctorRole.UPDATE)
|
|
|
@ApiOperation(value = "更新")
|
|
|
public ObjEnvelop<BaseDoctorRoleVO> update (
|
|
|
@ApiParam(name = "json_data", value = "Json数据", required = true)
|
|
|
@RequestBody String jsonData) throws Exception {
|
|
|
BaseDoctorRoleDO baseDoctorRole = toEntity(jsonData, BaseDoctorRoleDO.class);
|
|
|
if (null == baseDoctorRole.getId()) {
|
|
|
return failed("ID不能为空", ObjEnvelop.class);
|
|
|
public Envelop update (
|
|
|
@ApiParam(name = "jsonData", value = "Json数据", required = true)
|
|
|
@RequestBody String jsonData) {
|
|
|
try {
|
|
|
//先删除在新增
|
|
|
JSONObject json = JSON.parseObject(jsonData);
|
|
|
String roleCode = json.getString("roleCode");
|
|
|
String id = json.getString("id");
|
|
|
delete(id,roleCode);
|
|
|
return create(jsonData);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
baseDoctorRole = baseDoctorRoleService.save(baseDoctorRole);
|
|
|
return success(baseDoctorRole, BaseDoctorRoleVO.class);
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = BaseRequestMapping.BaseDoctorRole.PAGE)
|
|
|
@ApiOperation(value = "获取分页")
|
|
|
public PageEnvelop<BaseDoctorRoleVO> page (
|
|
|
@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
|
|
|
@RequestParam(value = "fields", required = false) String fields,
|
|
|
@ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
|
|
|
@RequestParam(value = "filters", required = false) String filters,
|
|
|
@ApiParam(name = "sorts", value = "排序,规则参见说明文档")
|
|
|
@RequestParam(value = "sorts", required = false) String sorts,
|
|
|
@ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
|
|
|
@RequestParam(value = "page") int page,
|
|
|
@ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
|
|
|
@RequestParam(value = "size") int size) throws Exception {
|
|
|
List<BaseDoctorRoleDO> baseDoctorRoles = baseDoctorRoleService.search(fields, filters, sorts, page, size);
|
|
|
int count = (int)baseDoctorRoleService.getCount(filters);
|
|
|
return success(baseDoctorRoles, count, page, size, BaseDoctorRoleVO.class);
|
|
|
}
|
|
|
return Envelop.getError("保存失败");
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = BaseRequestMapping.BaseDoctorRole.LIST)
|
|
|
@ApiOperation(value = "获取列表")
|
|
|
public ListEnvelop<BaseDoctorRoleVO> list (
|
|
|
@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
|
|
|
@RequestParam(value = "fields", required = false) String fields,
|
|
|
@ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
|
|
|
@RequestParam(value = "filters", required = false) String filters,
|
|
|
@ApiParam(name = "sorts", value = "排序,规则参见说明文档")
|
|
|
@RequestParam(value = "sorts", required = false) String sorts) throws Exception {
|
|
|
List<BaseDoctorRoleDO> baseDoctorRoles = baseDoctorRoleService.search(fields, filters, sorts);
|
|
|
return success(baseDoctorRoles, BaseDoctorRoleVO.class);
|
|
|
}
|
|
|
@GetMapping(value = BaseRequestMapping.BaseDoctorRole.PAGE)
|
|
|
@ApiOperation(value = "获取分页")
|
|
|
public Envelop page (
|
|
|
@ApiParam(name = "roleCode", value = "角色编码")
|
|
|
@RequestParam(value = "roleCode", required = true) String roleCode,
|
|
|
@ApiParam(name = "name", value = "医生姓名")
|
|
|
@RequestParam(value = "name", required = false) String name,
|
|
|
@ApiParam(name = "idcard", value = "医生身份证")
|
|
|
@RequestParam(value = "idcard", required = false) String idcard,
|
|
|
@ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
|
|
|
@RequestParam(value = "page") int page,
|
|
|
@ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
|
|
|
@RequestParam(value = "size") int size) {
|
|
|
try {
|
|
|
return baseDoctorRoleService.page(roleCode, name, idcard, page, size);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return Envelop.getError("获取失败");
|
|
|
}
|
|
|
|
|
|
}
|