南网oss登录接口修改
This commit is contained in:
parent
2ff85222c6
commit
13c82563b2
|
|
@ -3,17 +3,19 @@ package com.bonus.sgzb.auth.controller;
|
|||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.bonus.sgzb.auth.form.AuthenticationLoginFrom;
|
||||
import com.bonus.sgzb.auth.form.*;
|
||||
import com.bonus.sgzb.auth.service.NwRegisterService;
|
||||
import com.bonus.sgzb.auth.service.NwUserLoginService;
|
||||
import com.bonus.sgzb.common.core.constant.CacheConstants;
|
||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.sgzb.common.redis.service.RedisService;
|
||||
import com.bonus.sgzb.common.security.annotation.RequiresPermissions;
|
||||
import com.bonus.sgzb.system.api.RemoteUserService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.java.Log;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.bonus.sgzb.auth.form.LoginBody;
|
||||
import com.bonus.sgzb.auth.form.RegisterBody;
|
||||
import com.bonus.sgzb.auth.service.SysLoginService;
|
||||
import com.bonus.sgzb.common.core.domain.R;
|
||||
import com.bonus.sgzb.common.core.utils.JwtUtils;
|
||||
|
|
@ -48,6 +50,9 @@ public class TokenController {
|
|||
@Resource
|
||||
private NwUserLoginService nwUserLoginService;
|
||||
|
||||
@Autowired
|
||||
private NwRegisterService registerService;
|
||||
|
||||
//web端登录
|
||||
@PostMapping("login")
|
||||
public R<?> login(@RequestBody LoginBody form) {
|
||||
|
|
@ -134,4 +139,16 @@ public class TokenController {
|
|||
return R.fail("微服务平台认证失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("南网注册")
|
||||
@PostMapping("/registers")
|
||||
public AjaxResult addNw(HttpServletRequest request, @RequestBody RegisterForms registerForms) {
|
||||
AccountRegister accountRegister = new AccountRegister();
|
||||
accountRegister.setCode(1);
|
||||
accountRegister.setDesc("个人用户注册");
|
||||
accountRegister.setRemark("个人用户注册");
|
||||
registerForms.setIsPersonal(accountRegister.getCode());
|
||||
return AjaxResult.success("success", registerService.registersNew(request, registerForms));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
package com.bonus.sgzb.auth.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 账号类型
|
||||
*
|
||||
* @author zhangshuwei
|
||||
* @create 2019-05-17 16:56
|
||||
**/
|
||||
@Getter
|
||||
public enum AccountTypeEnum {
|
||||
ALl(0,"全部"),
|
||||
PLATFORM(1,"运营方"),
|
||||
PURCHASE(2,"承租方"),
|
||||
SUPPLIER(3, "出租方"),
|
||||
RESUPPLIER(4,"转售商"),
|
||||
PERSONAL(5, "个人"),
|
||||
ENTERPRISE(6, "企业"),
|
||||
BUYER_SELLER(7, "承租方和出租方")
|
||||
;
|
||||
|
||||
private Integer code;
|
||||
private String desc;
|
||||
|
||||
AccountTypeEnum(Integer code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public static String getView(Integer code) {
|
||||
for (AccountTypeEnum enums : AccountTypeEnum.values()) {
|
||||
if (null != code && enums.code.equals(code)) {
|
||||
return enums.getDesc();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据枚举名 转换为枚举类
|
||||
*
|
||||
* @param code 枚举名
|
||||
* @return
|
||||
*/
|
||||
public static AccountTypeEnum toEnum(Integer code) {
|
||||
for (AccountTypeEnum value : AccountTypeEnum.values()) {
|
||||
if (code.equals(value.getCode())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package com.bonus.sgzb.auth.form;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 注册类型枚举
|
||||
*
|
||||
* @author xncuiyongan
|
||||
* @date 2021-06-08 15:05 2021-06-08 15:05
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class AccountRegister {
|
||||
|
||||
/**
|
||||
* 注册类型code
|
||||
*/
|
||||
private Integer code;
|
||||
/**
|
||||
* 注册类型desc
|
||||
*/
|
||||
private String desc;
|
||||
|
||||
/**
|
||||
* 注册类型备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.bonus.sgzb.auth.form;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 南网集成平台验证类型
|
||||
*
|
||||
* @author ext.huangqiupeng
|
||||
* @date 2021/9/3
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class NwApp {
|
||||
|
||||
/* PC(1, NwLoginConstants.appId, NwLoginConstants.appsecret),
|
||||
H5(2, NwLoginConstants.h5AppId, NwLoginConstants.h5Appsecret),
|
||||
WECHAT(3, NwLoginConstants.wechatAppId, NwLoginConstants.wechatAppsecret),
|
||||
APP(4, NwLoginConstants.appAppId, NwLoginConstants.appAppsecret)
|
||||
;*/
|
||||
|
||||
private Integer code;
|
||||
private String appId;
|
||||
private String appsecret;
|
||||
|
||||
}
|
||||
|
|
@ -32,6 +32,33 @@ public class NwLoginConstants {
|
|||
public static final int LOGIN_ERROR_CODE = 501;
|
||||
public static final String LOGIN_ERROR_MESSAGE = "该用户不存在,请先注册";
|
||||
|
||||
public static final String LOGIN_TYPE_EXCEPTION_CODE = "500";
|
||||
|
||||
public static final String LOGIN_TYPE_EXCEPTION_MSG = "登录类型错误";
|
||||
|
||||
public static final String IP_NULL_CODE = "33-005";
|
||||
|
||||
public static final String IP_NULL_MSG = "IP地址为空";
|
||||
|
||||
public static final String PARAM_IS_NULL_ERROR_CODE = "0-0001";
|
||||
|
||||
public static final String PARAM_IS_NULL_ERROR_CODE_MSG = "参数为空:%s";
|
||||
|
||||
public static final String PHONE_NOT_NULL_CODE = "33-009";
|
||||
public static final String PHONE_NOT_NULL_MSG = "请输入手机号";
|
||||
|
||||
public static final String MOBILE_FORMAT_ERROR_CODE = "33-001";
|
||||
public static final String MOBILE_FORMAT_ERROR_CODE_MSG = "手机号格式不正确";
|
||||
|
||||
public static final String USER_NAME_NOT_NULL_CODE = "33-015";
|
||||
public static final String USER_NAME_NOT_NULL_MSG = "用户名称不能为空";
|
||||
|
||||
public static final String PASSWORD_NOT_NULL_CODE = "33-017";
|
||||
public static final String PASSWORD_NOT_NULL_MSG = "密码不能为空";
|
||||
|
||||
public static final String AGAIN_PASSWORD_NOT_NULL_CODE = "33-018";
|
||||
public static final String AGAIN_PASSWORD_NOT_NULL_MSG = "确认密码不能为空";
|
||||
public static final Long PLATFORM_ID = 20L;
|
||||
/**
|
||||
* 授权范围
|
||||
*/
|
||||
|
|
@ -53,6 +80,50 @@ public class NwLoginConstants {
|
|||
public static String baseUrl;
|
||||
public static String wechatAppsecret;
|
||||
|
||||
public static String appAppsecret;
|
||||
|
||||
@Value("${appAppsecret}")
|
||||
public void setAppAppsecret(String appAppsecret) {
|
||||
NwLoginConstants.appAppsecret = appAppsecret;
|
||||
}
|
||||
|
||||
public static String appsecret;
|
||||
|
||||
public static String h5Appsecret;
|
||||
|
||||
@Value("${h5Appsecret}")
|
||||
public void setH5Appsecret(String h5Appsecret) {
|
||||
NwLoginConstants.h5Appsecret = h5Appsecret;
|
||||
}
|
||||
|
||||
@Value("${appsecret}")
|
||||
public void setAppsecret(String appsecret) {
|
||||
NwLoginConstants.appsecret = appsecret;
|
||||
}
|
||||
|
||||
public static String appId;
|
||||
|
||||
public static String h5AppId;
|
||||
|
||||
public static String appAppId;
|
||||
|
||||
|
||||
@Value("${appAppId}")
|
||||
public void setAppAppId(String appAppId) {
|
||||
NwLoginConstants.appAppId = appAppId;
|
||||
}
|
||||
|
||||
|
||||
@Value("${h5AppId}")
|
||||
public void setH5AppId(String h5AppId) {
|
||||
NwLoginConstants.h5AppId = h5AppId;
|
||||
}
|
||||
|
||||
@Value("${appId}")
|
||||
public void setAppId(String appId) {
|
||||
NwLoginConstants.appId = appId;
|
||||
}
|
||||
|
||||
@Value("${baseUrl}")
|
||||
public void setBaseUrl(String baseUrl) {
|
||||
NwLoginConstants.baseUrl = baseUrl;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,95 @@
|
|||
package com.bonus.sgzb.auth.form;
|
||||
|
||||
import com.bonus.sgzb.auth.enums.AccountTypeEnum;
|
||||
import com.bonus.sgzb.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* 注冊form类
|
||||
*
|
||||
* @author shuqiwang
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
public class RegisterForms extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
@ApiModelProperty(name = "enterpriseName", value = "企业名称")
|
||||
private String enterpriseName;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@ApiModelProperty(name = "userAccount", value = "用户账号")
|
||||
private String userAccount;
|
||||
/**
|
||||
* 登录密码
|
||||
*/
|
||||
@ApiModelProperty(name = "userPassword", value = "登录密码")
|
||||
private String userPassword;
|
||||
/**
|
||||
* 确认密码
|
||||
*/
|
||||
@ApiModelProperty(name = "againPassword", value = "确认密码")
|
||||
private String againPassword;
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
@ApiModelProperty(name = "mobilePhone", value = "手机号码")
|
||||
private String mobilePhone;
|
||||
/**
|
||||
* 手机验证码
|
||||
*/
|
||||
@ApiModelProperty(name = "mobilePhoneCode", value = "手机验证码")
|
||||
private String mobilePhoneCode;
|
||||
/**
|
||||
* 注册用户类型 {@link AccountTypeEnum}
|
||||
*/
|
||||
@ApiModelProperty(name = "accountType", value = "账号类型,1,运营方,2.采购商,3供应商")
|
||||
private Integer accountType;
|
||||
/**
|
||||
* 重定向返回的地址
|
||||
*/
|
||||
private String returnUrl;
|
||||
|
||||
private Long platformId;
|
||||
|
||||
@ApiModelProperty(name = "isPersonal", value = "个人或企业")
|
||||
private Integer isPersonal;
|
||||
|
||||
/*==========================以下是辅助字段==========================begin*/
|
||||
/**
|
||||
* ip
|
||||
*/
|
||||
private String loginIp;
|
||||
/**
|
||||
* 媒介(IE,谷歌,火狐,APP)
|
||||
*/
|
||||
private String loginMedia;
|
||||
/**
|
||||
* 运行时的系统环境
|
||||
*/
|
||||
private String loginDevice;
|
||||
/*==========================以上是辅助字段==========================end*/
|
||||
|
||||
/**
|
||||
* 登录方式类型
|
||||
*/
|
||||
private Integer loginModeType;
|
||||
|
||||
/**
|
||||
* 是否原有用户
|
||||
*/
|
||||
@ApiModelProperty(name = "isOriginalUser",value = "是否原有用户")
|
||||
private Integer isOriginalUser;
|
||||
|
||||
/**
|
||||
* 南网 外部关联Id(集成平台联调Id)
|
||||
*/
|
||||
@ApiModelProperty(name = "externalId",value = "南网外部关联Id(集成平台联调Id)")
|
||||
private String externalId;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,209 @@
|
|||
package com.bonus.sgzb.auth.form;
|
||||
|
||||
import com.bonus.sgzb.auth.enums.AccountTypeEnum;
|
||||
import com.bonus.sgzb.common.core.web.domain.BaseEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author zhangshuwei
|
||||
* @create
|
||||
**/
|
||||
@Data
|
||||
public class UserAccount extends BaseEntity {
|
||||
|
||||
|
||||
/**
|
||||
* 父ID
|
||||
*/
|
||||
private Long pid;
|
||||
/**
|
||||
* 同步过来的用户id
|
||||
*/
|
||||
private String synUserId;
|
||||
/**
|
||||
* 同步过来的父ID
|
||||
*/
|
||||
private String synPid;
|
||||
/**
|
||||
* 账号类型,1,运营方,2.采购商,3供应商
|
||||
*/
|
||||
private Integer accountType;
|
||||
|
||||
private String accountTypeShow;
|
||||
/**
|
||||
* 用户姓名
|
||||
*/
|
||||
private String userName;
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
private String accountName;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
/**
|
||||
* 头像url
|
||||
*/
|
||||
private String avatarPicSrc;
|
||||
/**
|
||||
* 账号来源 1 导入,2 注册
|
||||
*/
|
||||
private Integer source;
|
||||
/**
|
||||
* 是否是管理员 0不是 1是
|
||||
*/
|
||||
private Integer administrator;
|
||||
/**
|
||||
* 供应商专用1.电商供应商(线上),2 非电商供应商(线下)
|
||||
*/
|
||||
private Integer channel;
|
||||
/**
|
||||
* 用户状态,0停用,1启用
|
||||
*/
|
||||
private Integer userStatus;
|
||||
/**
|
||||
* 是否子账号(0非子账号,1=子账号)
|
||||
*/
|
||||
private Integer subAccountType;
|
||||
/**
|
||||
* 用户所属核算单位组织机构编码
|
||||
*/
|
||||
private Long legalEntityOrganizationId;
|
||||
/**
|
||||
* 用户所属核算单位组织机构名称
|
||||
*/
|
||||
private String legalEntityOrganizationName;
|
||||
/**
|
||||
* 用户所属组织机构编码
|
||||
*/
|
||||
private Long departmentOrganizationId;
|
||||
/**
|
||||
* 用户所属组织机构编码
|
||||
*/
|
||||
private String departmentOrganizationName;
|
||||
/**
|
||||
* 系统3.0 对应账号,采购人身份会用到
|
||||
*/
|
||||
private String systemAccount;
|
||||
/**
|
||||
* 系统3.0对应的组织机构id
|
||||
*/
|
||||
private String systemOrganizationId;
|
||||
/**
|
||||
* 系统3.0对应的组织机构
|
||||
*/
|
||||
private String systemOrganization;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date updated;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date created;
|
||||
|
||||
private String token;
|
||||
/** 选中状态 */
|
||||
@ApiModelProperty(value = "选中状态true 选中,false未选中")
|
||||
private boolean lay_is_checked;
|
||||
|
||||
private Long shopId;
|
||||
|
||||
@ApiModelProperty(name = "supplierStatus",value = "供应商状态")
|
||||
private Integer supplierStatus;
|
||||
|
||||
@ApiModelProperty(name = "roleName",value = "账号角色名称")
|
||||
private String roleName;
|
||||
|
||||
@ApiModelProperty(name = "统一社会信用代码")
|
||||
private String unSocialCrCode;
|
||||
|
||||
private Long platformId;
|
||||
|
||||
@ApiModelProperty(name = "企业或个人")
|
||||
private Integer isPersonal;
|
||||
|
||||
@ApiModelProperty(name = "是否开通采购业务")
|
||||
private Integer isBuyer;
|
||||
|
||||
@ApiModelProperty(name = "是否开通供应业务")
|
||||
private Integer isSeller;
|
||||
|
||||
/** 所属企业id **/
|
||||
private Long enterpriseId;
|
||||
|
||||
/** 是否设置为个人 **/
|
||||
private Integer isSetPersonal;
|
||||
|
||||
/** 所属企业编码 **/
|
||||
private String enterpriseCode;
|
||||
|
||||
|
||||
private String externalId;
|
||||
|
||||
@ApiModelProperty(name = "id集合")
|
||||
private List<Long> userIdList;
|
||||
/**
|
||||
* 是否进行展示 , true展示,false不展示
|
||||
*/
|
||||
@ApiModelProperty(name = "showedVerificationCode", value = "是否进行展示 , true展示,false不展示")
|
||||
private boolean showedVerificationCode;
|
||||
/**
|
||||
* 校验码
|
||||
*/
|
||||
@ApiModelProperty(name = "verificationCode", value = "校验码")
|
||||
private String verificationCode;
|
||||
|
||||
@ApiModelProperty(name = "tagId", value = "标签Id")
|
||||
private Long tagId;
|
||||
|
||||
public String getAccountTypeShow() {
|
||||
return AccountTypeEnum.getView(this.accountType);
|
||||
}
|
||||
|
||||
public void setAccountTypeShow(String accountTypeShow) {
|
||||
this.accountTypeShow = accountTypeShow;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织机构全路径
|
||||
*/
|
||||
@ApiModelProperty(name = "fullName", value = "组织机构全路径")
|
||||
private String fullName;
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
@ApiModelProperty(name = "code",value = "验证码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 注销状态:1未注销,0已注销
|
||||
*/
|
||||
@ApiModelProperty(name = "cancelledStatus",value = "注销状态:1未注销,0已注销")
|
||||
private Integer cancelledStatus;
|
||||
|
||||
/**
|
||||
* 头像url
|
||||
*/
|
||||
@ApiModelProperty(name = "headPortraitUrl",value = "头像url")
|
||||
private String headPortraitUrl;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
package com.bonus.sgzb.auth.form;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author zhangshuwei
|
||||
* @create
|
||||
**/
|
||||
@Data
|
||||
public class UserAccountRequestVo {
|
||||
|
||||
|
||||
@ApiModelProperty(name = "platformId",value = "平台id")
|
||||
private Long platformId;
|
||||
|
||||
@ApiModelProperty(name = "pid",value = "父ID")
|
||||
private Long pid;
|
||||
|
||||
@ApiModelProperty(value = "同步过来的用户id")
|
||||
private String synUserId;
|
||||
|
||||
@ApiModelProperty(value = "同步过来的父ID")
|
||||
private String synPid;
|
||||
|
||||
@ApiModelProperty(name = "userAccountType",value = "账号类型,1,运营方,2.采购商,3供应商")
|
||||
private Integer userAccountType;
|
||||
|
||||
@ApiModelProperty(name = "userName",value = "用户姓名")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty(name = "userAccountName",value = "账号")
|
||||
private String userAccountName;
|
||||
|
||||
@ApiModelProperty(name = "accountNameLike",value = "账号模糊条件")
|
||||
private String accountNameLike;
|
||||
|
||||
@ApiModelProperty(name = "password",value = "密码")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty(name = "mobile",value = "电话")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty(name = "email",value = "邮箱")
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty(name = "avatarPicSrc",value = "头像url")
|
||||
private String avatarPicSrc;
|
||||
|
||||
@ApiModelProperty(name = "source",value = "账号来源 1 导入,2 注册")
|
||||
private Integer source;
|
||||
|
||||
@ApiModelProperty(name = "administrator",value = "是否是管理员 0不是 1是")
|
||||
private Integer administrator;
|
||||
|
||||
@ApiModelProperty(name = "channel",value = "供应商专用1.电商供应商(线上),2 非电商供应商(线下)")
|
||||
private Integer channel;
|
||||
|
||||
@ApiModelProperty(name = "userStatus",value = "用户状态,0停用,1启用")
|
||||
private Integer userStatus;
|
||||
|
||||
@ApiModelProperty(name = "subAccountType",value = "是否子账号(0非子账号,1=子账号)")
|
||||
private Integer subAccountType;
|
||||
|
||||
@ApiModelProperty(name = "legalEntityOrganizationId",value = "用户所属核算单位组织机构编码")
|
||||
private Long legalEntityOrganizationId;
|
||||
|
||||
@ApiModelProperty(name = "legalEntityOrganizationName",value = "用户所属核算单位组织机构名称")
|
||||
private String legalEntityOrganizationName;
|
||||
|
||||
@ApiModelProperty(name = "departmentOrganizationId",value = "用户所属组织机构编码")
|
||||
private Long departmentOrganizationId;
|
||||
|
||||
@ApiModelProperty(name = "departmentOrganizationName",value = "用户所属组织机构编码")
|
||||
private String departmentOrganizationName;
|
||||
|
||||
@ApiModelProperty(name = "systemAccount",value = "系统3.0 对应账号,采购人身份会用到")
|
||||
private String systemAccount;
|
||||
|
||||
@ApiModelProperty(name = "systemOrganizationId",value = "系统3.0对应的组织机构ID")
|
||||
private String systemOrganizationId;
|
||||
|
||||
@ApiModelProperty(name = "systemOrganization",value = "系统3.0对应的组织机构")
|
||||
private String systemOrganization;
|
||||
|
||||
@ApiModelProperty(name = "企业或个人")
|
||||
private Integer isPersonal;
|
||||
|
||||
@ApiModelProperty(name = "是否开通采购业务")
|
||||
private Integer isBuyer;
|
||||
|
||||
@ApiModelProperty(name = "是否开通供应业务")
|
||||
private Integer isSeller;
|
||||
|
||||
/** 所属企业id **/
|
||||
private Long enterpriseId;
|
||||
|
||||
/** 所属企业编码 **/
|
||||
private String enterpriseCode;
|
||||
|
||||
@ApiModelProperty(name = "created",value = "创建时间")
|
||||
private Date created;
|
||||
|
||||
@ApiModelProperty(name = "updated",value = "更新时间")
|
||||
private Date updated;
|
||||
|
||||
@ApiModelProperty(name = "yn",value = "是否有效:0 无效;1:有效;")
|
||||
private Integer yn;
|
||||
|
||||
@ApiModelProperty(name = "departmentOrganizationIdList",value = "用户所属组织机构编码集合")
|
||||
private List<Long> departmentOrganizationIdList;
|
||||
|
||||
/**
|
||||
* 请求来源
|
||||
*/
|
||||
private Integer requestSource;
|
||||
|
||||
/**
|
||||
* 查询用户类型list
|
||||
*/
|
||||
@ApiModelProperty(name = "userAccountTypeList",value = "账号类型,1,运营方,2.采购商,3供应商")
|
||||
private List<Integer> userAccountTypeList;
|
||||
|
||||
@ApiModelProperty(name = "tagId", value = "标签Id")
|
||||
private Long tagId;
|
||||
|
||||
@ApiModelProperty(name = "tagName", value = "标签名称")
|
||||
private String tagName;
|
||||
|
||||
@ApiModelProperty(name = "tagId", value = "标签Id")
|
||||
private List<Long> tagIdList;
|
||||
|
||||
@ApiModelProperty(name = "roleId", value = "角色ID")
|
||||
private Long roleId;
|
||||
|
||||
@ApiModelProperty(name = "isSubCompany", value = "是否是子公司账号")
|
||||
private Boolean isSubCompany;
|
||||
|
||||
/**
|
||||
* 注销状态:1未注销,0已注销
|
||||
*/
|
||||
@ApiModelProperty(name = "cancelledStatus",value = "注销状态:1未注销,0已注销")
|
||||
private Integer cancelledStatus;
|
||||
|
||||
/**
|
||||
* 企业编号集合
|
||||
*/
|
||||
@ApiModelProperty(name = "enterpriseIdList",value = "企业编号集合")
|
||||
private List<String> enterpriseIdList;
|
||||
|
||||
/**
|
||||
* 头像uid
|
||||
*/
|
||||
@ApiModelProperty(name = "headPortraitUrl",value = "头像uid")
|
||||
private Long headPortraitUid;
|
||||
|
||||
private Integer isPerson;
|
||||
|
||||
private List<Long> idList;
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.bonus.sgzb.auth.service;
|
||||
|
||||
|
||||
|
||||
import com.bonus.sgzb.auth.form.RegisterForms;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
*@author: LYJ
|
||||
*@date: 2021/8/14 18:46
|
||||
*@description: 注册Service接口
|
||||
*/
|
||||
public interface NwRegisterService {
|
||||
/**
|
||||
* 统一个人手机注册
|
||||
*
|
||||
* @param request
|
||||
* @param registerForms
|
||||
* @return
|
||||
*/
|
||||
String registersNew(HttpServletRequest request, RegisterForms registerForms);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,176 @@
|
|||
package com.bonus.sgzb.auth.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.bonus.sgzb.auth.form.*;
|
||||
import com.bonus.sgzb.auth.service.NwRegisterService;
|
||||
import com.bonus.sgzb.common.core.exception.base.BaseException;
|
||||
import com.bonus.sgzb.common.core.utils.ip.IpUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author: LYJ
|
||||
* @date: 2021/8/14 18:47
|
||||
* @description: 注册实现类
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class NwRegisterServiceImpl implements NwRegisterService {
|
||||
|
||||
@Override
|
||||
public String registersNew(HttpServletRequest request, RegisterForms registerForms) {
|
||||
log.info("统一个人手机注册 registersForPersonal方法 入参 request:{}, registerForms:{}", request, JSON.toJSONString(registerForms));
|
||||
/* 校验请求参数 */
|
||||
this.checkRequestParam(request, registerForms);
|
||||
Integer loginModeType = registerForms.getLoginModeType();
|
||||
NwApp nwApp = new NwApp();
|
||||
if (loginModeType == 1) {
|
||||
nwApp.setCode(1);
|
||||
nwApp.setAppId(NwLoginConstants.appId);
|
||||
nwApp.setAppsecret(NwLoginConstants.appsecret);
|
||||
} else if (loginModeType == 2) {
|
||||
nwApp.setCode(2);
|
||||
nwApp.setAppId(NwLoginConstants.h5AppId);
|
||||
nwApp.setAppsecret(NwLoginConstants.h5Appsecret);
|
||||
} else if (loginModeType == 3) {
|
||||
nwApp.setCode(3);
|
||||
nwApp.setAppId(NwLoginConstants.wechatAppId);
|
||||
nwApp.setAppsecret(NwLoginConstants.wechatAppsecret);
|
||||
} else if (loginModeType == 4) {
|
||||
nwApp.setCode(4);
|
||||
nwApp.setAppId(NwLoginConstants.appAppId);
|
||||
nwApp.setAppsecret(NwLoginConstants.appAppsecret);
|
||||
}
|
||||
try {
|
||||
//发送注册请求(调用南网的注册方法)
|
||||
RespLoginData respLoginData = null;
|
||||
//用户中心用户id
|
||||
String ossExternalId = null;
|
||||
/* 查询商城是否存在当前用户 */
|
||||
// UserAccount mallUser = this.queryUserByMall(registerForms);
|
||||
/* 查询用户中心是否存在当前用户 */
|
||||
CloudUserVo cloudUserVo = this.queryUserBySso(registerForms);
|
||||
/* 数据幂等性操作 记录日志 */
|
||||
RegistersVo registersVo = getRegisterVo(registerForms);
|
||||
log.error("check001_registersVo:{}", JsonUtils.object2Json(registersVo));
|
||||
|
||||
if (null != mallUser) {
|
||||
if (mallUser.getMobile().equals(registerForms.getMobilePhone())) {
|
||||
throw new BaseException(ExceptionDict.PHONE_NUMBER_EXISTS_CODE, ExceptionDict.PHONE_NUMBER_EXISTS_MSG);
|
||||
} else {
|
||||
throw new BaseException(ExceptionDict.USER_NAME_EXISTS_CODE, ExceptionDict.USER_NAME_EXISTS_MSG);
|
||||
}
|
||||
}
|
||||
/* 添加商城用户逻辑 */
|
||||
log.error("check002_respLoginData:{}", JsonUtils.object2Json(respLoginData));
|
||||
if (respLoginData.getCode().equals(CodeConstants.HTTP_RESPONSE_CODE_200)) {
|
||||
if (null != cloudUserVo) {
|
||||
if (IsOriginalUserEnum.YES.getCode().equals(cloudUserVo.getIsOriginalUser())) {
|
||||
registerForms.setUserAccount(cloudUserVo.getUserAccount());
|
||||
}
|
||||
Map<String, String> param = new HashMap();
|
||||
param.put(CodeConstants.USER_LBCLOUD_ID, registerForms.getExternalId());
|
||||
RespLoginData userDetailInfo = HttpUtils.postJsonForApi(LoginConstants.getPersonDetailData, null, null, Map.class, param, nwAppEnum);
|
||||
if (CodeConstants.HTTP_RESPONSE_CODE_200.equals(userDetailInfo.getCode())) {
|
||||
Map<String, String> userData = (Map<String, String>) userDetailInfo.getData();
|
||||
ossExternalId = userData.get(CodeConstants.USER_LBCLOUD_EXTERNA_ID);
|
||||
} else {
|
||||
this.deleteKey(registerForms);
|
||||
this.deleteInterceptor();
|
||||
throw new BaseException(respLoginData.getCode(), respLoginData.getMessage());
|
||||
}
|
||||
} else {
|
||||
Map<String, String> data = (Map<String, String>) respLoginData.getData();
|
||||
ossExternalId = data.get(CodeConstants.USER_EXTERNAL_ID);
|
||||
}
|
||||
} else {
|
||||
Map<String, String> data = (Map<String, String>) respLoginData.getData();
|
||||
ossExternalId = data.get(CodeConstants.USER_EXTERNAL_ID);
|
||||
}
|
||||
if (null == ossExternalId) {
|
||||
throw new BaseException(ExceptionDict.USER_NAME_EXISTS_CODE, "获取统一用户中心userExternalId数据失败,请联系管理员");
|
||||
}
|
||||
//添加商城账号(个人/企业)
|
||||
this.addMallUser(registerForms, ossExternalId);
|
||||
//发送短信提醒用户
|
||||
platformClient.sendMessageNew(CodeConstants.PLATFORM_ID, registerForms.getMobilePhone(), PropertyNameConstants.USER_REGISTERED_APPROVED);
|
||||
return AccountRegisterConstants.REGISTERIP_SUCCESS;
|
||||
} catch (Exception e) {
|
||||
deleteInterceptor();
|
||||
deleteKey(registerForms);
|
||||
throw new UserException("9999", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void checkRequestParam(HttpServletRequest request, RegisterForms registerForms) {
|
||||
String ipAddress = IpUtils.getIpAddr(request);
|
||||
Integer loginModeType = registerForms.getLoginModeType();
|
||||
NwApp nwApp = new NwApp();
|
||||
if (loginModeType == 1) {
|
||||
nwApp.setCode(1);
|
||||
nwApp.setAppId(NwLoginConstants.appId);
|
||||
nwApp.setAppsecret(NwLoginConstants.appsecret);
|
||||
} else if (loginModeType == 2) {
|
||||
nwApp.setCode(2);
|
||||
nwApp.setAppId(NwLoginConstants.h5AppId);
|
||||
nwApp.setAppsecret(NwLoginConstants.h5Appsecret);
|
||||
} else if (loginModeType == 3) {
|
||||
nwApp.setCode(3);
|
||||
nwApp.setAppId(NwLoginConstants.wechatAppId);
|
||||
nwApp.setAppsecret(NwLoginConstants.wechatAppsecret);
|
||||
} else if (loginModeType == 4) {
|
||||
nwApp.setCode(4);
|
||||
nwApp.setAppId(NwLoginConstants.appAppId);
|
||||
nwApp.setAppsecret(NwLoginConstants.appAppsecret);
|
||||
}
|
||||
|
||||
if (null == loginModeType) {
|
||||
throw new BaseException(NwLoginConstants.LOGIN_TYPE_EXCEPTION_CODE, NwLoginConstants.LOGIN_TYPE_EXCEPTION_MSG);
|
||||
}
|
||||
if (null == ipAddress) {
|
||||
throw new BaseException(NwLoginConstants.IP_NULL_CODE, NwLoginConstants.IP_NULL_MSG);
|
||||
}
|
||||
if (null == registerForms) {
|
||||
throw new BaseException(NwLoginConstants.PARAM_IS_NULL_ERROR_CODE, NwLoginConstants.PARAM_IS_NULL_ERROR_CODE_MSG);
|
||||
}
|
||||
if (StringUtils.isEmpty(registerForms.getMobilePhone())) {
|
||||
throw new BaseException(NwLoginConstants.PHONE_NOT_NULL_CODE, NwLoginConstants.PHONE_NOT_NULL_MSG);
|
||||
}
|
||||
if (!this.checkPhone(registerForms.getMobilePhone())) {
|
||||
throw new BaseException(NwLoginConstants.MOBILE_FORMAT_ERROR_CODE, NwLoginConstants.MOBILE_FORMAT_ERROR_CODE_MSG);
|
||||
}
|
||||
if (StringUtils.isBlank(registerForms.getUserAccount())) {
|
||||
throw new BaseException(NwLoginConstants.USER_NAME_NOT_NULL_CODE, NwLoginConstants.USER_NAME_NOT_NULL_MSG);
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(registerForms.getUserPassword())) {
|
||||
throw new BaseException(NwLoginConstants.PASSWORD_NOT_NULL_CODE, NwLoginConstants.PASSWORD_NOT_NULL_MSG);
|
||||
}
|
||||
if (null == registerForms.getAgainPassword()) {
|
||||
throw new BaseException(NwLoginConstants.AGAIN_PASSWORD_NOT_NULL_CODE, NwLoginConstants.AGAIN_PASSWORD_NOT_NULL_MSG);
|
||||
}
|
||||
|
||||
if (null == registerForms.getPlatformId()) {
|
||||
registerForms.setPlatformId(NwLoginConstants.PLATFORM_ID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证手机号
|
||||
*
|
||||
* @param phone
|
||||
* @return 验证成功返回true,验证失败返回false
|
||||
*/
|
||||
public static boolean checkPhone(String phone) {
|
||||
String regex = "^1\\d{10}$";
|
||||
return Pattern.matches(regex, phone);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue