|
|
|
@ -38,24 +38,27 @@ import com.alibaba.fastjson.*;
|
|
|
|
|
* @email
|
|
|
|
|
*/
|
|
|
|
|
@RestController
|
|
|
|
|
// 声明为Spring MVC控制器
|
|
|
|
|
@Controller
|
|
|
|
|
// 定义请求映射路径,所有以/yisheng开头的请求由该控制器处理
|
|
|
|
|
@RequestMapping("/yisheng")
|
|
|
|
|
public class YishengController {
|
|
|
|
|
// 日志记录器,用于记录当前控制器的日志信息
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(YishengController.class);
|
|
|
|
|
|
|
|
|
|
// 自动注入医生服务类,用于处理医生相关业务逻辑
|
|
|
|
|
@Autowired
|
|
|
|
|
private YishengService yishengService; // 医生服务
|
|
|
|
|
private YishengService yishengService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private TokenService tokenService; // token服务
|
|
|
|
|
private TokenService tokenService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private DictionaryService dictionaryService; // 字典服务
|
|
|
|
|
|
|
|
|
|
//级联表service
|
|
|
|
|
private DictionaryService dictionaryService;
|
|
|
|
|
|
|
|
|
|
// 级联表service,自动注入用户服务类
|
|
|
|
|
@Autowired
|
|
|
|
|
private YonghuService yonghuService; // 用户服务
|
|
|
|
|
|
|
|
|
|
private YonghuService yonghuService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 后端列表
|
|
|
|
@ -63,25 +66,25 @@ public class YishengController {
|
|
|
|
|
@RequestMapping("/page")
|
|
|
|
|
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
|
|
|
|
|
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
|
|
|
|
|
String role = String.valueOf(request.getSession().getAttribute("role")); // 获取用户角色
|
|
|
|
|
String role = String.valueOf(request.getSession().getAttribute("role"));
|
|
|
|
|
if(false)
|
|
|
|
|
return R.error(511,"永不会进入");
|
|
|
|
|
else if("用户".equals(role))
|
|
|
|
|
params.put("yonghuId",request.getSession().getAttribute("userId")); // 如果是用户角色,添加用户ID参数
|
|
|
|
|
params.put("yonghuId",request.getSession().getAttribute("userId"));
|
|
|
|
|
else if("医生".equals(role))
|
|
|
|
|
params.put("yishengId",request.getSession().getAttribute("userId")); // 如果是医生角色,添加医生ID参数
|
|
|
|
|
params.put("yishengId",request.getSession().getAttribute("userId"));
|
|
|
|
|
if(params.get("orderBy")==null || params.get("orderBy")==""){
|
|
|
|
|
params.put("orderBy","id"); // 默认按ID排序
|
|
|
|
|
params.put("orderBy","id");
|
|
|
|
|
}
|
|
|
|
|
PageUtils page = yishengService.queryPage(params); // 分页查询
|
|
|
|
|
PageUtils page = yishengService.queryPage(params);
|
|
|
|
|
|
|
|
|
|
//字典表数据转换
|
|
|
|
|
List<YishengView> list =(List<YishengView>)page.getList();
|
|
|
|
|
for(YishengView c:list){
|
|
|
|
|
//修改对应字典表字段
|
|
|
|
|
dictionaryService.dictionaryConvert(c, request); // 转换字典字段
|
|
|
|
|
dictionaryService.dictionaryConvert(c, request);
|
|
|
|
|
}
|
|
|
|
|
return R.ok().put("data", page); // 返回分页数据
|
|
|
|
|
return R.ok().put("data", page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -90,17 +93,17 @@ public class YishengController {
|
|
|
|
|
@RequestMapping("/info/{id}")
|
|
|
|
|
public R info(@PathVariable("id") Long id, HttpServletRequest request){
|
|
|
|
|
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
|
|
|
|
|
YishengEntity yisheng = yishengService.selectById(id); // 根据ID查询医生
|
|
|
|
|
YishengEntity yisheng = yishengService.selectById(id);
|
|
|
|
|
if(yisheng !=null){
|
|
|
|
|
//entity转view
|
|
|
|
|
YishengView view = new YishengView();
|
|
|
|
|
BeanUtils.copyProperties( yisheng , view );//把实体数据重构到view中
|
|
|
|
|
|
|
|
|
|
//修改对应字典表字段
|
|
|
|
|
dictionaryService.dictionaryConvert(view, request); // 转换字典字段
|
|
|
|
|
return R.ok().put("data", view); // 返回医生详情
|
|
|
|
|
dictionaryService.dictionaryConvert(view, request);
|
|
|
|
|
return R.ok().put("data", view);
|
|
|
|
|
}else {
|
|
|
|
|
return R.error(511,"查不到数据"); // 查询不到返回错误
|
|
|
|
|
return R.error(511,"查不到数据");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -109,27 +112,27 @@ public class YishengController {
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/save")
|
|
|
|
|
public R save(@RequestBody YishengEntity yisheng, HttpServletRequest request) {
|
|
|
|
|
// 记录方法调用日志,包含控制器类名和要保存的医生实体信息
|
|
|
|
|
logger.debug("save方法:,,Controller:{},,yisheng:{}", this.getClass().getName(), yisheng.toString());
|
|
|
|
|
|
|
|
|
|
String role = String.valueOf(request.getSession().getAttribute("role")); // 获取用户角色
|
|
|
|
|
String role = String.valueOf(request.getSession().getAttribute("role"));
|
|
|
|
|
if(false)
|
|
|
|
|
return R.error(511,"永远不会进入");
|
|
|
|
|
|
|
|
|
|
// 构建查询条件:用户名或手机号
|
|
|
|
|
Wrapper<YishengEntity> queryWrapper = new EntityWrapper<YishengEntity>()
|
|
|
|
|
.eq("username", yisheng.getUsername())
|
|
|
|
|
.or()
|
|
|
|
|
.eq("yisheng_phone", yisheng.getYishengPhone());
|
|
|
|
|
|
|
|
|
|
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
|
|
|
|
YishengEntity yishengEntity = yishengService.selectOne(queryWrapper); // 查询是否已存在
|
|
|
|
|
YishengEntity yishengEntity = yishengService.selectOne(queryWrapper);
|
|
|
|
|
if(yishengEntity==null){
|
|
|
|
|
yisheng.setCreateTime(new Date()); // 设置创建时间
|
|
|
|
|
yisheng.setPassword("123456"); // 设置默认密码
|
|
|
|
|
yishengService.insert(yisheng); // 插入新医生数据
|
|
|
|
|
return R.ok(); // 返回成功
|
|
|
|
|
yisheng.setCreateTime(new Date());
|
|
|
|
|
yisheng.setPassword("123456");
|
|
|
|
|
yishengService.insert(yisheng);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}else {
|
|
|
|
|
return R.error(511,"账户或者联系方式已经被使用"); // 已存在返回错误
|
|
|
|
|
return R.error(511,"账户或者联系方式已经被使用");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -138,27 +141,31 @@ public class YishengController {
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/update")
|
|
|
|
|
public R update(@RequestBody YishengEntity yisheng, HttpServletRequest request) {
|
|
|
|
|
// 记录方法调用日志,包含控制器类名和要更新的医生实体信息
|
|
|
|
|
logger.debug("update方法:,,Controller:{},,yisheng:{}", this.getClass().getName(), yisheng.toString());
|
|
|
|
|
|
|
|
|
|
String role = String.valueOf(request.getSession().getAttribute("role")); // 获取用户角色
|
|
|
|
|
// 构建查询条件:排除当前ID,查询用户名或手机号是否已被其他记录使用
|
|
|
|
|
String role = String.valueOf(request.getSession().getAttribute("role"));
|
|
|
|
|
// if(false)
|
|
|
|
|
// return R.error(511,"永远不会进入");
|
|
|
|
|
//根据字段查询是否有相同数据
|
|
|
|
|
Wrapper<YishengEntity> queryWrapper = new EntityWrapper<YishengEntity>()
|
|
|
|
|
.notIn("id",yisheng.getId())
|
|
|
|
|
.andNew()
|
|
|
|
|
.eq("username", yisheng.getUsername())
|
|
|
|
|
.or()
|
|
|
|
|
.eq("yisheng_phone", yisheng.getYishengPhone());
|
|
|
|
|
.eq("yisheng_phone", yisheng.getYishengPhone())
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
|
|
|
|
YishengEntity yishengEntity = yishengService.selectOne(queryWrapper); // 查询是否冲突
|
|
|
|
|
YishengEntity yishengEntity = yishengService.selectOne(queryWrapper);
|
|
|
|
|
if("".equals(yisheng.getYishengPhoto()) || "null".equals(yisheng.getYishengPhoto())){
|
|
|
|
|
yisheng.setYishengPhoto(null); // 处理空照片
|
|
|
|
|
yisheng.setYishengPhoto(null);
|
|
|
|
|
}
|
|
|
|
|
if(yishengEntity==null){
|
|
|
|
|
yishengService.updateById(yisheng);//根据id更新
|
|
|
|
|
return R.ok(); // 返回成功
|
|
|
|
|
return R.ok();
|
|
|
|
|
}else {
|
|
|
|
|
return R.error(511,"账户或者联系方式已经被使用"); // 冲突返回错误
|
|
|
|
|
return R.error(511,"账户或者联系方式已经被使用");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -168,40 +175,56 @@ public class YishengController {
|
|
|
|
|
@RequestMapping("/delete")
|
|
|
|
|
public R delete(@RequestBody Integer[] ids){
|
|
|
|
|
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
|
|
|
|
|
yishengService.deleteBatchIds(Arrays.asList(ids)); // 批量删除
|
|
|
|
|
return R.ok(); // 返回成功
|
|
|
|
|
yishengService.deleteBatchIds(Arrays.asList(ids));
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量上传
|
|
|
|
|
* 批量上传医生信息
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/batchInsert")
|
|
|
|
|
public R save(String fileName) {
|
|
|
|
|
// 记录方法调用日志,包含控制器类名和文件名
|
|
|
|
|
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}", this.getClass().getName(), fileName);
|
|
|
|
|
try {
|
|
|
|
|
List<YishengEntity> yishengList = new ArrayList<>(); // 上传的数据列表
|
|
|
|
|
List<YishengEntity> yishengList = new ArrayList<>();//上传的东西
|
|
|
|
|
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
// 获取文件名中最后一个点的索引
|
|
|
|
|
int lastIndexOf = fileName.lastIndexOf(".");
|
|
|
|
|
if(lastIndexOf == -1){
|
|
|
|
|
return R.error(511,"该文件没有后缀"); // 文件后缀检查
|
|
|
|
|
return R.error(511,"该文件没有后缀");
|
|
|
|
|
}else{
|
|
|
|
|
String suffix = fileName.substring(lastIndexOf);
|
|
|
|
|
if(!".xls".equals(suffix)){
|
|
|
|
|
return R.error(511,"只支持后缀为xls的excel文件"); // 文件格式检查
|
|
|
|
|
return R.error(511,"只支持后缀为xls的excel文件");
|
|
|
|
|
}else{
|
|
|
|
|
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
|
|
|
|
|
File file = new File(resource.getFile());
|
|
|
|
|
if(!file.exists()){
|
|
|
|
|
return R.error(511,"找不到上传文件,请联系管理员"); // 文件存在检查
|
|
|
|
|
return R.error(511,"找不到上传文件,请联系管理员");
|
|
|
|
|
}else{
|
|
|
|
|
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
|
|
|
|
|
dataList.remove(0); // 删除第一行提示行
|
|
|
|
|
dataList.remove(0);//删除第一行,因为第一行是提示
|
|
|
|
|
for(List<String> data:dataList){
|
|
|
|
|
//循环处理每行数据
|
|
|
|
|
//循环
|
|
|
|
|
YishengEntity yishengEntity = new YishengEntity();
|
|
|
|
|
// 这里注释掉的代码是字段映射示例,实际使用时需要根据Excel列对应关系修改
|
|
|
|
|
yishengList.add(yishengEntity); // 添加到列表
|
|
|
|
|
// yishengEntity.setYishengUuidNumber(data.get(0)); //医生工号 要改的
|
|
|
|
|
// yishengEntity.setUsername(data.get(0)); //账户 要改的
|
|
|
|
|
// //yishengEntity.setPassword("123456");//密码
|
|
|
|
|
// yishengEntity.setYishengName(data.get(0)); //医生名称 要改的
|
|
|
|
|
// yishengEntity.setYishengTypes(Integer.valueOf(data.get(0))); //科室 要改的
|
|
|
|
|
// yishengEntity.setZhiweiTypes(Integer.valueOf(data.get(0))); //职位 要改的
|
|
|
|
|
// yishengEntity.setYishengZhichneg(data.get(0)); //职称 要改的
|
|
|
|
|
// yishengEntity.setYishengPhoto("");//照片
|
|
|
|
|
// yishengEntity.setYishengPhone(data.get(0)); //联系方式 要改的
|
|
|
|
|
// yishengEntity.setYishengGuahao(data.get(0)); //挂号须知 要改的
|
|
|
|
|
// yishengEntity.setYishengEmail(data.get(0)); //邮箱 要改的
|
|
|
|
|
// yishengEntity.setYishengNewMoney(data.get(0)); //挂号价格 要改的
|
|
|
|
|
// yishengEntity.setYishengContent("");//照片
|
|
|
|
|
// yishengEntity.setCreateTime(date);//时间
|
|
|
|
|
yishengList.add(yishengEntity);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//把要查询是否重复的字段放入map中
|
|
|
|
|
//医生工号
|
|
|
|
@ -261,13 +284,13 @@ public class YishengController {
|
|
|
|
|
}
|
|
|
|
|
return R.error(511, "数据库的该表中的 [联系方式] 字段已经存在 存在数据为:" + repeatFields.toString());
|
|
|
|
|
}
|
|
|
|
|
yishengService.insertBatch(yishengList); // 批量插入
|
|
|
|
|
yishengService.insertBatch(yishengList);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
return R.error(511,"批量插入数据异常,请联系管理员"); // 异常处理
|
|
|
|
|
return R.error(511,"批量插入数据异常,请联系管理员");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -277,16 +300,21 @@ public class YishengController {
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@RequestMapping(value = "/login")
|
|
|
|
|
public R login(String username, String password, String captcha, HttpServletRequest request) {
|
|
|
|
|
YishengEntity yisheng = yishengService.selectOne(new EntityWrapper<YishengEntity>().eq("username", username)); // 根据用户名查询
|
|
|
|
|
YishengEntity yisheng = yishengService.selectOne(new EntityWrapper<YishengEntity>().eq("username", username));
|
|
|
|
|
if(yisheng==null || !yisheng.getPassword().equals(password))
|
|
|
|
|
return R.error("账号或密码不正确"); // 验证账号密码
|
|
|
|
|
String token = tokenService.generateToken(yisheng.getId(),username, "yisheng", "医生"); // 生成token
|
|
|
|
|
return R.error("账号或密码不正确");
|
|
|
|
|
// // 获取监听器中的字典表
|
|
|
|
|
// ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
|
|
|
|
|
// Map<String, Map<Integer, String>> dictionaryMap= (Map<String, Map<Integer, String>>) servletContext.getAttribute("dictionaryMap");
|
|
|
|
|
// Map<Integer, String> role_types = dictionaryMap.get("role_types");
|
|
|
|
|
// role_types.get(.getRoleTypes());
|
|
|
|
|
String token = tokenService.generateToken(yisheng.getId(),username, "yisheng", "医生");
|
|
|
|
|
R r = R.ok();
|
|
|
|
|
r.put("token", token); // 返回token
|
|
|
|
|
r.put("role","医生"); // 返回角色
|
|
|
|
|
r.put("username",yisheng.getYishengName()); // 返回医生姓名
|
|
|
|
|
r.put("tableName","yisheng"); // 返回表名
|
|
|
|
|
r.put("userId",yisheng.getId()); // 返回用户ID
|
|
|
|
|
r.put("token", token);
|
|
|
|
|
r.put("role","医生");
|
|
|
|
|
r.put("username",yisheng.getYishengName());
|
|
|
|
|
r.put("tableName","yisheng");
|
|
|
|
|
r.put("userId",yisheng.getId());
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -296,18 +324,19 @@ public class YishengController {
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@PostMapping(value = "/register")
|
|
|
|
|
public R register(@RequestBody YishengEntity yisheng){
|
|
|
|
|
// 构建查询条件:用户名或手机号
|
|
|
|
|
// ValidatorUtils.validateEntity(user);
|
|
|
|
|
Wrapper<YishengEntity> queryWrapper = new EntityWrapper<YishengEntity>()
|
|
|
|
|
.eq("username", yisheng.getUsername())
|
|
|
|
|
.or()
|
|
|
|
|
.eq("yisheng_phone", yisheng.getYishengPhone());
|
|
|
|
|
YishengEntity yishengEntity = yishengService.selectOne(queryWrapper); // 查询是否已存在
|
|
|
|
|
.eq("yisheng_phone", yisheng.getYishengPhone())
|
|
|
|
|
;
|
|
|
|
|
YishengEntity yishengEntity = yishengService.selectOne(queryWrapper);
|
|
|
|
|
if(yishengEntity != null)
|
|
|
|
|
return R.error("账户或者联系方式已经被使用"); // 已存在返回错误
|
|
|
|
|
yisheng.setYishengNewMoney(0.0); // 设置初始金额
|
|
|
|
|
yisheng.setCreateTime(new Date()); // 设置创建时间
|
|
|
|
|
yishengService.insert(yisheng); // 插入新医生
|
|
|
|
|
return R.ok(); // 返回成功
|
|
|
|
|
return R.error("账户或者联系方式已经被使用");
|
|
|
|
|
yisheng.setYishengNewMoney(0.0);
|
|
|
|
|
yisheng.setCreateTime(new Date());
|
|
|
|
|
yishengService.insert(yisheng);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -316,60 +345,66 @@ public class YishengController {
|
|
|
|
|
@GetMapping(value = "/resetPassword")
|
|
|
|
|
public R resetPassword(Integer id){
|
|
|
|
|
YishengEntity yisheng = new YishengEntity();
|
|
|
|
|
yisheng.setPassword("123456"); // 重置为默认密码
|
|
|
|
|
yisheng.setPassword("123456");
|
|
|
|
|
yisheng.setId(id);
|
|
|
|
|
yishengService.updateById(yisheng); // 更新密码
|
|
|
|
|
return R.ok(); // 返回成功
|
|
|
|
|
yishengService.updateById(yisheng);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 忘记密码
|
|
|
|
|
*/
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@RequestMapping(value = "/resetPass")
|
|
|
|
|
public R resetPass(String username, HttpServletRequest request) {
|
|
|
|
|
YishengEntity yisheng = yishengService.selectOne(new EntityWrapper<YishengEntity>().eq("username", username)); // 根据用户名查询
|
|
|
|
|
YishengEntity yisheng = yishengService.selectOne(new EntityWrapper<YishengEntity>().eq("username", username));
|
|
|
|
|
if(yisheng!=null){
|
|
|
|
|
yisheng.setPassword("123456"); // 重置为默认密码
|
|
|
|
|
boolean b = yishengService.updateById(yisheng); // 更新密码
|
|
|
|
|
yisheng.setPassword("123456");
|
|
|
|
|
boolean b = yishengService.updateById(yisheng);
|
|
|
|
|
if(!b){
|
|
|
|
|
return R.error(); // 更新失败
|
|
|
|
|
return R.error();
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
return R.error("账号不存在"); // 账号不存在
|
|
|
|
|
return R.error("账号不存在");
|
|
|
|
|
}
|
|
|
|
|
return R.ok(); // 返回成功
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取用户的session用户信息
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/session")
|
|
|
|
|
public R getCurrYisheng(HttpServletRequest request){
|
|
|
|
|
Integer id = (Integer)request.getSession().getAttribute("userId"); // 获取session中的用户ID
|
|
|
|
|
YishengEntity yisheng = yishengService.selectById(id); // 查询用户信息
|
|
|
|
|
Integer id = (Integer)request.getSession().getAttribute("userId");
|
|
|
|
|
YishengEntity yisheng = yishengService.selectById(id);
|
|
|
|
|
if(yisheng !=null){
|
|
|
|
|
//entity转view
|
|
|
|
|
YishengView view = new YishengView();
|
|
|
|
|
BeanUtils.copyProperties( yisheng , view ); // 复制属性到view
|
|
|
|
|
BeanUtils.copyProperties( yisheng , view );//把实体数据重构到view中
|
|
|
|
|
|
|
|
|
|
//修改对应字典表字段
|
|
|
|
|
dictionaryService.dictionaryConvert(view, request); // 转换字典字段
|
|
|
|
|
return R.ok().put("data", view); // 返回用户信息
|
|
|
|
|
dictionaryService.dictionaryConvert(view, request);
|
|
|
|
|
return R.ok().put("data", view);
|
|
|
|
|
}else {
|
|
|
|
|
return R.error(511,"查不到数据"); // 查询不到返回错误
|
|
|
|
|
return R.error(511,"查不到数据");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 退出
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping(value = "logout")
|
|
|
|
|
public R logout(HttpServletRequest request) {
|
|
|
|
|
request.getSession().invalidate(); // 使session失效
|
|
|
|
|
return R.ok("退出成功"); // 返回退出成功
|
|
|
|
|
request.getSession().invalidate();
|
|
|
|
|
return R.ok("退出成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 前端列表
|
|
|
|
|
*/
|
|
|
|
@ -382,13 +417,13 @@ public class YishengController {
|
|
|
|
|
if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
|
|
|
|
|
params.put("orderBy","id");
|
|
|
|
|
}
|
|
|
|
|
PageUtils page = yishengService.queryPage(params); // 分页查询
|
|
|
|
|
PageUtils page = yishengService.queryPage(params);
|
|
|
|
|
|
|
|
|
|
//字典表数据转换
|
|
|
|
|
List<YishengView> list =(List<YishengView>)page.getList();
|
|
|
|
|
for(YishengView c:list)
|
|
|
|
|
dictionaryService.dictionaryConvert(c, request); // 转换字典字段
|
|
|
|
|
return R.ok().put("data", page); // 返回分页数据
|
|
|
|
|
dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
|
|
|
|
|
return R.ok().put("data", page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -397,40 +432,45 @@ public class YishengController {
|
|
|
|
|
@RequestMapping("/detail/{id}")
|
|
|
|
|
public R detail(@PathVariable("id") Long id, HttpServletRequest request){
|
|
|
|
|
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
|
|
|
|
|
YishengEntity yisheng = yishengService.selectById(id); // 根据ID查询
|
|
|
|
|
YishengEntity yisheng = yishengService.selectById(id);
|
|
|
|
|
if(yisheng !=null){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//entity转view
|
|
|
|
|
YishengView view = new YishengView();
|
|
|
|
|
BeanUtils.copyProperties( yisheng , view ); // 复制属性到view
|
|
|
|
|
BeanUtils.copyProperties( yisheng , view );//把实体数据重构到view中
|
|
|
|
|
|
|
|
|
|
//修改对应字典表字段
|
|
|
|
|
dictionaryService.dictionaryConvert(view, request); // 转换字典字段
|
|
|
|
|
return R.ok().put("data", view); // 返回详情
|
|
|
|
|
dictionaryService.dictionaryConvert(view, request);
|
|
|
|
|
return R.ok().put("data", view);
|
|
|
|
|
}else {
|
|
|
|
|
return R.error(511,"查不到数据"); // 查询不到返回错误
|
|
|
|
|
return R.error(511,"查不到数据");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 前端保存
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/add")
|
|
|
|
|
public R add(@RequestBody YishengEntity yisheng, HttpServletRequest request){
|
|
|
|
|
logger.debug("add方法:,,Controller:{},,yisheng:{}",this.getClass().getName(),yisheng.toString());
|
|
|
|
|
// 构建查询条件:用户名或手机号
|
|
|
|
|
Wrapper<YishengEntity> queryWrapper = new EntityWrapper<YishengEntity>()
|
|
|
|
|
.eq("username", yisheng.getUsername())
|
|
|
|
|
.or()
|
|
|
|
|
.eq("yisheng_phone", yisheng.getYishengPhone());
|
|
|
|
|
.eq("yisheng_phone", yisheng.getYishengPhone())
|
|
|
|
|
;
|
|
|
|
|
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
|
|
|
|
YishengEntity yishengEntity = yishengService.selectOne(queryWrapper); // 查询是否已存在
|
|
|
|
|
YishengEntity yishengEntity = yishengService.selectOne(queryWrapper);
|
|
|
|
|
if(yishengEntity==null){
|
|
|
|
|
yisheng.setCreateTime(new Date()); // 设置创建时间
|
|
|
|
|
yisheng.setPassword("123456"); // 设置默认密码
|
|
|
|
|
yishengService.insert(yisheng); // 插入新医生
|
|
|
|
|
return R.ok(); // 返回成功
|
|
|
|
|
yisheng.setCreateTime(new Date());
|
|
|
|
|
yisheng.setPassword("123456");
|
|
|
|
|
yishengService.insert(yisheng);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}else {
|
|
|
|
|
return R.error(511,"账户或者联系方式已经被使用"); // 已存在返回错误
|
|
|
|
|
return R.error(511,"账户或者联系方式已经被使用");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|