Commit 9f473ac6 by 墨竹

fix:登录修改

parent 6af2cb73
......@@ -76,6 +76,11 @@ public class StaffPrivacyUseLogDTO implements Serializable {
*/
private Date updateTime;
private String wxUserId;
/**
* 第三方用户id
*/
private String wxOpenUseId;
public Long getId() {
return id;
}
......@@ -179,4 +184,20 @@ public class StaffPrivacyUseLogDTO implements Serializable {
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getWxUserId() {
return wxUserId;
}
public void setWxUserId(String wxUserId) {
this.wxUserId = wxUserId;
}
public String getWxOpenUseId() {
return wxOpenUseId;
}
public void setWxOpenUseId(String wxOpenUseId) {
this.wxOpenUseId = wxOpenUseId;
}
}
......@@ -203,11 +203,12 @@ public interface WxEnterpriseApiService {
void agreeExternalUseridFlag(String wxEnterpriseId, Integer openFlag);
/**
* 好办登录
* 好办登录-插入隐私协议
*
* @param staffLoginDTO 员工登录dto
* @param staffPrivacyUseLogDTO 员工隐私使用日志dto
* @author mozhu
* @date 2021-12-15 11:02:52
* @date 2022-04-15 15:03:14
*/
void wellDoneLogin(StaffLoginDTO staffLoginDTO);
void wellDoneLoginAddPrivacy(StaffPrivacyUseLogDTO staffPrivacyUseLogDTO);
}
......@@ -75,6 +75,7 @@ public class TabStaffPrivacyUseLog implements Serializable {
* update_time
*/
private Date updateTime;
private String wxOpenUseId;
public Long getId() {
return id;
......@@ -179,4 +180,12 @@ public class TabStaffPrivacyUseLog implements Serializable {
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getWxOpenUseId() {
return wxOpenUseId;
}
public void setWxOpenUseId(String wxOpenUseId) {
this.wxOpenUseId = wxOpenUseId;
}
}
......@@ -75,6 +75,8 @@ public class StaffPrivacyUseLogBO implements Serializable {
*/
private Date updateTime;
private String wxOpenUseId;
public Long getId() {
return id;
}
......@@ -178,4 +180,12 @@ public class StaffPrivacyUseLogBO implements Serializable {
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getWxOpenUseId() {
return wxOpenUseId;
}
public void setWxOpenUseId(String wxOpenUseId) {
this.wxOpenUseId = wxOpenUseId;
}
}
......@@ -123,7 +123,7 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
secretSetting.setSecretVal(permanentCode);
secretSettingService.saveSecretSetting(secretSetting);
}
agreeExternalUseridFlag(wxEnterpriseId,1);
agreeExternalUseridFlag(wxEnterpriseId, 1);
log.info("企业微信授权处理完成");
}
......@@ -351,13 +351,21 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
}
@Override
public void wellDoneLogin(StaffLoginDTO staffLoginDTO) {
public void wellDoneLoginAddPrivacy(StaffPrivacyUseLogDTO staffPrivacyUseLogDTO) {
//插入隐私协议
StaffPrivacyUseLogBO staffPrivacyUseLogBO = new StaffPrivacyUseLogBO();
BeanUtils.copyProperties(staffLoginDTO, staffPrivacyUseLogBO);
StaffPrivacyUseLogBO privacyUseLog = staffPrivacyUseLogService.getByStaffId(staffLoginDTO.getStaffId());
BeanUtils.copyProperties(staffPrivacyUseLogDTO, staffPrivacyUseLogBO);
String staffId = staffPrivacyUseLogDTO.getStaffId();
if (StringUtils.isNotBlank(staffId)) {
StaffPrivacyUseLogBO privacyUseLog = staffPrivacyUseLogService.getByStaffId(staffId);
if (privacyUseLog == null) {
staffPrivacyUseLogService.insert(staffPrivacyUseLogBO);
}
} else {
StaffPrivacyUseLogBO privacyUseLogBO = staffPrivacyUseLogService.getByUserId(staffPrivacyUseLogDTO.getWxOpenUseId());
if (privacyUseLogBO == null) {
staffPrivacyUseLogService.insert(staffPrivacyUseLogBO);
}
}
}
}
......@@ -17,6 +17,7 @@
<result column="staff_ip" property="staffIp"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="wx_open_user_id" property="wxOpenUseId"/>
</resultMap>
<sql id="Base_Column_List">
......@@ -32,7 +33,8 @@
staff_phone_version,
staff_ip,
create_time,
update_time
update_time,
wx_open_user_id
</sql>
<insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="id"
......@@ -42,6 +44,9 @@
<if test="null != staffId and '' != staffId">
staff_id,
</if>
<if test="null != wxOpenUseId">
wx_open_user_id
</if>
<if test="null != wxEnterpriseId and '' != wxEnterpriseId">
wx_enterprise_id,
</if>
......@@ -80,6 +85,9 @@
<if test="null != staffId and '' != staffId">
#{staffId},
</if>
<if test="null != wxOpenUseId">
#{wxOpenUseId},
</if>
<if test="null != wxEnterpriseId and '' != wxEnterpriseId">
#{wxEnterpriseId},
</if>
......@@ -119,20 +127,45 @@
<update id="update" parameterType="com.gic.haoban.manage.service.entity.TabStaffPrivacyUseLog">
UPDATE tab_staff_privacy_use_log
<set>
<if test="null != staffId and '' != staffId">staff_id = #{staffId},</if>
<if test="null != wxEnterpriseId and '' != wxEnterpriseId">wx_enterprise_id = #{wxEnterpriseId},</if>
<if test="null != privacyUseFlag">privacy_use_flag = #{privacyUseFlag},</if>
<if test="null != phoneNumber and '' != phoneNumber">phone_number = #{phoneNumber},</if>
<if test="null != welldoneVersion and '' != welldoneVersion">welldone_version = #{welldoneVersion},</if>
<if test="null != weworkVersion and '' != weworkVersion">wework_version = #{weworkVersion},</if>
<if test="null != staffPhoneBrand and '' != staffPhoneBrand">staff_phone_brand = #{staffPhoneBrand},</if>
<if test="null != staffPhoneModel and '' != staffPhoneModel">staff_phone_model = #{staffPhoneModel},</if>
<if test="null != staffPhoneVersion and '' != staffPhoneVersion">staff_phone_version =
#{staffPhoneVersion},
<if test="null != staffId and '' != staffId">
staff_id = #{staffId},
</if>
<if test="null != wxOpenUseId">
wx_open_user_id = #{wxOpenUseId},
</if>
<if test="null != wxEnterpriseId and '' != wxEnterpriseId">
wx_enterprise_id = #{wxEnterpriseId},
</if>
<if test="null != privacyUseFlag">
privacy_use_flag = #{privacyUseFlag},
</if>
<if test="null != phoneNumber and '' != phoneNumber">
phone_number = #{phoneNumber},
</if>
<if test="null != welldoneVersion and '' != welldoneVersion">
welldone_version = #{welldoneVersion},
</if>
<if test="null != weworkVersion and '' != weworkVersion">
wework_version = #{weworkVersion},
</if>
<if test="null != staffPhoneBrand and '' != staffPhoneBrand">
staff_phone_brand = #{staffPhoneBrand},
</if>
<if test="null != staffPhoneModel and '' != staffPhoneModel">
staff_phone_model = #{staffPhoneModel},
</if>
<if test="null != staffPhoneVersion and '' != staffPhoneVersion">
staff_phone_version = #{staffPhoneVersion},
</if>
<if test="null != staffIp and '' != staffIp">
staff_ip = #{staffIp},
</if>
<if test="null != createTime">
create_time = #{createTime},
</if>
<if test="null != updateTime">
update_time = #{updateTime}
</if>
<if test="null != staffIp and '' != staffIp">staff_ip = #{staffIp},</if>
<if test="null != createTime">create_time = #{createTime},</if>
<if test="null != updateTime">update_time = #{updateTime}</if>
</set>
WHERE id = #{id}
</update>
......
......@@ -195,6 +195,63 @@ public class WxEnterpriseInfoController extends WebBaseController {
@IgnoreLogin
public RestResponse<String> welldoneLogin(@RequestBody @Valid StaffLoginQO staffLoginQO, HttpServletRequest request) {
String staffId = staffLoginQO.getStaffId();
String wxOpenUseId = staffLoginQO.getWxOpenUseId();
//-1 代表游客登录
if ("-1".equals(staffId)) {
return wellDoneLoginPrivacy(staffLoginQO, request, staffId, wxOpenUseId);
}
//用户登录
return wellDoneLogin(staffLoginQO, request, staffId);
}
/**
* 游客登录
* @param staffLoginQO
* @param request
* @param staffId
* @param wxOpenUseId
* @return
*/
private RestResponse<String> wellDoneLoginPrivacy(StaffLoginQO staffLoginQO, HttpServletRequest request, String staffId, String wxOpenUseId) {
logger.info("游客登录,wxOpenUseId:{}", wxOpenUseId);
//登录和刷新token兼容
String headerToken = AuthRequestWellDoneUtil.getHeaderToken();
if (StringUtils.isNotBlank(headerToken)) {
return getRefreshToken();
}
Map<String, String> map = new HashMap<>();
map.put("staffId", "-1");
map.put("wxOpenUseId", wxOpenUseId);
String token = JwtUtil.genToken(map);
AuthRequestWellDoneUtil.setAppLoginUser(staffId, token);
StaffPrivacyUseLogDTO privacyUseLogDTO = new StaffPrivacyUseLogDTO();
BeanUtils.copyProperties(staffLoginQO, privacyUseLogDTO);
privacyUseLogDTO.setStaffIp(IPAddressUtil.getIpAddress(request));
wxEnterpriseApiService.wellDoneLoginAddPrivacy(privacyUseLogDTO);
return RestResponse.successResult(token);
}
/**
* 刷新token
* @return
*/
private RestResponse<String> getRefreshToken() {
String refreshToken = AuthRequestWellDoneUtil.refreshToken();
if (StringUtils.isBlank(refreshToken)) {
return RestResponse.failure(String.valueOf(HaoBanErrCode.ERR_30010.getCode()), HaoBanErrCode.ERR_30010.getMsg());
}
return RestResponse.successResult(refreshToken);
}
/**
* 用户登录
* @param staffLoginQO
* @param request
* @param staffId
* @return
*/
private RestResponse<String> wellDoneLogin(StaffLoginQO staffLoginQO, HttpServletRequest request, String staffId) {
// 正常登录
String loginPhoneNumber = staffLoginQO.getPhoneNumber();
logger.info("好办登录,staffId:{},loginPhoneNumber:{}", staffId, loginPhoneNumber);
StaffDTO staffDTO = staffApiService.selectById(staffId);
......@@ -209,11 +266,7 @@ public class WxEnterpriseInfoController extends WebBaseController {
//登录和刷新token兼容
String headerToken = AuthRequestWellDoneUtil.getHeaderToken();
if (StringUtils.isNotBlank(headerToken)) {
String refreshToken = AuthRequestWellDoneUtil.refreshToken();
if (StringUtils.isBlank(refreshToken)) {
return RestResponse.failure(String.valueOf(HaoBanErrCode.ERR_30010.getCode()), HaoBanErrCode.ERR_30010.getMsg());
}
return RestResponse.successResult(refreshToken);
return getRefreshToken();
}
Map<String, String> map = new HashMap<>();
map.put("staffId", staffId);
......@@ -221,13 +274,13 @@ public class WxEnterpriseInfoController extends WebBaseController {
map.put("phoneNumber", phoneNumber);
String token = JwtUtil.genToken(map);
AuthRequestWellDoneUtil.setAppLoginUser(staffId, token);
StaffLoginDTO staffLoginDTO = new StaffLoginDTO();
BeanUtils.copyProperties(staffLoginQO, staffLoginDTO);
staffLoginDTO.setStaffIp(IPAddressUtil.getIpAddress(request));
staffDTO.setWxEnterpriseId(staffDTO.getWxEnterpriseId());
staffDTO.setPhoneNumber(phoneNumber);
staffDTO.setWxUserId(staffDTO.getWxUserId());
wxEnterpriseApiService.wellDoneLogin(staffLoginDTO);
StaffPrivacyUseLogDTO privacyUseLogDTO = new StaffPrivacyUseLogDTO();
BeanUtils.copyProperties(staffLoginQO, privacyUseLogDTO);
privacyUseLogDTO.setStaffIp(IPAddressUtil.getIpAddress(request));
privacyUseLogDTO.setWxEnterpriseId(staffDTO.getWxEnterpriseId());
privacyUseLogDTO.setPhoneNumber(phoneNumber);
privacyUseLogDTO.setWxUserId(staffDTO.getWxUserId());
wxEnterpriseApiService.wellDoneLoginAddPrivacy(privacyUseLogDTO);
return RestResponse.successResult(token);
}
......@@ -239,12 +292,8 @@ public class WxEnterpriseInfoController extends WebBaseController {
* @date 2021-12-10 18:34:12
*/
@RequestMapping(value = "welldone-token-refresh", method = RequestMethod.GET)
public HaobanResponse welldoneTokenRefresh() {
String token = AuthRequestWellDoneUtil.refreshToken();
if (StringUtils.isBlank(token)) {
return resultResponse(HaoBanErrCode.ERR_30010);
}
return resultResponse(HaoBanErrCode.ERR_1, token);
public RestResponse<String> welldoneTokenRefresh() {
return getRefreshToken();
}
/**
......@@ -253,9 +302,9 @@ public class WxEnterpriseInfoController extends WebBaseController {
* @return
*/
@RequestMapping(value = "welldone-loginout", method = RequestMethod.GET)
public HaobanResponse welldoneLoginOut() {
public RestResponse welldoneLoginOut() {
AuthRequestWellDoneUtil.delToken();
return resultResponse(HaoBanErrCode.ERR_1);
return RestResponse.successResult();
}
/**
......
......@@ -51,6 +51,8 @@ public class StaffLoginQO implements Serializable {
* 用户手机版本
*/
private String staffPhoneVersion;
@NotEmpty(message = "用户id不允许为空")
private String wxOpenUseId;
public String getStaffId() {
return staffId;
......@@ -139,4 +141,12 @@ public class StaffLoginQO implements Serializable {
public void setStaffPhoneVersion(String staffPhoneVersion) {
this.staffPhoneVersion = staffPhoneVersion;
}
public String getWxOpenUseId() {
return wxOpenUseId;
}
public void setWxOpenUseId(String wxOpenUseId) {
this.wxOpenUseId = wxOpenUseId;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment