|
@ -0,0 +1,211 @@
|
|
|
package com.yihu.wlyy.controller.manager.user;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.wlyy.controller.BaseController;
|
|
|
import com.yihu.wlyy.entity.Doctor;
|
|
|
import com.yihu.wlyy.entity.User;
|
|
|
import com.yihu.wlyy.entity.WlyyRole;
|
|
|
import com.yihu.wlyy.service.manager.user.ManageRangeService;
|
|
|
import com.yihu.wlyy.service.manager.user.UserService;
|
|
|
import com.yihu.wlyy.util.MD5;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* Created by Reece on 2018/1/16.
|
|
|
*/
|
|
|
@Controller
|
|
|
@RequestMapping(value = "admin/range")
|
|
|
@Api(description = "管理端医生管理")
|
|
|
public class ManageRangeController extends BaseController {
|
|
|
@Autowired
|
|
|
private ManageRangeService rangeService;
|
|
|
|
|
|
/**
|
|
|
* 初始化及关键字搜索列表页
|
|
|
* @return 返回列表页路径
|
|
|
*/
|
|
|
@RequestMapping(value = "initial", method = RequestMethod.GET)
|
|
|
public String listPageInit(){
|
|
|
return "user/range/user_role_list";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*新增时跳转到新增页面
|
|
|
* @return 编辑页面路径
|
|
|
*/
|
|
|
@RequestMapping(value = "infoInit",method = RequestMethod.GET)
|
|
|
public String addPageInit(){
|
|
|
return "user/range/user_role_add";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查看和编辑时带参页面跳转
|
|
|
* @param doc 医生code
|
|
|
* @param mode
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "editInit",method = RequestMethod.GET)
|
|
|
public String editPageInit(String doc,String hospital,String mode){
|
|
|
request.setAttribute("doc",doc);
|
|
|
request.setAttribute("hospital",hospital);
|
|
|
request.setAttribute("mode",mode);
|
|
|
return "user/range/user_role_modify";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* wlyy_user_role 列表展示及页面搜索医生信息
|
|
|
* @param name
|
|
|
* @param idcard
|
|
|
* @param page
|
|
|
* @param pageSize
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "userRoleList")
|
|
|
@ResponseBody
|
|
|
public String searchList(
|
|
|
@RequestParam(value = "name",required = false) String name,
|
|
|
@RequestParam(value = "mobile",required = false) String idcard,
|
|
|
@RequestParam(value= "page",required = false) Integer page,
|
|
|
@RequestParam(value = "rows",required = false) Integer pageSize){
|
|
|
try{
|
|
|
Page<Doctor> userRoleList = rangeService.searchList(name, idcard, page, pageSize);
|
|
|
// List<Doctor> countRoleList = rangeService.searchList(name, idcard);
|
|
|
return write(200,"操作成功",page,pageSize,userRoleList);
|
|
|
}catch (Exception ex){
|
|
|
error(ex);
|
|
|
return error(-1,"操作失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 搜索新增的医生信息
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "doctorList")
|
|
|
@ResponseBody
|
|
|
public String getDoctorList(
|
|
|
@RequestParam(value = "name",required = false) String name,
|
|
|
@RequestParam(value = "mobile",required = false) String idcard,
|
|
|
@RequestParam(value= "page",required = false) Integer page,
|
|
|
@RequestParam(value = "rows",required = false) Integer pageSize){
|
|
|
try{
|
|
|
Page<Doctor> doctorList = rangeService.getDoctorList(name, idcard,page,pageSize);
|
|
|
return write(200,"操作成功",page,pageSize,doctorList);
|
|
|
}catch (Exception ex){
|
|
|
error(ex);
|
|
|
return error(-1,"操作失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询所有的医院信息
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "hostpitalList")
|
|
|
@ResponseBody
|
|
|
public String getHostpitalList( ){
|
|
|
try{
|
|
|
List<WlyyRole> roles = rangeService.getHostpitalList();
|
|
|
return write(200,"操作成功","data",roles);
|
|
|
}catch (Exception ex){
|
|
|
error(ex);
|
|
|
return error(-1,"操作失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 列表页根据医生code查询医生详情
|
|
|
* @param doc 医生code
|
|
|
* @param hospital 医院code
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "userRoleDetail")
|
|
|
@ResponseBody
|
|
|
public String getUserRole(
|
|
|
@ApiParam(name = "doc", defaultValue = "2")
|
|
|
@RequestParam(name = "doc", required = true) String doc,
|
|
|
@ApiParam(name = "hospital", defaultValue = "350001")
|
|
|
@RequestParam(name = "hospital", required = true) String hospital) {
|
|
|
try{
|
|
|
List<Doctor> doctor = rangeService.getUser(doc,hospital);
|
|
|
return write(200,"操作成功","data",doctor);
|
|
|
|
|
|
}catch (Exception ex){
|
|
|
error(ex);
|
|
|
return error(-1,"操作失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//删除医生在wlyy_user_role表的信息
|
|
|
@RequestMapping(value = "delete")
|
|
|
@ResponseBody
|
|
|
public String deleteUserRole(String doc,String hospital){
|
|
|
try{
|
|
|
if (StringUtils.isEmpty(doc) || StringUtils.isEmpty(hospital)){
|
|
|
return error(-1,"参数错误!");
|
|
|
}
|
|
|
rangeService.deleteUserRole(doc,hospital);
|
|
|
return write(200,"操作成功!");
|
|
|
}catch (Exception ex){
|
|
|
error(ex);
|
|
|
return error(-1,"操作失败!");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新增医生信息到wlyy_user_role
|
|
|
* @param info 新增医生及医院 信息 {["doc": "新增医生code(批量添加逗号分隔)","hospital" : "新增医生权限code(批量添加逗号分隔)"],[]}
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "create")
|
|
|
@ResponseBody
|
|
|
public String createUserRole(String info){
|
|
|
try{
|
|
|
String result = rangeService.saveUserRole(info);
|
|
|
return write(200,result);
|
|
|
}catch (Exception ex){
|
|
|
error(ex);
|
|
|
return error(-1,"操作失败!");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 编辑医生相关信息
|
|
|
* @param doc 编辑医生code(批量添加逗号分隔)
|
|
|
* @param oldHospital 修改前的医生权限code
|
|
|
* @param hospital 修改后的医生权限code
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "update")
|
|
|
@ResponseBody
|
|
|
public String updateUserRole(String doc,String oldHospital,String hospital){
|
|
|
try{
|
|
|
//先删除原信息在
|
|
|
rangeService.updateUserRole(doc,oldHospital,hospital);
|
|
|
return write(200,"操作成功!");
|
|
|
}catch (Exception ex){
|
|
|
error(ex);
|
|
|
return error(-1,"操作失败!");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|