Merge branch 'cc_20250529_login' into 'master'
Cc 20250529 login See merge request hangzhou/java/custom_zxjp!107
This commit is contained in:
@@ -259,7 +259,10 @@ public enum ErrorCodeEnum {
|
||||
EXPORT_LIMIT_5000(151008,"导出数据不能超过5000条,请增加筛选条件,减少导出数量",null),
|
||||
REGION_INTERSECTION_IS_NULL(151011,"所选所属大区/分公司,不在所选集团下",null),
|
||||
CHECK_PAYER_ERROR(151012,"缴费人必须是签约人,请重新填写!",null),
|
||||
SHOP_HAVE_NOT_OVER_ACCORDING(1511014,"该加盟商下有未结束跟进的门店,请先结束门店",null)
|
||||
STORE_INFO_INSUFFICIENT(151013,"门店信息不全,无法前往猎聘注册门店!",null),
|
||||
USER_ACCOUNT_WAIT_AUDIT(151015, "账号信息等待审核",null),
|
||||
SHOP_HAVE_NOT_OVER_ACCORDING(1511014,"该加盟商下有未结束跟进的门店,请先结束门店",null),
|
||||
MOBILE_NOT_EXIST(151016,"手机号不存在,请先维护手机号!",null),
|
||||
;
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,12 @@
|
||||
<result column="user_status" jdbcType="TINYINT" property="userStatus"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="third_oa_unique_flag" jdbcType="VARCHAR" property="thirdOaUniqueFlag"/>
|
||||
<result column="departments" jdbcType="VARCHAR" property="departments"/>
|
||||
<result column="roles" jdbcType="VARCHAR" property="roles"/>
|
||||
<result column="language" jdbcType="VARCHAR" property="language"/>
|
||||
<result column="position" jdbcType="VARCHAR" property="position"/>
|
||||
<result column="active" jdbcType="BIT" property="active"/>
|
||||
<result column="userType" jdbcType="BIT" property="userType"/>
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.cool.store.entity.EnterpriseUserDO">
|
||||
<result column="user_region_ids" jdbcType="LONGVARCHAR" property="userRegionIds"/>
|
||||
@@ -134,7 +140,7 @@
|
||||
</select>
|
||||
|
||||
<select id="selectByMobile" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/> FROM enterprise_user_${enterpriseId} WHERE mobile =#{mobile} and active = true LIMIT 1
|
||||
SELECT * FROM enterprise_user_${enterpriseId} WHERE mobile =#{mobile} and active = true LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectByInvestmentManager" resultMap="BaseResultMap">
|
||||
|
||||
@@ -72,4 +72,19 @@ public class EnterpriseUserDO implements Serializable {
|
||||
* 第三方OA系统唯一标识
|
||||
*/
|
||||
private String thirdOaUniqueFlag;
|
||||
|
||||
/**
|
||||
* 部门全路径
|
||||
*/
|
||||
private String departments;
|
||||
|
||||
private String roles;
|
||||
|
||||
private String language;
|
||||
|
||||
private Boolean active;
|
||||
|
||||
private String position;
|
||||
|
||||
private Integer userType;
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package com.cool.store.userholder;
|
||||
|
||||
import com.cool.store.entity.SysRoleDO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
* @Date 2025/5/29 16:34
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Data
|
||||
public class CurrentUser {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private String id;
|
||||
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 电话号码
|
||||
*/
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 账号
|
||||
* 当type为以下值的时候
|
||||
* 0.account
|
||||
* 1.account
|
||||
* 2.userId
|
||||
* 3.userId
|
||||
* 4.account
|
||||
*/
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 电子邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
private String typeStr;
|
||||
|
||||
/**
|
||||
* 培训机构id
|
||||
*/
|
||||
private Long supplierId;
|
||||
|
||||
private String enterpriseId;
|
||||
|
||||
private String enterpriseName;
|
||||
|
||||
private String logoName;
|
||||
|
||||
private String enterpriseLogo;
|
||||
|
||||
private String dingCorpId;
|
||||
/**
|
||||
* 企业类型(1:普通用户 2:付费用户 3:试用用户 4:共创用户)
|
||||
*/
|
||||
private Integer isVip;
|
||||
|
||||
/**
|
||||
* 开通时间
|
||||
*/
|
||||
private Date openTime;
|
||||
|
||||
/**
|
||||
* app类型('micro_app','e_app')
|
||||
*/
|
||||
private String appType;
|
||||
|
||||
/**
|
||||
* 需要配置的类型
|
||||
*/
|
||||
private List<String> configTypes;
|
||||
|
||||
private String accessToken;
|
||||
|
||||
/**
|
||||
* 职位信息
|
||||
*/
|
||||
private String position;
|
||||
|
||||
/**
|
||||
* 成员所属部门id列表
|
||||
*/
|
||||
private String departmentIds;
|
||||
|
||||
/**
|
||||
* 是否持久化
|
||||
*/
|
||||
private Boolean persistent = false;
|
||||
|
||||
/**
|
||||
* 员工工号
|
||||
*/
|
||||
private String jobnumber;
|
||||
|
||||
private Boolean active;
|
||||
/**
|
||||
* 员工角色
|
||||
*/
|
||||
private String roles;
|
||||
|
||||
private String unionid;
|
||||
|
||||
/**
|
||||
* 用户语言环境
|
||||
* 用户语言环境:en_us/英语_美国,zh_cn/中文_简体,zh_hk/中文_繁体_HK
|
||||
*/
|
||||
private String language;
|
||||
|
||||
private String dbName;
|
||||
|
||||
/**
|
||||
* 钉钉管理员和数智门店无关
|
||||
*/
|
||||
private Boolean isAdmin;
|
||||
|
||||
private String agentId;
|
||||
|
||||
private String groupCorpId;
|
||||
|
||||
/**
|
||||
* 角色权限
|
||||
*/
|
||||
private String roleAuth;
|
||||
|
||||
private String mainCorpId;
|
||||
|
||||
/**
|
||||
* 用户最高优先级角色
|
||||
*/
|
||||
private SysRoleDO sysRoleDO;
|
||||
|
||||
/**
|
||||
* 授权类型
|
||||
*/
|
||||
private Integer licenseType;
|
||||
|
||||
private Integer userType;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
* @Date 2025/5/29 16:34
|
||||
* @Version 1.0
|
||||
*/
|
||||
public interface EnterpriseService {
|
||||
|
||||
|
||||
/**
|
||||
* 通过手机号获取登录token
|
||||
* @param mobile
|
||||
* @return
|
||||
*/
|
||||
String getAccessToken(String mobile);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.cool.store.constants.RedisConstant;
|
||||
import com.cool.store.dao.EnterpriseUserDAO;
|
||||
import com.cool.store.entity.EnterpriseUserDO;
|
||||
import com.cool.store.entity.SysRoleDO;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.enums.Role;
|
||||
import com.cool.store.enums.UserStatusEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.mapper.SysRoleMapper;
|
||||
import com.cool.store.service.EnterpriseService;
|
||||
import com.cool.store.userholder.CurrentUser;
|
||||
import com.cool.store.utils.RedisUtilPool;
|
||||
import com.cool.store.utils.poi.DateUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.crypto.RandomNumberGenerator;
|
||||
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
* @Date 2025/5/29 16:34
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class EnterpriseServiceImpl implements EnterpriseService {
|
||||
|
||||
@Resource
|
||||
EnterpriseUserDAO enterpriseUserDAO;
|
||||
|
||||
@Resource
|
||||
SysRoleMapper sysRoleMapper;
|
||||
|
||||
@Resource
|
||||
RedisUtilPool redisUtilPool;
|
||||
|
||||
@Value("${mybatis.configuration.variables.enterpriseId}")
|
||||
private String eid;
|
||||
|
||||
@Override
|
||||
public String getAccessToken(String mobile) {
|
||||
CurrentUser currentUser = new CurrentUser();
|
||||
EnterpriseUserDO enterpriseUser = enterpriseUserDAO.selectByMobile(mobile);
|
||||
if (Objects.isNull(enterpriseUser)){
|
||||
throw new ServiceException(ErrorCodeEnum.MOBILE_NOT_EXIST);
|
||||
}
|
||||
if(UserStatusEnum.WAIT_AUDIT.getCode().equals(enterpriseUser.getUserStatus())){
|
||||
throw new ServiceException(ErrorCodeEnum.USER_ACCOUNT_WAIT_AUDIT);
|
||||
}
|
||||
//账号冻结
|
||||
if(UserStatusEnum.FREEZE.getCode().equals(enterpriseUser.getUserStatus())){
|
||||
throw new ServiceException(ErrorCodeEnum.USER_FREEZE);
|
||||
}
|
||||
SysRoleDO sysRoleDoByUserId = sysRoleMapper.getHighestPrioritySysRoleDoByUserId(enterpriseUser.getUserId());
|
||||
if(sysRoleDoByUserId==null){
|
||||
// 如果没有最高优先级的,给未分配的角色
|
||||
sysRoleDoByUserId = sysRoleMapper.getRoleByRoleEnum(Role.EMPLOYEE.getRoleEnum());
|
||||
}
|
||||
currentUser.setId(enterpriseUser.getId());
|
||||
currentUser.setUserId(enterpriseUser.getUserId());
|
||||
currentUser.setAccount(enterpriseUser.getUserId());
|
||||
currentUser.setDbName("coolcollege_intelligent_10027");
|
||||
currentUser.setDepartmentIds(enterpriseUser.getDepartments());
|
||||
currentUser.setRoles(enterpriseUser.getRoles());
|
||||
currentUser.setLanguage(enterpriseUser.getLanguage());
|
||||
currentUser.setIsAdmin(enterpriseUser.getIsAdmin());
|
||||
|
||||
//设置当前登录人使用的企业相关信息
|
||||
currentUser.setRoleAuth(sysRoleDoByUserId.getRoleAuth());
|
||||
currentUser.setSysRoleDO(sysRoleDoByUserId);
|
||||
currentUser.setEnterpriseId(eid);
|
||||
currentUser.setEnterpriseName("正新集团");
|
||||
currentUser.setEnterpriseLogo("https://oss-store.coolcollege.cn/eid/214ac5a3a517472a87268e02a2e6410a/2405/79049713395952825.jpg");
|
||||
currentUser.setActive(enterpriseUser.getActive());
|
||||
// 企业开通时间
|
||||
try {
|
||||
currentUser.setOpenTime(DateUtils.parseDate("2024-05-09 18:54:28",DateUtils.YYYY_MM_DD_HH_MM_SS));
|
||||
} catch (ParseException e) {
|
||||
log.error("时间转换异常");
|
||||
}
|
||||
currentUser.setAvatar(enterpriseUser.getAvatar());
|
||||
currentUser.setEmail(enterpriseUser.getEmail());
|
||||
// 水印增加员工工号
|
||||
if (StringUtils.isNotEmpty(enterpriseUser.getJobnumber())) {
|
||||
currentUser.setJobnumber(enterpriseUser.getJobnumber());
|
||||
}
|
||||
// 水印增加员工职位
|
||||
if (StringUtils.isNotEmpty(enterpriseUser.getPosition())) {
|
||||
currentUser.setPosition(enterpriseUser.getPosition());
|
||||
}
|
||||
currentUser.setMobile(enterpriseUser.getMobile());
|
||||
currentUser.setName(enterpriseUser.getName());
|
||||
|
||||
currentUser.setDingCorpId("wpayJeDAAAklx_q1jGhyGUd4yEh8vV_g");
|
||||
|
||||
currentUser.setAccessToken(getToken());
|
||||
currentUser.setAppType("qw_self_dkf");
|
||||
currentUser.setUnionid(enterpriseUser.getUnionid());
|
||||
currentUser.setUserType(enterpriseUser.getUserType());
|
||||
redisUtilPool.setString(RedisConstant.ACCESS_TOKEN_PREFIX + currentUser.getAccessToken(), JSON.toJSONString(currentUser), 24 * 60 * 60);
|
||||
return currentUser.getAccessToken();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
System.out.println(DateUtils.parseDate("2024-05-09 18:54:28",DateUtils.YYYY_MM_DD_HH_MM_SS));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
RandomNumberGenerator randomNumberGenerator = new SecureRandomNumberGenerator();
|
||||
return randomNumberGenerator.nextBytes().toHex();
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.cool.store.controller.webc;
|
||||
|
||||
import com.cool.store.context.PartnerUserHolder;
|
||||
import com.cool.store.dto.FoodTokenDTO;
|
||||
import com.cool.store.dto.GetAccessTokenDTO;
|
||||
import com.cool.store.dto.ModifyPasswordDTO;
|
||||
import com.cool.store.dto.ShopAccount.ShopAccountDTO;
|
||||
import com.cool.store.request.GetPasswordDTO;
|
||||
import com.cool.store.response.ResponseResult;
|
||||
import com.cool.store.service.PushService;
|
||||
import com.cool.store.service.ShopAccountService;
|
||||
import com.cool.store.service.ThirdFoodService;
|
||||
import com.cool.store.service.ThirdXinGuanJiaService;
|
||||
import com.cool.store.service.*;
|
||||
import com.cool.store.vo.PartnerUserInfoVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -40,6 +39,8 @@ public class MiniShopAccountController {
|
||||
|
||||
@Resource
|
||||
ThirdFoodService thirdFoodService;
|
||||
@Resource
|
||||
EnterpriseService enterpriseService;
|
||||
|
||||
|
||||
@ApiOperation("根据门店shopId查询平台账号")
|
||||
@@ -91,4 +92,10 @@ public class MiniShopAccountController {
|
||||
return ResponseResult.success(accountService.shopIdToYlsCode(shopId));
|
||||
}
|
||||
|
||||
@ApiOperation("获取标品登录token")
|
||||
@GetMapping("/getAccessToken")
|
||||
public ResponseResult<String> getAccessToken() {
|
||||
return ResponseResult.success(enterpriseService.getAccessToken(PartnerUserHolder.getUser().getMobile()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user