[fix]测试会员的接口并优化登录
This commit is contained in:
parent
4d0b6cb113
commit
f98db5fe4b
6
pom.xml
6
pom.xml
@ -411,7 +411,11 @@
|
||||
<version>2.5.4</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-auth</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
|
@ -107,6 +107,7 @@
|
||||
<artifactId>ruoyi-workflow</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-starter-client</artifactId>
|
||||
|
@ -80,7 +80,7 @@ public class AuthController {
|
||||
* @param body 登录信息
|
||||
* @return 结果
|
||||
*/
|
||||
@ApiEncrypt
|
||||
// @ApiEncrypt
|
||||
@PostMapping("/login")
|
||||
public R<LoginVo> login(@RequestBody String body) {
|
||||
LoginBody loginBody = JsonUtils.parseObject(body, LoginBody.class);
|
||||
@ -97,7 +97,10 @@ public class AuthController {
|
||||
return R.fail(MessageUtils.message("auth.grant.type.blocked"));
|
||||
}
|
||||
// 校验租户
|
||||
loginService.checkTenant(loginBody.getTenantId());
|
||||
if(!"app".equals(client.getClientKey())){
|
||||
loginService.checkTenant(loginBody.getTenantId());
|
||||
}
|
||||
|
||||
// 登录
|
||||
LoginVo loginVo = IAuthStrategy.login(body, client, grantType);
|
||||
|
||||
|
@ -56,22 +56,22 @@ public class CaptchaController {
|
||||
*
|
||||
* @param phonenumber 用户手机号
|
||||
*/
|
||||
@RateLimiter(key = "#phonenumber", time = 60, count = 1)
|
||||
// @RateLimiter(key = "#phonenumber", time = 60, count = 1)
|
||||
@GetMapping("/resource/sms/code")
|
||||
public R<Void> smsCode(@NotBlank(message = "{user.phonenumber.not.blank}") String phonenumber) {
|
||||
String key = GlobalConstants.CAPTCHA_CODE_KEY + phonenumber;
|
||||
String code = RandomUtil.randomNumbers(4);
|
||||
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
||||
// 验证码模板id 自行处理 (查数据库或写死均可)
|
||||
String templateId = "";
|
||||
String templateId = "2375314";
|
||||
LinkedHashMap<String, String> map = new LinkedHashMap<>(1);
|
||||
map.put("code", code);
|
||||
SmsBlend smsBlend = SmsFactory.getSmsBlend("config1");
|
||||
SmsResponse smsResponse = smsBlend.sendMessage(phonenumber, templateId, map);
|
||||
if (!smsResponse.isSuccess()) {
|
||||
log.error("验证码短信发送异常 => {}", smsResponse);
|
||||
return R.fail(smsResponse.getData().toString());
|
||||
}
|
||||
SmsBlend smsBlend = SmsFactory.getSmsBlend("config2");
|
||||
// SmsResponse smsResponse = smsBlend.sendMessage(phonenumber, templateId, map);
|
||||
// if (!smsResponse.isSuccess()) {
|
||||
// log.error("验证码短信发送异常 => {}", smsResponse);
|
||||
// return R.fail(smsResponse.getData().toString());
|
||||
// }
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
@ -51,4 +51,9 @@ public class LoginVo {
|
||||
*/
|
||||
private String openid;
|
||||
|
||||
/**
|
||||
* 用户 sig
|
||||
*/
|
||||
private String userSig;
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Opt;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.lock.annotation.Lock4j;
|
||||
import com.wzj.soopin.member.domain.po.Member;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
@ -18,6 +19,7 @@ import org.dromara.common.core.domain.dto.PostDTO;
|
||||
import org.dromara.common.core.domain.dto.RoleDTO;
|
||||
import org.dromara.common.core.domain.model.LoginUser;
|
||||
import org.dromara.common.core.enums.LoginType;
|
||||
import org.dromara.common.core.enums.UserType;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.exception.user.UserException;
|
||||
import org.dromara.common.core.utils.*;
|
||||
@ -171,6 +173,20 @@ public class SysLoginService {
|
||||
return loginUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建登录用户
|
||||
*/
|
||||
public LoginUser buildLoginUser(Member member) {
|
||||
LoginUser loginUser = new LoginUser();
|
||||
Long userId = member.getId();
|
||||
loginUser.setUserId(userId);
|
||||
loginUser.setUsername(member.getUserName());
|
||||
loginUser.setNickname(member.getNickname());
|
||||
loginUser.setUserType(UserType.APP_USER.getUserType());
|
||||
loginUser.setUserSig(member.getUserSig());
|
||||
return loginUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录登录信息
|
||||
*
|
||||
|
@ -4,14 +4,19 @@ import cn.dev33.satoken.stp.SaLoginModel;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.wzj.soopin.member.domain.po.Member;
|
||||
import com.wzj.soopin.member.mapper.MemberMapper;
|
||||
import com.wzj.soopin.member.service.MemberRegisterService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.constant.Constants;
|
||||
import org.dromara.common.core.constant.GlobalConstants;
|
||||
import org.dromara.common.core.constant.SystemConstants;
|
||||
import org.dromara.common.core.domain.model.LoginUser;
|
||||
import org.dromara.common.core.domain.model.RegisterBody;
|
||||
import org.dromara.common.core.domain.model.SmsLoginBody;
|
||||
import org.dromara.common.core.enums.LoginType;
|
||||
import org.dromara.common.core.enums.UserType;
|
||||
import org.dromara.common.core.exception.user.CaptchaExpireException;
|
||||
import org.dromara.common.core.exception.user.UserException;
|
||||
import org.dromara.common.core.utils.MessageUtils;
|
||||
@ -42,6 +47,8 @@ public class SmsAuthStrategy implements IAuthStrategy {
|
||||
|
||||
private final SysLoginService loginService;
|
||||
private final SysUserMapper userMapper;
|
||||
private final MemberMapper memberMapper;
|
||||
private final MemberRegisterService memberRegisterService;
|
||||
|
||||
@Override
|
||||
public LoginVo login(String body, SysClientVo client) {
|
||||
@ -51,10 +58,34 @@ public class SmsAuthStrategy implements IAuthStrategy {
|
||||
String phonenumber = loginBody.getPhonenumber();
|
||||
String smsCode = loginBody.getSmsCode();
|
||||
LoginUser loginUser = TenantHelper.dynamic(tenantId, () -> {
|
||||
SysUserVo user = loadUserByPhonenumber(phonenumber);
|
||||
loginService.checkLogin(LoginType.SMS, tenantId, user.getUserName(), () -> !validateSmsCode(tenantId, phonenumber, smsCode));
|
||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
||||
return loginService.buildLoginUser(user);
|
||||
|
||||
|
||||
if("app".equals(client.getClientKey())){
|
||||
//会员登录
|
||||
Member member = loadMemberByPhonenumber(phonenumber);
|
||||
|
||||
//手机号登录,如果没有则创建一个
|
||||
if (member == null) {
|
||||
RegisterBody registerBody = new RegisterBody();
|
||||
registerBody.setPhoneNumber(phonenumber);
|
||||
registerBody.setCode(smsCode);
|
||||
registerBody.setUserType(UserType.APP_USER.getUserType());
|
||||
registerBody.setClientId(client.getClientId());
|
||||
registerBody.setUuid(phonenumber);
|
||||
member = memberRegisterService.register(registerBody);
|
||||
return loginService.buildLoginUser(member);
|
||||
} else {
|
||||
loginService.checkLogin(LoginType.SMS, tenantId, member.getUserName(), () -> !validateSmsCode(tenantId, phonenumber, smsCode));
|
||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
||||
return loginService.buildLoginUser(member);
|
||||
}
|
||||
}else{
|
||||
//管理员登录
|
||||
SysUserVo user = loadUserByPhonenumber(phonenumber);
|
||||
loginService.checkLogin(LoginType.SMS, tenantId, user.getUserName(), () -> !validateSmsCode(tenantId, phonenumber, smsCode));
|
||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
||||
return loginService.buildLoginUser(user);
|
||||
}
|
||||
});
|
||||
loginUser.setClientKey(client.getClientKey());
|
||||
loginUser.setDeviceType(client.getDeviceType());
|
||||
@ -72,9 +103,16 @@ public class SmsAuthStrategy implements IAuthStrategy {
|
||||
loginVo.setAccessToken(StpUtil.getTokenValue());
|
||||
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
||||
loginVo.setClientId(client.getClientId());
|
||||
loginVo.setUserSig(loginUser.getUserSig());
|
||||
return loginVo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void checkMemberLogin(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验短信验证码
|
||||
*/
|
||||
@ -98,5 +136,16 @@ public class SmsAuthStrategy implements IAuthStrategy {
|
||||
}
|
||||
return user;
|
||||
}
|
||||
private Member loadMemberByPhonenumber(String phonenumber) {
|
||||
Member user = memberMapper.selectOne(new LambdaQueryWrapper<Member>().eq(Member::getPhoneEncrypted, phonenumber));
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", phonenumber);
|
||||
return null;
|
||||
} else if (SystemConstants.DISABLE.equals(user.getStatus())) {
|
||||
log.info("登录用户:{} 已被停用.", phonenumber);
|
||||
throw new UserException("user.blocked", phonenumber);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -182,10 +182,10 @@ sms:
|
||||
config2:
|
||||
# 厂商标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
|
||||
supplier: tencent
|
||||
access-key-id: 您的accessKey
|
||||
access-key-secret: 您的accessKeySecret
|
||||
signature: 您的短信签名
|
||||
sdk-app-id: 您的sdkAppId
|
||||
access-key-id: AKIDvhEVWHm0xe5JGxOZXGitnRovlKcfRzIN
|
||||
access-key-secret: qPhiTxA7oENFrCH5dvxiCQN4UdWAYgYA
|
||||
signature: 无终街科技
|
||||
sdk-app-id: 1400966042
|
||||
|
||||
|
||||
--- # 三方授权
|
||||
|
@ -116,14 +116,7 @@ security:
|
||||
- /*/api-docs
|
||||
- /*/api-docs/**
|
||||
- /warm-flow-ui/token-name
|
||||
- /admin/vlog/upload/detail/**
|
||||
- /admin/vlog/upload/**
|
||||
# - /admin/vlog/upload/pull
|
||||
# - /admin/vlog/upload/pull/batch
|
||||
# - /admin/vlog/upload/list
|
||||
# - /admin/vlog/upload/**
|
||||
# - /admin/vlog/pull/**
|
||||
# - /admin/vlog/pull
|
||||
|
||||
|
||||
# 多租户配置
|
||||
tenant:
|
||||
@ -140,6 +133,12 @@ tenant:
|
||||
- sys_user_role
|
||||
- sys_client
|
||||
- sys_oss_config
|
||||
- ums_member
|
||||
- ums_member_address
|
||||
- ums_feedback
|
||||
- ums_member_account
|
||||
- ums_member_logininfor
|
||||
- ums_member_cart
|
||||
|
||||
# MyBatisPlus配置
|
||||
# https://baomidou.com/config/
|
||||
|
@ -88,6 +88,11 @@
|
||||
<artifactId>mapstruct-plus-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 离线IP地址定位库 -->
|
||||
<dependency>
|
||||
<groupId>org.lionsoul</groupId>
|
||||
|
@ -65,7 +65,7 @@ public interface Constants {
|
||||
/**
|
||||
* 验证码有效期(分钟)
|
||||
*/
|
||||
Integer CAPTCHA_EXPIRATION = 2;
|
||||
Integer CAPTCHA_EXPIRATION = 5;
|
||||
|
||||
/**
|
||||
* 顶级父级id
|
||||
|
@ -2,6 +2,9 @@ package org.dromara.common.core.domain;
|
||||
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
|
||||
import java.sql.Wrapper;
|
||||
|
||||
public class BaseBO <T> {
|
||||
@ -11,7 +14,7 @@ public class BaseBO <T> {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public T toWrapper() {
|
||||
public LambdaQueryWrapper<T> toWrapper() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -133,6 +133,12 @@ public class LoginUser implements Serializable {
|
||||
private String deviceType;
|
||||
|
||||
|
||||
/**
|
||||
* 腾讯IM用户Sig
|
||||
*/
|
||||
private String userSig;
|
||||
|
||||
|
||||
/**
|
||||
* 获取登录id
|
||||
*/
|
||||
|
@ -30,4 +30,6 @@ public class RegisterBody extends LoginBody {
|
||||
|
||||
private String userType;
|
||||
|
||||
private String phoneNumber;
|
||||
|
||||
}
|
||||
|
@ -24,10 +24,10 @@
|
||||
<artifactId>ruoyi-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-data-mongodb</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
@ -1,14 +1,24 @@
|
||||
package org.dromara.common.web.core;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* web层通用数据处理
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public class BaseController {
|
||||
public class BaseController {
|
||||
|
||||
// @Autowired
|
||||
// public S service;
|
||||
//
|
||||
// @Autowired
|
||||
// public C convert;
|
||||
|
||||
|
||||
/**
|
||||
* 响应返回结果
|
||||
|
@ -2,30 +2,33 @@ package org.dromara.common.web.core;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.mapstruct.MapperConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@MapperConfig
|
||||
public interface BaseConverter<V,B,T> {
|
||||
/**
|
||||
* dto转vo
|
||||
* @param t
|
||||
* @return
|
||||
*/
|
||||
V convertToVO(T t);
|
||||
public V toVO(T t);
|
||||
|
||||
/**
|
||||
* dto列表转vo
|
||||
* @param tList
|
||||
* @return
|
||||
*/
|
||||
List<V> convertToVO(List<T> tList);
|
||||
public List<V> toVO(List<T> tList);
|
||||
/**
|
||||
* dto分页转vo
|
||||
* @param tPage
|
||||
* @return
|
||||
*/
|
||||
TableDataInfo<V> convertToVO(IPage<T> tPage);
|
||||
public Page<V> toVO(Page<T> tPage);
|
||||
|
||||
|
||||
|
||||
@ -35,7 +38,7 @@ public interface BaseConverter<V,B,T> {
|
||||
* @param d
|
||||
* @return
|
||||
*/
|
||||
T convertToPo(B d);
|
||||
public T toPo(B d);
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,89 @@
|
||||
package org.dromara.common.web.core;
|
||||
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 表格分页数据对象
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class Page<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 总记录数
|
||||
*/
|
||||
private long total;
|
||||
|
||||
/**
|
||||
* 列表数据
|
||||
*/
|
||||
private List<T> rows;
|
||||
|
||||
/**
|
||||
* 消息状态码
|
||||
*/
|
||||
private int code;
|
||||
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param list 列表数据
|
||||
* @param total 总记录数
|
||||
*/
|
||||
public Page(List<T> list, long total) {
|
||||
this.rows = list;
|
||||
this.total = total;
|
||||
this.code = HttpStatus.HTTP_OK;
|
||||
this.msg = "查询成功";
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分页对象构建表格分页数据对象
|
||||
*/
|
||||
public static <T> Page<T> build(IPage<T> page) {
|
||||
Page<T> rspData = new Page<>();
|
||||
rspData.setCode(HttpStatus.HTTP_OK);
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setRows(page.getRecords());
|
||||
rspData.setTotal(page.getTotal());
|
||||
return rspData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据数据列表构建表格分页数据对象
|
||||
*/
|
||||
public static <T> Page<T> build(List<T> list) {
|
||||
Page<T> rspData = new Page<>();
|
||||
rspData.setCode(HttpStatus.HTTP_OK);
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setRows(list);
|
||||
rspData.setTotal(list.size());
|
||||
return rspData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建表格分页数据对象
|
||||
*/
|
||||
public static <T> Page<T> build() {
|
||||
Page<T> rspData = new Page<>();
|
||||
rspData.setCode(HttpStatus.HTTP_OK);
|
||||
rspData.setMsg("查询成功");
|
||||
return rspData;
|
||||
}
|
||||
|
||||
}
|
@ -99,10 +99,20 @@
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-sse</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-social</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-member</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-system</artifactId>
|
||||
</dependency>
|
||||
<!-- 腾讯云 IM SDK -->
|
||||
<dependency>
|
||||
<groupId>com.tencentcloudapi</groupId>
|
||||
@ -116,6 +126,16 @@
|
||||
<artifactId>tls-sig-api-v2</artifactId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-crypto</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.12.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
@ -1,365 +0,0 @@
|
||||
package com.wzj.soopin.auth.controller;
|
||||
|
||||
|
||||
|
||||
import cn.hutool.json.JSONException;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.squareup.okhttp.OkHttpClient;
|
||||
import com.squareup.okhttp.Request;
|
||||
import com.squareup.okhttp.Response;
|
||||
import com.wzj.soopin.auth.domain.dto.entity.enums.VerificationEnums;
|
||||
import com.wzj.soopin.auth.util.TLSSigAPIv2;
|
||||
import com.wzj.soopin.member.domain.bo.MemberEditDTO;
|
||||
import org.dromara.common.core.constant.ResultCode;
|
||||
import com.wzj.soopin.auth.enums.UserEnums;
|
||||
import com.wzj.soopin.auth.service.IMemberService;
|
||||
import com.wzj.soopin.auth.service.IVerificationService;
|
||||
import com.wzj.soopin.auth.util.SmsUtil;
|
||||
import com.wzj.soopin.member.domain.po.Member;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 买家端,会员接口
|
||||
|
||||
*
|
||||
|
||||
* @author Chopper
|
||||
|
||||
* @since 2020/11/16 10:07 下午
|
||||
|
||||
*/
|
||||
|
||||
|
||||
@RestController
|
||||
|
||||
@Api(tags = "买家端,会员接口")
|
||||
|
||||
@Slf4j
|
||||
@RequestMapping("/buyer/passport/member")
|
||||
|
||||
public class MemberBuyerController {
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
|
||||
private IMemberService memberService;
|
||||
|
||||
@Autowired
|
||||
|
||||
private SmsUtil smsUtil;
|
||||
|
||||
|
||||
@Autowired
|
||||
|
||||
private IVerificationService verificationService;
|
||||
|
||||
// @Autowired
|
||||
|
||||
// private GenerateTestUserSig generateTestUserSig;
|
||||
|
||||
|
||||
|
||||
// 腾讯云 SDKAppID 和密钥
|
||||
|
||||
private static final long SDKAPPID = 1600080789; // 替换为您的 SDKAppID
|
||||
|
||||
private static final String SECRETKEY = "311b5309d714a20f7f5b54360ee21b1e24ec208ebcd25ce8f47d24753bccc091"; // 替换为您的密钥
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "登录接口")
|
||||
|
||||
@ApiImplicitParams({
|
||||
|
||||
@ApiImplicitParam(name = "username", value = "用户名", required = true, paramType = "query"),
|
||||
|
||||
@ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "query")
|
||||
|
||||
})
|
||||
|
||||
@PostMapping("/userLogin")
|
||||
|
||||
public R<Object> userLogin(@NotNull(message = "用户名不能为空") @RequestParam String username,
|
||||
|
||||
@NotNull(message = "密码不能为空") @RequestParam String password,
|
||||
|
||||
@RequestHeader String uuid) {
|
||||
|
||||
verificationService.check(uuid, VerificationEnums.LOGIN);
|
||||
|
||||
//return R.ok(this.memberService.usernameLogin(username, password));
|
||||
return R.ok(this.memberService.usernameLoginNew(username, password));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "注销接口")
|
||||
|
||||
@PostMapping("/logout")
|
||||
|
||||
public R<Object> logout() {
|
||||
|
||||
this.memberService.logout(UserEnums.MEMBER);
|
||||
|
||||
return R.ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value = "注销账号")
|
||||
@PutMapping("/cancellation")
|
||||
public R<Member> cancellation() {
|
||||
memberService.cancellation();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "短信登录接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "mobile", value = "手机号", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "code", value = "验证码", required = true, paramType = "query")
|
||||
})
|
||||
@PostMapping("/smsLogin")
|
||||
public R<Object> smsLogin(@NotNull(message = "手机号为空") @RequestParam String mobile,
|
||||
@NotNull(message = "验证码为空") @RequestParam String code,
|
||||
@RequestHeader String uuid) throws JSONException {
|
||||
log.info("短信验证码校验成功: mobile={}, code={}", mobile, code);
|
||||
return R.ok(memberService.mobilePhoneLoginNew(mobile));
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
@ApiOperation(value = "注册用户")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "username", value = "用户名", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "mobilePhone", value = "手机号", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "code", value = "验证码", required = true, paramType = "query")
|
||||
})
|
||||
@PostMapping("/register")
|
||||
public R<Object> register(@NotNull(message = "用户名不能为空") @RequestParam String username,
|
||||
@NotNull(message = "密码不能为空") @RequestParam String password,
|
||||
@NotNull(message = "手机号为空") @RequestParam String mobilePhone,
|
||||
@RequestHeader String uuid,
|
||||
@NotNull(message = "验证码不能为空") @RequestParam String code) {
|
||||
// 检查用户名是否已存在
|
||||
if (memberService.usernameExists(username)) {
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
}
|
||||
|
||||
// 验证短信验证码
|
||||
if (!smsUtil.verifyCode(mobilePhone, VerificationEnums.REGISTER, uuid, code)) {
|
||||
throw new ServiceException(ResultCode.VERIFICATION_SMS_CHECKED_ERROR);
|
||||
}
|
||||
|
||||
try {
|
||||
// 生成 UserSig
|
||||
TLSSigAPIv2 tlsSigAPIv2 = new TLSSigAPIv2(SDKAPPID, SECRETKEY);
|
||||
long expire = TimeUnit.DAYS.toSeconds(365 * 50); // 设置为 50 年
|
||||
String userSig = tlsSigAPIv2.genUserSig(mobilePhone, expire);
|
||||
String random = String.valueOf(System.currentTimeMillis());
|
||||
|
||||
// 构建腾讯云IM请求
|
||||
JSONObject requestBody = new JSONObject();
|
||||
requestBody.put("UserID", mobilePhone);
|
||||
requestBody.put("Nick", username);
|
||||
requestBody.put("FaceUrl", "http://www.qq.com");
|
||||
requestBody.put("Tag_Profile_IM_AllowType", "AllowType_Type_NeedConfirm");
|
||||
|
||||
String urlString = String.format("https://console.tim.qq.com/v4/im_open_login_svc/account_import?sdkappid=%s&identifier=%s&usersig=%s&random=%s&contenttype=json",
|
||||
SDKAPPID, mobilePhone, userSig, random);
|
||||
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Request request = new Request.Builder()
|
||||
.url(urlString)
|
||||
// .post(RequestBody.create(MediaType.get("application/json; charset=utf-8"), requestBody.toString()))
|
||||
.build();
|
||||
|
||||
Response response = client.newCall(request).execute();
|
||||
if (!response.isSuccessful()) {
|
||||
log.error("腾讯云IM账号导入失败: {}", response.body().string());
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
}
|
||||
|
||||
// 注册用户
|
||||
return R.ok(memberService.registerNew(username, password, mobilePhone, userSig));
|
||||
} catch (Exception e) {
|
||||
log.error("注册失败", e);
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/*@PostMapping("/registerTest")
|
||||
public R<Object> registerTest(){
|
||||
// 处理成功响应
|
||||
return R.ok(memberService.registerNew("leon", "12345678", "13899990000","qqqqqqqqqqqqqqqqqqqqqqq"));
|
||||
}*/
|
||||
|
||||
|
||||
@ApiOperation(value = "获取当前登录用户接口")
|
||||
@GetMapping
|
||||
public R<Member> getUserInfo() {
|
||||
return R.ok(memberService.getUserInfo());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "通过短信重置密码")
|
||||
|
||||
@ApiImplicitParams({
|
||||
|
||||
@ApiImplicitParam(name = "mobile", value = "手机号", required = true, paramType = "query"),
|
||||
|
||||
@ApiImplicitParam(name = "password", value = "是否保存登录", required = true, paramType = "query")
|
||||
|
||||
})
|
||||
|
||||
@PostMapping("/resetByMobile")
|
||||
|
||||
public R<Member> resetByMobile(@NotNull(message = "手机号为空") @RequestParam String mobile,
|
||||
|
||||
@NotNull(message = "验证码为空") @RequestParam String code,
|
||||
|
||||
@RequestHeader String uuid) {
|
||||
|
||||
//校验短信验证码是否正确
|
||||
|
||||
if (smsUtil.verifyCode(mobile, VerificationEnums.FIND_USER, uuid, code)) {
|
||||
|
||||
//校验是否通过手机号可获取会员,存在则将会员信息存入缓存,有效时间3分钟
|
||||
|
||||
memberService.findByMobile(uuid, mobile);
|
||||
|
||||
return R.ok();
|
||||
|
||||
} else {
|
||||
|
||||
throw new ServiceException(ResultCode.VERIFICATION_SMS_CHECKED_ERROR);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "修改密码")
|
||||
|
||||
@ApiImplicitParams({
|
||||
|
||||
@ApiImplicitParam(name = "mobile", value = "手机号", required = true, paramType = "query"),
|
||||
|
||||
@ApiImplicitParam(name = "password", value = "是否保存登录", required = true, paramType = "query")
|
||||
|
||||
})
|
||||
|
||||
@PostMapping("/resetPassword")
|
||||
|
||||
public R<Object> resetByMobile(@NotNull(message = "密码为空") @RequestParam String password, @RequestHeader String uuid) {
|
||||
|
||||
|
||||
|
||||
return R.ok(memberService.resetByMobile(uuid, password));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "修改用户自己资料")
|
||||
|
||||
@PutMapping("/editOwn")
|
||||
|
||||
public R<Member> editOwn(MemberEditDTO memberEditDTO) {
|
||||
|
||||
|
||||
|
||||
return R.ok(memberService.editOwn(memberEditDTO));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "修改密码")
|
||||
|
||||
@ApiImplicitParams({
|
||||
|
||||
@ApiImplicitParam(name = "password", value = "旧密码", required = true, paramType = "query"),
|
||||
|
||||
@ApiImplicitParam(name = "newPassword", value = "新密码", required = true, paramType = "query")
|
||||
|
||||
})
|
||||
|
||||
@PutMapping("/modifyPass")
|
||||
|
||||
public R<Member> modifyPass(@NotNull(message = "旧密码不能为空") @RequestParam String password,
|
||||
|
||||
@NotNull(message = "新密码不能为空") @RequestParam String newPassword) {
|
||||
|
||||
return R.ok(memberService.modifyPass(password, newPassword));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "刷新token")
|
||||
|
||||
@GetMapping("/refresh/{refreshToken}")
|
||||
|
||||
public R<Object> refreshToken(@NotNull(message = "刷新token不能为空") @PathVariable String refreshToken) {
|
||||
|
||||
return R.ok(this.memberService.refreshToken(refreshToken));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "获取当前登录用户的IM信息")
|
||||
@GetMapping("/im-info")
|
||||
public R<Map<String, Object>> getImInfo() {
|
||||
// 获取当前登录用户
|
||||
Member member = memberService.getUserInfo();
|
||||
if (member == null) {
|
||||
throw new ServiceException(ResultCode.USER_NOT_LOGIN);
|
||||
}
|
||||
|
||||
// 生成 UserSig
|
||||
TLSSigAPIv2 tlsSigAPIv2 = new TLSSigAPIv2(SDKAPPID, SECRETKEY);
|
||||
long expire = TimeUnit.DAYS.toSeconds(365 * 50); // 设置为 50 年
|
||||
String userSig = tlsSigAPIv2.genUserSig(member.getPhoneEncrypted(), expire);
|
||||
|
||||
// 构建返回数据
|
||||
Map<String, Object> imInfo = new HashMap<>();
|
||||
imInfo.put("sdkAppId", SDKAPPID);
|
||||
imInfo.put("userID", member.getPhoneEncrypted());
|
||||
imInfo.put("userSig", userSig);
|
||||
imInfo.put("nickName", member.getNickname());
|
||||
imInfo.put("faceUrl", member.getAvatar() != null ? member.getAvatar() : "http://www.qq.com");
|
||||
|
||||
return R.ok(imInfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,67 +0,0 @@
|
||||
package com.wzj.soopin.auth.domain.bo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* Token 实体类
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0 2020-11-13 10:02
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Token {
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 访问token
|
||||
*/
|
||||
private String accessToken;
|
||||
|
||||
/**
|
||||
* 刷新token
|
||||
*/
|
||||
private String refreshToken;
|
||||
|
||||
/**
|
||||
* 认证用户信息
|
||||
*/
|
||||
private Object authUser;
|
||||
|
||||
/**
|
||||
* 短视频系统账号信息
|
||||
*/
|
||||
private String tikUser;
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*
|
||||
* @param accessToken 访问token
|
||||
* @param refreshToken 刷新token
|
||||
*/
|
||||
public Token(String accessToken, String refreshToken) {
|
||||
this.accessToken = accessToken;
|
||||
this.refreshToken = refreshToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param accessToken 访问token
|
||||
* @param refreshToken 刷新token
|
||||
* @param authUser 认证用户信息
|
||||
*/
|
||||
public Token(String username, String accessToken, String refreshToken, Object authUser) {
|
||||
this.username = username;
|
||||
this.accessToken = accessToken;
|
||||
this.refreshToken = refreshToken;
|
||||
this.authUser = authUser;
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.wzj.soopin.auth.domain.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 联合登陆授权token
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @since 2020/12/4 23:48
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AuthToken implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2701476618576443366L;
|
||||
|
||||
/**
|
||||
* 第三方token
|
||||
*/
|
||||
private String accessToken;
|
||||
/**
|
||||
* 第三方刷新token
|
||||
*/
|
||||
private String refreshToken;
|
||||
/**
|
||||
* 有效时间
|
||||
*/
|
||||
private int expireIn;
|
||||
/**
|
||||
* 会员id
|
||||
*/
|
||||
private String uid;
|
||||
/**
|
||||
* 联合登录id
|
||||
*/
|
||||
private String unionId;
|
||||
/**
|
||||
* 联合登录openid
|
||||
*/
|
||||
private String openId;
|
||||
/**
|
||||
* 请求码
|
||||
*/
|
||||
private String accessCode;
|
||||
/**
|
||||
* 范围
|
||||
*/
|
||||
private String scope;
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package com.wzj.soopin.auth.enums;
|
||||
|
||||
/**
|
||||
* token角色类型
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* @since 2020/8/18 15:23
|
||||
*/
|
||||
public enum UserEnums {
|
||||
/**
|
||||
* 角色
|
||||
*/
|
||||
MEMBER("会员"),
|
||||
STORE("商家"),
|
||||
MANAGER("管理员"),
|
||||
SYSTEM("系统");
|
||||
private final String role;
|
||||
|
||||
UserEnums(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
package com.wzj.soopin.auth.security;
|
||||
|
||||
import cn.hutool.jwt.Claims;
|
||||
import com.google.gson.Gson;
|
||||
import com.wzj.soopin.auth.enums.SecurityEnum;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.dromara.common.core.constant.ResultCode;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.redis.redis.RedisCache;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
|
||||
/**
|
||||
* 用户上下文
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @since 2020/11/14 20:27
|
||||
*/
|
||||
public class UserContext {
|
||||
|
||||
/**
|
||||
* 根据request获取用户信息
|
||||
*
|
||||
* @return 授权用户
|
||||
*/
|
||||
// public static AuthUser getCurrentUser() {
|
||||
// if (RequestContextHolder.getRequestAttributes() != null) {
|
||||
// HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
// String accessToken = request.getHeader(SecurityEnum.HEADER_TOKEN.getValue());
|
||||
// return getAuthUser(accessToken);
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 根据request获取用户信息
|
||||
*
|
||||
* @return 授权用户
|
||||
*/
|
||||
public static String getUuid() {
|
||||
if (RequestContextHolder.getRequestAttributes() != null) {
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
return request.getHeader(SecurityEnum.UUID.getValue());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * 根据jwt获取token重的用户信息
|
||||
// *
|
||||
// * @param cache 缓存
|
||||
// * @param accessToken token
|
||||
// * @return 授权用户
|
||||
// */
|
||||
// public static AuthUser getAuthUser(RedisCache cache, String accessToken) {
|
||||
// try {
|
||||
// if (cache.keys("*" + accessToken).isEmpty()) {
|
||||
// throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
|
||||
// }
|
||||
// return getAuthUser(accessToken);
|
||||
// } catch (Exception e) {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
public static String getCurrentUserToken() {
|
||||
if (RequestContextHolder.getRequestAttributes() != null) {
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
return request.getHeader(SecurityEnum.HEADER_TOKEN.getValue());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 根据jwt获取token重的用户信息
|
||||
// *
|
||||
// * @param accessToken token
|
||||
// * @return 授权用户
|
||||
// */
|
||||
// public static AuthUser getAuthUser(String accessToken) {
|
||||
// try {
|
||||
// //获取token的信息
|
||||
// Claims claims
|
||||
// = Jwts.parser()
|
||||
// .setSigningKey(SecretKeyUtil.generalKeyByDecoders())
|
||||
// .parseClaimsJws(accessToken).getBody();
|
||||
// //获取存储在claims中的用户信息
|
||||
// String json = claims.get(SecurityEnum.USER_CONTEXT.getValue()).toString();
|
||||
// return new Gson().fromJson(json, AuthUser.class);
|
||||
// } catch (Exception e) {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
}
|
@ -1,295 +0,0 @@
|
||||
package com.wzj.soopin.auth.service;
|
||||
|
||||
|
||||
|
||||
import cn.hutool.json.JSONException;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.wzj.soopin.auth.domain.bo.Token;
|
||||
import com.wzj.soopin.auth.enums.UserEnums;
|
||||
import com.wzj.soopin.auth.vo.MemberSearchVO;
|
||||
import com.wzj.soopin.member.domain.bo.MemberAddDTO;
|
||||
import com.wzj.soopin.member.domain.bo.MemberEditDTO;
|
||||
import com.wzj.soopin.member.domain.po.Member;
|
||||
import com.wzj.soopin.member.domain.vo.MemberVO;
|
||||
import org.dromara.common.core.domain.R;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 会员业务层
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @since 2020-02-25 14:10:16
|
||||
*/
|
||||
public interface IMemberService extends IService<Member> {
|
||||
|
||||
boolean usernameExists(String username); // 确保这个方法在接口中定义
|
||||
|
||||
/**
|
||||
* 获取当前登录的用户信息
|
||||
*
|
||||
* @return 会员信息
|
||||
*/
|
||||
Member getUserInfo();
|
||||
|
||||
/**
|
||||
* 是否可以通过手机获取用户
|
||||
*
|
||||
* @param uuid UUID
|
||||
* @param mobile 手机号
|
||||
* @return 操作状态
|
||||
*/
|
||||
boolean findByMobile(String uuid, String mobile);
|
||||
|
||||
/**
|
||||
* 通过用户名获取用户
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return 会员信息
|
||||
*/
|
||||
Member findByUsername(String username);
|
||||
|
||||
/**
|
||||
* 登录:用户名、密码登录
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param password 密码
|
||||
* @return token
|
||||
*/
|
||||
Token usernameLogin(String username, String password);
|
||||
|
||||
/**
|
||||
* 商家登录:用户名、密码登录
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param password 密码
|
||||
* @return token
|
||||
*/
|
||||
Token usernameStoreLogin(String username, String password);
|
||||
|
||||
/**
|
||||
* 注册:手机号、验证码登录
|
||||
*
|
||||
* @param mobilePhone 手机号
|
||||
* @return token
|
||||
*/
|
||||
Token mobilePhoneLogin(String mobilePhone);
|
||||
|
||||
/**
|
||||
* 修改会员信息
|
||||
*
|
||||
* @param memberEditDTO 会员修改信息
|
||||
* @return 修改后的会员
|
||||
*/
|
||||
Member editOwn(MemberEditDTO memberEditDTO);
|
||||
|
||||
/**
|
||||
* 修改用户密码
|
||||
*
|
||||
* @param oldPassword 旧密码
|
||||
* @param newPassword 新密码
|
||||
* @return 操作结果
|
||||
*/
|
||||
Member modifyPass(String oldPassword, String newPassword);
|
||||
|
||||
/**
|
||||
* 注册会员
|
||||
*
|
||||
* @param userName 会员
|
||||
* @param password 密码
|
||||
* @param mobilePhone mobilePhone
|
||||
* @return 处理结果
|
||||
*/
|
||||
Token register(String userName, String password, String mobilePhone, String userSig);
|
||||
|
||||
/**
|
||||
* 修改当前会员的手机号
|
||||
*
|
||||
* @param mobile 手机号
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean changeMobile(String mobile);
|
||||
|
||||
/**
|
||||
* 通过手机号修改密码
|
||||
*
|
||||
* @param mobile 手机号
|
||||
* @param password 密码
|
||||
* @return
|
||||
*/
|
||||
boolean resetByMobile(String mobile, String password);
|
||||
|
||||
/**
|
||||
* 后台-添加会员
|
||||
*
|
||||
* @param memberAddDTO 会员
|
||||
* @return 会员
|
||||
*/
|
||||
Member addMember(MemberAddDTO memberAddDTO);
|
||||
|
||||
// /**
|
||||
// * 后台-修改会员
|
||||
// *
|
||||
// * @param managerMemberEditDTO 后台修改会员参数
|
||||
// * @return 会员
|
||||
// */
|
||||
// Member updateMember(ManagerMemberEditDTO managerMemberEditDTO);
|
||||
|
||||
/**
|
||||
* 获取会员分页
|
||||
*
|
||||
* @param memberSearchVO 会员搜索VO
|
||||
* @param page 分页
|
||||
* @return 会员分页
|
||||
*/
|
||||
IPage<MemberVO> getMemberPage(MemberSearchVO memberSearchVO, IPage page);
|
||||
|
||||
/**
|
||||
* 一键注册会员
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Token autoRegister();
|
||||
|
||||
// /**
|
||||
// * 一键注册会员
|
||||
// *
|
||||
// * @param authUser 联合登录用户
|
||||
// * @return Token
|
||||
// */
|
||||
// Token autoRegister(ConnectAuthUser authUser);
|
||||
|
||||
/**
|
||||
* 刷新token
|
||||
*
|
||||
* @param refreshToken
|
||||
* @return Token
|
||||
*/
|
||||
Token refreshToken(String refreshToken);
|
||||
|
||||
/**
|
||||
* 刷新token
|
||||
*
|
||||
* @param refreshToken
|
||||
* @return Token
|
||||
*/
|
||||
Token refreshStoreToken(String refreshToken);
|
||||
|
||||
/**
|
||||
* 会员积分变动
|
||||
*
|
||||
* @param point 变动积分
|
||||
* @param type 是否增加积分 INCREASE 增加 REDUCE 扣减
|
||||
* @param memberId 会员id
|
||||
* @param content 变动日志
|
||||
* @return 操作结果
|
||||
*/
|
||||
Boolean updateMemberPoint(Long point, String type, String memberId, String content);
|
||||
|
||||
/**
|
||||
* 更新会员状态
|
||||
*
|
||||
* @param memberIds 会员ID列表
|
||||
* @param disabled 是否禁用
|
||||
* @param banDays 封禁天数,如果为null则永久封禁
|
||||
* @return 操作结果代码
|
||||
*/
|
||||
R updateMemberStatus(List<String> memberIds, Boolean disabled, Integer banDays);
|
||||
|
||||
/**
|
||||
* 根据条件查询会员总数
|
||||
*
|
||||
* @param memberSearchVO
|
||||
* @return 会员总数
|
||||
*/
|
||||
long getMemberNum(MemberSearchVO memberSearchVO);
|
||||
|
||||
/**
|
||||
* 获取指定会员数据
|
||||
*
|
||||
* @param columns 指定获取的列
|
||||
* @param memberIds 会员ids
|
||||
* @return 指定会员数据
|
||||
*/
|
||||
List<Map<String, Object>> listFieldsByMemberIds(String columns, List<String> memberIds);
|
||||
|
||||
/**
|
||||
* 登出
|
||||
*
|
||||
* @param userEnums token角色类型
|
||||
*/
|
||||
void logout(UserEnums userEnums);
|
||||
|
||||
|
||||
/**
|
||||
* 注销账号
|
||||
*
|
||||
* @return 操作结果
|
||||
*/
|
||||
void cancellation();
|
||||
|
||||
/**
|
||||
* 获取所有会员的手机号
|
||||
*
|
||||
* @return 所有会员的手机号
|
||||
*/
|
||||
List<String> getAllMemberMobile();
|
||||
|
||||
/**
|
||||
* 更新会员登录时间为最新时间
|
||||
*
|
||||
* @param memberId 会员id
|
||||
* @return 是否更新成功
|
||||
*/
|
||||
boolean updateMemberLoginTime(String memberId);
|
||||
|
||||
/**
|
||||
* 获取用户VO
|
||||
*
|
||||
* @param id 会员id
|
||||
* @return 用户VO
|
||||
*/
|
||||
MemberVO getMember(String id);
|
||||
|
||||
/**
|
||||
* 注册会员
|
||||
*
|
||||
* @param userName 会员
|
||||
* @param password 密码
|
||||
* @param mobilePhone mobilePhone
|
||||
* @return 处理结果
|
||||
*/
|
||||
Token registerNew(String userName, String password, String mobilePhone, String userSig);
|
||||
|
||||
/**
|
||||
* 登录获取短视频系统账户信息
|
||||
*
|
||||
* @param username
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
Token usernameLoginNew(String username, String password);
|
||||
|
||||
/**
|
||||
* 短信登录获取短视频系统账户信息
|
||||
*
|
||||
* @param mobilePhone
|
||||
* @return
|
||||
*/
|
||||
Token mobilePhoneLoginNew(String mobilePhone) throws JSONException;
|
||||
|
||||
/**
|
||||
* 设置会员为代理人
|
||||
* @param memberId 会员ID
|
||||
* @param region 代理区域编码
|
||||
*/
|
||||
void setMemberAsAgent(String memberId, String region);
|
||||
|
||||
Member updateMemberS(Member member);
|
||||
|
||||
void endsetMemberAsAgent(String memberId, String region);
|
||||
|
||||
void updateRevenueSharingPercentage(String id, String percentage);
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package com.wzj.soopin.auth.service;
|
||||
|
||||
|
||||
import com.wzj.soopin.auth.domain.dto.entity.enums.VerificationEnums;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 验证码模块
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @since 2021/7/9 1:42 上午
|
||||
*/
|
||||
public interface IVerificationService {
|
||||
/**
|
||||
* 获取校验对象
|
||||
*
|
||||
* @param verificationEnums 校验枚举
|
||||
* @param uuid uuid
|
||||
* @return 校验对象
|
||||
* @throws IOException 校验错误
|
||||
*/
|
||||
Map<String, Object> createVerification(VerificationEnums verificationEnums, String uuid);
|
||||
|
||||
/**
|
||||
* 预校验
|
||||
*
|
||||
* @param xPos 位移距离
|
||||
* @param uuid 用户唯一表示
|
||||
* @param verificationEnums 校验枚举
|
||||
* @return
|
||||
*/
|
||||
boolean preCheck(Integer xPos, String uuid, VerificationEnums verificationEnums);
|
||||
|
||||
/**
|
||||
* 验证码校验
|
||||
*
|
||||
* @param uuid 用户唯一表示
|
||||
* @param verificationEnums 校验枚举
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean check(String uuid, VerificationEnums verificationEnums);
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package com.wzj.soopin.auth.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.wzj.soopin.auth.domain.dto.VerificationDTO;
|
||||
import com.wzj.soopin.auth.domain.dto.VerificationSource;
|
||||
import org.dromara.common.core.constant.CachePrefix;
|
||||
|
||||
/**
|
||||
* 验证码资源维护 业务层
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2020/11/17 3:44 下午
|
||||
*/
|
||||
public interface IVerificationSourceService extends IService<VerificationSource> {
|
||||
|
||||
/**
|
||||
* 缓存
|
||||
*/
|
||||
String VERIFICATION_CACHE = CachePrefix.VERIFICATION.getPrefix();
|
||||
|
||||
|
||||
/**
|
||||
* 初始化缓存
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
VerificationDTO initCache();
|
||||
|
||||
/**
|
||||
* 获取验证缓存
|
||||
*
|
||||
* @return 验证码
|
||||
*/
|
||||
VerificationDTO getVerificationCache();
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,228 +0,0 @@
|
||||
package com.wzj.soopin.auth.service.impl;
|
||||
|
||||
|
||||
import com.wzj.soopin.auth.domain.dto.VerificationDTO;
|
||||
import com.wzj.soopin.auth.domain.dto.VerificationSource;
|
||||
import com.wzj.soopin.auth.domain.dto.entity.enums.VerificationEnums;
|
||||
import com.wzj.soopin.auth.service.IVerificationService;
|
||||
import com.wzj.soopin.auth.service.IVerificationSourceService;
|
||||
import com.wzj.soopin.auth.vo.SerializableStream;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.constant.CachePrefix;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.redis.redis.RedisCache;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 认证处理类
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2020-11-17 14:59
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class VerificationServiceImpl {
|
||||
|
||||
@Autowired
|
||||
private IVerificationSourceService verificationSourceService;
|
||||
|
||||
//
|
||||
// @Autowired
|
||||
// private VerificationCodeProperties verificationCodeProperties;
|
||||
//
|
||||
//
|
||||
// @Autowired
|
||||
// private RedisCache cache;
|
||||
//
|
||||
// /**
|
||||
// * 创建校验
|
||||
// *
|
||||
// * @return 验证码参数
|
||||
// */
|
||||
// @Override
|
||||
// public Map<String, Object> createVerification(VerificationEnums verificationEnums, String uuid) {
|
||||
//// if (uuid == null) {
|
||||
//// throw new ServiceException(ResultCode.ILLEGAL_REQUEST_ERROR);
|
||||
//// }
|
||||
//
|
||||
// // 添加日志
|
||||
// log.info("开始生成验证码 - uuid: {}, type: {}", uuid, verificationEnums);
|
||||
//
|
||||
// // 清除可能存在的旧的验证信息
|
||||
// String oldKey = cacheKey(verificationEnums, uuid);
|
||||
// String oldResult = cacheResult(verificationEnums, uuid);
|
||||
// cache.deleteObject(oldKey);
|
||||
// cache.deleteObject(oldResult);
|
||||
// log.info("已清除旧验证码 - oldKey: {}, oldResult: {}", oldKey, oldResult);
|
||||
//
|
||||
// //获取验证码配置
|
||||
// VerificationDTO verificationDTO = verificationSourceService.getVerificationCache();
|
||||
// log.info("获取到验证码配置 - resources: {}, sliders: {}",
|
||||
// verificationDTO.getVerificationResources().size(),
|
||||
// verificationDTO.getVerificationSlider().size());
|
||||
//
|
||||
// List<VerificationSource> verificationResources = verificationDTO.getVerificationResources();
|
||||
// List<VerificationSource> verificationSlider = verificationDTO.getVerificationSlider();
|
||||
//
|
||||
// Random random = new Random();
|
||||
// //随机选择需要切的图下标
|
||||
// int resourceNum = random.nextInt(verificationResources.size());
|
||||
// //随机选择剪切模版下标
|
||||
// int sliderNum = random.nextInt(verificationSlider.size());
|
||||
//
|
||||
// //随机选择需要切的图片地址
|
||||
// String originalResource = verificationResources.get(resourceNum).getResource();
|
||||
// //随机选择剪切模版图片地址
|
||||
// String sliderResource = verificationSlider.get(sliderNum).getResource();
|
||||
// // 干扰块
|
||||
// String interfereResource = verificationSlider.get(sliderNum == verificationSlider.size() - 1 ?
|
||||
// sliderNum - 1 : sliderNum + 1).getResource();
|
||||
//
|
||||
// try {
|
||||
// //获取缓存中的资源
|
||||
// SerializableStream originalFile = getInputStream(originalResource);
|
||||
// SerializableStream sliderFile = getInputStream(sliderResource);
|
||||
// SerializableStream interfereSliderFile = verificationCodeProperties.getInterfereNum() > 0 ? getInputStream(interfereResource) : null;
|
||||
// //生成数据
|
||||
// Map<String, Object> resultMap = SliderImageUtil.pictureTemplatesCut(
|
||||
// sliderFile, interfereSliderFile, originalFile,
|
||||
// verificationCodeProperties.getWatermark(), verificationCodeProperties.getInterfereNum());
|
||||
//
|
||||
// // 延长缓存时间到5分钟
|
||||
// int effectiveTime = (int) Math.max(verificationCodeProperties.getEffectiveTime(), 1000);
|
||||
//
|
||||
// //生成验证参数
|
||||
// String cacheKeyStr = cacheKey(verificationEnums, uuid);
|
||||
// Object randomX = resultMap.get("randomX");
|
||||
// cache.setCacheObject(cacheKeyStr, randomX, effectiveTime, TimeUnit.MILLISECONDS);
|
||||
//
|
||||
// // 添加详细日志
|
||||
// log.info("验证码生成成功 - Key: {}, RandomX: {}, EffectiveTime: {}, ConfigTime: {}",
|
||||
// cacheKeyStr, randomX, effectiveTime, verificationCodeProperties.getEffectiveTime());
|
||||
//
|
||||
// // 验证缓存是否写入成功
|
||||
// Object cachedValue = cache.getCacheObject(cacheKeyStr);
|
||||
// log.info("缓存写入验证 - Key: {}, CachedValue: {}", cacheKeyStr, cachedValue);
|
||||
//
|
||||
// resultMap.put("key", cacheKeyStr);
|
||||
// resultMap.put("effectiveTime", effectiveTime);
|
||||
// resultMap.remove("randomX");
|
||||
// return resultMap;
|
||||
// } catch (ServiceException e) {
|
||||
// log.error("验证码生成服务异常 - \"uuid\": {}, type: {}", uuid, verificationEnums, e);
|
||||
// throw e;
|
||||
// } catch (Exception e) {
|
||||
// log.error("验证码生成异常 - uuid: {}, type: {}", uuid, verificationEnums, e);
|
||||
// throw new ServiceException(ResultCode.ERROR);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 根据网络地址,获取源文件
|
||||
// * 这里简单说一下,这里是将不可序列化的inputstream序列化对象,存入redis缓存
|
||||
// *
|
||||
// * @param originalResource
|
||||
// * @return
|
||||
// */
|
||||
// private SerializableStream getInputStream(String originalResource) throws Exception {
|
||||
//
|
||||
// Object object = cache.get(CachePrefix.VERIFICATION_IMAGE.getPrefix() + originalResource);
|
||||
// if (object != null) {
|
||||
// return (SerializableStream) object;
|
||||
// }
|
||||
// if (StringUtils.isNotEmpty(originalResource)) {
|
||||
// URL url = new URL(originalResource);
|
||||
// InputStream inputStream = url.openStream();
|
||||
// SerializableStream serializableStream = new SerializableStream(inputStream);
|
||||
// cache.put(CachePrefix.VERIFICATION_IMAGE.getPrefix() + originalResource, serializableStream);
|
||||
// return serializableStream;
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 预校验图片 用于前端回显
|
||||
// *
|
||||
// * @param xPos X轴移动距离
|
||||
// * @param verificationEnums 验证key
|
||||
// * @return 验证是否成功
|
||||
// */
|
||||
// @Override
|
||||
// public boolean preCheck(Integer xPos, String uuid, VerificationEnums verificationEnums) {
|
||||
// String key = cacheKey(verificationEnums, uuid);
|
||||
// Integer randomX = (Integer) cache.get(key);
|
||||
//
|
||||
// // 添加调试日志
|
||||
// log.debug("验证码预校验 - Key: {}, ExpectedPos: {}, ActualPos: {}", key, randomX, xPos);
|
||||
//
|
||||
// if (randomX == null) {
|
||||
// log.warn("验证码已过期或不存在 - Key: {}", key);
|
||||
// throw new ServiceException(ResultCode.VERIFICATION_CODE_INVALID);
|
||||
// }
|
||||
//
|
||||
// //验证结果正确 && 删除标记成功
|
||||
// if (Math.abs(randomX - xPos) < verificationCodeProperties.getFaultTolerant()) {
|
||||
// String resultKey = cacheResult(verificationEnums, uuid);
|
||||
// // 设置验证结果的有效期为60秒
|
||||
// cache.put(resultKey, true, 6000L);
|
||||
// cache.remove(key);
|
||||
// log.debug("验证码校验成功 - Key: {}, ResultKey: {}", key, resultKey);
|
||||
// return true;
|
||||
// }
|
||||
// createVerification(verificationEnums, uuid);
|
||||
// log.debug("验证码校验失败 - Key: {}, 误差: {}", key, Math.abs(randomX - xPos));
|
||||
// throw new ServiceException(ResultCode.VERIFICATION_ERROR);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 验证码校验
|
||||
// *
|
||||
// * @param uuid 用户标识
|
||||
// * @param verificationEnums 验证key
|
||||
// * @return 验证是否成功
|
||||
// */
|
||||
// @Override
|
||||
// public boolean check(String uuid, VerificationEnums verificationEnums) {
|
||||
// String resultKey = cacheResult(verificationEnums, uuid);
|
||||
// Boolean result = (Boolean) cache.get(resultKey);
|
||||
//
|
||||
// // 添加调试日志
|
||||
// log.debug("验证结果检查 - Key: {}, Result: {}", resultKey, result);
|
||||
//
|
||||
// if (Boolean.TRUE.equals(result)) {
|
||||
// // 验证通过后,立即删除验证结果,防止重复使用
|
||||
// cache.remove(resultKey);
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// // 如果验证结果不存在或已过期,抛出异常
|
||||
// log.warn("验证码已失效 - Key: {}", resultKey);
|
||||
// throw new ServiceException(ResultCode.VERIFICATION_CODE_INVALID);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 生成缓存key 记录缓存需要验证的内容
|
||||
*/
|
||||
public static String cacheKey(VerificationEnums verificationEnums, String uuid) {
|
||||
return CachePrefix.VERIFICATION_KEY.getPrefix() + verificationEnums.name() + "_" + "wzj666";
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成缓存key 记录缓存验证的结果
|
||||
*/
|
||||
public static String cacheResult(VerificationEnums verificationEnums, String uuid) {
|
||||
return CachePrefix.VERIFICATION_RESULT.getPrefix() + verificationEnums.name() + "_" + "wzj666";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,56 +0,0 @@
|
||||
package com.wzj.soopin.auth.service.impl;
|
||||
|
||||
import com.wzj.soopin.auth.domain.dto.VerificationDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 验证码资源维护 业务层实现
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2020/11/17 3:48 下午
|
||||
*/
|
||||
@Service
|
||||
public class VerificationSourceServiceImpl
|
||||
// extends ServiceImpl<VerificationSourceMapper, VerificationSource> implements VerificationSourceService
|
||||
{
|
||||
|
||||
// @Autowired
|
||||
// private Cache<VerificationDTO> cache;
|
||||
//
|
||||
// @Override
|
||||
// public VerificationDTO initCache() {
|
||||
// List<VerificationSource> dbList = this.list();
|
||||
// List<VerificationSource> resourceList = new ArrayList<>();
|
||||
// List<VerificationSource> sliderList = new ArrayList<>();
|
||||
// for (VerificationSource item : dbList) {
|
||||
// if (item.getType().equals(VerificationSourceEnum.RESOURCE.name())) {
|
||||
// resourceList.add(item);
|
||||
// } else if (item.getType().equals(VerificationSourceEnum.SLIDER.name())) {
|
||||
// sliderList.add(item);
|
||||
// }
|
||||
// }
|
||||
// VerificationDTO verificationDTO = new VerificationDTO();
|
||||
// verificationDTO.setVerificationResources(resourceList);
|
||||
// verificationDTO.setVerificationSlider(sliderList);
|
||||
// cache.put(VERIFICATION_CACHE, verificationDTO);
|
||||
// return verificationDTO;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public VerificationDTO getVerificationCache() {
|
||||
// VerificationDTO verificationDTO;
|
||||
// try {
|
||||
// verificationDTO = cache.get(VERIFICATION_CACHE);
|
||||
// } catch (ClassCastException cce) {
|
||||
// verificationDTO = null;
|
||||
// }
|
||||
// if (verificationDTO == null) {
|
||||
// return initCache();
|
||||
// }
|
||||
// return verificationDTO;
|
||||
// }
|
||||
}
|
@ -1,127 +0,0 @@
|
||||
package com.wzj.soopin.auth.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Base64;
|
||||
import java.util.Base64.Decoder;
|
||||
|
||||
/**
|
||||
* base64转为multipartFile工具类
|
||||
*
|
||||
* @author Chopper
|
||||
*/
|
||||
@Slf4j
|
||||
public class Base64DecodeMultipartFile implements MultipartFile {
|
||||
|
||||
private final byte[] imgContent;
|
||||
private final String header;
|
||||
|
||||
public Base64DecodeMultipartFile(byte[] imgContent, String header) {
|
||||
this.imgContent = imgContent;
|
||||
this.header = header.split(";")[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return System.currentTimeMillis() + Math.random() + "." + header.split("/")[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOriginalFilename() {
|
||||
return System.currentTimeMillis() + (int) Math.random() * 10000 + "." + header.split("/")[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return header.split(":")[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return imgContent == null || imgContent.length == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize() {
|
||||
return imgContent.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
return imgContent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() {
|
||||
return new ByteArrayInputStream(imgContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferTo(File dest) throws IOException, IllegalStateException {
|
||||
OutputStream stream = null;
|
||||
try {
|
||||
stream = new FileOutputStream(dest);
|
||||
stream.write(imgContent);
|
||||
} catch (IOException e) {
|
||||
log.error("transferTo错误", e);
|
||||
} finally {
|
||||
assert stream != null;
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static MultipartFile base64Convert(String base64) {
|
||||
|
||||
String[] baseStrs = base64.split(",");
|
||||
Decoder decoder = Base64.getDecoder();
|
||||
byte[] b = decoder.decode(baseStrs[1]);
|
||||
|
||||
for (int i = 0; i < b.length; ++i) {
|
||||
if (b[i] < 0) {
|
||||
b[i] += 256;
|
||||
}
|
||||
}
|
||||
return new Base64DecodeMultipartFile(b, baseStrs[0]);
|
||||
}
|
||||
|
||||
|
||||
public static InputStream base64ToInputStream(String base64) {
|
||||
ByteArrayInputStream stream = null;
|
||||
try {
|
||||
byte[] bytes = Base64.getDecoder().decode(base64);
|
||||
stream = new ByteArrayInputStream(bytes);
|
||||
} catch (Exception e) {
|
||||
log.error("base64ToInputStream错误", e);
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
public static String inputStreamToStream(InputStream in) {
|
||||
byte[] data = null;
|
||||
//读取图片字节数组
|
||||
try {
|
||||
ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
|
||||
byte[] buff = new byte[100];
|
||||
int rc = 0;
|
||||
while ((rc = in.read(buff, 0, 100)) > 0) {
|
||||
swapStream.write(buff, 0, rc);
|
||||
}
|
||||
data = swapStream.toByteArray();
|
||||
} catch (IOException e) {
|
||||
log.error("转码错误", e);
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
log.error("inputStreamToStream错误", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Base64.getEncoder().encodeToString(data);
|
||||
}
|
||||
}
|
||||
|
@ -1,59 +0,0 @@
|
||||
package com.wzj.soopin.auth.util;
|
||||
|
||||
|
||||
import com.wzj.soopin.auth.domain.dto.entity.enums.VerificationEnums;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 短信接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @since 2020/11/30 15:44
|
||||
*/
|
||||
public interface SmsUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 验证码发送
|
||||
*
|
||||
* @param mobile 手机号
|
||||
* @param verificationEnums 验证码场景
|
||||
* @param uuid 用户标识uuid
|
||||
*/
|
||||
void sendSmsCode(String mobile, VerificationEnums verificationEnums, String uuid);
|
||||
|
||||
/**
|
||||
* 验证码验证
|
||||
*
|
||||
* @param mobile 手机号
|
||||
* @param verificationEnums 验证码场景
|
||||
* @param uuid 用户标识uuid
|
||||
* @param code 待验证code
|
||||
* @return 操作状态
|
||||
*/
|
||||
boolean verifyCode(String mobile, VerificationEnums verificationEnums, String uuid, String code);
|
||||
|
||||
/**
|
||||
* 短信发送
|
||||
*
|
||||
* @param mobile 接收手机号
|
||||
* @param param 参数
|
||||
* @param templateCode 模版code
|
||||
* @param signName 签名名称
|
||||
*/
|
||||
void sendSmsCode(String signName, String mobile, Map<String, String> param, String templateCode);
|
||||
|
||||
/**
|
||||
* 短信批量发送
|
||||
*
|
||||
* @param mobile 接收手机号
|
||||
* @param signName 签名
|
||||
* @param templateCode 模版code
|
||||
*/
|
||||
void sendBatchSms(String signName, List<String> mobile, String templateCode);
|
||||
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package com.wzj.soopin.auth.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 会员搜索VO
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @since 2020/12/15 10:48
|
||||
*/
|
||||
@Data
|
||||
public class MemberSearchVO {
|
||||
|
||||
@ApiModelProperty(value = "用户名")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty(value = "昵称")
|
||||
private String nickName;
|
||||
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty(value = "专家标识")
|
||||
private Integer exper;
|
||||
|
||||
@ApiModelProperty(value = "代理标识")
|
||||
private Integer agent;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ApiModelProperty(value = "会员状态")
|
||||
private String disabled;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package com.wzj.soopin.auth.vo;
|
||||
|
||||
import com.wzj.soopin.auth.util.Base64DecodeMultipartFile;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* 序列化的input stream
|
||||
*
|
||||
* @author Chopper
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class SerializableStream {
|
||||
private String base64;
|
||||
|
||||
public SerializableStream(InputStream inputStream) {
|
||||
this.base64 = Base64DecodeMultipartFile.inputStreamToStream(inputStream);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,24 +1,29 @@
|
||||
package com.wzj.soopin.member.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.wzj.soopin.member.convert.FeedbackConvert;
|
||||
import com.wzj.soopin.member.domain.po.Feedback;
|
||||
import com.wzj.soopin.member.convert.MemberAccountConvert;
|
||||
import com.wzj.soopin.member.domain.bo.FeedbackBO;
|
||||
import com.wzj.soopin.member.domain.po.Feedback;
|
||||
import com.wzj.soopin.member.domain.po.MemberAccount;
|
||||
import com.wzj.soopin.member.domain.vo.FeedbackVO;
|
||||
import com.wzj.soopin.member.service.IFeedbackService;
|
||||
import com.wzj.soopin.member.service.IMemberAccountService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 意见反馈Controller
|
||||
*
|
||||
@ -28,33 +33,42 @@ import java.util.List;
|
||||
@Api(description ="意见反馈接口列表")
|
||||
@RestController
|
||||
@RequestMapping("/ums/feedback")
|
||||
public class FeedbackController extends BaseController {
|
||||
@Autowired
|
||||
private IFeedbackService service;
|
||||
@Autowired
|
||||
private FeedbackConvert convert;
|
||||
@RequiredArgsConstructor
|
||||
public class FeedbackController {
|
||||
|
||||
// @ApiOperation("查询意见反馈列表")
|
||||
// @PostMapping("/list")
|
||||
// public ResponseEntity<IPage<FeedbackVO>> list(@RequestBody FeedbackBO query, IPage page) {
|
||||
// service.page(page,query.toWrapper());
|
||||
// return ResponseEntity.ok(new PageImpl<>(list, page, ((com.github.pagehelper.Page)list).getTotal()));
|
||||
// }
|
||||
private final IFeedbackService service;
|
||||
private final FeedbackConvert convert;
|
||||
|
||||
|
||||
// @ApiOperation("修改意见反馈备注信息")
|
||||
// @Log(title = "意见反馈", businessType = BusinessType.UPDATE)
|
||||
// @PostMapping("/mark/update")
|
||||
// public ResponseEntity<Integer> editMark(@RequestBody Feedback feedback) {
|
||||
// return ResponseEntity.ok(service.updateMark(feedback));
|
||||
// }
|
||||
@ApiOperation("查询意见反馈列表")
|
||||
@PostMapping("/list")
|
||||
public R<IPage<FeedbackVO>> list(@RequestBody FeedbackBO query, Page page) {
|
||||
Page<Feedback> feedBackPage= (Page<Feedback>)service.page(page,query.toWrapper());
|
||||
return R.ok(convert.toVO( feedBackPage));
|
||||
}
|
||||
|
||||
// @ApiOperation(("修改状态"))
|
||||
// @Log(title = "意见反馈", businessType = BusinessType.UPDATE)
|
||||
// @PostMapping("/handle/status/change")
|
||||
// public ResponseEntity<Integer> changeStatus(@RequestBody Feedback dto){
|
||||
// return ResponseEntity.ok(service.changeStatus(dto));
|
||||
// }
|
||||
|
||||
@ApiOperation("修改意见反馈备注信息")
|
||||
@Log(title = "意见反馈", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
public R editMark(@RequestBody FeedbackBO feedback) {
|
||||
return R.ok(service.save(convert.toPo(feedback)));
|
||||
}
|
||||
|
||||
@ApiOperation("修改意见反馈备注信息")
|
||||
@Log(title = "新增意见反馈", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/add")
|
||||
public R add(@RequestBody FeedbackBO feedback) {
|
||||
return R.ok(service.save(convert.toPo(feedback)));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(("修改状态"))
|
||||
@Log(title = "意见反馈", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/handle/status/change")
|
||||
public R changeStatus(@RequestBody FeedbackBO bo){
|
||||
return R.ok(service.updateById(convert.toPo(bo)));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("删除意见反馈")
|
||||
|
@ -1,18 +1,20 @@
|
||||
package com.wzj.soopin.member.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.wzj.soopin.member.convert.MemberAccountConvert;
|
||||
import com.wzj.soopin.member.domain.po.MemberAccount;
|
||||
import com.wzj.soopin.member.domain.bo.MemberAccountQuery;
|
||||
import com.wzj.soopin.member.domain.bo.MemberAccountBO;
|
||||
import com.wzj.soopin.member.domain.vo.MemberAccountVO;
|
||||
import com.wzj.soopin.member.service.IMemberAccountService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -26,27 +28,27 @@ import java.util.List;
|
||||
@Api(description ="会员账户表接口列表")
|
||||
@RestController
|
||||
@RequestMapping("/ums/memberAccount")
|
||||
@RequiredArgsConstructor
|
||||
public class MemberAccountController {
|
||||
@Autowired
|
||||
private IMemberAccountService service;
|
||||
@Autowired
|
||||
private MemberAccountConvert convert;
|
||||
|
||||
// @ApiOperation("查询会员账户表列表")
|
||||
// @PostMapping("/list")
|
||||
// public ResponseEntity<Page<MemberAccount>> list(@RequestBody MemberAccountQuery query, Pageable page) {
|
||||
// List<MemberAccount> list = service.selectList(query, page);
|
||||
// return ResponseEntity.ok(new PageImpl<>(list, page, ((com.github.pagehelper.Page)list).getTotal()));
|
||||
// }
|
||||
private final IMemberAccountService service;
|
||||
private final MemberAccountConvert convert;
|
||||
|
||||
// @ApiOperation("导出会员账户表列表")
|
||||
// @Log(title = "会员账户表", businessType = BusinessType.EXPORT)
|
||||
// @GetMapping("/export")
|
||||
// public ResponseEntity<String> export(MemberAccountBO query) {
|
||||
// List<MemberAccount> list = service.selectList(query);
|
||||
// ExcelUtil<MemberAccountVO> util = new ExcelUtil<>(MemberAccountVO.class);
|
||||
// return ResponseEntity.ok(util.writeExcel(convert.dos2vos(list), "会员账户表数据"));
|
||||
// }
|
||||
@ApiOperation("查询会员账户表列表")
|
||||
@PostMapping("/list")
|
||||
public R<IPage<MemberAccountVO>> list(@RequestBody MemberAccountBO query, IPage page) {
|
||||
Page<MemberAccount> list = (Page<MemberAccount>) service.page(page,query.toWrapper() );
|
||||
return R.ok(convert.toVO(list));
|
||||
}
|
||||
|
||||
@ApiOperation("导出会员账户表列表")
|
||||
@Log(title = "会员账户表", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public ResponseEntity<String> export(MemberAccountBO query) {
|
||||
List<MemberAccount> list = service.list(query.toWrapper());
|
||||
ExcelUtil<MemberAccountVO> util = new ExcelUtil<>(MemberAccountVO.class);
|
||||
return ResponseEntity.ok(util.writeExcel(convert.toVO(list), "会员账户表数据"));
|
||||
}
|
||||
|
||||
@ApiOperation("获取会员账户表详细信息")
|
||||
@GetMapping(value = "/{memberId}")
|
||||
@ -57,15 +59,15 @@ public class MemberAccountController {
|
||||
@ApiOperation("新增会员账户表")
|
||||
@Log(title = "会员账户表", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public ResponseEntity<Object> add(@RequestBody MemberAccount memberAccount) {
|
||||
return ResponseEntity.ok(service.save(memberAccount));
|
||||
public ResponseEntity<Object> add(@RequestBody MemberAccountBO memberAccount) {
|
||||
return ResponseEntity.ok(service.save(convert.toPo(memberAccount)));
|
||||
}
|
||||
|
||||
@ApiOperation("修改会员账户表")
|
||||
@Log(title = "会员账户表", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public ResponseEntity<Object> edit(@RequestBody MemberAccount memberAccount) {
|
||||
return ResponseEntity.ok(service.updateById(memberAccount));
|
||||
public ResponseEntity<Object> edit(@RequestBody MemberAccountBO memberAccount) {
|
||||
return ResponseEntity.ok(service.updateById(convert.toPo(memberAccount)));
|
||||
}
|
||||
|
||||
@ApiOperation("删除会员账户表")
|
||||
|
@ -10,7 +10,9 @@ import com.wzj.soopin.member.domain.vo.MemberAddressVO;
|
||||
import com.wzj.soopin.member.service.IMemberAddressService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -30,27 +32,27 @@ import java.util.List;
|
||||
@Api(description ="会员收货地址接口列表")
|
||||
@RestController
|
||||
@RequestMapping("/ums/memberAddress")
|
||||
@RequiredArgsConstructor
|
||||
public class MemberAddressController {
|
||||
@Autowired
|
||||
private IMemberAddressService service;
|
||||
@Autowired
|
||||
private MemberAddressConvert convert;
|
||||
|
||||
private final IMemberAddressService service;
|
||||
|
||||
private final MemberAddressConvert convert;
|
||||
|
||||
@ApiOperation("查询会员收货地址列表")
|
||||
@PostMapping("/list")
|
||||
public R list(@RequestBody MemberAddressBO query, IPage page) {
|
||||
IPage<MemberAddress> list = service.page(page,query.toWrapper());
|
||||
return R.ok(convert.convertToVO(list));
|
||||
Page<MemberAddress> list =(Page<MemberAddress> ) service.page(page,query.toWrapper());
|
||||
return R.ok(convert.toVO(list));
|
||||
}
|
||||
|
||||
@ApiOperation("导出会员收货地址列表")
|
||||
@Log(title = "会员收货地址", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public ResponseEntity<String> export(MemberAddressBO query) {
|
||||
// List<MemberAddressV> list = service.selectList(query, null);
|
||||
// ExcelUtil<MemberAddressVO> util = new ExcelUtil<>(MemberAddressVO.class);
|
||||
// return ResponseEntity.ok(util.writeExcel(convert.dos2vos(list), "会员收货地址数据"));
|
||||
return null;
|
||||
List<MemberAddress> list = service.list(query.toWrapper());
|
||||
ExcelUtil<MemberAddressVO> util = new ExcelUtil<>(MemberAddressVO.class);
|
||||
return ResponseEntity.ok(util.writeExcel(convert.toVO(list), "会员收货地址数据"));
|
||||
}
|
||||
|
||||
@ApiOperation("获取会员收货地址详细信息")
|
||||
|
@ -7,9 +7,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.wzj.soopin.member.convert.MemberCartConvert;
|
||||
import com.wzj.soopin.member.domain.po.MemberCart;
|
||||
import com.wzj.soopin.member.domain.bo.MemberCartBO;
|
||||
import com.wzj.soopin.member.domain.vo.MemberCartVO;
|
||||
import com.wzj.soopin.member.service.IMemberCartService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
@ -35,12 +37,9 @@ public class MemberCartController extends BaseController {
|
||||
|
||||
@ApiOperation("查询购物车列表")
|
||||
@PostMapping("/list")
|
||||
public ResponseEntity<Object> list(@RequestBody MemberCartBO query, Pageable page) {
|
||||
IPage<MemberCart> poPage=new Page<MemberCart>();
|
||||
poPage.setSize(page.getPageSize());
|
||||
poPage.setCurrent(page.getPageNumber());
|
||||
IPage<MemberCart> userPage=service.page(poPage,new QueryWrapper<MemberCart>());
|
||||
return ResponseEntity.ok(convert.convertToVO(poPage));
|
||||
public R<Page<MemberCartVO>> list(@RequestBody MemberCartBO query, IPage page) {
|
||||
Page<MemberCart> userPage=(Page<MemberCart>) service.page(page,new QueryWrapper<MemberCart>());
|
||||
return R.ok(convert.toVO(userPage));
|
||||
}
|
||||
|
||||
@ApiOperation("导出购物车列表")
|
||||
|
@ -3,12 +3,13 @@ package com.wzj.soopin.member.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.wzj.soopin.member.convert.MemberConvert;
|
||||
import com.wzj.soopin.member.domain.bo.MemberBO;
|
||||
import com.wzj.soopin.member.domain.form.ChangeMemberStatusForm;
|
||||
import com.wzj.soopin.member.domain.po.Member;
|
||||
import com.wzj.soopin.member.domain.vo.MemberVO;
|
||||
import com.wzj.soopin.member.service.IMemberCrudService;
|
||||
import com.wzj.soopin.member.service.IMemberService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.dromara.common.core.domain.R;
|
||||
@ -29,39 +30,36 @@ import java.util.List;
|
||||
* @date 2022-11-28
|
||||
*/
|
||||
@Api(description ="会员信息接口列表")
|
||||
@RequestMapping("/ums/member/")
|
||||
@RestController
|
||||
public class MemberController extends BaseController {
|
||||
@Autowired
|
||||
private IMemberCrudService service;
|
||||
private IMemberService service;
|
||||
@Autowired
|
||||
private MemberConvert convert;
|
||||
|
||||
// @RequestMapping(path ={"/ums/member/wechat/code","/h5/member/wechat/code","/no-auth/wechat/code"},method=RequestMethod.GET)
|
||||
// public R getWechatCode(@RequestParam(required = false) String scene) {
|
||||
// return R.ok(wechatAuthService.getQRCode(scene));
|
||||
// }
|
||||
|
||||
@ApiOperation("查询会员信息列表")
|
||||
@SaCheckPermission("ums:member:list")
|
||||
@PostMapping("/ums/member/list")
|
||||
public TableDataInfo<MemberVO> list(@RequestBody MemberBO bo, IPage<Member> page) {
|
||||
IPage<Member> memberPage = service.page(page,bo.toWapper());
|
||||
return convert.convertToVO(memberPage);
|
||||
@PostMapping("list")
|
||||
public R<Page<MemberVO>> list(@RequestBody MemberBO bo, Page<Member> page) {
|
||||
Page<Member> memberPage = service.page(page,bo.toWapper());
|
||||
return R.ok(convert.toVO(memberPage));
|
||||
}
|
||||
|
||||
@ApiOperation("导出会员信息列表")
|
||||
@SaCheckPermission("ums:member:export")
|
||||
@Log(title = "会员信息", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/ums/member/export")
|
||||
@GetMapping("export")
|
||||
public ResponseEntity<String> export(MemberBO query) {
|
||||
List<Member> list = service.list(query.toWapper());
|
||||
ExcelUtil<MemberVO> util = new ExcelUtil<>(MemberVO.class);
|
||||
return ResponseEntity.ok(util.writeExcel(convert.convertToVO(list), "会员信息数据"));
|
||||
return ResponseEntity.ok(util.writeExcel(convert.toVO(list), "会员信息数据"));
|
||||
}
|
||||
|
||||
@ApiOperation("获取会员信息详细信息")
|
||||
@SaCheckPermission("ums:member:query")
|
||||
@GetMapping(value = "/ums/member/{id}")
|
||||
@GetMapping(value = "{id}")
|
||||
public ResponseEntity<Member> getInfo(@PathVariable("id") Long id) {
|
||||
return ResponseEntity.ok(service.getById(id));
|
||||
}
|
||||
@ -71,7 +69,7 @@ public class MemberController extends BaseController {
|
||||
@Log(title = "会员信息", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/ums/member")
|
||||
public R add(@RequestBody MemberBO member) {
|
||||
return R.ok(service.save(convert.convertToPo(member)));
|
||||
return R.ok(service.save(convert.toPo(member)));
|
||||
}
|
||||
|
||||
@ApiOperation("修改会员信息")
|
||||
@ -79,7 +77,7 @@ public class MemberController extends BaseController {
|
||||
@Log(title = "会员信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/ums/member")
|
||||
public R edit(@RequestBody MemberBO member) {
|
||||
return R.ok(service.updateById(convert.convertToPo(member)));
|
||||
return R.ok(service.updateById(convert.toPo(member)));
|
||||
}
|
||||
|
||||
@ApiOperation("修改会员备注信息")
|
||||
|
@ -13,7 +13,7 @@ import java.util.List;
|
||||
*
|
||||
* @author zcc
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
@Mapper(componentModel = "spring",uses = BaseConverter.class)
|
||||
public interface FeedbackConvert extends BaseConverter<FeedbackVO, FeedbackBO, Feedback> {
|
||||
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
package com.wzj.soopin.member.convert;
|
||||
|
||||
import com.wzj.soopin.member.domain.bo.MemberAccountBO;
|
||||
import com.wzj.soopin.member.domain.po.MemberAccount;
|
||||
import com.wzj.soopin.member.domain.vo.MemberAccountVO;
|
||||
import org.dromara.common.web.core.BaseConverter;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* 会员账户表 DO <=> DTO <=> VO / BO / Query
|
||||
*
|
||||
* @author zcc
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface MemberAccountConvert {
|
||||
@Mapper(componentModel = "spring",uses = BaseConverter.class)
|
||||
public interface MemberAccountConvert extends BaseConverter< MemberAccountVO, MemberAccountBO,MemberAccount> {
|
||||
|
||||
List<MemberAccountVO> dos2vos(List<MemberAccount> list);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import java.util.List;
|
||||
*
|
||||
* @author zcc
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
@Mapper(componentModel = "spring",uses = BaseConverter.class)
|
||||
public interface MemberAddressConvert extends BaseConverter<MemberAddressVO, MemberAddressBO,MemberAddress> {
|
||||
|
||||
}
|
||||
|
@ -13,16 +13,7 @@ import java.util.List;
|
||||
*
|
||||
* @author zcc
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
@Mapper(componentModel = "spring",uses = BaseConverter.class)
|
||||
public interface MemberCartConvert extends BaseConverter<MemberCartVO, MemberCartBO,MemberCart> {
|
||||
|
||||
List<MemberCartVO> dos2vos(List<MemberCart> list);
|
||||
|
||||
// @Mapping(target = "id", ignore = true)
|
||||
// @Mapping(target = "skuId", source = "id")
|
||||
// MemberCart sku2Cart(Sku sku);
|
||||
//
|
||||
// @BeanMapping(ignoreByDefault = true)
|
||||
// @Mapping(source = "name", target = "productName")
|
||||
// void injectProduct(@MappingTarget MemberCart memberCart, Product p);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.wzj.soopin.member.convert;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.wzj.soopin.member.domain.bo.MemberBO;
|
||||
import com.wzj.soopin.member.domain.po.Member;
|
||||
import com.wzj.soopin.member.domain.vo.MemberVO;
|
||||
@ -12,7 +13,8 @@ import java.util.List;
|
||||
*
|
||||
* @author zcc
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
@Mapper(componentModel = "spring",uses = BaseConverter.class)
|
||||
public interface MemberConvert extends BaseConverter<MemberVO, MemberBO,Member> {
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.wzj.soopin.member.convert;
|
||||
|
||||
import com.wzj.soopin.member.domain.po.MemberLogininfor;
|
||||
import com.wzj.soopin.member.domain.vo.MemberLogininforVO;
|
||||
import org.dromara.common.web.core.BaseConverter;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
@ -10,7 +11,7 @@ import java.util.List;
|
||||
*
|
||||
* @author zcc
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
@Mapper(componentModel = "spring",uses = BaseConverter.class)
|
||||
public interface MemberLogininforConvert {
|
||||
|
||||
List<MemberLogininforVO> dos2vos(List<MemberLogininfor> list);
|
||||
|
@ -2,6 +2,7 @@ package com.wzj.soopin.member.convert;
|
||||
|
||||
import com.wzj.soopin.member.domain.po.MemberWechat;
|
||||
import com.wzj.soopin.member.domain.vo.MemberWechatVO;
|
||||
import org.dromara.common.web.core.BaseConverter;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
@ -10,7 +11,7 @@ import java.util.List;
|
||||
*
|
||||
* @author zcc
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
@Mapper(componentModel = "spring",uses = BaseConverter.class)
|
||||
public interface MemberWechatConvert {
|
||||
|
||||
List<MemberWechatVO> dos2vos(List<MemberWechat> list);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.wzj.soopin.member.domain.bo;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@ -39,4 +40,8 @@ public class FeedbackBO extends BaseBO {
|
||||
private String endTime;
|
||||
|
||||
|
||||
@Override
|
||||
public LambdaQueryWrapper toWrapper() {
|
||||
return super.toWrapper();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
package com.wzj.soopin.member.domain.bo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.wzj.soopin.member.domain.po.MemberAccount;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.BaseBO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 会员账户表 查询 对象
|
||||
*
|
||||
* @author zcc
|
||||
*/
|
||||
@ApiModel(description="会员账户表 查询 对象")
|
||||
@Data
|
||||
public class MemberAccountBO extends BaseBO {
|
||||
@ApiModelProperty("积分余额 精确匹配")
|
||||
private BigDecimal integralBalance;
|
||||
|
||||
@ApiModelProperty("历史总共积分 精确匹配")
|
||||
private BigDecimal totalIntegralBalance;
|
||||
|
||||
|
||||
@ApiModelProperty("MEMBER_ID")
|
||||
@TableId(value="member_id", type = IdType.ASSIGN_ID)
|
||||
private Long memberId;
|
||||
|
||||
public LambdaQueryWrapper<MemberAccount> toWrapper() {
|
||||
LambdaQueryWrapper<MemberAccount> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(MemberAccount::getIntegralBalance, integralBalance);
|
||||
queryWrapper.eq(MemberAccount::getTotalIntegralBalance, totalIntegralBalance);
|
||||
queryWrapper.eq(MemberAccount::getMemberId, memberId);
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package com.wzj.soopin.member.domain.bo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 会员账户表 查询 对象
|
||||
*
|
||||
* @author zcc
|
||||
*/
|
||||
@ApiModel(description="会员账户表 查询 对象")
|
||||
@Data
|
||||
public class MemberAccountQuery {
|
||||
@ApiModelProperty("积分余额 精确匹配")
|
||||
private BigDecimal integralBalance;
|
||||
|
||||
@ApiModelProperty("历史总共积分 精确匹配")
|
||||
private BigDecimal totalIntegralBalance;
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.wzj.soopin.member.domain.bo;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.fasterxml.jackson.databind.ser.Serializers;
|
||||
import com.wzj.soopin.member.domain.po.Member;
|
||||
@ -48,7 +49,7 @@ public class MemberAddressBO extends BaseBO {
|
||||
private Integer isDefault;
|
||||
|
||||
@Override
|
||||
public QueryWrapper<MemberAddress> toWrapper() {
|
||||
return null;
|
||||
public LambdaQueryWrapper<MemberAddress> toWrapper() {
|
||||
return new QueryWrapper<MemberAddress>().lambda().eq(MemberAddress::getMemberId,this.getMemberId());
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public class MemberBO extends BaseBO {
|
||||
|
||||
public QueryWrapper<Member> toWapper(){
|
||||
QueryWrapper<Member> qw = new QueryWrapper<>();
|
||||
qw.lambda().like(!getNickname().isEmpty(),Member::getNickname, this.getNickname());
|
||||
qw.lambda().like(!StringUtils.isEmpty(this.getNickname()),Member::getNickname, this.getNickname());
|
||||
|
||||
String phone = this.getPhone();
|
||||
if (!StringUtils.isEmpty(phone)) {
|
||||
|
@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 地址对象
|
||||
@ -13,7 +15,7 @@ import org.dromara.common.excel.annotation.Excel;
|
||||
@ApiModel(description="地址对象")
|
||||
@Data
|
||||
@TableName("address")
|
||||
public class Address {
|
||||
public class Address extends BaseAudit {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("ID")
|
||||
@ -35,16 +37,6 @@ public class Address {
|
||||
@Excel(name = "地区层级")
|
||||
private Integer level;
|
||||
|
||||
@ApiModelProperty("CREATED_AT")
|
||||
@Excel(name = "CREATED_AT")
|
||||
private String createdAt;
|
||||
|
||||
@ApiModelProperty("UPDATED_AT")
|
||||
@Excel(name = "UPDATED_AT")
|
||||
private String updatedAt;
|
||||
|
||||
@ApiModelProperty("DELETED_AT")
|
||||
@Excel(name = "DELETED_AT")
|
||||
private String deletedAt;
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
/**
|
||||
@ -15,7 +17,7 @@ import java.time.LocalDateTime;
|
||||
@ApiModel(description="意见反馈对象")
|
||||
@Data
|
||||
@TableName("ums_feedback")
|
||||
public class Feedback {
|
||||
public class Feedback extends BaseAudit {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("ID")
|
||||
@ -37,12 +39,6 @@ public class Feedback {
|
||||
@Excel(name = "联系电话")
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty("创建人")
|
||||
private Long createBy;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@ApiModelProperty("处理状态 0:未处理 1:已处理")
|
||||
@Excel(name = "处理状态 0:未处理 1:已处理")
|
||||
private Integer handleStatus;
|
||||
|
@ -1,9 +1,12 @@
|
||||
package com.wzj.soopin.member.domain.po;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckHttpDigest;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
@ -17,13 +20,21 @@ import java.time.LocalDateTime;
|
||||
*/
|
||||
@ApiModel(description="会员信息对象")
|
||||
@Data
|
||||
@Builder
|
||||
@TableName("ums_member")
|
||||
public class Member extends BaseEntity {
|
||||
public class Member extends BaseAudit {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty("ID")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("用户名")
|
||||
@Excel(name = "用户名")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty("昵称")
|
||||
@Excel(name = "昵称")
|
||||
private String nickname;
|
||||
@ -90,4 +101,9 @@ public class Member extends BaseEntity {
|
||||
@Excel(name = "用户剩余积分")
|
||||
private BigDecimal integral;
|
||||
|
||||
@ApiModelProperty("im签名")
|
||||
@Excel(name = "im签名")
|
||||
private String userSig; // 添加 UserSig 属性
|
||||
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
@ -18,7 +20,7 @@ import java.time.LocalDateTime;
|
||||
@ApiModel(description="会员账户表对象")
|
||||
@Data
|
||||
@TableName("ums_member_account")
|
||||
public class MemberAccount {
|
||||
public class MemberAccount extends BaseAudit {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("MEMBER_ID")
|
||||
@ -33,10 +35,6 @@ public class MemberAccount {
|
||||
@Excel(name = "历史总共积分")
|
||||
private BigDecimal totalIntegralBalance;
|
||||
|
||||
@ApiModelProperty("修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
@ -15,7 +16,7 @@ import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
@ApiModel(description="会员收货地址对象")
|
||||
@Data
|
||||
@TableName("ums_member_address")
|
||||
public class MemberAddress extends BaseEntity {
|
||||
public class MemberAddress extends BaseAudit {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("ID")
|
||||
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
@ -15,7 +16,7 @@ import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
@ApiModel(description="购物车对象")
|
||||
@Data
|
||||
@TableName("ums_member_cart")
|
||||
public class MemberCart extends BaseEntity {
|
||||
public class MemberCart extends BaseAudit {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("购物车表ID")
|
||||
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
@ -16,7 +17,7 @@ import java.time.LocalDateTime;
|
||||
@ApiModel(description="用户微信信息对象")
|
||||
@Data
|
||||
@TableName("ums_member_wechat")
|
||||
public class MemberWechat extends BaseEntity {
|
||||
public class MemberWechat extends BaseAudit {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("ID")
|
||||
|
@ -0,0 +1,71 @@
|
||||
package com.wzj.soopin.member.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 会员信息 用于
|
||||
*
|
||||
* @author zcc
|
||||
*/
|
||||
@Data
|
||||
public class MemberInfoVO {
|
||||
/** ID */
|
||||
private Long id;
|
||||
/** 昵称 */
|
||||
@Excel(name = "昵称")
|
||||
private String nickname;
|
||||
/** 手机号 */
|
||||
private String phone;
|
||||
/** 隐藏前三位后四位的手机号 */
|
||||
private String phoneHidden;
|
||||
/** 用户备注 */
|
||||
@Excel(name = "用户备注")
|
||||
private String mark;
|
||||
/** 帐号启用状态:0->禁用;1->启用 */
|
||||
@Excel(name = "帐号启用状态:0->禁用;1->启用")
|
||||
private Integer status;
|
||||
/** 头像 */
|
||||
@Excel(name = "头像")
|
||||
private String avatar;
|
||||
/** 性别:0->未知;1->男;2->女 */
|
||||
@Excel(name = "性别:0->未知;1->男;2->女")
|
||||
private Integer gender;
|
||||
/** 用户所在城市 */
|
||||
@Excel(name = "用户所在城市")
|
||||
private String city;
|
||||
/** 用户所在省份 */
|
||||
@Excel(name = "用户所在省份")
|
||||
private String province;
|
||||
/** 用户所在国家 */
|
||||
@Excel(name = "用户所在国家")
|
||||
private String country;
|
||||
/** 公众号运营者对粉丝的备注,公众号运营者可在微信公众平台用户管理界面对粉丝添加备注 */
|
||||
@Excel(name = "公众号运营者对粉丝的备注,公众号运营者可在微信公众平台用户管理界面对粉丝添加备注")
|
||||
private String remark;
|
||||
/** 生日 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private LocalDate birthday;
|
||||
/** 推广员id */
|
||||
@Excel(name = "推广员id")
|
||||
private Long spreadUid;
|
||||
/** 推广员关联时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "推广员关联时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime spreadTime;
|
||||
/** 等级 */
|
||||
@Excel(name = "等级")
|
||||
private Integer level;
|
||||
/** 用户剩余积分 */
|
||||
@Excel(name = "用户剩余积分")
|
||||
private BigDecimal integral;
|
||||
/** openId */
|
||||
@Excel(name = "openId")
|
||||
private String openId;
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package com.wzj.soopin.member.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.wzj.soopin.member.domain.form.ChangeMemberStatusForm;
|
||||
import com.wzj.soopin.member.domain.po.Member;
|
||||
|
||||
public interface IMemberCrudService extends IService<Member> {
|
||||
Integer changeStatus(ChangeMemberStatusForm dto);
|
||||
|
||||
int updateMark(Member member);
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.wzj.soopin.member.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.wzj.soopin.member.domain.form.ChangeMemberStatusForm;
|
||||
import com.wzj.soopin.member.domain.po.Member;
|
||||
import org.dromara.common.core.constant.ResultCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IMemberService extends IService<Member> {
|
||||
Integer changeStatus(ChangeMemberStatusForm dto);
|
||||
|
||||
int updateMark(Member member);
|
||||
|
||||
boolean usernameExists(String username); // 确保这个方法在接口中定义
|
||||
|
||||
/**
|
||||
* 是否可以通过手机获取用户
|
||||
*
|
||||
* @param uuid UUID
|
||||
* @param mobile 手机号
|
||||
* @return 操作状态
|
||||
*/
|
||||
boolean findByMobile(String uuid, String mobile);
|
||||
|
||||
/**
|
||||
* 通过用户名获取用户
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return 会员信息
|
||||
*/
|
||||
Member findByUsername(String username);
|
||||
|
||||
/**
|
||||
* 修改用户密码
|
||||
*
|
||||
* @param oldPassword 旧密码
|
||||
* @param newPassword 新密码
|
||||
* @return 操作结果
|
||||
*/
|
||||
Member modifyPass(String oldPassword, String newPassword);
|
||||
|
||||
/**
|
||||
* 修改当前会员的手机号
|
||||
*
|
||||
* @param mobile 手机号
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean changeMobile(String mobile);
|
||||
|
||||
ResultCode updateMemberStatus(List<String> memberIds, Boolean disabled, Integer banDays);
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.wzj.soopin.member.service;
|
||||
|
||||
|
||||
/**km//,
|
||||
* 腾讯IM服务
|
||||
* @author wqx
|
||||
*/
|
||||
public interface ITencentIMServicce {
|
||||
String createTencentIMAccount(String userId);
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
package com.wzj.soopin.member.service;
|
||||
|
||||
import cn.dev33.satoken.secure.BCrypt;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.wzj.soopin.member.domain.po.Member;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.Constants;
|
||||
import org.dromara.common.core.constant.GlobalConstants;
|
||||
import org.dromara.common.core.domain.model.RegisterBody;
|
||||
import org.dromara.common.core.enums.UserType;
|
||||
import org.dromara.common.core.exception.user.CaptchaException;
|
||||
import org.dromara.common.core.exception.user.CaptchaExpireException;
|
||||
import org.dromara.common.core.exception.user.UserException;
|
||||
import org.dromara.common.core.utils.MessageUtils;
|
||||
import org.dromara.common.core.utils.ServletUtils;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.log.event.LogininforEvent;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
import org.dromara.common.web.config.properties.CaptchaProperties;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 注册校验方法
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class MemberRegisterService {
|
||||
|
||||
private final IMemberService memberService;
|
||||
private final CaptchaProperties captchaProperties;
|
||||
private final ITencentIMServicce tencentIMServicce;
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
public Member register(RegisterBody registerBody) {
|
||||
String tenantId = registerBody.getTenantId();
|
||||
String username = registerBody.getUsername();
|
||||
String phoneNumber= registerBody.getPhoneNumber();
|
||||
String password = registerBody.getPassword();
|
||||
// 校验用户类型是否存在
|
||||
String userType = UserType.getUserType(registerBody.getUserType()).getUserType();
|
||||
|
||||
boolean captchaEnabled = captchaProperties.getEnable();
|
||||
// 验证码开关
|
||||
if (captchaEnabled) {
|
||||
validateCaptcha(tenantId, username, registerBody.getCode(), registerBody.getUuid());
|
||||
}
|
||||
Member member = Member.builder().phoneEncrypted(phoneNumber)
|
||||
.userName(username==null?phoneNumber:username)
|
||||
.nickname(username)
|
||||
.password(BCrypt.hashpw(password==null?"123456":password)).build();
|
||||
|
||||
boolean exist = memberService.exists(new LambdaQueryWrapper<Member>()
|
||||
.eq(Member::getPhoneEncrypted, phoneNumber));
|
||||
if (exist) {
|
||||
throw new UserException("user.register.save.error", username);
|
||||
}
|
||||
|
||||
// 生成 UserSig
|
||||
String userSig = tencentIMServicce.createTencentIMAccount(phoneNumber);
|
||||
member.setUserSig(userSig);
|
||||
|
||||
boolean regFlag = memberService.save(member);
|
||||
if (!regFlag) {
|
||||
throw new UserException("user.register.error");
|
||||
}
|
||||
recordLogininfor(tenantId, username, Constants.REGISTER, MessageUtils.message("user.register.success"));
|
||||
return member;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验验证码
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param code 验证码
|
||||
* @param uuid 唯一标识
|
||||
*/
|
||||
public void validateCaptcha(String tenantId, String username, String code, String uuid) {
|
||||
String verifyKey = GlobalConstants.CAPTCHA_CODE_KEY + StringUtils.blankToDefault(uuid, "");
|
||||
String captcha = RedisUtils.getCacheObject(verifyKey);
|
||||
RedisUtils.deleteObject(verifyKey);
|
||||
if (captcha == null) {
|
||||
recordLogininfor(tenantId, username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
|
||||
throw new CaptchaExpireException();
|
||||
}
|
||||
if (!code.equalsIgnoreCase(captcha)) {
|
||||
recordLogininfor(tenantId, username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"));
|
||||
throw new CaptchaException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录登录信息
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @param username 用户名
|
||||
* @param status 状态
|
||||
* @param message 消息内容
|
||||
* @return
|
||||
*/
|
||||
private void recordLogininfor(String tenantId, String username, String status, String message) {
|
||||
LogininforEvent logininforEvent = new LogininforEvent();
|
||||
logininforEvent.setTenantId(tenantId);
|
||||
logininforEvent.setUsername(username);
|
||||
logininforEvent.setStatus(status);
|
||||
logininforEvent.setMessage(message);
|
||||
logininforEvent.setRequest(ServletUtils.getRequest());
|
||||
SpringUtils.context().publishEvent(logininforEvent);
|
||||
}
|
||||
|
||||
}
|
@ -4,14 +4,12 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.wzj.soopin.member.domain.po.MemberAccount;
|
||||
import com.wzj.soopin.member.domain.bo.MemberAccountQuery;
|
||||
import com.wzj.soopin.member.domain.bo.MemberAccountBO;
|
||||
import com.wzj.soopin.member.mapper.MemberAccountMapper;
|
||||
import com.wzj.soopin.member.service.IMemberAccountService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 会员账户表Service业务层处理
|
||||
@ -39,7 +37,7 @@ public class MemberAccountServiceImpl extends ServiceImpl<MemberAccountMapper,Me
|
||||
* @param page 分页条件
|
||||
* @return 会员账户表
|
||||
*/
|
||||
public IPage<MemberAccount> selectList(MemberAccountQuery query, IPage page) {
|
||||
public IPage<MemberAccount> selectList(MemberAccountBO query, IPage page) {
|
||||
|
||||
QueryWrapper<MemberAccount> qw = new QueryWrapper<>();
|
||||
BigDecimal integralBalance = query.getIntegralBalance();
|
||||
|
@ -9,6 +9,8 @@ import com.wzj.soopin.member.domain.po.MemberAddress;
|
||||
import com.wzj.soopin.member.domain.bo.MemberAddressBO;
|
||||
import com.wzj.soopin.member.mapper.MemberAddressMapper;
|
||||
import com.wzj.soopin.member.service.IMemberAddressService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -23,9 +25,10 @@ import java.util.List;
|
||||
* @author zcc
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class MemberAddressServiceImpl extends ServiceImpl<MemberAddressMapper, MemberAddress> implements IMemberAddressService {
|
||||
@Autowired
|
||||
private MemberAddressConvert memberAddressConvert;
|
||||
private final MemberAddressConvert memberAddressConvert;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1,66 +0,0 @@
|
||||
package com.wzj.soopin.member.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.wzj.soopin.member.domain.form.ChangeMemberStatusForm;
|
||||
import com.wzj.soopin.member.domain.po.Member;
|
||||
import com.wzj.soopin.member.mapper.MemberCartMapper;
|
||||
import com.wzj.soopin.member.mapper.MemberMapper;
|
||||
import com.wzj.soopin.member.service.IMemberCrudService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 会员信息Service业务层处理
|
||||
*
|
||||
*
|
||||
* @author zcc
|
||||
*/
|
||||
@Service
|
||||
public class MemberCrudServiceImpl extends ServiceImpl<MemberMapper,Member> implements IMemberCrudService {
|
||||
@Autowired
|
||||
private MemberMapper memberMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
private MemberCartMapper memberCartMapper;
|
||||
|
||||
// @Autowired
|
||||
// private OrderMapper orderMapper;
|
||||
//
|
||||
// @Autowired
|
||||
// private AftersaleMapper aftersaleMapper;
|
||||
|
||||
|
||||
|
||||
|
||||
public int updateMark(Member member) {
|
||||
UpdateWrapper<Member> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.set("mark",member.getMark())
|
||||
.set("update_time",LocalDateTime.now())
|
||||
.eq("id",member.getId());
|
||||
return memberMapper.update(null,updateWrapper);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Integer changeStatus(ChangeMemberStatusForm dto) {
|
||||
UpdateWrapper<Member> wrapper = new UpdateWrapper<>();
|
||||
wrapper.eq("id", dto.getMemberId());
|
||||
wrapper.set("status", dto.getStatus());
|
||||
return memberMapper.update(null, wrapper);
|
||||
}
|
||||
|
||||
|
||||
// public MemberDataStatisticsVO viewStatistics(Long memberId) {
|
||||
// LambdaQueryWrapper<MemberCart> wrapper = new LambdaQueryWrapper<>();
|
||||
// wrapper.eq(MemberCart::getMemberId, memberId);
|
||||
// long cartCount = memberCartMapper.selectCount(wrapper);
|
||||
// MemberDataStatisticsVO vo = orderMapper.statOrderCountAndAmount(memberId);
|
||||
// vo.setCartCount(Long.bitCount(cartCount));
|
||||
// vo.setAftersaleCount(aftersaleMapper.countByMemberId(memberId));
|
||||
// return vo;
|
||||
// }
|
||||
}
|
@ -0,0 +1,219 @@
|
||||
package com.wzj.soopin.member.service.impl;
|
||||
|
||||
import cn.dev33.satoken.secure.BCrypt;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.wzj.soopin.member.domain.form.ChangeMemberStatusForm;
|
||||
import com.wzj.soopin.member.domain.po.Member;
|
||||
import com.wzj.soopin.member.mapper.MemberCartMapper;
|
||||
import com.wzj.soopin.member.mapper.MemberMapper;
|
||||
import com.wzj.soopin.member.service.IMemberService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.constant.CachePrefix;
|
||||
import org.dromara.common.core.constant.ResultCode;
|
||||
import org.dromara.common.core.domain.model.LoginUser;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.redis.redis.RedisCache;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 会员信息Service业务层处理
|
||||
*
|
||||
*
|
||||
* @author zcc
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class MemberServiceImpl extends ServiceImpl<MemberMapper,Member> implements IMemberService {
|
||||
|
||||
private final MemberCartMapper memberCartMapper;
|
||||
|
||||
private final RedisCache redisCache;
|
||||
|
||||
@Override
|
||||
public boolean usernameExists(String username) {
|
||||
return baseMapper.countByUsername(username) > 0; // 确保实现
|
||||
}
|
||||
|
||||
@Override
|
||||
public Member findByUsername(String userName) {
|
||||
QueryWrapper<Member> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("username", userName);
|
||||
return this.baseMapper.selectOne(queryWrapper);
|
||||
}
|
||||
@Override
|
||||
public boolean findByMobile(String uuid, String mobile) {
|
||||
QueryWrapper<Member> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("mobile", mobile);
|
||||
Member member = this.baseMapper.selectOne(queryWrapper);
|
||||
if (member == null) {
|
||||
throw new ServiceException(ResultCode.USER_NOT_PHONE);
|
||||
}
|
||||
redisCache.setCacheObject(CachePrefix.FIND_MOBILE + uuid, mobile, 300, TimeUnit.SECONDS);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int updateMark(Member member) {
|
||||
UpdateWrapper<Member> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.set("mark",member.getMark())
|
||||
.set("update_time",LocalDateTime.now())
|
||||
.eq("id",member.getId());
|
||||
return baseMapper.update(null,updateWrapper);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Integer changeStatus(ChangeMemberStatusForm dto) {
|
||||
UpdateWrapper<Member> wrapper = new UpdateWrapper<>();
|
||||
wrapper.eq("id", dto.getMemberId());
|
||||
wrapper.set("status", dto.getStatus());
|
||||
return baseMapper.update(null, wrapper);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Member modifyPass(String oldPassword, String newPassword) {
|
||||
LoginUser tokenUser = LoginHelper.getLoginUser();
|
||||
if (tokenUser == null) {
|
||||
throw new ServiceException(ResultCode.USER_NOT_LOGIN);
|
||||
}
|
||||
Member member = this.getById(tokenUser.getUserId());
|
||||
// 判断旧密码输入是否正确
|
||||
if (!BCrypt.checkpw(member.getPassword(),oldPassword)) {
|
||||
throw new ServiceException(ResultCode.USER_OLD_PASSWORD_ERROR);
|
||||
}
|
||||
// 修改会员密码
|
||||
LambdaUpdateWrapper<Member> lambdaUpdateWrapper = Wrappers.lambdaUpdate();
|
||||
lambdaUpdateWrapper.eq(Member::getId, member.getId());
|
||||
lambdaUpdateWrapper.set(Member::getPassword, BCrypt.hashpw(newPassword));
|
||||
this.update(lambdaUpdateWrapper);
|
||||
return member;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean changeMobile(String mobile) {
|
||||
LoginUser tokenUser = LoginHelper.getLoginUser();
|
||||
Member member = this.getById(tokenUser.getUserId());
|
||||
|
||||
// 修改会员手机号
|
||||
LambdaUpdateWrapper<Member> lambdaUpdateWrapper = Wrappers.lambdaUpdate();
|
||||
lambdaUpdateWrapper.eq(Member::getId, member.getId());
|
||||
lambdaUpdateWrapper.set(Member::getPhoneEncrypted, mobile);
|
||||
return this.update(lambdaUpdateWrapper);
|
||||
}
|
||||
/**
|
||||
* 更新会员状态
|
||||
* 支持设置封禁时长
|
||||
*
|
||||
* @param memberIds 会员ID列表
|
||||
* @param disabled 是否禁用
|
||||
* @param banDays 封禁天数,null表示永久封禁
|
||||
* @return 操作结果代码
|
||||
*/
|
||||
@Override
|
||||
public ResultCode updateMemberStatus(List<String> memberIds, Boolean disabled, Integer banDays) {
|
||||
if (memberIds == null || memberIds.isEmpty()) {
|
||||
return ResultCode.USER_NOT_EXIST;
|
||||
}
|
||||
|
||||
try {
|
||||
UpdateWrapper<Member> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.in("id", memberIds);
|
||||
|
||||
if (Boolean.TRUE.equals(disabled)) {
|
||||
// 计算解封时间
|
||||
Date banEndTime = null;
|
||||
if (banDays != null && banDays > 0) {
|
||||
// 使用 Calendar 设置解封日期
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.DAY_OF_MONTH, banDays);
|
||||
banEndTime = calendar.getTime();
|
||||
}
|
||||
// 设置封禁状态和解封时间
|
||||
updateWrapper.set("delete_flag", true);
|
||||
updateWrapper.set("ban_end_time", banEndTime);
|
||||
|
||||
// 记录操作日志
|
||||
log.info("封禁会员: memberIds={}, banDays={}, banEndTime={}",
|
||||
memberIds, banDays, banEndTime);
|
||||
} else {
|
||||
// 解除封禁
|
||||
updateWrapper.set("delete_flag", false);
|
||||
updateWrapper.set("ban_end_time", null);
|
||||
|
||||
// 记录操作日志
|
||||
log.info("解封会员: memberIds={}", memberIds);
|
||||
}
|
||||
|
||||
boolean result = this.update(updateWrapper);
|
||||
|
||||
// 如果更新失败,检查记录是否存在
|
||||
if (!result) {
|
||||
long count = this.count(new QueryWrapper<Member>().in("id", memberIds));
|
||||
if (count == 0) {
|
||||
log.warn("更新会员状态失败: 未找到指定会员, memberIds={}", memberIds);
|
||||
return ResultCode.USER_NOT_EXIST;
|
||||
} else {
|
||||
log.warn("更新会员状态失败: 更新操作失败, memberIds={}", memberIds);
|
||||
return ResultCode.ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return ResultCode.SUCCESS;
|
||||
} catch (Exception e) {
|
||||
log.error("更新会员状态异常", e);
|
||||
return ResultCode.ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时任务:检查并解除到期的封禁账号
|
||||
* 每天凌晨执行
|
||||
*/
|
||||
@Scheduled(cron = "0 0 0 * * ?")
|
||||
public void checkAndUnbanMembers() {
|
||||
log.info("开始执行会员自动解封任务");
|
||||
Date now = new Date();
|
||||
|
||||
// 查找到期需要解封的会员数量
|
||||
QueryWrapper<Member> countWrapper = new QueryWrapper<>();
|
||||
countWrapper.eq("disabled", true)
|
||||
.isNotNull("ban_end_time")
|
||||
.le("ban_end_time", now);
|
||||
long count = this.count(countWrapper);
|
||||
|
||||
if (count > 0) {
|
||||
// 解除封禁
|
||||
UpdateWrapper<Member> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.set("disabled", false)
|
||||
.set("ban_end_time", null)
|
||||
.eq("disabled", true)
|
||||
.isNotNull("ban_end_time")
|
||||
.le("ban_end_time", now);
|
||||
|
||||
boolean result = this.update(updateWrapper);
|
||||
log.info("会员自动解封任务完成,解封会员数量:{},处理结果:{}", count, result);
|
||||
} else {
|
||||
log.info("会员自动解封任务完成,无需要解封的会员");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package com.wzj.soopin.member.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.wzj.soopin.member.service.ITencentIMServicce;
|
||||
import com.wzj.soopin.member.util.GenerateTestUserSig;
|
||||
import com.wzj.soopin.member.util.TLSSigAPIv2;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class TencentIMServiceImpl implements ITencentIMServicce {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 创建腾讯云IM账号
|
||||
*/
|
||||
@Override
|
||||
public String createTencentIMAccount(String userId) {
|
||||
try {
|
||||
|
||||
String userSig=generateUserSig(userId);
|
||||
String random = String.valueOf(System.currentTimeMillis());
|
||||
|
||||
// 构建请求体
|
||||
JSONObject requestBody = new JSONObject();
|
||||
requestBody.put("UserID", userId);
|
||||
requestBody.put("Nick", userId);
|
||||
requestBody.put("FaceUrl", "http://www.qq.com");
|
||||
|
||||
// 构建URL - 使用管理员账号(administrator)而不是用户ID来生成签名
|
||||
String urlString = String.format(
|
||||
"https://console.tim.qq.com/v4/im_open_login_svc/account_import" +
|
||||
"?sdkappid=%s&identifier=%s&usersig=%s&random=%s&contenttype=json",
|
||||
GenerateTestUserSig.SDKAPPID,
|
||||
"administrator", // 使用管理员账号
|
||||
userSig, // 使用管理员的UserSig
|
||||
random);
|
||||
return userSig;
|
||||
|
||||
// // 创建HTTP客户端
|
||||
// OkHttpClient client = new OkHttpClient.Builder()
|
||||
// .connectTimeout(10, TimeUnit.SECONDS)
|
||||
// .writeTimeout(10, TimeUnit.SECONDS)
|
||||
// .readTimeout(10, TimeUnit.SECONDS)
|
||||
// .build();
|
||||
//
|
||||
// // 发送请求
|
||||
// Request request = new Request.Builder()
|
||||
// .url(urlString)
|
||||
// .post(RequestBody.create(MediaType.get("application/json; charset=utf-8"),
|
||||
// requestBody.toString()))
|
||||
// .build();
|
||||
//
|
||||
// try (Response response = client.newCall(request).execute()) {
|
||||
// if (!response.isSuccessful()) {
|
||||
// log.error("创建IM账号失败: {}, 状态码: {}", userId, response.code());
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// String responseBody = response.body().string();
|
||||
// JSONObject jsonResponse = new JSONObject(responseBody);
|
||||
// int errorCode = jsonResponse.getInt("ErrorCode");
|
||||
//
|
||||
// if (errorCode == 0) {
|
||||
// log.info("创建IM账号成功: {}", userId);
|
||||
// return userSig;
|
||||
// } else {
|
||||
// log.error("创建IM账号失败: {}, 错误码: {}, 错误信息: {}",
|
||||
// userId, errorCode, jsonResponse.optString("ErrorInfo"));
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
} catch (Exception e) {
|
||||
log.error("创建IM账号异常: {}", userId, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成UserSig
|
||||
*/
|
||||
private String generateUserSig(String userId) {
|
||||
TLSSigAPIv2 tlsSigAPIv2 = new TLSSigAPIv2(GenerateTestUserSig.SDKAPPID, GenerateTestUserSig.SECRETKEY);
|
||||
long expire = TimeUnit.DAYS.toSeconds(365 * 50); // 50年有效期
|
||||
return tlsSigAPIv2.genUserSig(userId, expire);
|
||||
}
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
package com.wzj.soopin.member.util;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.zip.Deflater;
|
||||
|
||||
public class GenerateTestUserSig {
|
||||
/**
|
||||
* 腾讯云 SDKAppId,需要替换为您自己账号下的 SDKAppId
|
||||
*/
|
||||
public static final int SDKAPPID = 1600080789; // 请替换为您的 SDKAppId
|
||||
|
||||
/**
|
||||
* 签名过期时间,建议不要设置的过短
|
||||
* 时间单位:秒
|
||||
* 默认时间:7 天
|
||||
*/
|
||||
private static final int EXPIRETIME = 604800;
|
||||
|
||||
/**
|
||||
* 计算签名用的加密密钥,获取步骤如下:
|
||||
*
|
||||
* step1. 进入腾讯云云通信[控制台] ,如果还没有应用就创建一个
|
||||
* step2. 单击"应用配置"进入基础配置页面,并进一步找到"帐号体系集成"部分
|
||||
* step3. 点击"查看密钥"按钮,就可以看到计算 UserSig 使用的加密的密钥了
|
||||
*/
|
||||
public static final String SECRETKEY = "311b5309d714a20f7f5b54360ee21b1e24ec208ebcd25ce8f47d24753bccc091"; // 请替换为您的密钥
|
||||
|
||||
/**
|
||||
* 生成 UserSig 签名
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 返回生成的UserSig签名
|
||||
*/
|
||||
public static String genTestUserSig(String userId) {
|
||||
return GenTLSSignature(SDKAPPID, userId, EXPIRETIME, null, SECRETKEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 TLS 票据
|
||||
*
|
||||
* @param sdkappid 应用的 SDKAppID
|
||||
* @param userId 用户 ID
|
||||
* @param expire 有效期,单位是秒
|
||||
* @param userbuf 默认填null
|
||||
* @param priKeyContent 私钥内容
|
||||
* @return 如果出错,会返回空字符串
|
||||
*/
|
||||
private static String GenTLSSignature(long sdkappid, String userId, long expire, byte[] userbuf, String priKeyContent) {
|
||||
if (StringUtils.isEmpty(priKeyContent)) {
|
||||
return "";
|
||||
}
|
||||
long currTime = System.currentTimeMillis() / 1000;
|
||||
JSONObject sigDoc = new JSONObject();
|
||||
try {
|
||||
sigDoc.set("TLS.ver", "2.0");
|
||||
sigDoc.set("TLS.identifier", userId);
|
||||
sigDoc.set("TLS.sdkappid", sdkappid);
|
||||
sigDoc.set("TLS.expire", expire);
|
||||
sigDoc.set("TLS.time", currTime);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
|
||||
String base64UserBuf = null;
|
||||
if (null != userbuf) {
|
||||
base64UserBuf = Base64.getEncoder().encodeToString(userbuf);
|
||||
try {
|
||||
sigDoc.set("TLS.userbuf", base64UserBuf);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
String sig = hmacsha256(sdkappid, userId, currTime, expire, priKeyContent, base64UserBuf);
|
||||
if (sig.length() == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
try {
|
||||
sigDoc.set("TLS.sig", sig);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
|
||||
Deflater compressor = new Deflater();
|
||||
compressor.setInput(sigDoc.toString().getBytes(Charset.forName("UTF-8")));
|
||||
compressor.finish();
|
||||
byte[] compressedBytes = new byte[2048];
|
||||
int compressedBytesLength = compressor.deflate(compressedBytes);
|
||||
compressor.end();
|
||||
return new String(base64EncodeUrl(Arrays.copyOfRange(compressedBytes, 0, compressedBytesLength)));
|
||||
}
|
||||
|
||||
private static String hmacsha256(long sdkappid, String userId, long currTime, long expire, String priKeyContent, String base64Userbuf) {
|
||||
String contentToBeSigned = "TLS.identifier:" + userId + "\n"
|
||||
+ "TLS.sdkappid:" + sdkappid + "\n"
|
||||
+ "TLS.time:" + currTime + "\n"
|
||||
+ "TLS.expire:" + expire + "\n";
|
||||
if (null != base64Userbuf) {
|
||||
contentToBeSigned += "TLS.userbuf:" + base64Userbuf + "\n";
|
||||
}
|
||||
try {
|
||||
byte[] byteKey = priKeyContent.getBytes("UTF-8");
|
||||
Mac hmac = Mac.getInstance("HmacSHA256");
|
||||
SecretKeySpec keySpec = new SecretKeySpec(byteKey, "HmacSHA256");
|
||||
hmac.init(keySpec);
|
||||
byte[] byteSig = hmac.doFinal(contentToBeSigned.getBytes("UTF-8"));
|
||||
return Base64.getEncoder().encodeToString(byteSig);
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] base64EncodeUrl(byte[] input) {
|
||||
byte[] base64 = Base64.getEncoder().encode(input);
|
||||
for (int i = 0; i < base64.length; ++i) {
|
||||
switch (base64[i]) {
|
||||
case '+':
|
||||
base64[i] = '*';
|
||||
break;
|
||||
case '/':
|
||||
base64[i] = '-';
|
||||
break;
|
||||
case '=':
|
||||
base64[i] = '_';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return base64;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.wzj.soopin.auth.util;
|
||||
package com.wzj.soopin.member.util;
|
||||
|
||||
|
||||
import cn.hutool.json.JSONException;
|
6
script/sql/rzj.sql
Normal file
6
script/sql/rzj.sql
Normal file
@ -0,0 +1,6 @@
|
||||
-- 添加用户名字段
|
||||
ALTER TABLE `wzj`.`ums_member`
|
||||
ADD COLUMN `user_name` varchar(255) NULL COMMENT '用户名' AFTER `update_time`;
|
||||
-- 添加用户签名字段
|
||||
ALTER TABLE `wzj`.`ums_member`
|
||||
ADD COLUMN `user_sig` varchar(255) NULL COMMENT '腾讯的签名' AFTER `user_name`;
|
Loading…
x
Reference in New Issue
Block a user