7/5
This commit is contained in:
@@ -12,11 +12,10 @@ import com.yxt.common.core.result.ResultBean;
|
||||
import com.yxt.common.core.vo.PagerVo;
|
||||
import com.yxt.portal.biz.sysstaffinfo.SysStaffinfoService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collections;
|
||||
@@ -59,7 +58,8 @@ public class SysStaffinfoRest{
|
||||
* @param pq 查询条件
|
||||
* @return
|
||||
*/
|
||||
|
||||
@ApiOperation("员工管理分页列表")
|
||||
@PostMapping("/listPage")
|
||||
public ResultBean<PagerVo<SysStaffinfoVo>> listPage(@RequestBody PagerQuery<SysStaffinfoQuery> pq) {
|
||||
ResultBean<PagerVo<SysStaffinfoVo>> rb = ResultBean.fireFail();
|
||||
IPage<SysStaffinfoVo> page = sysStaffinfoService.pagerList(pq);
|
||||
@@ -74,7 +74,8 @@ public class SysStaffinfoRest{
|
||||
* @param dto 数据传输对象
|
||||
* @return
|
||||
*/
|
||||
|
||||
@ApiOperation("新增保存")
|
||||
@PostMapping("/save")
|
||||
public ResultBean save(SysStaffinfoDto dto) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
ResultBean resultBean = sysStaffinfoService.saveStaffInfo(dto);
|
||||
@@ -91,7 +92,8 @@ public class SysStaffinfoRest{
|
||||
* @param sid 员工信息sid
|
||||
* @return
|
||||
*/
|
||||
|
||||
@ApiOperation("修改保存")
|
||||
@PostMapping("/update/{sid}")
|
||||
public ResultBean update(SysStaffinfoDto dto, String sid) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
ResultBean resultBean = sysStaffinfoService.updateStaffInfo(dto, sid);
|
||||
@@ -107,7 +109,8 @@ public class SysStaffinfoRest{
|
||||
* @param sysStaffQuery 数据传输对象
|
||||
* @return
|
||||
*/
|
||||
|
||||
@ApiOperation("设置离职")
|
||||
@PostMapping("/del")
|
||||
public ResultBean del(SysStaffQuery sysStaffQuery) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
//查询员工是否是离职
|
||||
@@ -126,8 +129,9 @@ public class SysStaffinfoRest{
|
||||
return rb.success().setMsg("成功");
|
||||
}
|
||||
|
||||
|
||||
public ResultBean<SysStaffinfoDetailsVo> fetchBySid(String sid) {
|
||||
@ApiOperation("员工信息编辑初始化及详情")
|
||||
@GetMapping("/fetchBySid/{sid}")
|
||||
public ResultBean<SysStaffinfoDetailsVo> fetchBySid(@PathVariable("sid") String sid) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
SysStaffinfoDetailsVo sysStaffinfo = sysStaffinfoService.selectDetailsBySid(sid);
|
||||
if (sysStaffinfo == null) {
|
||||
@@ -135,14 +139,28 @@ public class SysStaffinfoRest{
|
||||
}
|
||||
return rb.success().setData(sysStaffinfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取集团内全部员工姓名
|
||||
*
|
||||
* @param staffName 员工姓名
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("获取集团内全部员工姓名")
|
||||
@GetMapping("/getStaffName")
|
||||
|
||||
public ResultBean<List<Map<String, String>>> getStaffName(String staffName, String deptSid) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
List<Map<String, String>> staffNameList = sysStaffinfoService.getStaffName(staffName, deptSid);
|
||||
return rb.success().setData(staffNameList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门内全部员工姓名
|
||||
*
|
||||
* @param staffName 员工姓名
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("获取部门内全部员工姓名")
|
||||
@GetMapping("/getStaffNameByDeptSid")
|
||||
|
||||
public ResultBean<List<Map<String, String>>> getStaffNameByDeptSid(String staffName, String deptSid) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
@@ -151,12 +169,16 @@ public class SysStaffinfoRest{
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation("获取App通讯录")
|
||||
@ResponseBody
|
||||
@GetMapping("/selectAppContactsList")
|
||||
public ResultBean<List<SysStaffinfoAppContactsVo>> selectAppContactsList(String names) {
|
||||
return new ResultBean<List<SysStaffinfoAppContactsVo>>().success().setData(sysStaffinfoService.selectAppContactsList());
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("app查看通讯录详情")
|
||||
@ResponseBody
|
||||
@GetMapping("/selectAppContactsVO/{staffSid}")
|
||||
public ResultBean<AppContactsDetailsVo> selectAppContactsVO(String staffSid) {
|
||||
if (StringUtils.isBlank(staffSid)) {
|
||||
return new ResultBean<AppContactsDetailsVo>().fail().setMsg("staffSid不能为空");
|
||||
@@ -176,7 +198,9 @@ public class SysStaffinfoRest{
|
||||
return new ResultBean<AppContactsDetailsVo>().success().setData(appContactsDetailsVo);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("App通讯录搜索")
|
||||
@ResponseBody
|
||||
@PostMapping("/searchAppContactsList")
|
||||
public ResultBean<PagerVo<SysStaffinfoAppContactsSearchVo>> searchAppContactsList(PagerQuery<SysStaffinfoQuery> pq) {
|
||||
String names = pq.getParams().getName();
|
||||
if (StringUtils.isBlank(names))
|
||||
@@ -189,7 +213,9 @@ public class SysStaffinfoRest{
|
||||
return new ResultBean<PagerVo<SysStaffinfoAppContactsSearchVo>>().success().setData(pv_result);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("App通讯录搜索2")
|
||||
@ResponseBody
|
||||
@PostMapping("/searchAppContactsList2")
|
||||
public ResultBean<PagerVo<SysStaffinfoAppContactsSearchVo>> searchAppContactsList2(PagerQuery<SysStaffinfoQuery> pq) {
|
||||
PagerVo<SysStaffinfoAppContactsSearchVo> page1 = new PagerVo<>();
|
||||
IPage<SysStaffinfoAppContactsSearchVo> iPage = sysStaffinfoService.searchAppContactsList2(pq);
|
||||
@@ -199,34 +225,46 @@ public class SysStaffinfoRest{
|
||||
return new ResultBean<PagerVo<SysStaffinfoAppContactsSearchVo>>().success().setData(pv_result);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("销售订单-内部推荐人下拉框")
|
||||
@ResponseBody
|
||||
@GetMapping("/selectStaffList")
|
||||
public ResultBean<List<PcSysStaffVo>> selectStaffList(PcSysStaffQuery pcSysStaffQuery) {
|
||||
return sysStaffinfoService.selectStaffList(pcSysStaffQuery);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("移动端-销售订单-内部推荐人下拉框")
|
||||
@ResponseBody
|
||||
@PostMapping("/getUserList")
|
||||
public ResultBean<PagerVo<AppSysStaffVo>> getUserList(PagerQuery<AppSysStaffQuery> pagerQuery) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
PagerVo<AppSysStaffVo> pv = sysStaffinfoService.getUserList(pagerQuery);
|
||||
return rb.success().setData(pv);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("存放地点变更-获取人员列表")
|
||||
@ResponseBody
|
||||
@GetMapping("/getGressionUserList/{userSid}")
|
||||
public ResultBean<List<AppSysStaffVo>> getGressionUserList(String userSid) {
|
||||
return sysStaffinfoService.getGressionUserList(userSid, "");
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("切换机构:存放地点变更-获取人员列表")
|
||||
@ResponseBody
|
||||
@GetMapping("/getGressionUserList")
|
||||
public ResultBean<List<AppSysStaffVo>> getGressionUserList(String userSid, String orgPath) {
|
||||
return sysStaffinfoService.getGressionUserList(userSid, orgPath);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("获取集团所有人员")
|
||||
@ResponseBody
|
||||
@GetMapping("/selectStaffLists")
|
||||
public ResultBean<List<PcSysStaffVo>> selectStaffLists() {
|
||||
return sysStaffinfoService.selectStaffLists();
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("获取集团所有在职人员")
|
||||
@ResponseBody
|
||||
@GetMapping("/selectStaffListss")
|
||||
public ResultBean<List<PcSysStaffVo>> selectStaffListss() {
|
||||
return sysStaffinfoService.selectStaffListss();
|
||||
}
|
||||
|
||||
486
src/main/java/com/yxt/portal/apiwx/AppSysUserRest.java
Normal file
486
src/main/java/com/yxt/portal/apiwx/AppSysUserRest.java
Normal file
@@ -0,0 +1,486 @@
|
||||
package com.yxt.portal.apiwx;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
import com.yxt.common.base.config.RedisUtil;
|
||||
import com.yxt.common.base.config.component.FileUploadComponent;
|
||||
import com.yxt.common.base.utils.*;
|
||||
import com.yxt.common.core.result.ResultBean;
|
||||
import com.yxt.portal.biz.sysorganization.SysOrganization;
|
||||
import com.yxt.portal.biz.sysorganization.SysOrganizationService;
|
||||
import com.yxt.portal.biz.sysrole.SysRoleService;
|
||||
import com.yxt.portal.biz.sysstafforg.SysStaffOrg;
|
||||
import com.yxt.portal.biz.sysuser.SysUser;
|
||||
import com.yxt.portal.biz.sysuser.SysUserQuery;
|
||||
import com.yxt.portal.biz.sysuser.SysUserService;
|
||||
import com.yxt.portal.biz.sysuser.SysUserVo;
|
||||
import com.yxt.portal.biz.sysuser.app.AppMySysUserInfo;
|
||||
import com.yxt.portal.biz.sysuser.app.MyInfoQuery;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description
|
||||
* @Author liuguohui
|
||||
* @Date 2021/9/4
|
||||
*/
|
||||
@Api(tags = "用户表-移动端")
|
||||
@Controller
|
||||
@RequestMapping("apiwx/appuser")
|
||||
public class AppSysUserRest{
|
||||
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@Autowired(required = false)
|
||||
private HttpServletRequest httpServletRequest;
|
||||
@Autowired
|
||||
private FileUploadComponent fileUploadComponent;
|
||||
@Autowired
|
||||
private SysRoleService sysRoleService;
|
||||
@Autowired
|
||||
private SysOrganizationService sysOrganizationService;
|
||||
|
||||
@PostMapping("/login")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "1、app用户登录")
|
||||
public ResultBean<SysUserVo> login(SysUserQuery userQuery) {
|
||||
/*
|
||||
1、根据传参设备appId查询绑定账号
|
||||
1、1未查询到绑定的账号:
|
||||
1、1、1、查询用户登录账号(不存在-->返回“账号不存在”);
|
||||
1、1、2、账号存在,获取当前账号绑定的设备值:
|
||||
1)设备值为空,验证登录成功后即绑定设备,返回用户信息,验证不成功返回错误信息(验证码、密码错误)
|
||||
2)设备值存在,向表sys_exception_log插入数据,返回:当前账号已被其它设备绑定(错误码101(说明:错误码为sys_exception_log的id))
|
||||
1、2查询到绑定的账号
|
||||
1、2、1、根据传参设备appId查询到绑定的账号与用户传递的账号不一致
|
||||
1)向表sys_exception_log插入数据,返回:当前设备已绑定其它账号(错误码102)
|
||||
1、2、2、根据传参设备appId查询到绑定的账号与用户传递的账号一致,验证登录信息
|
||||
1)验证登录信息,成功后返回用户信息,验证不成功返回错误信息(验证码、密码错误)
|
||||
*/
|
||||
ResultBean<SysUserVo> rb = ResultBean.fireFail();
|
||||
String userName = userQuery.getUserName();
|
||||
String password = userQuery.getPassword();
|
||||
String appId = userQuery.getAppId();
|
||||
String verifyCode = userQuery.getVerifyCode();
|
||||
String type = userQuery.getType(); // type:1、密码登录2、验证码登录
|
||||
|
||||
if (StringUtils.isBlank(userName)) return new ResultBean<SysUserVo>().fail().setMsg("用户名不能为空");
|
||||
// if (StringUtils.isBlank(appId)) return new ResultBean<SysUserVo>().fail().setMsg("appId不能为空");
|
||||
if (type.equals("1")) {
|
||||
if (StringUtils.isBlank(password)) return new ResultBean<SysUserVo>().fail().setMsg("密码不能为空");
|
||||
} else {
|
||||
if (StringUtils.isBlank(verifyCode)) return new ResultBean<SysUserVo>().fail().setMsg("验证码不能为空");
|
||||
// 访问后清理key
|
||||
}
|
||||
boolean isTest = false;
|
||||
if(userQuery.getIsTest() != null){
|
||||
isTest = userQuery.getIsTest();
|
||||
}
|
||||
isTest = true;
|
||||
if (isTest) {//添加测试版
|
||||
//将该appId的所有账号的appId都置为空
|
||||
if(StringUtils.isNotBlank(appId)){
|
||||
sysUserService.updateAppIdNull(appId);
|
||||
}
|
||||
SysUser sysUser = sysUserService.selectByUserNameApp(userName);
|
||||
if (sysUser == null) {
|
||||
sysUser = sysUserService.selectByMobile(userName);
|
||||
if (sysUser == null) {
|
||||
return rb.setMsg("用户名或密码错误");
|
||||
}
|
||||
}
|
||||
if (type.equals("1")) {
|
||||
String md5 = Encodes.md5(password);
|
||||
if (md5.equals(sysUser.getPassword())) {
|
||||
if(StringUtils.isNotBlank(appId)){
|
||||
sysUserService.updateAppId(sysUser.getSid(), appId);
|
||||
}
|
||||
SysUserVo sysUserVo = sysUserService.selectUser(sysUser);
|
||||
if (sysUserVo == null) {
|
||||
return rb.setMsg("用户名或密码错误");
|
||||
}
|
||||
insertLoginLog(sysUser);
|
||||
return new ResultBean<SysUserVo>().success().setData(sysUserVo);
|
||||
} else {
|
||||
return new ResultBean<SysUserVo>().fail().setMsg("用户名或密码错误");
|
||||
}
|
||||
} else {
|
||||
String codeFromRedis = redisUtil.get("loginCode" + userName);
|
||||
if (StringUtils.isBlank(codeFromRedis))
|
||||
return new ResultBean<SysUserVo>().fail().setMsg("短信验证码已失效,请重新发送");
|
||||
if (verifyCode.equals(codeFromRedis.substring(0, 4))) {
|
||||
if(StringUtils.isNotBlank(appId)){
|
||||
sysUserService.updateAppId(sysUser.getSid(), appId);
|
||||
}
|
||||
SysUserVo sysUserVo = sysUserService.selectUser(sysUser);
|
||||
if (sysUserVo == null) {
|
||||
return rb.setMsg("用户名或密码错误");
|
||||
}
|
||||
redisUtil.remove("loginCode" + userName);
|
||||
insertLoginLog(sysUser);
|
||||
return new ResultBean<SysUserVo>().success().setData(sysUserVo);
|
||||
} else {
|
||||
return new ResultBean<SysUserVo>().fail().setMsg("短信验证码错误或已失效,请重新获取");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
SysUser sysUser = sysUserService.selectByAppId(appId);
|
||||
if (null == sysUser) { // 未查询到绑定的账号
|
||||
sysUser = sysUserService.selectByUserNameApp(userName);
|
||||
if (sysUser == null) {
|
||||
sysUser = sysUserService.selectByMobile(userName);
|
||||
if (sysUser == null) {
|
||||
return rb.setMsg("用户名或密码错误");
|
||||
}
|
||||
}
|
||||
String appIdVal = sysUser.getAppId();
|
||||
if (StringUtils.isBlank(appIdVal)) { // 设备值为空
|
||||
if (type.equals("1")) {
|
||||
String md5 = Encodes.md5(password);
|
||||
if (md5.equals(sysUser.getPassword())) {
|
||||
sysUserService.updateAppId(sysUser.getSid(), appId);
|
||||
SysUserVo sysUserVo = sysUserService.selectUser(sysUser);
|
||||
if (sysUserVo == null) {
|
||||
return rb.setMsg("用户名或密码错误");
|
||||
}
|
||||
insertLoginLog(sysUser);
|
||||
return new ResultBean<SysUserVo>().success().setData(sysUserVo);
|
||||
} else {
|
||||
return new ResultBean<SysUserVo>().fail().setMsg("用户名或密码错误");
|
||||
}
|
||||
} else {
|
||||
String codeFromRedis = redisUtil.get("loginCode" + userName);
|
||||
if (StringUtils.isBlank(codeFromRedis))
|
||||
return new ResultBean<SysUserVo>().fail().setMsg("短信验证码已失效,请重新发送");
|
||||
if (verifyCode.equals(codeFromRedis.substring(0, 4))) {
|
||||
sysUserService.updateAppId(sysUser.getSid(), appId);
|
||||
SysUserVo sysUserVo = sysUserService.selectUser(sysUser);
|
||||
if (sysUserVo == null) {
|
||||
return rb.setMsg("用户名或密码错误");
|
||||
}
|
||||
redisUtil.remove("loginCode" + userName);
|
||||
insertLoginLog(sysUser);
|
||||
return new ResultBean<SysUserVo>().success().setData(sysUserVo);
|
||||
} else {
|
||||
return new ResultBean<SysUserVo>().fail().setMsg("短信验证码错误或已失效,请重新获取");
|
||||
}
|
||||
}
|
||||
} else { // 设备值存在
|
||||
int res = insertSysExceptionLog("b", JSON.toJSON(userQuery).toString(), "当前账号已被其它设备绑定");
|
||||
return new ResultBean<SysUserVo>().fail().setMsg("当前账号已被其它设备绑定(错误码:" + res + ")");
|
||||
}
|
||||
} else { // 查询到绑定的账号
|
||||
if (userName.equals(sysUser.getUserName()) || userName.equals(sysUser.getMobile())) { // 设备appId一致,验证用户名
|
||||
if (type.equals("1")) {
|
||||
String md5 = Encodes.md5(password);
|
||||
if (md5.equals(sysUser.getPassword())) {
|
||||
SysUserVo sysUserVo = sysUserService.selectUser(sysUser);
|
||||
if (sysUserVo == null) {
|
||||
return rb.setMsg("用户名或密码错误");
|
||||
}
|
||||
insertLoginLog(sysUser);
|
||||
return new ResultBean<SysUserVo>().success().setData(sysUserVo);
|
||||
} else {
|
||||
return new ResultBean<SysUserVo>().fail().setMsg("用户名或密码错误");
|
||||
}
|
||||
} else {
|
||||
String codeFromRedis = redisUtil.get("loginCode" + userName);
|
||||
if (StringUtils.isBlank(codeFromRedis))
|
||||
return new ResultBean<SysUserVo>().fail().setMsg("短信验证码已失效,请重新发送");
|
||||
if (verifyCode.equals(codeFromRedis.substring(0, 4))) {
|
||||
SysUserVo sysUserVo = sysUserService.selectUser(sysUser);
|
||||
if (sysUserVo == null) {
|
||||
return rb.setMsg("该用户不是公司员工");
|
||||
}
|
||||
redisUtil.remove("loginCode" + userName);
|
||||
insertLoginLog(sysUser);
|
||||
return new ResultBean<SysUserVo>().success().setData(sysUserVo);
|
||||
} else {
|
||||
return new ResultBean<SysUserVo>().fail().setMsg("短信验证码错误或已失效,请重新获取");
|
||||
}
|
||||
}
|
||||
} else { // 用户名不一致
|
||||
int res = insertSysExceptionLog("a", JSON.toJSON(userQuery).toString(), "当前设备已绑定其它账号");
|
||||
return new ResultBean<SysUserVo>().fail().setMsg("当前设备已绑定其它账号(错误码:" + res + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入登录日志
|
||||
*
|
||||
* @param user
|
||||
*/
|
||||
private void insertLoginLog(SysUser user) {
|
||||
// SystemLog systemLog = new SystemLog();
|
||||
// systemLog.setUserName(user.getUserName());
|
||||
// String ip = WebUtil.getIpAddr(httpServletRequest);
|
||||
// systemLog.setUserIp(ip);
|
||||
// systemLog.setEventUrl("portal/v1/appuser/login");
|
||||
// systemLog.setEventContent("用户登录");
|
||||
// systemLog.setEventName("用户登录");
|
||||
// systemLogService.save(systemLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机发送短信验证码
|
||||
*
|
||||
* @param mobile
|
||||
* @param type 1、登录2、修改密码3、找回密码
|
||||
* @param appId 绑定手机的appid
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "手机发送验证码(登录、修改密码、找回密码)")
|
||||
@ResponseBody
|
||||
@PostMapping("/sendVerificationCodeForApp")
|
||||
public ResultBean sendVerificationCodeForApp(String mobile, String type, String appId) {
|
||||
if (StringUtils.isBlank(mobile) || !RegexUtil.isMobile(mobile)) {
|
||||
return new ResultBean().fail().setMsg("请输入正确的手机号");
|
||||
}
|
||||
if (type.equals("1") && StringUtils.isBlank(appId)) {
|
||||
return new ResultBean().fail().setMsg("appId不能为空");
|
||||
}
|
||||
// 登录、修改密码、重置密码先验证mobile与appId是否一致
|
||||
// if(type.equals("1") && !appId.equals(sysUser.getAppId())){
|
||||
// return new ResultBean().fail().setMsg("当前设备与账号不匹配,请解绑后再试");
|
||||
// }
|
||||
if (type.equals("2") || type.equals("3")) {
|
||||
SysUser sysUser = sysUserService.selectByUserNameApp(mobile);
|
||||
if (null == sysUser) {
|
||||
sysUser = sysUserService.selectByMobile(mobile);
|
||||
if (sysUser == null) {
|
||||
return new ResultBean().fail().setMsg("该手机号暂时还未注册,请先注册");
|
||||
}
|
||||
|
||||
}
|
||||
} else { // 登录
|
||||
SysUser sysUser = sysUserService.selectByAppId(appId);
|
||||
if (sysUser == null) { // 设备未绑定账号
|
||||
sysUser = sysUserService.selectByUserNameApp(mobile);
|
||||
if (sysUser == null) {
|
||||
sysUser = sysUserService.selectByMobile(mobile);
|
||||
if (sysUser == null) {
|
||||
return new ResultBean().fail().setMsg("该手机号暂时还未注册,请先注册");
|
||||
}
|
||||
}
|
||||
/*if (StringUtils.isNotBlank(sysUser.getAppId())) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("mobile", mobile);
|
||||
map.put("appId", appId);
|
||||
int res = insertSysExceptionLog("b", JSON.toJSON(map).toString(), "当前账号已被其它设备绑定");
|
||||
return new ResultBean<SysUserVo>().fail().setMsg("当前账号已被其它设备绑定(错误码:" + res + ")");
|
||||
}*/
|
||||
} else { // 设备已绑定账号
|
||||
/* if (!mobile.equals(sysUser.getMobile())) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("mobile", mobile);
|
||||
map.put("appId", appId);
|
||||
int res = insertSysExceptionLog("a", JSON.toJSON(map).toString(), "当前设备已绑定其它账号");
|
||||
return new ResultBean<SysUserVo>().fail().setMsg("当前设备已绑定其它账号(错误码:" + res + ")");
|
||||
}*/
|
||||
}
|
||||
}
|
||||
return sysUserService.sendVerificationCodeForApp(mobile, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入错误的信息
|
||||
*
|
||||
* @param operChar
|
||||
* @param operArg
|
||||
* @param remark
|
||||
*/
|
||||
private int insertSysExceptionLog(String operChar, String operArg, String remark) {
|
||||
// SysExceptionLog sysExceptionLog = new SysExceptionLog();
|
||||
// sysExceptionLog.setExceptionCode("M00001"); // 当前设备已绑定其它账号
|
||||
// sysExceptionLog.setExceptionType("移动端登陆");
|
||||
// sysExceptionLog.setOperChar(operChar);
|
||||
// sysExceptionLog.setOperArg(operArg);
|
||||
// sysExceptionLog.setRemark(remark);
|
||||
// sysExceptionLogService.insert(sysExceptionLog);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "我的信息")
|
||||
@ResponseBody
|
||||
@GetMapping("/getMyInfo/{userSid}")
|
||||
public ResultBean getMyInfo(String userSid) {
|
||||
if (StringUtils.isBlank(userSid)) return new ResultBean().fail().setMsg("userSid不能为空");
|
||||
SysUserVo sysUserVo = sysUserService.fetchBySidVo(userSid);
|
||||
if (null == sysUserVo) new ResultBean().fail().setMsg("信息错误");
|
||||
AppMySysUserInfo userInfo = new AppMySysUserInfo();
|
||||
String headImage = "";
|
||||
if (StringUtils.isNotBlank(sysUserVo.getHeadImage())) {
|
||||
headImage = fileUploadComponent.getUrlPrefix() + sysUserVo.getHeadImage();
|
||||
}
|
||||
userInfo.setHeadImage(headImage);
|
||||
userInfo.setName(StringUtils.isBlank(sysUserVo.getName()) ? "" : sysUserVo.getName());
|
||||
userInfo.setId("ID:" + sysUserVo.getId());
|
||||
// Map<String, Object> map = new HashMap<>();
|
||||
// map.put("headImage", StringUtils.isBlank(sysUserVo.getHeadImage())?"":sysUserVo.getHeadImage());
|
||||
// map.put("name", StringUtils.isBlank(sysUserVo.getName())?"":sysUserVo.getName());
|
||||
// map.put("ID", "ID:"+sysUserVo.getId()); // 是否为jobNumber,暂时为空
|
||||
return new ResultBean().success().setData(userInfo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "我的信息:切换机构")
|
||||
@ResponseBody
|
||||
@GetMapping("/getMyInfo")
|
||||
public ResultBean getMyInfo(MyInfoQuery myInfoQuery) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
String userSid = myInfoQuery.getUserSid();
|
||||
String orgPath = myInfoQuery.getOrgPath();
|
||||
SysUserVo sysUserVo = sysUserService.fetchBySidVo(userSid);
|
||||
if (null == sysUserVo) rb.setMsg("信息错误");
|
||||
AppMySysUserInfo userInfo = new AppMySysUserInfo();
|
||||
String headImage = "";
|
||||
if (StringUtils.isNotBlank(sysUserVo.getHeadImage())) {
|
||||
headImage = fileUploadComponent.getUrlPrefix() + sysUserVo.getHeadImage();
|
||||
}
|
||||
userInfo.setHeadImage(headImage);
|
||||
userInfo.setName(StringUtils.isBlank(sysUserVo.getName()) ? "" : sysUserVo.getName());
|
||||
userInfo.setId("ID:" + sysUserVo.getJobNumber());
|
||||
//根据组织机构sid查询该用户的职位以及分公司的部门
|
||||
List<String> strings = new ArrayList<>();
|
||||
List<SysStaffOrg> list = sysUserService.selectOrgBySid(orgPath, sysUserVo.getStaffSid());
|
||||
for (SysStaffOrg s : list) {
|
||||
String orgSid = s.getOrgSid();
|
||||
SysOrganization sysOrganization = sysOrganizationService.fetchBySid(orgSid);
|
||||
// String orgName = s.getOrgName();
|
||||
strings.add(sysOrganization.getName());
|
||||
}
|
||||
strings.removeAll(Collections.singleton(null));
|
||||
if (!strings.isEmpty()) {
|
||||
userInfo.setDepartment(String.join("|", strings));
|
||||
}
|
||||
String isAdmin = "";
|
||||
SysUser sysUser = sysUserService.fetchBySid(userSid);
|
||||
if(sysUser != null){
|
||||
isAdmin = sysUser.getIsAdmin();
|
||||
}
|
||||
if("1".equals(isAdmin)){
|
||||
String roleName = sysRoleService.selectByUserSid(userSid);
|
||||
userInfo.setPosition(roleName);
|
||||
|
||||
}else{
|
||||
//根据用户sid查询岗位
|
||||
List<String> stringList = sysUserService.getPost(sysUserVo.getStaffSid());
|
||||
stringList.removeAll(Collections.singleton(null));
|
||||
if (!stringList.isEmpty()) {
|
||||
userInfo.setPosition(String.join("|", stringList));
|
||||
}
|
||||
}
|
||||
|
||||
return new ResultBean().success().setData(userInfo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "手机更改密码")
|
||||
@ResponseBody
|
||||
@PostMapping("/updatePassword")
|
||||
public ResultBean<SysUserVo> updatePassword(String userSid, String appId, String oldPassword, String newPassword, HttpServletRequest httpServletRequest) {
|
||||
ResultBean<SysUserVo> rb = ResultBean.fireFail();
|
||||
String token = httpServletRequest.getHeader("token");
|
||||
SysUser user = sysUserService.fetchBySid(userSid);
|
||||
if (user == null) {
|
||||
return rb.setMsg("抱歉,用户不存在");
|
||||
}
|
||||
if (!appId.equals(user.getAppId())) {
|
||||
return rb.setMsg("当前设备与账号不匹配,请解绑后再试");
|
||||
}
|
||||
return sysUserService.updatePasswordApp(user, oldPassword, newPassword, token);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "手机找回密码验证验证码")
|
||||
@ResponseBody
|
||||
@PostMapping("/checkResetPwdCode")
|
||||
public ResultBean checkResetPwdCode(String resetPwdCode, String mobile) {
|
||||
if (StringUtils.isBlank(resetPwdCode)) return new ResultBean().fail().setMsg("验证码不能为空");
|
||||
String codeFromRedis = redisUtil.get("resetPwdCode" + mobile);
|
||||
if (StringUtils.isBlank(codeFromRedis)) return new ResultBean<SysUserVo>().fail().setMsg("短信验证码已失效,请重新发送");
|
||||
if (resetPwdCode.equals(codeFromRedis.substring(0, 4))) {
|
||||
redisUtil.remove("resetPwdCode" + mobile);
|
||||
return new ResultBean<SysUserVo>().success();
|
||||
} else {
|
||||
return new ResultBean<SysUserVo>().fail().setMsg("短信验证码错误或已失效,请重新获取");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "手机端找回密码")
|
||||
@ResponseBody
|
||||
@PostMapping("/resetPwd")
|
||||
public ResultBean resetPwdApp(String mobile, String newPwd, HttpServletRequest httpServletRequest) {
|
||||
String token = httpServletRequest.getHeader("token");
|
||||
if (StringUtils.isBlank(mobile) || !RegexUtil.isMobile(mobile))
|
||||
return new ResultBean().fail().setMsg("请输入正确的手机号");
|
||||
if (StringUtils.isBlank(newPwd)) return new ResultBean().fail().setMsg("请输入密码");
|
||||
return sysUserService.resetPwdApp(mobile, newPwd, token);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "手机修改用户头像")
|
||||
@ResponseBody
|
||||
@PostMapping("/updateHeadImage")
|
||||
public ResultBean updateHeadImage(MultipartFile multipartFile, String userSid) {
|
||||
SysUser user = sysUserService.fetchBySid(userSid);
|
||||
if (user == null) return new ResultBean().fail().setMsg("抱歉,用户不存在");
|
||||
if (multipartFile.isEmpty()) {
|
||||
return new ResultBean().fail().setMsg("上传图片不能为空");
|
||||
}
|
||||
String filename = multipartFile.getOriginalFilename();
|
||||
String suffix = filename.substring(filename.lastIndexOf("."));
|
||||
if (!suffix.equals(".jpg") && !suffix.equals(".jpeg") && !suffix.equals(".png") && !suffix.equals(".bmp") && !suffix.equals(".tif") && !suffix.equals(".gif")) {
|
||||
return new ResultBean().fail().setMsg("图片格式不正确");
|
||||
}
|
||||
return sysUserService.updateHeadImage(multipartFile, user);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机端根据token获取userSid
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "手机端根据token获取userSid")
|
||||
@ResponseBody
|
||||
@PostMapping("/getUserSidByToken")
|
||||
public ResultBean<String> getUserSidByToken(String token) {
|
||||
DecodedJWT decode = JWT.decode(token.substring(3));
|
||||
String userSid = JWTUtil.getUserSid(decode);
|
||||
if (StringUtils.isBlank(userSid)) {
|
||||
return new ResultBean().fail().setMsg("用户sid不能为空");
|
||||
} else {
|
||||
return new ResultBean<String>().success().setData(userSid);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "解绑某个用户或解绑所有的用户")
|
||||
@ResponseBody
|
||||
@PutMapping("/updateAppId")
|
||||
public ResultBean updateAppId(String mobile) {
|
||||
return sysUserService.updateAppIdByMobile(mobile);
|
||||
}
|
||||
|
||||
// @ApiOperation(value = "移动端:查询该菜单是否允许创建,是否有提醒消息")
|
||||
// @GetMapping(value = "/selectAppHaveMessage")
|
||||
// public ResultBean selectAppHaveMessage(String menuSid, String orgPath) {
|
||||
// return sysUserService.selectAppHaveMessage(menuSid,orgPath);
|
||||
// }
|
||||
|
||||
|
||||
// 解绑设备关联的账号
|
||||
// 解绑账号绑定的设备
|
||||
}
|
||||
578
src/main/java/com/yxt/portal/apiwx/WxSysUserRest.java
Normal file
578
src/main/java/com/yxt/portal/apiwx/WxSysUserRest.java
Normal file
@@ -0,0 +1,578 @@
|
||||
package com.yxt.portal.apiwx;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
import com.yxt.common.base.config.RedisUtil;
|
||||
import com.yxt.common.base.config.component.FileUploadComponent;
|
||||
import com.yxt.common.base.utils.*;
|
||||
import com.yxt.common.core.result.ResultBean;
|
||||
import com.yxt.portal.biz.sysorganization.SysOrganization;
|
||||
import com.yxt.portal.biz.sysorganization.SysOrganizationService;
|
||||
import com.yxt.portal.biz.sysstaffinfo.SysStaffinfoService;
|
||||
import com.yxt.portal.biz.sysuser.SysUser;
|
||||
import com.yxt.portal.biz.sysuser.SysUserService;
|
||||
import com.yxt.portal.biz.sysuser.wx.*;
|
||||
import com.yxt.portal.config.DictCommonType;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.Key;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author dimengzhe
|
||||
* @date 2021/10/5 13:09
|
||||
* @description 客户端用户接口
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("apiwx/wxuser")
|
||||
@Api(tags = "用户表-小程序端")
|
||||
public class WxSysUserRest{
|
||||
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
@Autowired
|
||||
private SysStaffinfoService sysStaffinfoService;
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Autowired
|
||||
private SysOrganizationService sysOrganizationService;
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
@Autowired
|
||||
private FileUploadComponent fileUploadComponent;
|
||||
@Autowired
|
||||
private HttpServletRequest httpServletRequest;
|
||||
|
||||
/**
|
||||
* 调用发送短信接口返回值
|
||||
*/
|
||||
static final String RESULT_CODE = "1";
|
||||
|
||||
/**
|
||||
* @param mobile 手机号
|
||||
* @param type 类型:1、注册,2、登录 3、忘记密码,4旧手机号获取验证码、5新手机号
|
||||
* @description: 获取验证码(按类型区分是哪块验证码)
|
||||
* @return:
|
||||
* @Author: dimengzhe
|
||||
* @Date: 2021/10/9 9:12
|
||||
*/
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "mobile", value = "手机号", required = true),
|
||||
@ApiImplicitParam(name = "type", value = "类型:1、注册,2、登录 3、忘记密码 4、旧手机号获取验证码、5新手机号", required = true),
|
||||
})
|
||||
@ApiOperation(value = "获取验证码(1、注册,2、登录 3、忘记密码)")
|
||||
@GetMapping("/sendMessageCode")
|
||||
@ResponseBody
|
||||
public ResultBean sendMessageCode(String mobile, String type) {
|
||||
//1、注册,2、登录 3、忘记密码
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
//验证手机号是否正确
|
||||
if (StringUtils.isBlank(mobile) || !RegexUtil.isMobile(mobile)) {
|
||||
return rb.setMsg("请输入正确的手机号");
|
||||
}
|
||||
if ("2".equals(type) || "3".equals(type)) {
|
||||
//查询该手机号是否已注册
|
||||
SysUser sysUser = sysUserService.selectByMobileAndType(mobile, 2);
|
||||
if (null == sysUser) {
|
||||
return rb.setMsg("该手机号还未注册或已被停用");
|
||||
}
|
||||
}
|
||||
if ("4".equals(type)) {
|
||||
//将token解密userSid
|
||||
String token = request.getHeader("token");
|
||||
DecodedJWT decodedJWT = JWT.decode(token.substring(2, token.length()));
|
||||
String userSid = JWTUtil.getUserSid(decodedJWT);
|
||||
SysUser sysUser = sysUserService.fetchBySid(userSid);
|
||||
if (sysUser == null) {
|
||||
return rb.setMsg("请登录");
|
||||
}
|
||||
if (!sysUser.getUserName().equals(mobile)) {
|
||||
return rb.setMsg("手机号错误");
|
||||
}
|
||||
}
|
||||
//验证是否已注册
|
||||
if ("5".equals(type)) {
|
||||
SysUser sysUser = sysUserService.selectByMobileAndType(mobile, 2);
|
||||
if (sysUser != null) {
|
||||
return rb.setMsg("该手机号已注册");
|
||||
}
|
||||
}
|
||||
String verificationCode = "";
|
||||
return sysUserService.getWxVerificationCode(mobile, verificationCode, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param wxSysUserLoginQuery 数据传输对象
|
||||
* @description: 免密码登录、账号密码登录
|
||||
* @return:
|
||||
* @Author: dimengzhe
|
||||
* @Date: 2021/10/9 9:15
|
||||
*/
|
||||
@ApiOperation(value = "登录")
|
||||
@ResponseBody
|
||||
@PostMapping("/login")
|
||||
public ResultBean<WxSysUserVo> login(WxSysUserLoginQuery wxSysUserLoginQuery) {
|
||||
WxSysUserVo wxSysUserVo = new WxSysUserVo();
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
String type = wxSysUserLoginQuery.getType();//手机登录类型:1、密码登录,2、验证码登录
|
||||
String verifyCode = wxSysUserLoginQuery.getVerifyCode();//验证码
|
||||
String password = wxSysUserLoginQuery.getPassword();//密码
|
||||
String userName = wxSysUserLoginQuery.getUserName();
|
||||
if ("1".equals(type)) {//密码登录
|
||||
if (StringUtils.isBlank(password)) {
|
||||
return rb.setMsg("密码不能为空");
|
||||
}
|
||||
} else if ("2".equals(type)) {//验证码登录
|
||||
if (StringUtils.isBlank(verifyCode)) {
|
||||
return rb.setMsg("验证码不能为空");
|
||||
}
|
||||
}
|
||||
SysUser sysUser = sysUserService.selectByMobileAndType(userName, 2);
|
||||
if (null == sysUser) {
|
||||
return rb.setMsg("账号不存在或已被停用");
|
||||
}
|
||||
if ("1".equals(type)) {//密码登录
|
||||
String md5 = Encodes.md5(password);
|
||||
if (md5.equals(sysUser.getPassword())) {//匹配
|
||||
wxSysUserVo = sysUserService.selectByWxUserName(userName, 2);
|
||||
} else {
|
||||
return rb.setMsg("用户名或密码错误");
|
||||
}
|
||||
} else if ("2".equals(type)) {//验证码登录
|
||||
String redisCode = redisUtil.get(DictCommonType.WX_LOGIN + userName);
|
||||
if (StringUtils.isBlank(redisCode)) {
|
||||
return rb.setMsg("短信验证码错误或已失效,请重新获取");
|
||||
}
|
||||
if (verifyCode.equals(redisCode.substring(0, 4))) {
|
||||
wxSysUserVo = sysUserService.selectByWxUserName(userName, 2);
|
||||
redisUtil.remove(DictCommonType.WX_LOGIN + userName);
|
||||
|
||||
} else {
|
||||
return rb.setMsg("短信验证码错误或已失效,请重新获取");
|
||||
}
|
||||
}
|
||||
return new ResultBean<WxSysUserVo>().success().setData(wxSysUserVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param wxSysUserDto 数据传输对象
|
||||
* @description: 客户端注册
|
||||
* @return:
|
||||
* @Author: dimengzhe
|
||||
* @Date: 2021/10/9 9:21
|
||||
*/
|
||||
@ApiOperation(value = "注册")
|
||||
@ResponseBody
|
||||
@PostMapping("/registsUser")
|
||||
public ResultBean registsUser(WxSysUserDto wxSysUserDto) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
String mobile = wxSysUserDto.getMobile();//手机号
|
||||
String idNo = wxSysUserDto.getIdNo();//身份证号
|
||||
String verificationCode = wxSysUserDto.getVerificationCode();//验证码
|
||||
String name = wxSysUserDto.getName();//姓名
|
||||
String result = "";
|
||||
//判断身份证号是否正确
|
||||
try {
|
||||
if (StringUtils.isNotBlank(RegexUtil.IDCardValidate(idNo))) {
|
||||
return rb.setMsg(RegexUtil.IDCardValidate(idNo));
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//判断是否已注册
|
||||
int userType = 2;//用户类型
|
||||
SysUser sysUser = sysUserService.selectByMobileAndType(mobile, userType);
|
||||
if (sysUser != null) {
|
||||
return rb.setMsg("该手机号已注册");
|
||||
}
|
||||
//验证码是否正确
|
||||
Map<String, Object> map = sysUserService.mobileValidateWxRegister(mobile, verificationCode);
|
||||
String code = map.get("code").toString();
|
||||
boolean isSave = false;
|
||||
if (Tools.CODE_SUCCESS.equals(code)) {
|
||||
//需验证手机号+姓名+身份证号是否匹配
|
||||
WxSysUserRegistQuery wxSysUserRegistQuery = new WxSysUserRegistQuery();
|
||||
wxSysUserRegistQuery.setMobile(mobile);
|
||||
wxSysUserRegistQuery.setName(name);
|
||||
wxSysUserRegistQuery.setIdcard(idNo);
|
||||
try {
|
||||
ResultBean resultBean = isTr2(wxSysUserRegistQuery);
|
||||
if (!resultBean.getSuccess()) {
|
||||
return ResultBean.fireFail().setMsg(resultBean.getMsg());
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidKeyException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
SysUser sysUser1 = new SysUser();
|
||||
sysUser1.setUserName(mobile);
|
||||
sysUser1.setMobile(mobile);
|
||||
sysUser1.setUserType(userType);
|
||||
String password = mobile.substring(5, 11);
|
||||
String md5 = Encodes.md5(password);
|
||||
sysUser1.setPassword(md5);
|
||||
//查询客户表中身份证号是否存在,若存在直接更新客户信息。若不存在,则根据姓名和手机号查询,
|
||||
// 若存在,则更新身份证号,若不存在,则直接创建客户信息
|
||||
// WxCrmCustomerQuery wxCrmCustomerQuery = new WxCrmCustomerQuery();
|
||||
// wxCrmCustomerQuery.setMobile(mobile);
|
||||
// wxCrmCustomerQuery.setName(name);
|
||||
// wxCrmCustomerQuery.setIdNo(idNo);
|
||||
// //查询最大一级的组织机构
|
||||
// SysOrganization sysOrganization = sysOrganizationService.selectOrgCode();
|
||||
// if (StringUtils.isBlank(sysOrganization.getOrgCode())) {
|
||||
// wxCrmCustomerQuery.setOrgCode("" + 1);
|
||||
// wxCrmCustomerQuery.setOrgSid(sysOrganization.getSid());
|
||||
// } else {
|
||||
// wxCrmCustomerQuery.setOrgSid(sysOrganization.getSid());
|
||||
// wxCrmCustomerQuery.setOrgCode(sysOrganization.getOrgCode() + 1);
|
||||
// }
|
||||
//
|
||||
// ResultBean resultBean = crmCustomerFeign.wxSaveCustomer(wxCrmCustomerQuery);
|
||||
// sysUser1.setStaffSid(resultBean.getData().toString());
|
||||
sysUser1.setHeadImage("http://120.46.131.15:8111/upload/appImage/headImage.jpg");
|
||||
isSave = sysUserService.save(sysUser1);
|
||||
String regiMsg = "客户端账号为:" + mobile + "的账号,已注册成功,登录密码为" + password;
|
||||
result = MsgWs.SendWaitWorkMsg(mobile, regiMsg);
|
||||
} else {
|
||||
return ResultBean.fireFail().setMsg(map.get("details").toString());
|
||||
}
|
||||
if (!isSave) {
|
||||
return ResultBean.fireSuccess().setMsg("注册失败");
|
||||
}
|
||||
if (!RESULT_CODE.equals(result)) {
|
||||
return ResultBean.fireFail().setMsg("注册成功,未发送密码");
|
||||
}
|
||||
return ResultBean.fireSuccess().setMsg("注册成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userSid 用户sid
|
||||
* @description: 客户端获取我的信息
|
||||
* @return: 头像+保密后的姓名
|
||||
* @Author: dimengzhe
|
||||
* @Date: 2021/10/6 12:19
|
||||
*/
|
||||
@ApiOperation(value = "我的信息")
|
||||
@ResponseBody
|
||||
@GetMapping("/myInfo/{userSid}")
|
||||
public ResultBean<WxMySysUserInfoVo> selectMyInfo(String userSid) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
SysUser sysUser = sysUserService.fetchBySid(userSid);
|
||||
if (null == sysUser) {
|
||||
return rb.setMsg("该用户不存在");
|
||||
}
|
||||
WxMySysUserInfoVo infoVo = sysUserService.selectMyInfo(userSid);
|
||||
// ResultBean<CrmCustomer> resultBean = crmCustomerFeign.selectBySid(sysUser.getStaffSid());
|
||||
// if (resultBean.getSuccess()) {
|
||||
// infoVo.setName(resultBean.getData().getName());
|
||||
// }
|
||||
if (StringUtils.isBlank(infoVo.getHeadImage())) {
|
||||
//默认头像
|
||||
infoVo.setHeadImage("http://120.46.131.15:8111/upload/appImage/headImage.jpg");
|
||||
} else {
|
||||
infoVo.setHeadImage(fileUploadComponent.getUrlPrefix() + infoVo.getHeadImage());
|
||||
}
|
||||
return rb.success().setData(infoVo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "首页")
|
||||
@ResponseBody
|
||||
@GetMapping("/selectHomePage/{userSid}")
|
||||
public ResultBean<WxHomePageVo> selectHomePage(String userSid) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
SysUser sysUser = sysUserService.fetchBySid(userSid);
|
||||
if (null == sysUser) {
|
||||
return rb.setMsg("该用户不存在");
|
||||
}
|
||||
boolean isHave = false;
|
||||
WxHomePageVo wxHomePageVo = sysUserService.selectHomePage(userSid);
|
||||
// ResultBean<CrmCustomer> resultBean = crmCustomerFeign.selectBySid(wxHomePageVo.getStaffSid());
|
||||
// if (resultBean.getSuccess()) {
|
||||
// wxHomePageVo.setIdTerm(resultBean.getData().getEndDate());
|
||||
// }
|
||||
if (StringUtils.isBlank(wxHomePageVo.getHeadImage())) {
|
||||
//默认头像
|
||||
wxHomePageVo.setHeadImage("http://120.46.131.15:8111/upload/appImage/headImage.jpg");
|
||||
} else {
|
||||
wxHomePageVo.setHeadImage(fileUploadComponent.getUrlPrefix() + wxHomePageVo.getHeadImage());
|
||||
}
|
||||
//2018.08.24-2038.08.24
|
||||
/*String idTerm = wxHomePageVo.getIdTerm();
|
||||
List<String> split = Arrays.asList(idTerm.split("-"));
|
||||
if (split.size() == 2) {
|
||||
String idTermEnd = split.get(1);
|
||||
String date = idTermEnd.replace('.', '-');
|
||||
int days = days(date);
|
||||
if (days == 30 || days == 60) {
|
||||
isHave = true;
|
||||
wxHomePageVo.setMessage("您的身份证将在" + days + "天后到期,请及时更新信息");
|
||||
}
|
||||
}*/
|
||||
wxHomePageVo.setIsHave(isHave);
|
||||
return new ResultBean<WxHomePageVo>().success().setData(wxHomePageVo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "客户端验证验证码是否正确")
|
||||
@ResponseBody
|
||||
@PostMapping("/checkResetPwdCode")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "code", value = "验证码", required = true),
|
||||
@ApiImplicitParam(name = "mobile", value = "手机号", required = true),
|
||||
@ApiImplicitParam(name = "type", value = "类型:1、找回密码 2、验证旧手机号的验证码、3、验证新手机好的验证码", required = true)
|
||||
})
|
||||
public ResultBean checkResetPwdCode(String code, String mobile, String type) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
String key = "";
|
||||
if (!"1".equals(type) && !"2".equals(type) && !"3".equals(type)) {
|
||||
return rb.setMsg("类型错误");
|
||||
}
|
||||
if ("1".equals(type)) {
|
||||
key = DictCommonType.WX_FORGET + mobile;
|
||||
} else if ("2".equals(type)) {
|
||||
key = DictCommonType.WX_UPDATE + mobile;
|
||||
} else if ("3".equals(type)) {
|
||||
key = DictCommonType.WX_NEW + mobile;
|
||||
}
|
||||
String keyOne = redisUtil.get(key);
|
||||
String redisCode = redisUtil.get(key).substring(0, 4);
|
||||
// 判断验证码是否失效
|
||||
if (StringUtils.isEmpty(redisCode)) {
|
||||
return rb.setMsg("验证码失效");
|
||||
} else if (!"".equals(redisCode) && !code.equals(redisCode)) {
|
||||
return rb.setMsg("验证码错误");
|
||||
}
|
||||
return rb.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mobile 手机号
|
||||
* @param newPwd 新密码
|
||||
* @description: 客户端找回密码
|
||||
* @return:
|
||||
* @Author: dimengzhe
|
||||
* @Date: 2021/10/9 9:21
|
||||
*/
|
||||
@ApiOperation(value = "客户端找回密码")
|
||||
@ResponseBody
|
||||
@PostMapping("/resetPwd")
|
||||
public ResultBean resetPwdWx(String mobile, String newPwd) {
|
||||
if (StringUtils.isBlank(mobile) || !RegexUtil.isMobile(mobile)) {
|
||||
return new ResultBean().fail().setMsg("请输入正确的手机号");
|
||||
}
|
||||
if (StringUtils.isBlank(newPwd)) {
|
||||
return new ResultBean().fail().setMsg("请输入密码");
|
||||
}
|
||||
return sysUserService.resetPwdWx(mobile, newPwd);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据用户sid查询用户信息")
|
||||
@ResponseBody
|
||||
@PostMapping("/selectBySid")
|
||||
public ResultBean<SysUser> selectBySid(String sid) {
|
||||
SysUser sysUser = sysUserService.fetchBySid(sid);
|
||||
if (sysUser == null) {
|
||||
sysUser = new SysUser();
|
||||
return new ResultBean<SysUser>().fail().setData(sysUser).setMsg("用户不存在");
|
||||
}
|
||||
return new ResultBean<SysUser>().success().setData(sysUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param end 结束日期
|
||||
* @description: 计算两个日期相差多少天
|
||||
* @return:
|
||||
* @Author: dimengzhe
|
||||
* @Date: 2021/10/12 14:36
|
||||
*/
|
||||
private int days(String end) {
|
||||
int i = 0;
|
||||
DateFormat dft = new SimpleDateFormat("yyyy-MM-dd");
|
||||
try {
|
||||
Date star = new Date();//开始时间
|
||||
Date endDay = dft.parse(end);//结束时间
|
||||
Date nextDay = star;
|
||||
while (nextDay.before(endDay)) {//当明天不在结束时间之前是终止循环
|
||||
Calendar cld = Calendar.getInstance();
|
||||
cld.setTime(star);
|
||||
cld.add(Calendar.DATE, 1);
|
||||
star = cld.getTime();
|
||||
//获得下一天日期字符串
|
||||
nextDay = star;
|
||||
i++;
|
||||
}
|
||||
System.out.println("相差天数为:" + i);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public ResultBean isTr2(WxSysUserRegistQuery wxSysUserRegistQuery) throws UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException {
|
||||
String result = "";
|
||||
String msg = "";
|
||||
//云市场分配的密钥Id
|
||||
String secretId = "AKID7rl35uAlxzadzo1I299iEiYnMH111I0beWu";
|
||||
//云市场分配的密钥Key
|
||||
String secretKey = "atdsoC8Q2fjuhf31agmub4g8fzh93n8V9yoXQJtk";
|
||||
String source = "market";
|
||||
|
||||
Calendar cd = Calendar.getInstance();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
String datetime = sdf.format(cd.getTime());
|
||||
// 签名
|
||||
String auth = calcAuthorization(source, secretId, secretKey, datetime);
|
||||
// 请求方法
|
||||
String method = "GET";
|
||||
// 请求头
|
||||
Map<String, String> headers = new HashMap<String, String>();
|
||||
headers.put("X-Source", source);
|
||||
headers.put("X-Date", datetime);
|
||||
headers.put("Authorization", auth);
|
||||
|
||||
// 查询参数
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
queryParams.put("idCard", wxSysUserRegistQuery.getIdcard());
|
||||
queryParams.put("mobile", wxSysUserRegistQuery.getMobile());
|
||||
queryParams.put("realName", wxSysUserRegistQuery.getName());
|
||||
// body参数
|
||||
Map<String, String> bodyParams = new HashMap<String, String>();
|
||||
|
||||
// url参数拼接
|
||||
String url = "https://service-08ijl3bf-1301232119.bj.apigw.tencentcs.com/release/phonecheck";
|
||||
if (!queryParams.isEmpty()) {
|
||||
url += "?" + urlencode(queryParams);
|
||||
}
|
||||
|
||||
BufferedReader in = null;
|
||||
try {
|
||||
URL realUrl = new URL(url);
|
||||
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
|
||||
conn.setConnectTimeout(5000);
|
||||
conn.setReadTimeout(5000);
|
||||
conn.setRequestMethod(method);
|
||||
|
||||
// request headers
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
conn.setRequestProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
// request body
|
||||
Map<String, Boolean> methods = new HashMap<>();
|
||||
methods.put("POST", true);
|
||||
methods.put("PUT", true);
|
||||
methods.put("PATCH", true);
|
||||
Boolean hasBody = methods.get(method);
|
||||
if (hasBody != null) {
|
||||
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||
|
||||
conn.setDoOutput(true);
|
||||
DataOutputStream out = new DataOutputStream(conn.getOutputStream());
|
||||
out.writeBytes(urlencode(bodyParams));
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
|
||||
// 定义 BufferedReader输入流来读取URL的响应
|
||||
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
result += line;
|
||||
}
|
||||
|
||||
System.out.println(result);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
//判断result
|
||||
JSONObject object = JSONObject.parseObject(result);
|
||||
Map<String, Object> map = JSONObject.parseObject(object.toJSONString(), new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
int code = ConstantUtils.getInteger(map, "error_code");
|
||||
if (code == 0) {
|
||||
Map<String, Object> mapo = ConstantUtils.getMap(map, "result");
|
||||
String VerificationResult = mapo.get("VerificationResult").toString();
|
||||
if ("1".equals(VerificationResult)) {
|
||||
msg = "信息匹配";
|
||||
} else if ("-1".equals(VerificationResult)) {
|
||||
return ResultBean.fireFail().setMsg("信息不匹配");
|
||||
} else if ("0".equals(VerificationResult)) {
|
||||
return ResultBean.fireFail().setMsg("运营商系统中无记录");
|
||||
}
|
||||
} else {
|
||||
return ResultBean.fireFail().setMsg(ConstantUtils.getString(map, "reason", "错误"));
|
||||
}
|
||||
return ResultBean.fireSuccess().setMsg(msg);
|
||||
|
||||
}
|
||||
|
||||
public static String calcAuthorization(String source, String secretId, String secretKey, String datetime)
|
||||
throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
|
||||
String signStr = "x-date: " + datetime + "\n" + "x-source: " + source;
|
||||
Mac mac = Mac.getInstance("HmacSHA1");
|
||||
Key sKey = new SecretKeySpec(secretKey.getBytes("UTF-8"), mac.getAlgorithm());
|
||||
mac.init(sKey);
|
||||
byte[] hash = mac.doFinal(signStr.getBytes("UTF-8"));
|
||||
String sig = Base64.encode(hash);
|
||||
|
||||
String auth = "hmac id=\"" + secretId + "\", algorithm=\"hmac-sha1\", headers=\"x-date x-source\", signature=\"" + sig + "\"";
|
||||
return auth;
|
||||
}
|
||||
|
||||
public static String urlencode(Map<?, ?> map) throws UnsupportedEncodingException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Map.Entry<?, ?> entry : map.entrySet()) {
|
||||
if (sb.length() > 0) {
|
||||
sb.append("&");
|
||||
}
|
||||
sb.append(String.format("%s=%s",
|
||||
URLEncoder.encode(entry.getKey().toString(), "UTF-8"),
|
||||
URLEncoder.encode(entry.getValue().toString(), "UTF-8")
|
||||
));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,4 +46,5 @@ public class SysRole extends BaseEntity {
|
||||
@ApiModelProperty(value = "角色组织层级value")
|
||||
private String roleTypeValue;
|
||||
private String orgSid;
|
||||
private String dataRuleId;
|
||||
}
|
||||
|
||||
@@ -44,4 +44,6 @@ public class SysRoleVo implements Vo {
|
||||
private String postName;
|
||||
@ApiModelProperty(value = "组织层级")
|
||||
private String roleTypeValue;
|
||||
private String dataRuleId;
|
||||
private String dataRuleValue;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
package com.yxt.portal.biz.sysstaffinfo;
|
||||
|
||||
import com.yxt.portal.biz.sysrole.SysRole;
|
||||
import com.yxt.portal.biz.sysrole.SysRoleVo;
|
||||
import com.yxt.portal.biz.sysstafforg.SysStaffOrgDetailsVo;
|
||||
import com.yxt.portal.biz.sysstaffpost.SysStaffPostDetailsVo;
|
||||
import com.yxt.common.core.vo.Vo;
|
||||
import com.yxt.portal.biz.sysuserrole.SysUserRole;
|
||||
import com.yxt.portal.biz.sysuserrole.SysUserRoleVo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author dimengzhe
|
||||
* @Date 2022/2/11 16:12
|
||||
@@ -14,72 +21,41 @@ import lombok.Data;
|
||||
@Data
|
||||
public class SysStaffinfoDetailsVo implements Vo {
|
||||
private static final long serialVersionUID = 1232171677690215067L;
|
||||
|
||||
@ApiModelProperty(value = "工号")
|
||||
private String sid;
|
||||
@ApiModelProperty("工号")
|
||||
private String jobNumber;
|
||||
|
||||
@ApiModelProperty(value = "姓名")
|
||||
@ApiModelProperty("姓名")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "性别key")
|
||||
private Integer genderKey;
|
||||
@ApiModelProperty(value = "性别")
|
||||
private String gender;
|
||||
@ApiModelProperty(value = "身份证号")
|
||||
@ApiModelProperty("身份证号")
|
||||
private String idNo;
|
||||
@ApiModelProperty(value = "证件有效期")
|
||||
@ApiModelProperty("证件有效期")
|
||||
private String idTerm;
|
||||
@ApiModelProperty("生日")
|
||||
private String birthday;
|
||||
@ApiModelProperty(value = "民族")
|
||||
private Date birthday;
|
||||
@ApiModelProperty("民族")
|
||||
private String national;
|
||||
@ApiModelProperty(value = "民族key")
|
||||
private String nationalKey;
|
||||
@ApiModelProperty("籍贯")
|
||||
private String nativePlace;
|
||||
@ApiModelProperty(value = "省")
|
||||
private String province;
|
||||
@ApiModelProperty(value = "市")
|
||||
private String city;
|
||||
@ApiModelProperty(value = "县区")
|
||||
private String county;
|
||||
@ApiModelProperty(value = "省code")
|
||||
private String provinceCode;
|
||||
@ApiModelProperty(value = "市code")
|
||||
private String cityCode;
|
||||
@ApiModelProperty(value = "县区code")
|
||||
private String countyCode;
|
||||
@ApiModelProperty("住址")
|
||||
private String address;
|
||||
@ApiModelProperty(value = "手机号")
|
||||
@ApiModelProperty("手机号")
|
||||
private String mobile;
|
||||
@ApiModelProperty("邮箱")
|
||||
private String email;
|
||||
@ApiModelProperty(value = "紧急联系人")
|
||||
private String emergencyContact;
|
||||
@ApiModelProperty(value = "紧急联系电话")
|
||||
private String emergencyMobile;
|
||||
@ApiModelProperty("政治面貌")
|
||||
private String poliCode;
|
||||
@ApiModelProperty(value = "政治面貌key")
|
||||
private String poliCodeKey;
|
||||
@ApiModelProperty("婚姻状况")
|
||||
private String maritalStatus;
|
||||
@ApiModelProperty("婚姻状况key")
|
||||
private String maritalStatusKey;
|
||||
@ApiModelProperty("员工类型(无类型、全职、兼职、实习、劳务派遣、退休返聘、劳务外包)")
|
||||
private String personType;
|
||||
@ApiModelProperty("员工类型key")
|
||||
private String personTypeKey;
|
||||
@ApiModelProperty("入职时间")
|
||||
private String joinCompnyDate;
|
||||
private Date joinCompnyDate;
|
||||
@ApiModelProperty("试用期(无试用期、1个月、2个月、3个月、其他)")
|
||||
private String probPeriod;
|
||||
@ApiModelProperty("试用期key")
|
||||
private String probPeriodKey;
|
||||
@ApiModelProperty("计划转正日期")
|
||||
private String plannedConfirmDate;
|
||||
private Date plannedConfirmDate;
|
||||
@ApiModelProperty("实际转正日期")
|
||||
private String confirmationDate;
|
||||
private Date confirmationDate;
|
||||
@ApiModelProperty("银行卡号")
|
||||
private String bankCardNo;
|
||||
@ApiModelProperty("开户行")
|
||||
@@ -98,58 +74,9 @@ public class SysStaffinfoDetailsVo implements Vo {
|
||||
private String photo;
|
||||
@ApiModelProperty(value = "员工部门信息")
|
||||
private SysStaffOrgDetailsVo sysStaffOrg;
|
||||
@ApiModelProperty(value = "员工岗位信息")
|
||||
private SysStaffPostDetailsVo sysStaffPost;
|
||||
private List<SysUserRoleVo> sysUserRoles;
|
||||
|
||||
//===========================================//
|
||||
@ApiModelProperty(value = "毕业院校")
|
||||
private String graduate;
|
||||
@ApiModelProperty(value = "学历/专业")
|
||||
private String education;
|
||||
@ApiModelProperty(value = "职称")
|
||||
private String title;
|
||||
@ApiModelProperty(value = "资格认证")
|
||||
private String qualification;
|
||||
@ApiModelProperty(value = "驾照类型")
|
||||
private String licenseType;
|
||||
@ApiModelProperty(value = "驾照类型key")
|
||||
private String licenseTypeKey;
|
||||
@ApiModelProperty(value = "意外险参保:1是,0否")
|
||||
private Integer isHaveInsurance;
|
||||
@ApiModelProperty(value = "意外险参保:1是,0否")
|
||||
private String isHaveInsuranceValue;
|
||||
@ApiModelProperty(value = "意外险参保时间")
|
||||
private String insuranceStartDate;
|
||||
@ApiModelProperty(value = "意外险参保终止日期")
|
||||
private String insuranceEndDate;
|
||||
@ApiModelProperty(value = "意外险参保地")
|
||||
private String insuranceAddr;
|
||||
@ApiModelProperty(value = "养老:1是,0否")
|
||||
private Integer isHaveAged;
|
||||
@ApiModelProperty(value = "养老:1是,0否")
|
||||
private String isHaveAgedValue;
|
||||
@ApiModelProperty(value = "医疗:1是,0否")
|
||||
private Integer isHaveMedical;
|
||||
@ApiModelProperty(value = "医疗:1是,0否")
|
||||
private String isHaveMedicalValue;
|
||||
@ApiModelProperty(value = "工伤:1是,0否")
|
||||
private Integer isHaveInjury;
|
||||
@ApiModelProperty(value = "工伤:1是,0否")
|
||||
private String isHaveInjuryValue;
|
||||
@ApiModelProperty(value = "失业:1是,0否")
|
||||
private Integer isHaveUnemploy;
|
||||
@ApiModelProperty(value = "失业:1是,0否")
|
||||
private String isHaveUnemployValue;
|
||||
@ApiModelProperty(value = "社保参保地")
|
||||
private String insuredPlace;
|
||||
@ApiModelProperty(value = "纸质档案保管地")
|
||||
private String paperPlace;
|
||||
@ApiModelProperty(value = "合同起止日期")
|
||||
private String contractStartDate;
|
||||
@ApiModelProperty(value = "合同结束日期")
|
||||
private String contractEndDate;
|
||||
@ApiModelProperty(value = "离职日期")
|
||||
private String quitDate;
|
||||
@ApiModelProperty(value = "离职原因")
|
||||
private String quitReason;
|
||||
private String accountType;//账号类型 1单位管理员,2操作员,0是平台管理员 3非登录账户
|
||||
private String userType;//用户类型:1员工、2客户、3供应商
|
||||
private List<SysRoleVo> sysRoleVos;//
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.yxt.portal.biz.sysstafforg.SysStaffOrgDto;
|
||||
import com.yxt.portal.biz.sysstaffpost.SysStaffPostDto;
|
||||
import com.yxt.common.core.dto.Dto;
|
||||
import com.yxt.portal.biz.sysuserrole.SysUserRole;
|
||||
import com.yxt.portal.biz.sysuserrole.SysUserRoleDto;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -12,6 +14,7 @@ import lombok.Data;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Project: anrui_portal(门户建设) <br/>
|
||||
@@ -133,7 +136,8 @@ public class SysStaffinfoDto implements Dto {
|
||||
private SysStaffOrgDto sysStaffOrg;
|
||||
@ApiModelProperty(value = "员工岗位信息")
|
||||
private SysStaffPostDto sysStaffPost;
|
||||
|
||||
@ApiModelProperty(value = "员工角色信息")
|
||||
private List<SysUserRoleDto> sysUserRoles;
|
||||
//========================================//
|
||||
@ApiModelProperty(value = "毕业院校")
|
||||
private String graduate;
|
||||
@@ -182,5 +186,7 @@ public class SysStaffinfoDto implements Dto {
|
||||
private Date quitDate;
|
||||
@ApiModelProperty(value = "离职原因")
|
||||
private String quitReason;
|
||||
|
||||
private String accountType;//账号类型 1单位管理员,2操作员,0是平台管理员 3非登录账户
|
||||
private String userType;//用户类型:1员工、2客户、3供应商
|
||||
private String orgSid;
|
||||
}
|
||||
@@ -143,12 +143,11 @@
|
||||
<!--根据员工sid查询员工信息-->
|
||||
<select id="selectDetailsBySid" resultType="com.yxt.portal.biz.sysstaffinfo.SysStaffinfoDetailsVo">
|
||||
select
|
||||
sid,
|
||||
<!--工号-->
|
||||
jobNumber,
|
||||
<!--姓名-->
|
||||
name,
|
||||
<!--性别key-->
|
||||
genderKey,
|
||||
<!--性别-->
|
||||
gender,
|
||||
<!--身份证号-->
|
||||
@@ -159,50 +158,22 @@
|
||||
DATE_FORMAT(birthday, '%Y-%m-%d') as birthday,
|
||||
<!--民族-->
|
||||
national,
|
||||
<!--民族key-->
|
||||
nationalKey,
|
||||
<!--籍贯-->
|
||||
nativePlace,
|
||||
<!--省-->
|
||||
province,
|
||||
<!--市-->
|
||||
city,
|
||||
<!--县区-->
|
||||
county,
|
||||
<!--省code-->
|
||||
provinceCode,
|
||||
<!--市code-->
|
||||
cityCode,
|
||||
<!--县区code-->
|
||||
countyCode,
|
||||
<!--住址-->
|
||||
address,
|
||||
<!--手机号-->
|
||||
mobile,
|
||||
<!--邮箱-->
|
||||
email,
|
||||
<!--紧急联系人-->
|
||||
emergencyContact,
|
||||
<!--紧急联系电话-->
|
||||
emergencyMobile,
|
||||
<!--政治面貌-->
|
||||
poliCode,
|
||||
<!--政治面貌key-->
|
||||
poliCodeKey,
|
||||
<!--婚姻状况-->
|
||||
maritalStatus,
|
||||
<!--婚姻状况key-->
|
||||
maritalStatusKey,
|
||||
<!--员工类型-->
|
||||
personType,
|
||||
<!--员工类型key-->
|
||||
personTypeKey,
|
||||
<!--入职时间-->
|
||||
DATE_FORMAT(joinCompnyDate, '%Y-%m-%d') as joinCompnyDate,
|
||||
<!--试用期-->
|
||||
probPeriod,
|
||||
<!--试用期key-->
|
||||
probPeriodKey,
|
||||
<!--计划转正日期-->
|
||||
DATE_FORMAT(plannedConfirmDate, '%Y-%m-%d') as plannedConfirmDate,
|
||||
<!--实际转正日期-->
|
||||
@@ -232,70 +203,9 @@
|
||||
<!--NULLIF(CONCAT(#{path}, leaveCertificate) as leaveCertificate,leaveCertificate),-->
|
||||
<!--when leaveCertificate is null then leaveCertificate else concat(#{path}, leaveCertificate) as leaveCertificate end,-->
|
||||
<!--员工照片-->
|
||||
IF(photo = "", photo, CONCAT(#{path}, photo)) AS photo,
|
||||
IF(photo = "", photo, CONCAT(#{path}, photo)) AS photo
|
||||
<!--NULLIF(CONCAT(#{path}, photo) as photo,photo),-->
|
||||
<!--when photo is null then photo else concat(#{path}, photo) as photo end,-->
|
||||
<!--毕业院校-->
|
||||
graduate,
|
||||
<!--学历/专业-->
|
||||
education,
|
||||
educationKey,
|
||||
<!--职称-->
|
||||
title,
|
||||
<!--资格认证-->
|
||||
qualification,
|
||||
<!--驾照类型-->
|
||||
licenseType,
|
||||
<!--驾照类型key-->
|
||||
licenseTypeKey,
|
||||
<!--意外险参保:1是,0否-->
|
||||
isHaveInsurance,
|
||||
<!--意外险参保:1是,0否-->
|
||||
case isHaveInsurance
|
||||
when 1 then '是'
|
||||
when 0 then '否' end as isHaveInsuranceValue,
|
||||
<!--意外险参保时间-->
|
||||
DATE_FORMAT(insuranceStartDate, '%Y-%m-%d') as insuranceStartDate,
|
||||
<!--意外险参保终止日期-->
|
||||
DATE_FORMAT(insuranceEndDate, '%Y-%m-%d') as insuranceEndDate,
|
||||
<!--意外险参保地-->
|
||||
insuranceAddr,
|
||||
<!--养老:1是,0否-->
|
||||
isHaveAged,
|
||||
<!--养老:1是,0否-->
|
||||
case isHaveAged
|
||||
when 1 then '是'
|
||||
when 0 then '否' end as isHaveAgedValue,
|
||||
<!--医疗:1是,0否-->
|
||||
isHaveMedical,
|
||||
<!--医疗:1是,0否-->
|
||||
case isHaveMedical
|
||||
when 1 then '是'
|
||||
when 0 then '否' end as isHaveMedicalValue,
|
||||
<!--工伤:1是,0否-->
|
||||
isHaveInjury,
|
||||
<!--工伤:1是,0否-->
|
||||
case isHaveInjury
|
||||
when 1 then '是'
|
||||
when 0 then '否' end as isHaveInjuryValue,
|
||||
<!--失业:1是,0否-->
|
||||
isHaveUnemploy,
|
||||
<!--失业:1是,0否-->
|
||||
case isHaveUnemploy
|
||||
when 1 then '是'
|
||||
when 0 then '否' end as isHaveUnemployValue,
|
||||
<!--社保参保地-->
|
||||
insuredPlace,
|
||||
<!--纸质档案保管地-->
|
||||
paperPlace,
|
||||
<!--合同起止日期-->
|
||||
DATE_FORMAT(contractStartDate, '%Y-%m-%d') as contractStartDate,
|
||||
<!--合同结束日期-->
|
||||
DATE_FORMAT(contractEndDate, '%Y-%m-%d') as contractEndDate,
|
||||
<!--离职日期-->
|
||||
DATE_FORMAT(quitDate, '%Y-%m-%d') as quitDate,
|
||||
<!--离职原因-->
|
||||
quitReason
|
||||
from sys_staffinfo
|
||||
where sid = #{sid}
|
||||
</select>
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.yxt.portal.biz.sysrole.SysRoleService;
|
||||
import com.yxt.portal.biz.sysstafforg.SysStaffOrgService;
|
||||
import com.yxt.portal.biz.sysstaffpost.SysStaffPostService;
|
||||
import com.yxt.portal.biz.sysuser.SysUserService;
|
||||
import com.yxt.portal.biz.sysuserrole.SysUserRoleDto;
|
||||
import com.yxt.portal.biz.sysuserrole.SysUserRoleService;
|
||||
import com.yxt.common.base.config.RedisUtil;
|
||||
import com.yxt.common.base.config.component.FileUploadComponent;
|
||||
@@ -33,6 +34,7 @@ import com.yxt.common.base.utils.PinYinUtils;
|
||||
import com.yxt.common.core.query.PagerQuery;
|
||||
import com.yxt.common.core.result.ResultBean;
|
||||
import com.yxt.common.core.vo.PagerVo;
|
||||
import com.yxt.portal.biz.sysuserrole.SysUserRoleVo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -270,7 +272,7 @@ public class SysStaffinfoService extends MybatisBaseService<SysStaffinfoMapper,
|
||||
* @param dto 数据传输对象
|
||||
* @return
|
||||
*/
|
||||
public ResultBean saveStaffInfo(SysStaffinfoDto dto) {
|
||||
public ResultBean saveStaffInfo1(SysStaffinfoDto dto) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
SysRoleVo sysRoleVo = sysRoleService.fetchByName("试用期员工");
|
||||
if (sysRoleVo == null) {
|
||||
@@ -429,6 +431,70 @@ public class SysStaffinfoService extends MybatisBaseService<SysStaffinfoMapper,
|
||||
sysUserRoleService.save(sysUserRole);
|
||||
return rb.success().setMsg("添加员工信息成功");
|
||||
|
||||
}
|
||||
public ResultBean saveStaffInfo(SysStaffinfoDto dto) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
//员工类型
|
||||
//String personTypeKey = dto.getPersonTypeKey();
|
||||
String jobNumber = "";
|
||||
SysStaffinfo sysStaffinfo = baseMapper.selectJobNumber();
|
||||
if (sysStaffinfo == null) {
|
||||
//无此员工类型的员工
|
||||
jobNumber = addOne("0000");
|
||||
} else {
|
||||
jobNumber = sysStaffinfo.getJobNumber();
|
||||
jobNumber = addOne(jobNumber);
|
||||
}
|
||||
//查询员工的手机号是否重复
|
||||
SysStaffinfo sysStaffinfo1 = baseMapper.selectByMobile(dto.getMobile());
|
||||
SysUser sysUser1 = sysUserService.selectByMobile(dto.getMobile());
|
||||
if (sysStaffinfo1 != null || sysUser1 != null) {
|
||||
return rb.setMsg("已存在手机号为" + dto.getMobile() + "的员工");
|
||||
}
|
||||
|
||||
//查询部门是否为空
|
||||
if (dto.getSysStaffOrg() == null) {
|
||||
return rb.setMsg("员工部门信息不能为空");
|
||||
}
|
||||
//添加员工基础信息
|
||||
SysStaffinfo sysStaffinfo3 = new SysStaffinfo();
|
||||
dto.fillEntity(sysStaffinfo3);
|
||||
sysStaffinfo3.setJobNumber(jobNumber);
|
||||
|
||||
//增加员工的关联的部门信息
|
||||
SysStaffOrg sysStaffOrg = new SysStaffOrg();
|
||||
SysStaffOrgDto sysStaffOrgDto = dto.getSysStaffOrg();
|
||||
if (StringUtils.isBlank(sysStaffOrgDto.getOrgName())) {
|
||||
return rb.setMsg("所在部门不能为空");
|
||||
}
|
||||
sysStaffOrgDto.fillEntity(sysStaffOrg);
|
||||
sysStaffOrg.setStaffSid(sysStaffinfo3.getSid());
|
||||
sysStaffOrg.setManageType("3");
|
||||
sysStaffOrgService.save(sysStaffOrg);
|
||||
save(sysStaffinfo3);
|
||||
//添加用户信息
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setStaffSid(sysStaffinfo3.getSid());
|
||||
sysUser.setUserName(jobNumber);
|
||||
sysUser.setMobile(sysStaffinfo3.getMobile());
|
||||
sysUser.setUserType(1);
|
||||
String password = sysStaffinfo3.getMobile().substring(5, 11);
|
||||
String md5 = Encodes.md5(password);
|
||||
sysUser.setPassword(md5);
|
||||
sysUser.setAccountType(dto.getAccountType());
|
||||
boolean isSave = sysUserService.save(sysUser);
|
||||
if (!isSave) {
|
||||
return rb.setMsg("添加员工信息失败");
|
||||
}
|
||||
for (SysUserRoleDto sysUserRole : dto.getSysUserRoles()) {
|
||||
SysUserRole ss = new SysUserRole();
|
||||
ss.setUserSid(sysUser.getSid());
|
||||
ss.setRoleSid(sysUserRole.getRoleSid());
|
||||
sysUserRoleService.save(ss);
|
||||
}
|
||||
|
||||
return rb.success().setMsg("添加员工信息成功");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -465,7 +531,7 @@ public class SysStaffinfoService extends MybatisBaseService<SysStaffinfoMapper,
|
||||
* @param sid 员工信息sid
|
||||
* @return
|
||||
*/
|
||||
public ResultBean updateStaffInfo(SysStaffinfoDto dto, String sid) {
|
||||
public ResultBean updateStaffInfo1(SysStaffinfoDto dto, String sid) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
//查询该人员的组织机构list
|
||||
List<SysStaffOrgVo> sysStaffOrgVos = sysStaffOrgService.selectByStaffS(sid);
|
||||
@@ -628,7 +694,100 @@ public class SysStaffinfoService extends MybatisBaseService<SysStaffinfoMapper,
|
||||
}
|
||||
return rb.success().setMsg("更新员工信息成功");
|
||||
}
|
||||
/**
|
||||
* 员工信息修改保存
|
||||
*
|
||||
* @param dto 数据传输对象
|
||||
* @param sid 员工信息sid
|
||||
* @return
|
||||
*/
|
||||
public ResultBean updateStaffInfo(SysStaffinfoDto dto, String sid) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
//查询该人员的组织机构list
|
||||
List<SysStaffOrgVo> sysStaffOrgVos = sysStaffOrgService.selectByStaffS(sid);
|
||||
List<String> orgList = new ArrayList<>();
|
||||
if (sysStaffOrgVos.size() > 0) {
|
||||
for (SysStaffOrgVo vv : sysStaffOrgVos) {
|
||||
// String orgSid = sysStaffOrgService.getOrgByOrgSid(vv.getOrgSid());
|
||||
String orgSid = vv.getOrgSid();
|
||||
SysOrganization sysOrganization = sysOrganizationService.fetchBySid(orgSid);
|
||||
if (sysOrganization != null) {
|
||||
orgList.add(orgSid);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
//根据员工sid查询员工的信息
|
||||
SysStaffinfo sysStaffinfo = fetchBySid(sid);
|
||||
if (sysStaffinfo == null) {
|
||||
return rb.setMsg("此员工信息不存在");
|
||||
}
|
||||
//查询员工的手机号是否重复
|
||||
SysStaffinfo sysStaffinfo2 = baseMapper.selectByMobileAndSid(dto.getMobile(), sid);
|
||||
if (sysStaffinfo2 != null) {
|
||||
return rb.setMsg("已存在手机号为" + dto.getMobile() + "的员工");
|
||||
}
|
||||
|
||||
//更新员工基础信息
|
||||
BeanUtil.copyProperties(dto, sysStaffinfo);
|
||||
sysStaffinfo.setJobNumber(dto.getJobNumber());
|
||||
|
||||
//更新用户信息
|
||||
sysUserService.updateByStaffSid(dto.getJobNumber(), sysStaffinfo.getMobile(), sid);
|
||||
//更新员工的关联的部门信息
|
||||
SysStaffOrgDto sysStaffOrgDto = dto.getSysStaffOrg();
|
||||
// int count = sysStaffOrgService.selectByStaffAndOrg(sysStaffOrgDto.getOrgSidPath(), sid, "2");
|
||||
// if (count > 0) {
|
||||
// sysStaffOrgService.deleteByStaffSidAndType(sysStaffOrgDto.getOrgSidPath(), sid, "2");
|
||||
// }
|
||||
// SysStaffOrg sysStaffOrg = sysStaffOrgService.getOrgByStaffSidAndPath(sid,sysStaffOrgDto.getOrgSidPath());
|
||||
// if(sysStaffOrg == null){
|
||||
// ResultBean<SysStaffOrg> staffOrgResultBean = sysStaffOrgService.selectAllByStaffSid(sid);
|
||||
// sysStaffOrg = staffOrgResultBean.getData();
|
||||
// if(sysStaffOrg == null){
|
||||
// sysStaffOrg = new SysStaffOrg();
|
||||
// sysStaffOrg.setStaffSid(sid);
|
||||
// BeanUtil.copyProperties(sysStaffOrgDto,sysStaffOrg);
|
||||
// sysStaffOrg.setManageType("3");
|
||||
// sysStaffOrgService.insert(sysStaffOrg);
|
||||
// }else{
|
||||
// BeanUtil.copyProperties(sysStaffOrgDto,sysStaffOrg);
|
||||
// sysStaffOrg.setManageType("3");
|
||||
// sysStaffOrgService.updateById(sysStaffOrg);
|
||||
// }
|
||||
// }else{
|
||||
// BeanUtil.copyProperties(sysStaffOrgDto,sysStaffOrg);
|
||||
// sysStaffOrg.setManageType("3");
|
||||
// sysStaffOrgService.updateById(sysStaffOrg);
|
||||
// }
|
||||
boolean isUpdate = updateById(sysStaffinfo);
|
||||
if (!isUpdate) {
|
||||
return rb.setMsg("更新员工信息失败");
|
||||
}
|
||||
List<SysStaffOrgVo> sysStaffOrgVos1 = sysStaffOrgService.selectByStaffS(sid);
|
||||
List<String> orgList1 = new ArrayList<>();
|
||||
if (sysStaffOrgVos1.size() > 0) {
|
||||
for (SysStaffOrgVo vv : sysStaffOrgVos1) {
|
||||
// String orgSid = sysStaffOrgService.getOrgByOrgSid(vv.getOrgSid());
|
||||
String orgSid = vv.getOrgSid();
|
||||
SysOrganization sysOrganization = sysOrganizationService.fetchBySid(orgSid);
|
||||
if (sysOrganization != null) {
|
||||
orgList1.add(orgSid);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<String> reduce1 = orgList.stream().filter(item -> !orgList1.contains(item)).collect(toList());
|
||||
if (reduce1.size() > 0) {
|
||||
//根据staffSid查询token
|
||||
String token = sysUserService.selectByStaffsid(sid).getToken();
|
||||
//清空该token
|
||||
redisUtil.remove(token);
|
||||
}
|
||||
return rb.success().setMsg("更新员工信息成功");
|
||||
}
|
||||
/**
|
||||
* 根据员工sid查询员工信息
|
||||
*
|
||||
@@ -656,22 +815,17 @@ public class SysStaffinfoService extends MybatisBaseService<SysStaffinfoMapper,
|
||||
type = s.getManageType();
|
||||
}
|
||||
}
|
||||
SysStaffPostDetailsVo staffPostDetailsVo = sysStaffPostService.getPostByStaffSid(sid);
|
||||
// SysStaffPostDetailsVo staffPostDetailsVo = sysStaffPostService.getPostByStaffSid(sid);
|
||||
SysStaffOrgDetailsVo sysStaffOrgDetailsVo = sysStaffOrgService.selectByStaffByType(sid, orgSid, type);
|
||||
SysStaffPostDetailsVo sysStaffPostDetailsVo = sysStaffPostService.selectByStaff(sid, staffPostDetailsVo.getPostSid());
|
||||
SysUser s= sysUserService.getOne(new QueryWrapper<SysUser>().eq("staffSid",sysStaffinfoDetailsVo.getSid()));
|
||||
List<SysUserRoleVo> list=sysUserRoleService.selByUserSid(s.getSid());
|
||||
sysStaffinfoDetailsVo.setSysUserRoles(list);
|
||||
// SysStaffPostDetailsVo sysStaffPostDetailsVo = sysStaffPostService.selectByStaff(sid, staffPostDetailsVo.getPostSid());
|
||||
if(sysStaffOrgDetailsVo != null){
|
||||
sysStaffinfoDetailsVo.setSysStaffOrg(sysStaffOrgDetailsVo);
|
||||
}else{
|
||||
sysStaffinfoDetailsVo.setSysStaffOrg(new SysStaffOrgDetailsVo());
|
||||
}
|
||||
if(sysStaffPostDetailsVo != null){
|
||||
sysStaffinfoDetailsVo.setSysStaffPost(sysStaffPostDetailsVo);
|
||||
}else{
|
||||
sysStaffinfoDetailsVo.setSysStaffPost(new SysStaffPostDetailsVo());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
return sysStaffinfoDetailsVo;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ public class SysStaffOrgDetailsVo implements Vo {
|
||||
private String orgName;
|
||||
@ApiModelProperty("部门路径")
|
||||
private String orgSidPath;
|
||||
@ApiModelProperty("部门名称路径")
|
||||
private String orgNamePath;
|
||||
// @ApiModelProperty("部门名称路径")
|
||||
// private String orgNamePath;
|
||||
@ApiModelProperty(value = "部门编码")
|
||||
private String orgCode;
|
||||
@ApiModelProperty("管理类型:1、主管。2、分管。3、员工")
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
</select>
|
||||
|
||||
<select id="selectByStaffByType" resultType="com.yxt.portal.biz.sysstafforg.SysStaffOrgDetailsVo">
|
||||
select sso.orgSid, sso.orgName, sso.orgNamePath, sso.manageType, so.orgCode, sso.orgSidPath
|
||||
select sso.orgSid, sso.orgName, sso.manageType, so.orgCode
|
||||
from sys_staff_org sso
|
||||
left join sys_organization so on sso.orgSid = so.sid
|
||||
where sso.staffSid = #{sid}
|
||||
|
||||
@@ -68,4 +68,5 @@ public class SysUser extends BaseEntity {
|
||||
private String headImage;
|
||||
@TableField(exist = false)
|
||||
private String orgSid;
|
||||
private String accountType;////账号类型 1单位管理员,2操作员,0是平台管理员 3非登录账户
|
||||
}
|
||||
|
||||
@@ -22,7 +22,9 @@ import com.yxt.portal.biz.sysstafforg.SysStaffOrgService;
|
||||
import com.yxt.portal.biz.sysstaffpost.SysStaffPostService;
|
||||
//import com.yxt.user.biz.sysuserdefaultorg.SysUserDefaultOrgService;
|
||||
import com.yxt.portal.biz.sysuser.app.OrgList;
|
||||
import com.yxt.portal.biz.sysuser.wx.WxHomePageVo;
|
||||
import com.yxt.portal.biz.sysuser.wx.WxMySysUserInfoVo;
|
||||
import com.yxt.portal.biz.sysuser.wx.WxSysUserVo;
|
||||
import com.yxt.portal.biz.sysuserdefaultorg.SysUserDefaultOrgService;
|
||||
import com.yxt.portal.biz.sysuserrole.SysUserRoleService;
|
||||
import com.yxt.common.base.config.RedisUtil;
|
||||
@@ -157,6 +159,7 @@ public class SysUserService extends MybatisBaseService<SysUserMapper, SysUser> {
|
||||
IPage<SysUserVo> pagging = baseMapper.selectPageVo(page, qw, deptName, userName);
|
||||
List<SysUserVo> records = pagging.getRecords();
|
||||
for (SysUserVo record : records) {
|
||||
record.setSysRoleVos(sysUserRoleService.selByUserSid(record.getSid()));
|
||||
String departmentSid = record.getDepartmentSid();
|
||||
String orgName = "";
|
||||
if (StringUtils.isNotBlank(departmentSid)) {
|
||||
@@ -986,11 +989,12 @@ public class SysUserService extends MybatisBaseService<SysUserMapper, SysUser> {
|
||||
}
|
||||
String content = "";
|
||||
if (type.equals("1")) {
|
||||
content = "登录验证码:" + verificationCode + ",用于登录App,有效期5分钟,如非本人操作,请忽略。";
|
||||
content = "登录验证码:" + verificationCode + ",有效期5分钟,如非本人操作,请忽略。"+"【商享通】";
|
||||
} else {
|
||||
content = "修改密码验证码:" + verificationCode + ",用于修改登录密码,有效期5分钟,如非本人操作,请忽略。";
|
||||
content = "修改验证码:" + verificationCode + ",有效期5分钟,如非本人操作,请忽略。"+"【商享通】";
|
||||
}
|
||||
String res = MsgWs.SendWaitWorkMsg(mobile, content);
|
||||
// String res = MsgWs.SendWaitWorkMsg(mobile, content);
|
||||
String res = com.yxt.portal.utils.MsgWs.SendWaitWorkMsg(mobile, content);
|
||||
// String res = "1";
|
||||
if (res.equals("1")) {
|
||||
redisUtil.set(redisKey + mobile, verificationCode + date.getTime(), APP_LOGIN_CODE_TIME_LIMIT);
|
||||
@@ -1195,34 +1199,34 @@ public class SysUserService extends MybatisBaseService<SysUserMapper, SysUser> {
|
||||
* @Author: dimengzhe
|
||||
* @Date: 2021/10/6 15:09
|
||||
*/
|
||||
// public WxSysUserVo selectByWxUserName(String userName, int userType) {
|
||||
// WxSysUserVo wxSysUserVo = baseMapper.selectByWxUserName(userName, userType);
|
||||
// //根据客户sid查询姓名
|
||||
// String staffSid = wxSysUserVo.getStaffSid();
|
||||
public WxSysUserVo selectByWxUserName(String userName, int userType) {
|
||||
WxSysUserVo wxSysUserVo = baseMapper.selectByWxUserName(userName, userType);
|
||||
//根据客户sid查询姓名
|
||||
String staffSid = wxSysUserVo.getStaffSid();
|
||||
// ResultBean<CrmCustomer> resultBean = crmCustomerFeign.selectBySid(staffSid);
|
||||
// if (resultBean.getSuccess()) {
|
||||
// wxSysUserVo.setName(resultBean.getData().getName());
|
||||
// }
|
||||
// // 生成token
|
||||
// String uniqueToken = JWTUtil.create(wxSysUserVo.getUserSid() + "");
|
||||
// String token = "WX" + uniqueToken;
|
||||
// //查询是否有旧token,存在的话清除掉redis中的该token
|
||||
// if (StringUtils.isNotBlank(wxSysUserVo.getToken())) {
|
||||
// //查询是否过期
|
||||
// String values = redisUtil.get(wxSysUserVo.getToken());
|
||||
// if (StringUtils.isNotBlank(values)) {
|
||||
// redisUtil.remove(wxSysUserVo.getToken());
|
||||
// }
|
||||
// }
|
||||
// // redis中缓存token
|
||||
// redisUtil.set(token, wxSysUserVo.getUserName(),
|
||||
// USERS_REDIS_SESSION_TL_PC);
|
||||
// wxSysUserVo.setToken(token);
|
||||
// wxSysUserVo.setNum("1");
|
||||
// // 更新用户中的token
|
||||
// updateToken(wxSysUserVo.getUserSid(), token);
|
||||
// return wxSysUserVo;
|
||||
// }
|
||||
// 生成token
|
||||
String uniqueToken = JWTUtil.create(wxSysUserVo.getUserSid() + "");
|
||||
String token = "WX" + uniqueToken;
|
||||
//查询是否有旧token,存在的话清除掉redis中的该token
|
||||
if (StringUtils.isNotBlank(wxSysUserVo.getToken())) {
|
||||
//查询是否过期
|
||||
String values = redisUtil.get(wxSysUserVo.getToken());
|
||||
if (StringUtils.isNotBlank(values)) {
|
||||
redisUtil.remove(wxSysUserVo.getToken());
|
||||
}
|
||||
}
|
||||
// redis中缓存token
|
||||
redisUtil.set(token, wxSysUserVo.getUserName(),
|
||||
USERS_REDIS_SESSION_TL_PC);
|
||||
wxSysUserVo.setToken(token);
|
||||
wxSysUserVo.setNum("1");
|
||||
// 更新用户中的token
|
||||
updateToken(wxSysUserVo.getUserSid(), token);
|
||||
return wxSysUserVo;
|
||||
}
|
||||
|
||||
public ResultBean resetPwdWx(String mobile, String newPwd) {
|
||||
if (!newPwd.matches("^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])[a-zA-Z0-9]{8,16}$")) {
|
||||
@@ -1255,9 +1259,9 @@ public class SysUserService extends MybatisBaseService<SysUserMapper, SysUser> {
|
||||
* @Author: dimengzhe
|
||||
* @Date: 2021/10/12 11:29
|
||||
*/
|
||||
// public WxHomePageVo selectHomePage(String userSid) {
|
||||
// return baseMapper.selectHomePage(userSid);
|
||||
// }
|
||||
public WxHomePageVo selectHomePage(String userSid) {
|
||||
return baseMapper.selectHomePage(userSid);
|
||||
}
|
||||
|
||||
public int delSysUserByMobile(String mobile) {
|
||||
return baseMapper.delSysUserByMobile(mobile);
|
||||
|
||||
@@ -1,18 +1,23 @@
|
||||
package com.yxt.portal.biz.sysuser;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.yxt.common.core.vo.Vo;
|
||||
import com.yxt.portal.biz.sysorganization.SysOrganization;
|
||||
import com.yxt.portal.biz.sysorganization.SysOrganizationVo;
|
||||
import com.yxt.portal.biz.sysrole.SysRole;
|
||||
import com.yxt.portal.biz.sysrole.SysRoleVo;
|
||||
import com.yxt.portal.biz.sysstafforg.SysStaffOrgVo;
|
||||
import com.yxt.portal.biz.sysuser.app.OrgList;
|
||||
import com.yxt.portal.biz.sysuserrole.SysUserRoleVo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -102,4 +107,7 @@ public class SysUserVo implements Vo {
|
||||
List<SysStaffOrgVo> sysOrganizationVos;
|
||||
private String orgSid;
|
||||
private String orgName;
|
||||
private List<SysUserRoleVo> sysRoleVos;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@ public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
|
||||
void delByUserSidAndRoleSid(@Param("userSid") String userSid,@Param("roleSid") String roleSid);
|
||||
|
||||
List<SysUserRoleVo> selectByUserSid(@Param("userSid")String userSid,@Param("orgSid")String orgSid,@Param("sourceSid")String sourceSid);
|
||||
List<SysUserRoleVo> selByUserSid(@Param("userSid")String userSid);
|
||||
|
||||
|
||||
@Select("SELECT roleSid FROM sys_user_role WHERE userSid=#{userSid}")
|
||||
List<String> getUserRoleSidByUserSid(@Param("userSid")String userSid);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
SELECT * FROM sys_user_role <where> ${ew.sqlSegment} </where>
|
||||
</select>
|
||||
<select id="selectByUserSid" resultType="com.yxt.portal.biz.sysuserrole.SysUserRoleVo">
|
||||
SELECT a.*
|
||||
SELECT a.*,b.name as roleName
|
||||
FROM sys_user_role a
|
||||
left join sys_role b on b.sid =a.roleSid
|
||||
left join sys_role_authorize c ON c.roleSid = b.sid
|
||||
@@ -23,6 +23,13 @@
|
||||
and c.sourceSid =#{sourceSid}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selByUserSid" resultType="com.yxt.portal.biz.sysuserrole.SysUserRoleVo">
|
||||
SELECT a.*,b.name as roleName
|
||||
FROM sys_user_role a
|
||||
left join sys_role b on b.sid =a.roleSid
|
||||
WHERE a.userSid = #{userSid}
|
||||
</select>
|
||||
|
||||
<delete id="deleteByUserSid">
|
||||
delete from sys_user_role where userSid=#{params}
|
||||
</delete>
|
||||
|
||||
@@ -99,6 +99,9 @@ public class SysUserRoleService extends MybatisBaseService<SysUserRoleMapper, Sy
|
||||
public List<SysUserRoleVo> selectByUserSid(String userSid,String orgSid,String sourceSid) {
|
||||
return baseMapper.selectByUserSid(userSid,orgSid,sourceSid);
|
||||
}
|
||||
public List<SysUserRoleVo> selByUserSid(String userSid) {
|
||||
return baseMapper.selByUserSid(userSid);
|
||||
}
|
||||
/*public void updateUserRole(SysUserRoleDto dto) {
|
||||
//sysUserRoleService.deleteByUserSid(dto.getUserSid());
|
||||
SysUserRole entity = new SysUserRole();
|
||||
|
||||
@@ -29,4 +29,5 @@ public class SysUserRoleVo implements Vo {
|
||||
|
||||
@ApiModelProperty("角色sid")
|
||||
private String roleSid;
|
||||
private String roleName;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user