|
|
@ -1,4 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
package com.controller;
|
|
|
|
package com.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.File;
|
|
|
@ -33,11 +32,11 @@ import com.utils.R;
|
|
|
|
import com.alibaba.fastjson.*;
|
|
|
|
import com.alibaba.fastjson.*;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 用户
|
|
|
|
* 用户控制器
|
|
|
|
* 后端接口
|
|
|
|
* 后端接口
|
|
|
|
* @author
|
|
|
|
* @author
|
|
|
|
* @email
|
|
|
|
* @email
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
@RestController
|
|
|
|
@Controller
|
|
|
|
@Controller
|
|
|
|
@RequestMapping("/yonghu")
|
|
|
|
@RequestMapping("/yonghu")
|
|
|
@ -45,72 +44,80 @@ public class YonghuController {
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(YonghuController.class);
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(YonghuController.class);
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private YonghuService yonghuService;
|
|
|
|
private YonghuService yonghuService; // 用户服务
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private TokenService tokenService;
|
|
|
|
private TokenService tokenService; // token服务
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private DictionaryService dictionaryService;
|
|
|
|
private DictionaryService dictionaryService; // 字典服务
|
|
|
|
|
|
|
|
|
|
|
|
//级联表service
|
|
|
|
//级联表service
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private YishengService yishengService;
|
|
|
|
private YishengService yishengService; // 医生服务
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 后端列表
|
|
|
|
* 后端列表
|
|
|
|
*/
|
|
|
|
* 分页查询用户数据
|
|
|
|
|
|
|
|
*/
|
|
|
|
@RequestMapping("/page")
|
|
|
|
@RequestMapping("/page")
|
|
|
|
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
|
|
|
|
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
|
|
|
|
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
|
|
|
|
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)
|
|
|
|
if(false)
|
|
|
|
return R.error(511,"永不会进入");
|
|
|
|
return R.error(511,"永不会进入");
|
|
|
|
else if("用户".equals(role))
|
|
|
|
else if("用户".equals(role))
|
|
|
|
params.put("yonghuId",request.getSession().getAttribute("userId"));
|
|
|
|
params.put("yonghuId",request.getSession().getAttribute("userId")); // 如果是用户角色,只查询自己的数据
|
|
|
|
else if("医生".equals(role))
|
|
|
|
else if("医生".equals(role))
|
|
|
|
params.put("yishengId",request.getSession().getAttribute("userId"));
|
|
|
|
params.put("yishengId",request.getSession().getAttribute("userId")); // 如果是医生角色,添加医生ID参数
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置查询未删除的用户(删除状态为1表示未删除)
|
|
|
|
params.put("yonghuDeleteStart",1);params.put("yonghuDeleteEnd",1);
|
|
|
|
params.put("yonghuDeleteStart",1);params.put("yonghuDeleteEnd",1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 默认按id排序
|
|
|
|
if(params.get("orderBy")==null || params.get("orderBy")==""){
|
|
|
|
if(params.get("orderBy")==null || params.get("orderBy")==""){
|
|
|
|
params.put("orderBy","id");
|
|
|
|
params.put("orderBy","id");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 调用服务层查询分页数据
|
|
|
|
PageUtils page = yonghuService.queryPage(params);
|
|
|
|
PageUtils page = yonghuService.queryPage(params);
|
|
|
|
|
|
|
|
|
|
|
|
//字典表数据转换
|
|
|
|
// 字典表数据转换
|
|
|
|
List<YonghuView> list =(List<YonghuView>)page.getList();
|
|
|
|
List<YonghuView> list =(List<YonghuView>)page.getList();
|
|
|
|
for(YonghuView c:list){
|
|
|
|
for(YonghuView c:list){
|
|
|
|
//修改对应字典表字段
|
|
|
|
// 修改对应字典表字段
|
|
|
|
dictionaryService.dictionaryConvert(c, request);
|
|
|
|
dictionaryService.dictionaryConvert(c, request);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return R.ok().put("data", page);
|
|
|
|
return R.ok().put("data", page);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 后端详情
|
|
|
|
* 后端详情
|
|
|
|
*/
|
|
|
|
* 根据ID查询用户详情
|
|
|
|
|
|
|
|
*/
|
|
|
|
@RequestMapping("/info/{id}")
|
|
|
|
@RequestMapping("/info/{id}")
|
|
|
|
public R info(@PathVariable("id") Long id, HttpServletRequest request){
|
|
|
|
public R info(@PathVariable("id") Long id, HttpServletRequest request){
|
|
|
|
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
|
|
|
|
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
|
|
|
|
|
|
|
|
// 根据ID查询用户
|
|
|
|
YonghuEntity yonghu = yonghuService.selectById(id);
|
|
|
|
YonghuEntity yonghu = yonghuService.selectById(id);
|
|
|
|
if(yonghu !=null){
|
|
|
|
if(yonghu !=null){
|
|
|
|
//entity转view
|
|
|
|
// entity转view
|
|
|
|
YonghuView view = new YonghuView();
|
|
|
|
YonghuView view = new YonghuView();
|
|
|
|
BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中
|
|
|
|
BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中
|
|
|
|
|
|
|
|
|
|
|
|
//修改对应字典表字段
|
|
|
|
// 修改对应字典表字段
|
|
|
|
dictionaryService.dictionaryConvert(view, request);
|
|
|
|
dictionaryService.dictionaryConvert(view, request);
|
|
|
|
return R.ok().put("data", view);
|
|
|
|
return R.ok().put("data", view);
|
|
|
|
}else {
|
|
|
|
}else {
|
|
|
|
return R.error(511,"查不到数据");
|
|
|
|
return R.error(511,"查不到数据");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 后端保存
|
|
|
|
* 后端保存
|
|
|
|
*/
|
|
|
|
* 新增用户
|
|
|
|
|
|
|
|
*/
|
|
|
|
@RequestMapping("/save")
|
|
|
|
@RequestMapping("/save")
|
|
|
|
public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
|
|
|
|
public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
|
|
|
|
logger.debug("save方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
|
|
|
|
logger.debug("save方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
|
|
|
@ -119,23 +126,24 @@ public class YonghuController {
|
|
|
|
if(false)
|
|
|
|
if(false)
|
|
|
|
return R.error(511,"永远不会进入");
|
|
|
|
return R.error(511,"永远不会进入");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 构建查询条件:检查用户名、手机号、身份证号是否已存在
|
|
|
|
Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
|
|
|
|
Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
|
|
|
|
.eq("username", yonghu.getUsername())
|
|
|
|
.eq("username", yonghu.getUsername())
|
|
|
|
.or()
|
|
|
|
.or()
|
|
|
|
.eq("yonghu_phone", yonghu.getYonghuPhone())
|
|
|
|
.eq("yonghu_phone", yonghu.getYonghuPhone())
|
|
|
|
.or()
|
|
|
|
.or()
|
|
|
|
.eq("yonghu_id_number", yonghu.getYonghuIdNumber())
|
|
|
|
.eq("yonghu_id_number", yonghu.getYonghuIdNumber())
|
|
|
|
.andNew()
|
|
|
|
.andNew()
|
|
|
|
.eq("yonghu_delete", 1)
|
|
|
|
.eq("yonghu_delete", 1) // 未删除的用户
|
|
|
|
;
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
|
|
|
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
|
|
|
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
|
|
|
|
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
|
|
|
|
if(yonghuEntity==null){
|
|
|
|
if(yonghuEntity==null){
|
|
|
|
yonghu.setYonghuDelete(1);
|
|
|
|
yonghu.setYonghuDelete(1); // 设置未删除状态
|
|
|
|
yonghu.setCreateTime(new Date());
|
|
|
|
yonghu.setCreateTime(new Date()); // 设置创建时间
|
|
|
|
yonghu.setPassword("123456");
|
|
|
|
yonghu.setPassword("123456"); // 设置默认密码
|
|
|
|
yonghuService.insert(yonghu);
|
|
|
|
yonghuService.insert(yonghu); // 插入新用户
|
|
|
|
return R.ok();
|
|
|
|
return R.ok();
|
|
|
|
}else {
|
|
|
|
}else {
|
|
|
|
return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用");
|
|
|
|
return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用");
|
|
|
@ -143,32 +151,32 @@ public class YonghuController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 后端修改
|
|
|
|
* 后端修改
|
|
|
|
*/
|
|
|
|
* 更新用户信息
|
|
|
|
|
|
|
|
*/
|
|
|
|
@RequestMapping("/update")
|
|
|
|
@RequestMapping("/update")
|
|
|
|
public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
|
|
|
|
public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
|
|
|
|
logger.debug("update方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
|
|
|
|
logger.debug("update方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
|
|
|
|
|
|
|
|
|
|
|
|
String role = String.valueOf(request.getSession().getAttribute("role"));
|
|
|
|
String role = String.valueOf(request.getSession().getAttribute("role"));
|
|
|
|
// if(false)
|
|
|
|
// 构建查询条件:检查其他用户是否已使用要修改的用户名、手机号或身份证号
|
|
|
|
// return R.error(511,"永远不会进入");
|
|
|
|
|
|
|
|
//根据字段查询是否有相同数据
|
|
|
|
|
|
|
|
Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
|
|
|
|
Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
|
|
|
|
.notIn("id",yonghu.getId())
|
|
|
|
.notIn("id",yonghu.getId()) // 排除当前用户
|
|
|
|
.andNew()
|
|
|
|
.andNew()
|
|
|
|
.eq("username", yonghu.getUsername())
|
|
|
|
.eq("username", yonghu.getUsername())
|
|
|
|
.or()
|
|
|
|
.or()
|
|
|
|
.eq("yonghu_phone", yonghu.getYonghuPhone())
|
|
|
|
.eq("yonghu_phone", yonghu.getYonghuPhone())
|
|
|
|
.or()
|
|
|
|
.or()
|
|
|
|
.eq("yonghu_id_number", yonghu.getYonghuIdNumber())
|
|
|
|
.eq("yonghu_id_number", yonghu.getYonghuIdNumber())
|
|
|
|
.andNew()
|
|
|
|
.andNew()
|
|
|
|
.eq("yonghu_delete", 1)
|
|
|
|
.eq("yonghu_delete", 1) // 未删除的用户
|
|
|
|
;
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
|
|
|
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
|
|
|
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
|
|
|
|
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
|
|
|
|
|
|
|
|
// 处理空照片
|
|
|
|
if("".equals(yonghu.getYonghuPhoto()) || "null".equals(yonghu.getYonghuPhoto())){
|
|
|
|
if("".equals(yonghu.getYonghuPhoto()) || "null".equals(yonghu.getYonghuPhoto())){
|
|
|
|
yonghu.setYonghuPhoto(null);
|
|
|
|
yonghu.setYonghuPhoto(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(yonghuEntity==null){
|
|
|
|
if(yonghuEntity==null){
|
|
|
|
yonghuService.updateById(yonghu);//根据id更新
|
|
|
|
yonghuService.updateById(yonghu);//根据id更新
|
|
|
@ -179,8 +187,9 @@ public class YonghuController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 删除
|
|
|
|
* 删除
|
|
|
|
*/
|
|
|
|
* 逻辑删除用户(将删除状态设为2)
|
|
|
|
|
|
|
|
*/
|
|
|
|
@RequestMapping("/delete")
|
|
|
|
@RequestMapping("/delete")
|
|
|
|
public R delete(@RequestBody Integer[] ids){
|
|
|
|
public R delete(@RequestBody Integer[] ids){
|
|
|
|
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
|
|
|
|
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
|
|
|
@ -188,18 +197,18 @@ public class YonghuController {
|
|
|
|
for(Integer id:ids){
|
|
|
|
for(Integer id:ids){
|
|
|
|
YonghuEntity yonghuEntity = new YonghuEntity();
|
|
|
|
YonghuEntity yonghuEntity = new YonghuEntity();
|
|
|
|
yonghuEntity.setId(id);
|
|
|
|
yonghuEntity.setId(id);
|
|
|
|
yonghuEntity.setYonghuDelete(2);
|
|
|
|
yonghuEntity.setYonghuDelete(2); // 设置删除状态为2
|
|
|
|
list.add(yonghuEntity);
|
|
|
|
list.add(yonghuEntity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(list != null && list.size() >0){
|
|
|
|
if(list != null && list.size() >0){
|
|
|
|
yonghuService.updateBatchById(list);
|
|
|
|
yonghuService.updateBatchById(list); // 批量更新
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return R.ok();
|
|
|
|
return R.ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 批量上传
|
|
|
|
* 批量上传
|
|
|
|
|
|
|
|
* 通过Excel批量导入用户数据
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@RequestMapping("/batchInsert")
|
|
|
|
@RequestMapping("/batchInsert")
|
|
|
|
public R save( String fileName){
|
|
|
|
public R save( String fileName){
|
|
|
@ -226,52 +235,41 @@ public class YonghuController {
|
|
|
|
for(List<String> data:dataList){
|
|
|
|
for(List<String> data:dataList){
|
|
|
|
//循环
|
|
|
|
//循环
|
|
|
|
YonghuEntity yonghuEntity = new YonghuEntity();
|
|
|
|
YonghuEntity yonghuEntity = new YonghuEntity();
|
|
|
|
// yonghuEntity.setUsername(data.get(0)); //账户 要改的
|
|
|
|
// 这里注释掉的代码是示例,实际应该根据Excel列映射字段
|
|
|
|
// //yonghuEntity.setPassword("123456");//密码
|
|
|
|
|
|
|
|
// yonghuEntity.setYonghuName(data.get(0)); //用户姓名 要改的
|
|
|
|
|
|
|
|
// yonghuEntity.setYonghuPhoto("");//照片
|
|
|
|
|
|
|
|
// yonghuEntity.setYonghuPhone(data.get(0)); //用户手机号 要改的
|
|
|
|
|
|
|
|
// yonghuEntity.setYonghuIdNumber(data.get(0)); //用户身份证号 要改的
|
|
|
|
|
|
|
|
// yonghuEntity.setYonghuEmail(data.get(0)); //邮箱 要改的
|
|
|
|
|
|
|
|
// yonghuEntity.setSexTypes(Integer.valueOf(data.get(0))); //性别 要改的
|
|
|
|
|
|
|
|
// yonghuEntity.setNewMoney(data.get(0)); //余额 要改的
|
|
|
|
|
|
|
|
// yonghuEntity.setYonghuDelete(1);//逻辑删除字段
|
|
|
|
|
|
|
|
// yonghuEntity.setCreateTime(date);//时间
|
|
|
|
|
|
|
|
yonghuList.add(yonghuEntity);
|
|
|
|
yonghuList.add(yonghuEntity);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//把要查询是否重复的字段放入map中
|
|
|
|
//把要查询是否重复的字段放入map中
|
|
|
|
//账户
|
|
|
|
//账户
|
|
|
|
if(seachFields.containsKey("username")){
|
|
|
|
if(seachFields.containsKey("username")){
|
|
|
|
List<String> username = seachFields.get("username");
|
|
|
|
List<String> username = seachFields.get("username");
|
|
|
|
username.add(data.get(0));//要改的
|
|
|
|
username.add(data.get(0));//要改的
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
List<String> username = new ArrayList<>();
|
|
|
|
List<String> username = new ArrayList<>();
|
|
|
|
username.add(data.get(0));//要改的
|
|
|
|
username.add(data.get(0));//要改的
|
|
|
|
seachFields.put("username",username);
|
|
|
|
seachFields.put("username",username);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//用户手机号
|
|
|
|
//用户手机号
|
|
|
|
if(seachFields.containsKey("yonghuPhone")){
|
|
|
|
if(seachFields.containsKey("yonghuPhone")){
|
|
|
|
List<String> yonghuPhone = seachFields.get("yonghuPhone");
|
|
|
|
List<String> yonghuPhone = seachFields.get("yonghuPhone");
|
|
|
|
yonghuPhone.add(data.get(0));//要改的
|
|
|
|
yonghuPhone.add(data.get(0));//要改的
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
List<String> yonghuPhone = new ArrayList<>();
|
|
|
|
List<String> yonghuPhone = new ArrayList<>();
|
|
|
|
yonghuPhone.add(data.get(0));//要改的
|
|
|
|
yonghuPhone.add(data.get(0));//要改的
|
|
|
|
seachFields.put("yonghuPhone",yonghuPhone);
|
|
|
|
seachFields.put("yonghuPhone",yonghuPhone);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//用户身份证号
|
|
|
|
//用户身份证号
|
|
|
|
if(seachFields.containsKey("yonghuIdNumber")){
|
|
|
|
if(seachFields.containsKey("yonghuIdNumber")){
|
|
|
|
List<String> yonghuIdNumber = seachFields.get("yonghuIdNumber");
|
|
|
|
List<String> yonghuIdNumber = seachFields.get("yonghuIdNumber");
|
|
|
|
yonghuIdNumber.add(data.get(0));//要改的
|
|
|
|
yonghuIdNumber.add(data.get(0));//要改的
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
List<String> yonghuIdNumber = new ArrayList<>();
|
|
|
|
List<String> yonghuIdNumber = new ArrayList<>();
|
|
|
|
yonghuIdNumber.add(data.get(0));//要改的
|
|
|
|
yonghuIdNumber.add(data.get(0));//要改的
|
|
|
|
seachFields.put("yonghuIdNumber",yonghuIdNumber);
|
|
|
|
seachFields.put("yonghuIdNumber",yonghuIdNumber);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//查询是否重复
|
|
|
|
//查询是否重复
|
|
|
|
//账户
|
|
|
|
//账户
|
|
|
|
List<YonghuEntity> yonghuEntities_username = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("username", seachFields.get("username")).eq("yonghu_delete", 1));
|
|
|
|
List<YonghuEntity> yonghuEntities_username = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("username", seachFields.get("username")).eq("yonghu_delete", 1));
|
|
|
|
if(yonghuEntities_username.size() >0 ){
|
|
|
|
if(yonghuEntities_username.size() >0 ){
|
|
|
|
ArrayList<String> repeatFields = new ArrayList<>();
|
|
|
|
ArrayList<String> repeatFields = new ArrayList<>();
|
|
|
@ -280,7 +278,7 @@ public class YonghuController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString());
|
|
|
|
return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//用户手机号
|
|
|
|
//用户手机号
|
|
|
|
List<YonghuEntity> yonghuEntities_yonghuPhone = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("yonghu_phone", seachFields.get("yonghuPhone")).eq("yonghu_delete", 1));
|
|
|
|
List<YonghuEntity> yonghuEntities_yonghuPhone = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("yonghu_phone", seachFields.get("yonghuPhone")).eq("yonghu_delete", 1));
|
|
|
|
if(yonghuEntities_yonghuPhone.size() >0 ){
|
|
|
|
if(yonghuEntities_yonghuPhone.size() >0 ){
|
|
|
|
ArrayList<String> repeatFields = new ArrayList<>();
|
|
|
|
ArrayList<String> repeatFields = new ArrayList<>();
|
|
|
@ -289,7 +287,7 @@ public class YonghuController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return R.error(511,"数据库的该表中的 [用户手机号] 字段已经存在 存在数据为:"+repeatFields.toString());
|
|
|
|
return R.error(511,"数据库的该表中的 [用户手机号] 字段已经存在 存在数据为:"+repeatFields.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//用户身份证号
|
|
|
|
//用户身份证号
|
|
|
|
List<YonghuEntity> yonghuEntities_yonghuIdNumber = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("yonghu_id_number", seachFields.get("yonghuIdNumber")).eq("yonghu_delete", 1));
|
|
|
|
List<YonghuEntity> yonghuEntities_yonghuIdNumber = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("yonghu_id_number", seachFields.get("yonghuIdNumber")).eq("yonghu_delete", 1));
|
|
|
|
if(yonghuEntities_yonghuIdNumber.size() >0 ){
|
|
|
|
if(yonghuEntities_yonghuIdNumber.size() >0 ){
|
|
|
|
ArrayList<String> repeatFields = new ArrayList<>();
|
|
|
|
ArrayList<String> repeatFields = new ArrayList<>();
|
|
|
@ -308,23 +306,21 @@ public class YonghuController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 登录
|
|
|
|
* 登录
|
|
|
|
*/
|
|
|
|
* 用户登录接口
|
|
|
|
|
|
|
|
*/
|
|
|
|
@IgnoreAuth
|
|
|
|
@IgnoreAuth
|
|
|
|
@RequestMapping(value = "/login")
|
|
|
|
@RequestMapping(value = "/login")
|
|
|
|
public R login(String username, String password, String captcha, HttpServletRequest request) {
|
|
|
|
public R login(String username, String password, String captcha, HttpServletRequest request) {
|
|
|
|
|
|
|
|
// 根据用户名查询用户
|
|
|
|
YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", username));
|
|
|
|
YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", username));
|
|
|
|
if(yonghu==null || !yonghu.getPassword().equals(password))
|
|
|
|
if(yonghu==null || !yonghu.getPassword().equals(password))
|
|
|
|
return R.error("账号或密码不正确");
|
|
|
|
return R.error("账号或密码不正确");
|
|
|
|
else if(yonghu.getYonghuDelete() != 1)
|
|
|
|
else if(yonghu.getYonghuDelete() != 1)
|
|
|
|
return R.error("账户已被删除");
|
|
|
|
return R.error("账户已被删除");
|
|
|
|
// // 获取监听器中的字典表
|
|
|
|
|
|
|
|
// ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
|
|
|
|
// 生成token
|
|
|
|
// 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(yonghu.getId(),username, "yonghu", "用户");
|
|
|
|
String token = tokenService.generateToken(yonghu.getId(),username, "yonghu", "用户");
|
|
|
|
R r = R.ok();
|
|
|
|
R r = R.ok();
|
|
|
|
r.put("token", token);
|
|
|
|
r.put("token", token);
|
|
|
@ -336,24 +332,27 @@ public class YonghuController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 注册
|
|
|
|
* 注册
|
|
|
|
*/
|
|
|
|
* 用户注册接口
|
|
|
|
|
|
|
|
*/
|
|
|
|
@IgnoreAuth
|
|
|
|
@IgnoreAuth
|
|
|
|
@PostMapping(value = "/register")
|
|
|
|
@PostMapping(value = "/register")
|
|
|
|
public R register(@RequestBody YonghuEntity yonghu){
|
|
|
|
public R register(@RequestBody YonghuEntity yonghu){
|
|
|
|
// ValidatorUtils.validateEntity(user);
|
|
|
|
// 检查用户名、手机号、身份证号是否已存在
|
|
|
|
Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
|
|
|
|
Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
|
|
|
|
.eq("username", yonghu.getUsername())
|
|
|
|
.eq("username", yonghu.getUsername())
|
|
|
|
.or()
|
|
|
|
.or()
|
|
|
|
.eq("yonghu_phone", yonghu.getYonghuPhone())
|
|
|
|
.eq("yonghu_phone", yonghu.getYonghuPhone())
|
|
|
|
.or()
|
|
|
|
.or()
|
|
|
|
.eq("yonghu_id_number", yonghu.getYonghuIdNumber())
|
|
|
|
.eq("yonghu_id_number", yonghu.getYonghuIdNumber())
|
|
|
|
.andNew()
|
|
|
|
.andNew()
|
|
|
|
.eq("yonghu_delete", 1)
|
|
|
|
.eq("yonghu_delete", 1)
|
|
|
|
;
|
|
|
|
;
|
|
|
|
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
|
|
|
|
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
|
|
|
|
if(yonghuEntity != null)
|
|
|
|
if(yonghuEntity != null)
|
|
|
|
return R.error("账户或者用户手机号或者用户身份证号已经被使用");
|
|
|
|
return R.error("账户或者用户手机号或者用户身份证号已经被使用");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置默认值
|
|
|
|
yonghu.setNewMoney(0.0);
|
|
|
|
yonghu.setNewMoney(0.0);
|
|
|
|
yonghu.setYonghuDelete(1);
|
|
|
|
yonghu.setYonghuDelete(1);
|
|
|
|
yonghu.setCreateTime(new Date());
|
|
|
|
yonghu.setCreateTime(new Date());
|
|
|
@ -363,40 +362,41 @@ public class YonghuController {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 重置密码
|
|
|
|
* 重置密码
|
|
|
|
|
|
|
|
* 将用户密码重置为默认值123456
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@GetMapping(value = "/resetPassword")
|
|
|
|
@GetMapping(value = "/resetPassword")
|
|
|
|
public R resetPassword(Integer id){
|
|
|
|
public R resetPassword(Integer id){
|
|
|
|
YonghuEntity yonghu = new YonghuEntity();
|
|
|
|
YonghuEntity yonghu = new YonghuEntity();
|
|
|
|
yonghu.setPassword("123456");
|
|
|
|
yonghu.setPassword("123456"); // 设置默认密码
|
|
|
|
yonghu.setId(id);
|
|
|
|
yonghu.setId(id);
|
|
|
|
yonghuService.updateById(yonghu);
|
|
|
|
yonghuService.updateById(yonghu);
|
|
|
|
return R.ok();
|
|
|
|
return R.ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 忘记密码
|
|
|
|
* 忘记密码
|
|
|
|
|
|
|
|
* 通过用户名重置密码
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@IgnoreAuth
|
|
|
|
@IgnoreAuth
|
|
|
|
@RequestMapping(value = "/resetPass")
|
|
|
|
@RequestMapping(value = "/resetPass")
|
|
|
|
public R resetPass(String username, HttpServletRequest request) {
|
|
|
|
public R resetPass(String username, HttpServletRequest request) {
|
|
|
|
YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", username));
|
|
|
|
YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", username));
|
|
|
|
if(yonghu!=null){
|
|
|
|
if(yonghu!=null){
|
|
|
|
yonghu.setPassword("123456");
|
|
|
|
yonghu.setPassword("123456"); // 重置为默认密码
|
|
|
|
boolean b = yonghuService.updateById(yonghu);
|
|
|
|
boolean b = yonghuService.updateById(yonghu);
|
|
|
|
if(!b){
|
|
|
|
if(!b){
|
|
|
|
return R.error();
|
|
|
|
return R.error();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
return R.error("账号不存在");
|
|
|
|
return R.error("账号不存在");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return R.ok();
|
|
|
|
return R.ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 获取用户的session用户信息
|
|
|
|
* 获取用户的session用户信息
|
|
|
|
*/
|
|
|
|
* 获取当前登录用户的信息
|
|
|
|
|
|
|
|
*/
|
|
|
|
@RequestMapping("/session")
|
|
|
|
@RequestMapping("/session")
|
|
|
|
public R getCurrYonghu(HttpServletRequest request){
|
|
|
|
public R getCurrYonghu(HttpServletRequest request){
|
|
|
|
Integer id = (Integer)request.getSession().getAttribute("userId");
|
|
|
|
Integer id = (Integer)request.getSession().getAttribute("userId");
|
|
|
@ -414,22 +414,20 @@ public class YonghuController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 退出
|
|
|
|
* 退出
|
|
|
|
*/
|
|
|
|
* 用户注销登录
|
|
|
|
|
|
|
|
*/
|
|
|
|
@GetMapping(value = "logout")
|
|
|
|
@GetMapping(value = "logout")
|
|
|
|
public R logout(HttpServletRequest request) {
|
|
|
|
public R logout(HttpServletRequest request) {
|
|
|
|
request.getSession().invalidate();
|
|
|
|
request.getSession().invalidate(); // 使session失效
|
|
|
|
return R.ok("退出成功");
|
|
|
|
return R.ok("退出成功");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 前端列表
|
|
|
|
* 前端列表
|
|
|
|
*/
|
|
|
|
* 提供给前端使用的用户列表接口
|
|
|
|
|
|
|
|
*/
|
|
|
|
@IgnoreAuth
|
|
|
|
@IgnoreAuth
|
|
|
|
@RequestMapping("/list")
|
|
|
|
@RequestMapping("/list")
|
|
|
|
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
|
|
|
|
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
|
|
|
@ -449,55 +447,53 @@ public class YonghuController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 前端详情
|
|
|
|
* 前端详情
|
|
|
|
*/
|
|
|
|
* 提供给前端使用的用户详情接口
|
|
|
|
|
|
|
|
*/
|
|
|
|
@RequestMapping("/detail/{id}")
|
|
|
|
@RequestMapping("/detail/{id}")
|
|
|
|
public R detail(@PathVariable("id") Long id, HttpServletRequest request){
|
|
|
|
public R detail(@PathVariable("id") Long id, HttpServletRequest request){
|
|
|
|
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
|
|
|
|
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
|
|
|
|
YonghuEntity yonghu = yonghuService.selectById(id);
|
|
|
|
YonghuEntity yonghu = yonghuService.selectById(id);
|
|
|
|
if(yonghu !=null){
|
|
|
|
if(yonghu !=null){
|
|
|
|
|
|
|
|
//entity转view
|
|
|
|
|
|
|
|
YonghuView view = new YonghuView();
|
|
|
|
//entity转view
|
|
|
|
BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中
|
|
|
|
YonghuView view = new YonghuView();
|
|
|
|
|
|
|
|
BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//修改对应字典表字段
|
|
|
|
//修改对应字典表字段
|
|
|
|
dictionaryService.dictionaryConvert(view, request);
|
|
|
|
dictionaryService.dictionaryConvert(view, request);
|
|
|
|
return R.ok().put("data", view);
|
|
|
|
return R.ok().put("data", view);
|
|
|
|
}else {
|
|
|
|
}else {
|
|
|
|
return R.error(511,"查不到数据");
|
|
|
|
return R.error(511,"查不到数据");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 前端保存
|
|
|
|
* 前端保存
|
|
|
|
*/
|
|
|
|
* 提供给前端使用的用户新增接口
|
|
|
|
|
|
|
|
*/
|
|
|
|
@RequestMapping("/add")
|
|
|
|
@RequestMapping("/add")
|
|
|
|
public R add(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
|
|
|
|
public R add(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
|
|
|
|
logger.debug("add方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
|
|
|
|
logger.debug("add方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
|
|
|
|
|
|
|
|
// 检查用户名、手机号、身份证号是否已存在
|
|
|
|
Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
|
|
|
|
Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
|
|
|
|
.eq("username", yonghu.getUsername())
|
|
|
|
.eq("username", yonghu.getUsername())
|
|
|
|
.or()
|
|
|
|
.or()
|
|
|
|
.eq("yonghu_phone", yonghu.getYonghuPhone())
|
|
|
|
.eq("yonghu_phone", yonghu.getYonghuPhone())
|
|
|
|
.or()
|
|
|
|
.or()
|
|
|
|
.eq("yonghu_id_number", yonghu.getYonghuIdNumber())
|
|
|
|
.eq("yonghu_id_number", yonghu.getYonghuIdNumber())
|
|
|
|
.andNew()
|
|
|
|
.andNew()
|
|
|
|
.eq("yonghu_delete", 1)
|
|
|
|
.eq("yonghu_delete", 1)
|
|
|
|
;
|
|
|
|
;
|
|
|
|
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
|
|
|
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
|
|
|
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
|
|
|
|
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
|
|
|
|
if(yonghuEntity==null){
|
|
|
|
if(yonghuEntity==null){
|
|
|
|
yonghu.setYonghuDelete(1);
|
|
|
|
yonghu.setYonghuDelete(1); // 设置未删除状态
|
|
|
|
yonghu.setCreateTime(new Date());
|
|
|
|
yonghu.setCreateTime(new Date()); // 设置创建时间
|
|
|
|
yonghu.setPassword("123456");
|
|
|
|
yonghu.setPassword("123456"); // 设置默认密码
|
|
|
|
yonghuService.insert(yonghu);
|
|
|
|
yonghuService.insert(yonghu);
|
|
|
|
return R.ok();
|
|
|
|
return R.ok();
|
|
|
|
}else {
|
|
|
|
}else {
|
|
|
|
return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用");
|
|
|
|
return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|