最新代码
This commit is contained in:
@@ -29,7 +29,6 @@ import java.util.Objects;
|
||||
public class ClerkUserLoginAspect {
|
||||
|
||||
|
||||
|
||||
@Resource
|
||||
private PlayClerkUserInfoServiceImpl clerkUserInfoService;
|
||||
|
||||
@@ -45,7 +44,9 @@ public class ClerkUserLoginAspect {
|
||||
if (StringUtils.isEmpty(userToken)) {
|
||||
throw new ServiceException("token为空", HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
userToken = userToken.replace(Constants.TOKEN_PREFIX, "");
|
||||
if (userToken.startsWith(Constants.TOKEN_PREFIX)) {
|
||||
userToken = userToken.replace(Constants.TOKEN_PREFIX, "");
|
||||
}
|
||||
// 解析token
|
||||
String userId;
|
||||
try {
|
||||
|
||||
@@ -43,7 +43,9 @@ public class CustomUserLoginAspect {
|
||||
if (StringUtils.isEmpty(userToken)) {
|
||||
throw new ServiceException("token为空", HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
userToken = userToken.replace(Constants.TOKEN_PREFIX, "");
|
||||
if (userToken.startsWith(Constants.TOKEN_PREFIX)) {
|
||||
userToken = userToken.replace(Constants.TOKEN_PREFIX, "");
|
||||
}
|
||||
// 解析token
|
||||
String userId;
|
||||
try {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.starry.admin.common.aspect;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.starry.admin.common.domain.LoginUser;
|
||||
import com.starry.admin.modules.system.entity.SysRoleEntity;
|
||||
import com.starry.admin.modules.system.entity.SysUserEntity;
|
||||
@@ -72,7 +73,7 @@ public class DataScopeAspect {
|
||||
if (!DATA_SCOPE_CUSTOM.equals(dataScope) && conditions.contains(dataScope)) {
|
||||
continue;
|
||||
}
|
||||
if (StringUtils.isNotEmpty(permission) && StringUtils.isNotEmpty(role.getPermissions())
|
||||
if (StrUtil.isNotBlank(permission) && StringUtils.isNotEmpty(role.getPermissions())
|
||||
&& !StringUtils.containsAny(role.getPermissions(), Convert.toStrArray(permission))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.starry.admin.common.component;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.hutool.http.useragent.UserAgent;
|
||||
import cn.hutool.http.useragent.UserAgentUtil;
|
||||
@@ -185,7 +186,7 @@ public class JwtToken {
|
||||
*/
|
||||
public JwtUser getLoginUser(HttpServletRequest request) {
|
||||
String token = getToken(request);
|
||||
if (StringUtils.isNotEmpty(token)) {
|
||||
if (StrUtil.isNotBlank(token)) {
|
||||
try {
|
||||
Claims claims = getClaimsFromToken(token);
|
||||
String uuid = (String) claims.get(Constants.LOGIN_USER_KEY);
|
||||
@@ -208,7 +209,7 @@ public class JwtToken {
|
||||
private String getToken(HttpServletRequest request) {
|
||||
// 获取请求头
|
||||
String token = request.getHeader(tokenHeader);
|
||||
if (StringUtils.isNotEmpty(token) && token.startsWith(tokenHead)) {
|
||||
if (StrUtil.isNotBlank(token) && token.startsWith(tokenHead)) {
|
||||
token = token.replace(tokenHead, "");
|
||||
}
|
||||
return token;
|
||||
@@ -232,7 +233,7 @@ public class JwtToken {
|
||||
* 删除用户身份信息
|
||||
*/
|
||||
public void removeJwtUser(String token) {
|
||||
if (StringUtils.isNotEmpty(token)) {
|
||||
if (StrUtil.isNotBlank(token)) {
|
||||
String userKey = getTokenKey(token);
|
||||
redisCache.deleteObject(userKey);
|
||||
}
|
||||
@@ -307,7 +308,7 @@ public class JwtToken {
|
||||
*/
|
||||
public LoginUser getNewLoginUser(HttpServletRequest request) {
|
||||
String token = getToken(request);
|
||||
if (StringUtils.isNotEmpty(token)) {
|
||||
if (StrUtil.isNotBlank(token)) {
|
||||
try {
|
||||
Claims claims = getClaimsFromToken(token);
|
||||
String uuid = (String) claims.get(SecurityConstants.USER_KEY);
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.starry.admin.common.conf;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.TypeReference;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedJdbcTypes;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@MappedJdbcTypes(JdbcType.VARCHAR) //数据库类型
|
||||
@MappedTypes({List.class}) //java数据类型
|
||||
public abstract class ListTypeHandler<T> extends BaseTypeHandler<List<T>> {
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i, List<T> parameter, JdbcType jdbcType) throws SQLException {
|
||||
String content = StringUtils.isEmpty(parameter) ? null : JSON.toJSONString(parameter);
|
||||
ps.setString(i, content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
return this.getListByJsonArrayString(rs.getString(columnName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
return this.getListByJsonArrayString(rs.getString(columnIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
return this.getListByJsonArrayString(cs.getString(columnIndex));
|
||||
}
|
||||
|
||||
private List<T> getListByJsonArrayString(String content) {
|
||||
return StringUtils.isEmpty(content) ? new ArrayList<>() : JSON.parseObject(content, this.specificType());
|
||||
}
|
||||
|
||||
/**
|
||||
* 具体类型,由子类提供
|
||||
*
|
||||
* @return 具体类型
|
||||
*/
|
||||
protected abstract TypeReference<List<T>> specificType();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.starry.admin.common.conf;
|
||||
|
||||
import com.alibaba.fastjson2.TypeReference;
|
||||
import java.util.List;
|
||||
|
||||
public class StringTypeHandler extends ListTypeHandler<String> {
|
||||
// 将ListTypeHandler<T>(T为任意对象),具体为特定的对象String
|
||||
@Override
|
||||
protected TypeReference<List<String>> specificType() {
|
||||
return new TypeReference<List<String>>() {
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,19 @@
|
||||
package com.starry.admin.common.exception.handler;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
import com.starry.admin.common.exception.CustomException;
|
||||
import com.starry.admin.common.exception.ServiceException;
|
||||
import com.starry.common.result.R;
|
||||
import com.starry.common.utils.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.MissingServletRequestParameterException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
@@ -79,6 +82,22 @@ public class GlobalExceptionHandler {
|
||||
return R.error("请求参数异常," + errorMessageBuilder);
|
||||
}
|
||||
|
||||
@ExceptionHandler(MismatchedInputException.class)
|
||||
public R mismatchedInputException(MismatchedInputException e) {
|
||||
return R.error("请求参数格式异常");
|
||||
}
|
||||
|
||||
@ExceptionHandler(HttpMessageNotReadableException.class)
|
||||
public R httpMessageNotReadableException(HttpMessageNotReadableException e) {
|
||||
return R.error("请求参数格式异常");
|
||||
}
|
||||
|
||||
@ExceptionHandler(MissingServletRequestParameterException.class)
|
||||
public R missingServletRequestParameterException(MissingServletRequestParameterException e) {
|
||||
return R.error("请求参数格式异常");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 自定义异常
|
||||
*
|
||||
@@ -89,10 +108,5 @@ public class GlobalExceptionHandler {
|
||||
return R.error(e.getMessage());
|
||||
}
|
||||
|
||||
// @ExceptionHandler(ServiceException.class)
|
||||
// public R serviceException(ServiceException e) {
|
||||
// return R.error(e.getMessage());
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.starry.admin.common.mybatis.handler;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.starry.admin.modules.weichat.service.WxTokenService;
|
||||
import com.starry.admin.utils.SecurityUtils;
|
||||
@@ -54,13 +55,16 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
public String getOperatorId() {
|
||||
if (request.getServletPath().startsWith("/wx/")) {
|
||||
String clerkToken = request.getHeader(Constants.CLERK_USER_LOGIN_TOKEN);
|
||||
String customToken = request.getHeader(Constants.CUSTOM_USER_LOGIN_TOKEN);
|
||||
if (clerkToken != null) {
|
||||
return tokenService.getWxUserIdByToken(clerkToken);
|
||||
}
|
||||
if (customToken != null) {
|
||||
return tokenService.getWxUserIdByToken(customToken);
|
||||
String tenantKey = request.getHeader("tenantkey");
|
||||
if (StrUtil.isBlankIfStr(tenantKey)) {
|
||||
String clerkToken = request.getHeader(Constants.CLERK_USER_LOGIN_TOKEN);
|
||||
String customToken = request.getHeader(Constants.CUSTOM_USER_LOGIN_TOKEN);
|
||||
if (clerkToken != null) {
|
||||
return tokenService.getWxUserIdByToken(clerkToken);
|
||||
}
|
||||
if (customToken != null) {
|
||||
return tokenService.getWxUserIdByToken(customToken);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
} else {
|
||||
@@ -70,4 +74,4 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.starry.admin.common.mybatis.handler;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
|
||||
import com.starry.admin.utils.SecurityUtils;
|
||||
import com.starry.common.utils.StringUtils;
|
||||
@@ -23,7 +22,7 @@ public class MyTenantLineHandler implements TenantLineHandler {
|
||||
/**
|
||||
* 排除过滤的表
|
||||
*/
|
||||
private static final String[] TABLE_FILTER = {"sys_user", "sys_menu", "sys_tenant_package", "sys_tenant", "sys_dict", "sys_dict_data", "sys_administrative_area_dict_info"};
|
||||
private static final String[] TABLE_FILTER = {"sys_login_log", "sys_role", "sys_user", "sys_menu", "sys_tenant_package", "sys_tenant", "sys_dict", "sys_dict_data", "sys_administrative_area_dict_info"};
|
||||
|
||||
/**
|
||||
* 排除过滤的表前缀
|
||||
@@ -34,9 +33,9 @@ public class MyTenantLineHandler implements TenantLineHandler {
|
||||
public Expression getTenantId() {
|
||||
// 取出当前请求的服务商ID,通过解析器注入到SQL中。
|
||||
String tenantId = SecurityUtils.getTenantId();
|
||||
if (StrUtil.isBlankIfStr(tenantId)) {
|
||||
tenantId = "9999";
|
||||
}
|
||||
// if (!StrUtil.isBlankIfStr(tenantId)) {
|
||||
// throw new CustomException("租户信息获取异常");
|
||||
// }
|
||||
return new StringValue(tenantId);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,14 +4,12 @@ import com.starry.admin.common.oss.service.IOssFileService;
|
||||
import com.starry.common.result.R;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
@@ -36,11 +34,4 @@ public class CosController {
|
||||
}
|
||||
return R.error("上传照片异常,请联系管理员");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取cos临时密钥")
|
||||
@GetMapping("/temp-key")
|
||||
public R getTempKey() throws FileNotFoundException {
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,15 @@ import java.io.InputStream;
|
||||
public interface IOssFileService {
|
||||
|
||||
/**
|
||||
* 文件上传阿里云
|
||||
* 文件上传只阿里云OSS
|
||||
*
|
||||
* @param inputStream InputStream
|
||||
* @param module String
|
||||
* @param originalFilename 文件名称
|
||||
*/
|
||||
* @param inputStream 文件流
|
||||
* @param module 文件保存模块地址
|
||||
* @param originalFilename 原始文件名
|
||||
* @return String
|
||||
* @author admin
|
||||
* @since 2024/4/11 10:24
|
||||
**/
|
||||
String upload(InputStream inputStream, String module, String originalFilename);
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,8 +17,13 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class OssFileServiceImpl implements IOssFileService {
|
||||
@@ -26,6 +31,15 @@ public class OssFileServiceImpl implements IOssFileService {
|
||||
|
||||
@Override
|
||||
public String upload(InputStream inputStream, String module, String filename) {
|
||||
|
||||
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
|
||||
bufferedInputStream.mark(0);
|
||||
String fileType = FileTypeUtil.getType(bufferedInputStream);
|
||||
try {
|
||||
bufferedInputStream.reset();
|
||||
} catch (IOException e) {
|
||||
throw new CustomException("文件上传到OSS失败");
|
||||
}
|
||||
// 创建OSSClient实例。
|
||||
OSS ossClient = new OSSClientBuilder().build(OssProperties.ENDPOINT, OssProperties.KEY_ID, OssProperties.KEY_SECRET);
|
||||
log.info("OSSClient实例创建成功");
|
||||
@@ -42,16 +56,21 @@ public class OssFileServiceImpl implements IOssFileService {
|
||||
// 构建日期路径:avatar/2019/02/26/文件名
|
||||
String folder = new DateTime().toString("yyyy/MM/dd");
|
||||
// 文件名:uuid.扩展名
|
||||
filename = IdUtil.fastSimpleUUID() + FileTypeUtil.getType(inputStream);
|
||||
|
||||
|
||||
filename = IdUtil.fastSimpleUUID() + "." + fileType;
|
||||
// 文件根路径
|
||||
String key = module + "/" + folder + "/" + filename;
|
||||
// 创建PutObjectRequest对象。
|
||||
PutObjectRequest putObjectRequest = new PutObjectRequest(OssProperties.BUCKET_NAME, key, inputStream);
|
||||
PutObjectRequest putObjectRequest = new PutObjectRequest(OssProperties.BUCKET_NAME, key, bufferedInputStream);
|
||||
// 创建PutObject请求。
|
||||
ossClient.putObject(putObjectRequest);
|
||||
log.info("oss文件上传成功");
|
||||
// 阿里云文件绝对路径
|
||||
String endpoint = OssProperties.ENDPOINT.substring(OssProperties.ENDPOINT.lastIndexOf("//") + 2);
|
||||
String endpoint = OssProperties.ENDPOINT;
|
||||
if (OssProperties.ENDPOINT.contains("//")) {
|
||||
endpoint = OssProperties.ENDPOINT.substring(OssProperties.ENDPOINT.lastIndexOf("//") + 2);
|
||||
}
|
||||
// 返回文件的访问路径
|
||||
return "https://" + OssProperties.BUCKET_NAME + "." + endpoint + "/" + key;
|
||||
} catch (OSSException oe) {
|
||||
|
||||
@@ -46,6 +46,7 @@ public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
@Resource
|
||||
private CustomLogoutSuccessHandler customLogoutSuccessHandler;
|
||||
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity httpSecurity) throws Exception {
|
||||
httpSecurity.csrf().disable()// 由于使用的是JWT,我们这里不需要csrf
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
package com.starry.admin.common.security.filter;
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.starry.admin.common.component.JwtToken;
|
||||
import com.starry.admin.common.domain.LoginUser;
|
||||
import com.starry.admin.common.exception.CustomException;
|
||||
import com.starry.admin.modules.clear.service.impl.PlayClerkUserInfoServiceImpl;
|
||||
import com.starry.admin.modules.custom.service.impl.PlayCustomUserInfoServiceImpl;
|
||||
import com.starry.admin.modules.platform.entity.SysTenantEntity;
|
||||
import com.starry.admin.modules.platform.service.ISysTenantService;
|
||||
import com.starry.admin.modules.weichat.service.WxTokenService;
|
||||
import com.starry.admin.utils.SecurityUtils;
|
||||
import com.starry.common.constant.Constants;
|
||||
import com.starry.common.utils.StringUtils;
|
||||
import com.starry.common.redis.RedisCache;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
import org.springframework.web.servlet.HandlerExceptionResolver;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.FilterChain;
|
||||
@@ -37,33 +43,36 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
|
||||
@Resource
|
||||
private JwtToken jwtToken;
|
||||
|
||||
@Resource
|
||||
@Qualifier("handlerExceptionResolver")
|
||||
private HandlerExceptionResolver resolver;
|
||||
|
||||
@Resource
|
||||
private PlayCustomUserInfoServiceImpl customUserInfoService;
|
||||
|
||||
@Resource
|
||||
private PlayClerkUserInfoServiceImpl clerkUserInfoService;
|
||||
|
||||
@Resource
|
||||
private ISysTenantService sysTenantService;
|
||||
|
||||
@Resource
|
||||
private RedisCache redisCache;
|
||||
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(@NotNull HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
|
||||
protected void doFilterInternal(@NotNull HttpServletRequest httpServletRequest, @NotNull HttpServletResponse httpServletResponse, @NotNull FilterChain filterChain) throws ServletException, IOException {
|
||||
// 微信公众号的请求
|
||||
if (httpServletRequest.getServletPath().startsWith("/wx/")) {
|
||||
String clerkToken = httpServletRequest.getHeader(Constants.CLERK_USER_LOGIN_TOKEN);
|
||||
String customToken = httpServletRequest.getHeader(Constants.CUSTOM_USER_LOGIN_TOKEN);
|
||||
if (StringUtils.isNotEmpty(clerkToken) || StringUtils.isNotEmpty(customToken)) {
|
||||
String userId = tokenService.getWxUserIdByToken(StringUtils.isNotEmpty(clerkToken) ? clerkToken : customToken);
|
||||
if (clerkToken != null) {
|
||||
SecurityUtils.setTenantId(clerkUserInfoService.selectById(userId).getTenantId());
|
||||
} else {
|
||||
SecurityUtils.setTenantId(customUserInfoService.selectById(userId).getTenantId());
|
||||
}
|
||||
} else {
|
||||
// 如果是微信端接口,并且未登录的话,从head中获取token
|
||||
String header = httpServletRequest.getHeader("tenantkey");
|
||||
// 根据租户表信息,查询租户ID(暂时先写死)
|
||||
String tenantId = "9999";
|
||||
SecurityUtils.setTenantId(header);
|
||||
String tenantKey = httpServletRequest.getHeader("tenantkey");
|
||||
String tenantId = getTenantId(clerkToken, customToken, tenantKey);
|
||||
if (!checkTenantId(tenantId)) {
|
||||
resolver.resolveException(httpServletRequest, httpServletResponse, null, new CustomException("租户信息异常"));
|
||||
return;
|
||||
}
|
||||
SecurityUtils.setTenantId(tenantId);
|
||||
} else {
|
||||
// 管理端的请求
|
||||
LoginUser jwtUser = jwtToken.getNewLoginUser(httpServletRequest);
|
||||
@@ -76,4 +85,61 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
|
||||
}
|
||||
filterChain.doFilter(httpServletRequest, httpServletResponse);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 微信公众号端访问时,获取当前用户租户ID
|
||||
* 如果用户(陪玩或客户)已登录,从token中获取租户ID
|
||||
* 如果用户未登录,从tenantKey中获取租户ID
|
||||
*
|
||||
* @param clerkToken 陪玩登录Key
|
||||
* @param customToken 客户登录key
|
||||
* @param tenantKey 租户标识
|
||||
*/
|
||||
public String getTenantId(String clerkToken, String customToken, String tenantKey) {
|
||||
String tenantId = "";
|
||||
//如果用户(陪玩或客户)已登录,从token中获取租户ID
|
||||
if (StrUtil.isNotBlank(clerkToken) || StrUtil.isNotBlank(customToken)) {
|
||||
String userId;
|
||||
try {
|
||||
userId = tokenService.getWxUserIdByToken(StrUtil.isNotBlank(clerkToken) ? clerkToken : customToken);
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
if (clerkToken != null) {
|
||||
String redisKey = "TENANT_INFO:" + userId;
|
||||
SecurityUtils.setTenantId(redisCache.getCacheObject(redisKey));
|
||||
tenantId = clerkUserInfoService.selectById(userId).getTenantId();
|
||||
} else {
|
||||
tenantId = customUserInfoService.selectById(userId).getTenantId();
|
||||
}
|
||||
} else {
|
||||
// 如果用户未登录,从tenantKey中获取租户ID,然后验证租户ID是否存在,以及租户是否过期等
|
||||
SysTenantEntity entity = sysTenantService.selectByTenantKey(tenantKey);
|
||||
if (entity != null) {
|
||||
tenantId = entity.getTenantId();
|
||||
}
|
||||
}
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验租户是否正常
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @return true:租户正常,false:租户不正常
|
||||
*/
|
||||
public boolean checkTenantId(String tenantId) {
|
||||
if (StrUtil.isBlankIfStr(tenantId)) {
|
||||
return false;
|
||||
}
|
||||
SysTenantEntity entity = sysTenantService.selectSysTenantByTenantId(tenantId);
|
||||
if (entity == null) {
|
||||
return false;
|
||||
}
|
||||
//判断租户是否过期
|
||||
//...
|
||||
//校验通过
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.starry.admin.modules.clear.service.IPlayClerkClassificationInfoServic
|
||||
import com.starry.common.annotation.Log;
|
||||
import com.starry.common.enums.BusinessType;
|
||||
import com.starry.common.result.R;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -27,10 +26,9 @@ public class PlayClerkClassificationInfoController {
|
||||
/**
|
||||
* 查询店员分类列表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:list')")
|
||||
@GetMapping("/listAll")
|
||||
public R listAll() {
|
||||
List<PlayClerkClassificationInfoEntity> list = playClerkClassificationInfoService.selectPlayClerkClassificationInfo();
|
||||
List<PlayClerkClassificationInfoEntity> list = playClerkClassificationInfoService.selectAll();
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@@ -38,7 +36,6 @@ public class PlayClerkClassificationInfoController {
|
||||
/**
|
||||
* 查询店员分类列表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:list')")
|
||||
@GetMapping("/list")
|
||||
public R list(PlayClerkClassificationInfoEntity playClerkClassificationInfo) {
|
||||
IPage<PlayClerkClassificationInfoEntity> list = playClerkClassificationInfoService.selectPlayClerkClassificationInfoByPage(playClerkClassificationInfo);
|
||||
@@ -48,7 +45,6 @@ public class PlayClerkClassificationInfoController {
|
||||
/**
|
||||
* 获取店员分类详细信息
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public R getInfo(@PathVariable("id") String id) {
|
||||
return R.ok(playClerkClassificationInfoService.selectPlayClerkClassificationInfoById(id));
|
||||
@@ -57,7 +53,6 @@ public class PlayClerkClassificationInfoController {
|
||||
/**
|
||||
* 新增店员分类
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:create')")
|
||||
@Log(title = "店员分类", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/create")
|
||||
public R create(@RequestBody PlayClerkClassificationInfoEntity playClerkClassificationInfo) {
|
||||
@@ -71,7 +66,6 @@ public class PlayClerkClassificationInfoController {
|
||||
/**
|
||||
* 修改店员分类
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:edit')")
|
||||
@Log(title = "店员分类", businessType = BusinessType.UPDATE)
|
||||
@PostMapping(value = "/update/{id}")
|
||||
public R update(@PathVariable String id, @RequestBody PlayClerkClassificationInfoEntity playClerkClassificationInfo) {
|
||||
@@ -86,7 +80,6 @@ public class PlayClerkClassificationInfoController {
|
||||
/**
|
||||
* 删除店员分类
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:remove')")
|
||||
@Log(title = "店员分类", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R remove(@PathVariable String[] ids) {
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.starry.common.annotation.Log;
|
||||
import com.starry.common.enums.BusinessType;
|
||||
import com.starry.common.result.R;
|
||||
import com.starry.common.utils.ConvertUtil;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -31,7 +30,6 @@ public class PlayClerkCommodityController {
|
||||
/**
|
||||
* 查询陪玩服务项目列表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:commodity:list')")
|
||||
@GetMapping("/listAllCommodity")
|
||||
public R listAllCommodity() {
|
||||
List<PlayClerkCommodityEntity> list = playClerkCommodityService.selectAll();
|
||||
@@ -42,7 +40,6 @@ public class PlayClerkCommodityController {
|
||||
/**
|
||||
* 查询陪玩服务项目列表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:commodity:list')")
|
||||
@GetMapping("/list")
|
||||
public R list(PlayClerkCommodityEntity playClerkCommodity) {
|
||||
IPage<PlayClerkCommodityEntity> list = playClerkCommodityService.selectPlayClerkCommodityByPage(playClerkCommodity);
|
||||
@@ -52,7 +49,6 @@ public class PlayClerkCommodityController {
|
||||
/**
|
||||
* 获取陪玩服务项目详细信息
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:commodity:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public R getInfo(@PathVariable("id") String id) {
|
||||
return R.ok(playClerkCommodityService.selectPlayClerkCommodityById(id));
|
||||
@@ -61,7 +57,6 @@ public class PlayClerkCommodityController {
|
||||
/**
|
||||
* 新增陪玩服务项目
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:commodity:create')")
|
||||
@Log(title = "陪玩服务项目", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/create")
|
||||
public R create(@RequestBody PlayClerkCommodityEntity playClerkCommodity) {
|
||||
@@ -73,7 +68,6 @@ public class PlayClerkCommodityController {
|
||||
}
|
||||
|
||||
|
||||
@PreAuthorize("@customSs.hasPermission('play:commodity:edit')")
|
||||
@Log(title = "启停陪玩服务项目", businessType = BusinessType.UPDATE)
|
||||
@PostMapping(value = "/startStopClerkItem")
|
||||
public R startStopClerkItem(@Validated @RequestBody PlayClerkCommodityEditVo vo) {
|
||||
@@ -85,7 +79,6 @@ public class PlayClerkCommodityController {
|
||||
/**
|
||||
* 修改陪玩服务项目
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:commodity:edit')")
|
||||
@Log(title = "陪玩服务项目", businessType = BusinessType.UPDATE)
|
||||
@PostMapping(value = "/update/{id}")
|
||||
public R update(@PathVariable String id, @RequestBody PlayClerkCommodityEntity playClerkCommodity) {
|
||||
@@ -100,7 +93,6 @@ public class PlayClerkCommodityController {
|
||||
/**
|
||||
* 删除陪玩服务项目
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:commodity:remove')")
|
||||
@Log(title = "陪玩服务项目", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R remove(@PathVariable String[] ids) {
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.starry.admin.modules.clear.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkDataReviewInfoEditVo;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkDataReviewInfoEntity;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkDataReviewInfoQueryVo;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoEntity;
|
||||
import com.starry.admin.modules.clear.service.IPlayClerkCommodityService;
|
||||
import com.starry.admin.modules.clear.service.IPlayClerkDataReviewInfoService;
|
||||
import com.starry.admin.modules.clear.service.impl.PlayClerkUserInfoServiceImpl;
|
||||
import com.starry.admin.modules.weichat.entity.PlayClerkUserAlbumVo;
|
||||
import com.starry.admin.modules.weichat.entity.PlayClerkUserAudioVo;
|
||||
import com.starry.admin.modules.weichat.entity.PlayClerkUserAvatarVo;
|
||||
import com.starry.common.annotation.Log;
|
||||
import com.starry.common.enums.BusinessType;
|
||||
import com.starry.common.result.R;
|
||||
import com.starry.common.utils.ConvertUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 店员资料审核Controller
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024-04-11
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/clerk/data/review")
|
||||
public class PlayClerkDataReviewInfoController {
|
||||
private static final Logger log = LoggerFactory.getLogger(PlayClerkDataReviewInfoController.class);
|
||||
@Resource
|
||||
private IPlayClerkDataReviewInfoService playClerkDataReviewInfoService;
|
||||
|
||||
|
||||
@Resource
|
||||
private PlayClerkUserInfoServiceImpl playClerkUserInfoService;
|
||||
|
||||
|
||||
@Resource
|
||||
private IPlayClerkCommodityService playClerkCommodityService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询店员资料审核列表
|
||||
*/
|
||||
@PostMapping("/listByPage")
|
||||
public R list(PlayClerkDataReviewInfoQueryVo vo) {
|
||||
IPage<PlayClerkDataReviewInfoEntity> list = playClerkDataReviewInfoService.selectPlayClerkDataReviewInfoByPage(vo);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店员资料审核详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
public R getInfo(@PathVariable("id") String id) {
|
||||
return R.ok(playClerkDataReviewInfoService.selectPlayClerkDataReviewInfoById(id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改店员资料审核
|
||||
*/
|
||||
|
||||
@Log(title = "店员资料审核", businessType = BusinessType.UPDATE)
|
||||
@PostMapping(value = "/update")
|
||||
public R update(@RequestBody PlayClerkDataReviewInfoEditVo vo) {
|
||||
PlayClerkDataReviewInfoEntity entity = ConvertUtil.entityToVo(vo, PlayClerkDataReviewInfoEntity.class);
|
||||
boolean success = playClerkDataReviewInfoService.update(entity);
|
||||
if (success) {
|
||||
entity = playClerkDataReviewInfoService.selectPlayClerkDataReviewInfoById(entity.getId());
|
||||
if (entity != null && entity.getState().equals("1")) {
|
||||
switch (entity.getDataType()) {
|
||||
case "0": {
|
||||
//陪玩申请审批通过,初始化陪玩信息
|
||||
PlayClerkUserInfoEntity item = JSONObject.parseObject(entity.getContent(), PlayClerkUserInfoEntity.class);
|
||||
item.setId(entity.getPlayUserId());
|
||||
item.setClerkState("1");
|
||||
playClerkUserInfoService.update(item);
|
||||
//初始化陪玩服务项目
|
||||
playClerkCommodityService.initClerkCommodity(entity.getPlayUserId());
|
||||
break;
|
||||
}
|
||||
case "1": {
|
||||
PlayClerkUserAvatarVo item = JSONObject.parseObject(entity.getContent(), PlayClerkUserAvatarVo.class);
|
||||
PlayClerkUserInfoEntity userInfo = new PlayClerkUserInfoEntity();
|
||||
userInfo.setId(entity.getPlayUserId());
|
||||
userInfo.setAvatar(item.getAvatar());
|
||||
playClerkUserInfoService.update(userInfo);
|
||||
break;
|
||||
}
|
||||
case "2": {
|
||||
PlayClerkUserAlbumVo item = JSONObject.parseObject(entity.getContent(), PlayClerkUserAlbumVo.class);
|
||||
PlayClerkUserInfoEntity userInfo = new PlayClerkUserInfoEntity();
|
||||
userInfo.setId(entity.getPlayUserId());
|
||||
userInfo.setAlbum(item.getAlbum());
|
||||
playClerkUserInfoService.update(userInfo);
|
||||
|
||||
break;
|
||||
}
|
||||
case "3": {
|
||||
PlayClerkUserAudioVo item = JSONObject.parseObject(entity.getContent(), PlayClerkUserAudioVo.class);
|
||||
PlayClerkUserInfoEntity userInfo = new PlayClerkUserInfoEntity();
|
||||
userInfo.setId(entity.getPlayUserId());
|
||||
userInfo.setAudio(item.getAudio());
|
||||
playClerkUserInfoService.update(userInfo);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
log.error("dataType not,dataType = {}", entity.getDataType());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("修改失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除店员资料审核
|
||||
*/
|
||||
@Log(title = "店员资料审核", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R remove(@PathVariable String[] ids) {
|
||||
return R.ok(playClerkDataReviewInfoService.deletePlayClerkDataReviewInfoByIds(ids));
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import com.starry.common.annotation.Log;
|
||||
import com.starry.common.enums.BusinessType;
|
||||
import com.starry.common.result.R;
|
||||
import com.starry.common.utils.ConvertUtil;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -29,7 +28,6 @@ public class PlayClerkLevelInfoController {
|
||||
/**
|
||||
* 查询店员等级列表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:list')")
|
||||
@GetMapping("/listAll")
|
||||
public R listAll() {
|
||||
return R.ok(playClerkLevelInfoService.selectAll());
|
||||
@@ -38,7 +36,6 @@ public class PlayClerkLevelInfoController {
|
||||
/**
|
||||
* 获取店员等级详细信息
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public R getInfo(@PathVariable("id") String id) {
|
||||
return R.ok(playClerkLevelInfoService.selectPlayClerkLevelInfoById(id));
|
||||
@@ -47,7 +44,6 @@ public class PlayClerkLevelInfoController {
|
||||
/**
|
||||
* 新增店员等级
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:create')")
|
||||
@Log(title = "店员等级", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/create")
|
||||
public R create(@RequestBody PlayClerkLevelAddVo vo) {
|
||||
@@ -64,7 +60,6 @@ public class PlayClerkLevelInfoController {
|
||||
/**
|
||||
* 修改店员等级
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:edit')")
|
||||
@Log(title = "店员等级", businessType = BusinessType.UPDATE)
|
||||
@PostMapping(value = "/update")
|
||||
public R update(@Validated @RequestBody PlayClerkLevelEditVo vo) {
|
||||
@@ -79,7 +74,6 @@ public class PlayClerkLevelInfoController {
|
||||
/**
|
||||
* 删除店员等级
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:remove')")
|
||||
@Log(title = "店员等级", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("delMaxLevel")
|
||||
public R remove() {
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.starry.common.annotation.Log;
|
||||
import com.starry.common.enums.BusinessType;
|
||||
import com.starry.common.result.R;
|
||||
import com.starry.common.utils.ConvertUtil;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -56,8 +55,7 @@ public class PlayClerkUserInfoController {
|
||||
/**
|
||||
* 查询店员列表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:list')")
|
||||
@GetMapping("/wx/listByPage")
|
||||
@PostMapping("listByPage")
|
||||
public R listByPage(PlayClerkUserInfoQueryVo vo) {
|
||||
IPage<PlayClerkUserInfoEntity> list = playClerkUserInfoService.selectPlayClerkUserInfoByPage(vo);
|
||||
return R.ok(list);
|
||||
@@ -67,7 +65,6 @@ public class PlayClerkUserInfoController {
|
||||
/**
|
||||
* 查询店员列表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:list')")
|
||||
@GetMapping("/list")
|
||||
public R list(PlayClerkUserInfoQueryVo vo) {
|
||||
IPage<PlayClerkUserInfoEntity> list = playClerkUserInfoService.selectPlayClerkUserInfoByPage(vo);
|
||||
@@ -77,7 +74,6 @@ public class PlayClerkUserInfoController {
|
||||
/**
|
||||
* 获取店员详细信息
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public R getInfo(@PathVariable("id") String id) {
|
||||
return R.ok(playClerkUserInfoService.selectById(id));
|
||||
@@ -87,7 +83,6 @@ public class PlayClerkUserInfoController {
|
||||
/**
|
||||
* 微信端口新增店员
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:create')")
|
||||
@Log(title = "店员", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/wx/add")
|
||||
public R add(@Validated @RequestBody PlayClerkUserAddToWxVo vo) {
|
||||
@@ -110,7 +105,6 @@ public class PlayClerkUserInfoController {
|
||||
/**
|
||||
* 新增店员
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:create')")
|
||||
@Log(title = "店员", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/create")
|
||||
public R create(@Validated @RequestBody PlayClerkUserAddVo vo) {
|
||||
@@ -126,7 +120,6 @@ public class PlayClerkUserInfoController {
|
||||
/**
|
||||
* 修改店员
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:edit')")
|
||||
@Log(title = "店员", businessType = BusinessType.UPDATE)
|
||||
@PostMapping(value = "/update")
|
||||
public R update(@Validated @RequestBody PlayClerkUserEditVo vo) {
|
||||
@@ -141,7 +134,6 @@ public class PlayClerkUserInfoController {
|
||||
/**
|
||||
* 删除店员
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:remove')")
|
||||
@Log(title = "店员", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R remove(@PathVariable String[] ids) {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.starry.admin.modules.clear.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkDataReviewInfoEntity;
|
||||
|
||||
/**
|
||||
* 店员资料审核Mapper接口
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024-04-11
|
||||
*/
|
||||
public interface PlayClerkDataReviewInfoMapper extends BaseMapper<PlayClerkDataReviewInfoEntity> {
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.starry.admin.modules.clear.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoEntity;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoEntity;
|
||||
* @author admin
|
||||
* @since 2024-03-30
|
||||
*/
|
||||
public interface PlayClerkUserInfoMapper extends BaseMapper<PlayClerkUserInfoEntity> {
|
||||
public interface PlayClerkUserInfoMapper extends MPJBaseMapper<PlayClerkUserInfoEntity> {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.starry.admin.modules.clear.module.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 店员评价信息
|
||||
*/
|
||||
@Data
|
||||
public class PlayClarkUserEvaluateInfoEntity {
|
||||
|
||||
private String id;
|
||||
|
||||
|
||||
/**
|
||||
* 评价人ID
|
||||
*/
|
||||
private String evaluatorId;
|
||||
|
||||
|
||||
/**
|
||||
* 评价人昵称
|
||||
*/
|
||||
private String evaluatorUsername;
|
||||
|
||||
/**
|
||||
* 评价人头像
|
||||
*/
|
||||
private String evaluatorAvatar;
|
||||
|
||||
/**
|
||||
* 评价内容
|
||||
*/
|
||||
private String con;
|
||||
|
||||
/**
|
||||
* 评价时间
|
||||
*/
|
||||
private Date evaluateTime;
|
||||
|
||||
|
||||
/**
|
||||
* 订单ID
|
||||
*/
|
||||
private String orderId;
|
||||
|
||||
/**
|
||||
* 店员昵称
|
||||
*/
|
||||
private String clarkUsername;
|
||||
|
||||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
private String commodityId;
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
private String commodityName;
|
||||
|
||||
/**
|
||||
* 商品单位
|
||||
*/
|
||||
private String commodityUnit;
|
||||
|
||||
|
||||
public PlayClarkUserEvaluateInfoEntity(String id, String evaluatorId, String evaluatorUsername, String evaluatorAvatar, String con, Date evaluateTime, String orderId, String clarkUsername, String commodityId, String commodityName, String commodityUnit) {
|
||||
this.id = id;
|
||||
this.evaluatorId = evaluatorId;
|
||||
this.evaluatorUsername = evaluatorUsername;
|
||||
this.evaluatorAvatar = evaluatorAvatar;
|
||||
this.con = con;
|
||||
this.evaluateTime = evaluateTime;
|
||||
this.orderId = orderId;
|
||||
this.clarkUsername = clarkUsername;
|
||||
this.commodityId = commodityId;
|
||||
this.commodityName = commodityName;
|
||||
this.commodityUnit = commodityUnit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.starry.admin.modules.clear.module.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 店员动态
|
||||
*/
|
||||
@Data
|
||||
public class PlayClarkUserTrendsInfoEntity {
|
||||
|
||||
private String id;
|
||||
|
||||
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 动态类型(0:照片,1:视频)
|
||||
*/
|
||||
private String type;
|
||||
|
||||
|
||||
private String con;
|
||||
|
||||
|
||||
private Date releaseTime;
|
||||
|
||||
public PlayClarkUserTrendsInfoEntity(String id, String title, String con, Date releaseTime) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.con = con;
|
||||
this.releaseTime = releaseTime;
|
||||
this.type = "1";
|
||||
}
|
||||
|
||||
public PlayClarkUserTrendsInfoEntity(String id, String title, String type, String con, Date releaseTime) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.type = type;
|
||||
this.con = con;
|
||||
this.releaseTime = releaseTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.starry.admin.modules.clear.module.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 店员资料审核对象 play_clerk_data_review_info
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024-04-11
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class PlayClerkDataReviewInfoEditVo {
|
||||
|
||||
|
||||
/**
|
||||
* UUID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 资料类型[0:店员申请,1:头像;2:相册;3:录音]
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 审核状态
|
||||
* 0:未审核
|
||||
* 1:审核通过
|
||||
* 2:审核未通过
|
||||
*/
|
||||
private String state;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.starry.admin.modules.clear.module.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.starry.common.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 店员资料审核对象 play_clerk_data_review_info
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024-04-11
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("play_clerk_data_review_info")
|
||||
public class PlayClerkDataReviewInfoEntity extends BaseEntity<PlayClerkDataReviewInfoEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* UUID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 店员ID
|
||||
*/
|
||||
private String playUserId;
|
||||
|
||||
/**
|
||||
* 资料类型[0:店员申请,1:头像;2:相册;3:录音]
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 资料内容(JSON格式)
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 审核状态
|
||||
* 0:未审核
|
||||
* 1:审核通过
|
||||
* 2:审核未通过
|
||||
*/
|
||||
private String state;
|
||||
|
||||
/**
|
||||
* 资料添加时间
|
||||
*/
|
||||
private Date addTime;
|
||||
|
||||
/**
|
||||
* 审核时间
|
||||
*/
|
||||
private Date reviewTime;
|
||||
|
||||
/**
|
||||
* 审核人
|
||||
*/
|
||||
private String reviewBy;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.starry.admin.modules.clear.module.entity;
|
||||
|
||||
import com.starry.common.domain.BasePageEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 店员资料审核对象 play_clerk_data_review_info
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024-04-11
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class PlayClerkDataReviewInfoQueryVo extends BasePageEntity {
|
||||
|
||||
|
||||
/**
|
||||
* UUID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
|
||||
/**
|
||||
* 资料类型[0:店员申请,1:头像;2:相册;3:录音]
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 资料内容(JSON格式)
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 审核状态
|
||||
* 0:未审核
|
||||
* 1:审核通过
|
||||
* 2:审核未通过
|
||||
*/
|
||||
private String state = "0";
|
||||
|
||||
/**
|
||||
* 资料添加时间
|
||||
*/
|
||||
private Date addTime;
|
||||
|
||||
/**
|
||||
* 审核时间
|
||||
*/
|
||||
private Date reviewTime;
|
||||
|
||||
/**
|
||||
* 审核人
|
||||
*/
|
||||
private String reviewBy;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.starry.admin.modules.clear.module.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PlayClerkUserDetailResultVo {
|
||||
|
||||
/**
|
||||
* UUID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 店员昵称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 店员等级
|
||||
*/
|
||||
private String levelId;
|
||||
|
||||
/**
|
||||
* 店员等级
|
||||
*/
|
||||
private String levelName;
|
||||
|
||||
/**
|
||||
* 性别[0:未知;1:男;2:女]
|
||||
*/
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 头像框
|
||||
*/
|
||||
private String avatarFrameId;
|
||||
|
||||
/**
|
||||
* 音频
|
||||
*/
|
||||
private String audio;
|
||||
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* 个性签名
|
||||
*/
|
||||
private String signature;
|
||||
|
||||
/**
|
||||
* 年龄
|
||||
*/
|
||||
private Integer age;
|
||||
|
||||
/**
|
||||
* 关注(0:未关注,1:已关注)
|
||||
*/
|
||||
private String followState = "0";
|
||||
/**
|
||||
* 价格
|
||||
*/
|
||||
private String price;
|
||||
|
||||
/**
|
||||
* 礼物列表
|
||||
*/
|
||||
|
||||
private List<PlayGiftInfoEntity> gifts;
|
||||
|
||||
/**
|
||||
* 服务项目
|
||||
*/
|
||||
private List<PlayClerkCommodityEntity> commodity;
|
||||
|
||||
}
|
||||
@@ -1,11 +1,16 @@
|
||||
package com.starry.admin.modules.clear.module.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.starry.admin.common.conf.StringTypeHandler;
|
||||
import com.starry.common.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 店员对象 play_clerk_user_info
|
||||
*
|
||||
@@ -14,7 +19,7 @@ import lombok.EqualsAndHashCode;
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("play_clerk_user_info")
|
||||
@TableName(value = "play_clerk_user_info", autoResultMap = true)
|
||||
public class PlayClerkUserInfoEntity extends BaseEntity<PlayClerkUserInfoEntity> {
|
||||
|
||||
|
||||
@@ -28,6 +33,11 @@ public class PlayClerkUserInfoEntity extends BaseEntity<PlayClerkUserInfoEntity>
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 电话号码
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 陪玩用户ID
|
||||
*/
|
||||
@@ -54,7 +64,7 @@ public class PlayClerkUserInfoEntity extends BaseEntity<PlayClerkUserInfoEntity>
|
||||
private String typeId;
|
||||
|
||||
/**
|
||||
* 店员性别(1:男:0:女)
|
||||
* 性别[0:未知;1:男;2:女]
|
||||
*/
|
||||
private String sex;
|
||||
|
||||
@@ -71,7 +81,7 @@ public class PlayClerkUserInfoEntity extends BaseEntity<PlayClerkUserInfoEntity>
|
||||
/**
|
||||
* 音频
|
||||
*/
|
||||
private String audioFrequency;
|
||||
private String audio;
|
||||
|
||||
/**
|
||||
* 星座
|
||||
@@ -81,7 +91,8 @@ public class PlayClerkUserInfoEntity extends BaseEntity<PlayClerkUserInfoEntity>
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
private String label;
|
||||
@TableField(typeHandler = StringTypeHandler.class)
|
||||
private List<String> label = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 个性签名
|
||||
@@ -91,7 +102,7 @@ public class PlayClerkUserInfoEntity extends BaseEntity<PlayClerkUserInfoEntity>
|
||||
/**
|
||||
* 年龄
|
||||
*/
|
||||
private Long age;
|
||||
private Integer age;
|
||||
|
||||
/**
|
||||
* 所在国家
|
||||
@@ -118,7 +129,6 @@ public class PlayClerkUserInfoEntity extends BaseEntity<PlayClerkUserInfoEntity>
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
/**
|
||||
* 在职状态(1:在职,0:离职)
|
||||
*/
|
||||
@@ -164,6 +174,30 @@ public class PlayClerkUserInfoEntity extends BaseEntity<PlayClerkUserInfoEntity>
|
||||
*/
|
||||
private String randomOrder;
|
||||
|
||||
/**
|
||||
* 店员状态(0:不是陪玩,1:陪玩)
|
||||
*/
|
||||
private String clerkState;
|
||||
/**
|
||||
* 相册
|
||||
*/
|
||||
@TableField(typeHandler = StringTypeHandler.class)
|
||||
private List<String> album = new ArrayList<>();
|
||||
/**
|
||||
* 微信二维码
|
||||
**/
|
||||
private String weChatCodeImage;
|
||||
|
||||
/**
|
||||
* 微信收款码图片
|
||||
**/
|
||||
private String weChatPayImage;
|
||||
|
||||
/**
|
||||
* 支付宝收款码图片
|
||||
**/
|
||||
private String alipayImage;
|
||||
|
||||
/**
|
||||
* 最近一次登录token
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 店员对象 play_clerk_user_info
|
||||
* 分页查询店员对象
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024-03-30
|
||||
@@ -15,6 +15,10 @@ import lombok.EqualsAndHashCode;
|
||||
public class PlayClerkUserInfoQueryVo extends BasePageEntity {
|
||||
|
||||
|
||||
/**
|
||||
* 店员昵称
|
||||
**/
|
||||
private String nickname;
|
||||
/**
|
||||
* 店员等级
|
||||
*/
|
||||
@@ -41,5 +45,16 @@ public class PlayClerkUserInfoQueryVo extends BasePageEntity {
|
||||
*/
|
||||
private String listingState;
|
||||
|
||||
/**
|
||||
* 员工状态【1:是陪玩,0:不是陪玩】
|
||||
*/
|
||||
private String clerkState;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.starry.admin.modules.clear.module.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PlayClerkUserListResultVo {
|
||||
|
||||
/**
|
||||
* UUID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 店员昵称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 店员等级
|
||||
*/
|
||||
private String levelId;
|
||||
|
||||
/**
|
||||
* 店员等级
|
||||
*/
|
||||
private String levelName;
|
||||
|
||||
|
||||
/**
|
||||
* 性别[0:未知;1:男;2:女]
|
||||
*/
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
|
||||
/**
|
||||
* 音频
|
||||
*/
|
||||
private String audio;
|
||||
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
private List<String> label = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 相册
|
||||
*/
|
||||
private List<String> album = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 个性签名
|
||||
*/
|
||||
private String signature;
|
||||
|
||||
/**
|
||||
* 年龄
|
||||
*/
|
||||
private Integer age;
|
||||
|
||||
|
||||
/**
|
||||
* 关注(0:未关注,1:已关注)
|
||||
*/
|
||||
private String followState = "0";
|
||||
|
||||
/**
|
||||
* 在线状态【1:在线,0:离线】
|
||||
*/
|
||||
private String onlineState;
|
||||
|
||||
/**
|
||||
* 服务项目
|
||||
*/
|
||||
private List<String> commodity;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.starry.admin.modules.clear.module.entity;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 礼物信息
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class PlayGiftInfoEntity {
|
||||
|
||||
|
||||
/**
|
||||
* 礼物ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 礼物名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 礼物地址
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 获得数量
|
||||
*/
|
||||
private Integer number;
|
||||
|
||||
|
||||
/**
|
||||
* 礼物状态(0:正常,1:已下架)
|
||||
*/
|
||||
private String state;
|
||||
|
||||
public PlayGiftInfoEntity(String id, String name, String url, Integer number, String state) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
this.number = number;
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.starry.admin.modules.clear.module.vo;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
@Data
|
||||
public class PlayClerkCommodityEditVo {
|
||||
@@ -20,5 +21,6 @@ public class PlayClerkCommodityEditVo {
|
||||
* 1:启用
|
||||
*/
|
||||
@NotNull(message = "服务状态不能为空")
|
||||
@Pattern(regexp = "[01]", message = "服务状态必须为0或1")
|
||||
private String enablingState;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public interface IPlayClerkClassificationInfoService extends IService<PlayClerkC
|
||||
*
|
||||
* @return 店员分类集合
|
||||
*/
|
||||
List<PlayClerkClassificationInfoEntity> selectPlayClerkClassificationInfo();
|
||||
List<PlayClerkClassificationInfoEntity> selectAll();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,14 @@ public interface IPlayClerkCommodityService extends IService<PlayClerkCommodityE
|
||||
void initClerkCommodity(String playUserId);
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户ID,查询当前用户的服务项目
|
||||
*
|
||||
* @param playUserId 用户ID
|
||||
* @return List<PlayClerkCommodityEntity>
|
||||
*/
|
||||
List<PlayClerkCommodityEntity> selectByUser(String playUserId);
|
||||
|
||||
/**
|
||||
* 查询当前陪玩所有服务项目
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.starry.admin.modules.clear.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkDataReviewInfoEntity;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkDataReviewInfoQueryVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 店员资料审核Service接口
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024-04-11
|
||||
*/
|
||||
public interface IPlayClerkDataReviewInfoService extends IService<PlayClerkDataReviewInfoEntity> {
|
||||
/**
|
||||
* 查询店员资料审核
|
||||
*
|
||||
* @param id 店员资料审核主键
|
||||
* @return 店员资料审核
|
||||
*/
|
||||
PlayClerkDataReviewInfoEntity selectPlayClerkDataReviewInfoById(String id);
|
||||
|
||||
/**
|
||||
* 查询店员资料审核列表
|
||||
*
|
||||
* @param entity 店员资料审核
|
||||
* @return 店员资料审核集合
|
||||
*/
|
||||
List<PlayClerkDataReviewInfoEntity> queryList(PlayClerkDataReviewInfoEntity entity);
|
||||
|
||||
/**
|
||||
* 查询店员资料审核列表
|
||||
*
|
||||
* @param playClerkDataReviewInfo 店员资料审核
|
||||
* @return 店员资料审核集合
|
||||
*/
|
||||
IPage<PlayClerkDataReviewInfoEntity> selectPlayClerkDataReviewInfoByPage(PlayClerkDataReviewInfoQueryVo playClerkDataReviewInfo);
|
||||
|
||||
/**
|
||||
* 新增店员资料审核
|
||||
*
|
||||
* @param playClerkDataReviewInfo 店员资料审核
|
||||
* @return 结果
|
||||
*/
|
||||
boolean create(PlayClerkDataReviewInfoEntity playClerkDataReviewInfo);
|
||||
|
||||
/**
|
||||
* 修改店员资料审核
|
||||
*
|
||||
* @param playClerkDataReviewInfo 店员资料审核
|
||||
* @return 结果
|
||||
*/
|
||||
boolean update(PlayClerkDataReviewInfoEntity playClerkDataReviewInfo);
|
||||
|
||||
/**
|
||||
* 批量删除店员资料审核
|
||||
*
|
||||
* @param ids 需要删除的店员资料审核主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deletePlayClerkDataReviewInfoByIds(String[] ids);
|
||||
|
||||
/**
|
||||
* 删除店员资料审核信息
|
||||
*
|
||||
* @param id 店员资料审核主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deletePlayClerkDataReviewInfoById(String id);
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoEntity;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoQueryVo;
|
||||
import com.starry.admin.modules.weichat.entity.PlayClerkUserLoginResponseVo;
|
||||
|
||||
|
||||
/**
|
||||
@@ -38,13 +39,20 @@ public interface IPlayClerkUserInfoService extends IService<PlayClerkUserInfoEnt
|
||||
*/
|
||||
PlayClerkUserInfoEntity selectById(String id);
|
||||
|
||||
/**
|
||||
* 获得陪玩用户登录返回信息
|
||||
*
|
||||
* @param vo PlayClerkUserInfoEntity
|
||||
* @return PlayClerkUserLoginResponseVo
|
||||
*/
|
||||
PlayClerkUserLoginResponseVo getVo(PlayClerkUserInfoEntity vo);
|
||||
|
||||
/**
|
||||
* 跟新token
|
||||
*
|
||||
* @param id 用户ID
|
||||
* @param token token
|
||||
* @author 杭州世平信息科技有限公司-xuhq
|
||||
* @author admin
|
||||
* @since 2024/4/9 14:30
|
||||
**/
|
||||
void updateTokenById(String id, String token);
|
||||
|
||||
@@ -44,7 +44,7 @@ public class PlayClerkClassificationInfoServiceImpl extends ServiceImpl<PlayCler
|
||||
* @return 店员分类
|
||||
*/
|
||||
@Override
|
||||
public List<PlayClerkClassificationInfoEntity> selectPlayClerkClassificationInfo() {
|
||||
public List<PlayClerkClassificationInfoEntity> selectAll() {
|
||||
return this.baseMapper.selectList(new LambdaQueryWrapper<>());
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -50,13 +51,18 @@ public class PlayClerkCommodityServiceImpl extends ServiceImpl<PlayClerkCommodit
|
||||
|
||||
|
||||
@Override
|
||||
public List<PlayClerkCommodityEntity> selectAll() {
|
||||
public List<PlayClerkCommodityEntity> selectByUser(String playUserId) {
|
||||
LambdaQueryWrapper<PlayClerkCommodityEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.groupBy(PlayClerkCommodityEntity::getCommodityType);
|
||||
lambdaQueryWrapper.eq(PlayClerkCommodityEntity::getPlayUserId, "1");
|
||||
lambdaQueryWrapper.eq(PlayClerkCommodityEntity::getPlayUserId, playUserId);
|
||||
return this.baseMapper.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlayClerkCommodityEntity> selectAll() {
|
||||
return this.baseMapper.selectList(new LambdaQueryWrapper<>());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void startStopClerkItem(String type, String enablingState) {
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.starry.admin.modules.clear.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.starry.admin.modules.clear.mapper.PlayClerkDataReviewInfoMapper;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkDataReviewInfoEntity;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkDataReviewInfoQueryVo;
|
||||
import com.starry.admin.modules.clear.service.IPlayClerkDataReviewInfoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 店员资料审核Service业务层处理
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024-04-11
|
||||
*/
|
||||
@Service
|
||||
public class PlayClerkDataReviewInfoServiceImpl extends ServiceImpl<PlayClerkDataReviewInfoMapper, PlayClerkDataReviewInfoEntity> implements IPlayClerkDataReviewInfoService {
|
||||
@Resource
|
||||
private PlayClerkDataReviewInfoMapper playClerkDataReviewInfoMapper;
|
||||
|
||||
/**
|
||||
* 查询店员资料审核
|
||||
*
|
||||
* @param id 店员资料审核主键
|
||||
* @return 店员资料审核
|
||||
*/
|
||||
@Override
|
||||
public PlayClerkDataReviewInfoEntity selectPlayClerkDataReviewInfoById(String id) {
|
||||
return this.baseMapper.selectById(id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询店员资料审核列表
|
||||
*
|
||||
* @param entity 店员资料审核
|
||||
* @return 店员资料审核
|
||||
*/
|
||||
@Override
|
||||
public List<PlayClerkDataReviewInfoEntity> queryList(PlayClerkDataReviewInfoEntity entity) {
|
||||
LambdaQueryWrapper<PlayClerkDataReviewInfoEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StrUtil.isNotBlank(entity.getId())) {
|
||||
lambdaQueryWrapper.eq(PlayClerkDataReviewInfoEntity::getId, entity.getId());
|
||||
}
|
||||
if (StrUtil.isNotBlank(entity.getPlayUserId())) {
|
||||
lambdaQueryWrapper.eq(PlayClerkDataReviewInfoEntity::getPlayUserId, entity.getPlayUserId());
|
||||
}
|
||||
if (StrUtil.isNotBlank(entity.getState())) {
|
||||
lambdaQueryWrapper.eq(PlayClerkDataReviewInfoEntity::getState, entity.getState());
|
||||
}
|
||||
if (StrUtil.isNotBlank(entity.getDataType())) {
|
||||
lambdaQueryWrapper.eq(PlayClerkDataReviewInfoEntity::getDataType, entity.getDataType());
|
||||
}
|
||||
return this.baseMapper.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询店员资料审核列表
|
||||
*
|
||||
* @param vo 店员资料审核分页对象
|
||||
* @return 店员资料审核
|
||||
*/
|
||||
@Override
|
||||
public IPage<PlayClerkDataReviewInfoEntity> selectPlayClerkDataReviewInfoByPage(PlayClerkDataReviewInfoQueryVo vo) {
|
||||
LambdaQueryWrapper<PlayClerkDataReviewInfoEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StrUtil.isNotBlank(vo.getState())) {
|
||||
lambdaQueryWrapper.eq(PlayClerkDataReviewInfoEntity::getState, vo.getState());
|
||||
}
|
||||
Page<PlayClerkDataReviewInfoEntity> page = new Page<>(vo.getPageNum(), vo.getPageSize());
|
||||
return this.baseMapper.selectPage(page, lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增店员资料审核
|
||||
*
|
||||
* @param playClerkDataReviewInfo 店员资料审核
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean create(PlayClerkDataReviewInfoEntity playClerkDataReviewInfo) {
|
||||
if (StrUtil.isBlankIfStr(playClerkDataReviewInfo.getId())) {
|
||||
playClerkDataReviewInfo.setId(IdUtil.fastSimpleUUID());
|
||||
}
|
||||
return save(playClerkDataReviewInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改店员资料审核
|
||||
*
|
||||
* @param playClerkDataReviewInfo 店员资料审核
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean update(PlayClerkDataReviewInfoEntity playClerkDataReviewInfo) {
|
||||
return updateById(playClerkDataReviewInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除店员资料审核
|
||||
*
|
||||
* @param ids 需要删除的店员资料审核主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePlayClerkDataReviewInfoByIds(String[] ids) {
|
||||
return playClerkDataReviewInfoMapper.deleteBatchIds(Arrays.asList(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除店员资料审核信息
|
||||
*
|
||||
* @param id 店员资料审核主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePlayClerkDataReviewInfoById(String id) {
|
||||
return playClerkDataReviewInfoMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,25 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.starry.admin.modules.clear.mapper.PlayClerkUserInfoMapper;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkDataReviewInfoEntity;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkLevelInfoEntity;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoEntity;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoQueryVo;
|
||||
import com.starry.admin.modules.clear.module.vo.PlayClerkCommodityQueryVo;
|
||||
import com.starry.admin.modules.clear.service.IPlayClerkCommodityService;
|
||||
import com.starry.admin.modules.clear.service.IPlayClerkDataReviewInfoService;
|
||||
import com.starry.admin.modules.clear.service.IPlayClerkUserInfoService;
|
||||
import com.starry.admin.modules.weichat.entity.PlayClerkUserLoginResponseVo;
|
||||
import com.starry.common.utils.ConvertUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@@ -27,6 +38,16 @@ public class PlayClerkUserInfoServiceImpl extends ServiceImpl<PlayClerkUserInfoM
|
||||
@Resource
|
||||
private PlayClerkUserInfoMapper playClerkUserInfoMapper;
|
||||
|
||||
@Resource
|
||||
private PlayClerkDataReviewInfoServiceImpl dataReviewInfoService;
|
||||
|
||||
|
||||
@Resource
|
||||
private IPlayClerkCommodityService playClerkCommodityService;
|
||||
|
||||
@Resource
|
||||
private IPlayClerkDataReviewInfoService playClerkDataReviewInfoService;
|
||||
|
||||
|
||||
@Override
|
||||
public PlayClerkUserInfoEntity queryByUserId() {
|
||||
@@ -51,7 +72,32 @@ public class PlayClerkUserInfoServiceImpl extends ServiceImpl<PlayClerkUserInfoM
|
||||
@Override
|
||||
public PlayClerkUserInfoEntity selectById(String id) {
|
||||
return this.baseMapper.selectById(id);
|
||||
}
|
||||
|
||||
public PlayClerkUserLoginResponseVo getVo(PlayClerkUserInfoEntity userInfo) {
|
||||
PlayClerkUserLoginResponseVo result = ConvertUtil.entityToVo(userInfo, PlayClerkUserLoginResponseVo.class);
|
||||
|
||||
// 判断头像、音频、相册是否可以编辑,如果存在未审核的数据,则不允许编辑
|
||||
PlayClerkDataReviewInfoEntity dataReviewInfo = new PlayClerkDataReviewInfoEntity();
|
||||
dataReviewInfo.setPlayUserId(userInfo.getOpenid());
|
||||
dataReviewInfo.setState("0");
|
||||
List<PlayClerkDataReviewInfoEntity> list = dataReviewInfoService.queryList(dataReviewInfo);
|
||||
Map<String, PlayClerkDataReviewInfoEntity> map = list.stream().collect(Collectors.toMap(PlayClerkDataReviewInfoEntity::getDataType, account -> account));
|
||||
if (map.containsKey("1")) {
|
||||
result.setAvatarAllowEdit(false);
|
||||
}
|
||||
if (map.containsKey("2")) {
|
||||
result.setAvatarAllowEdit(false);
|
||||
}
|
||||
if (map.containsKey("3")) {
|
||||
result.setAudioAllowEdit(false);
|
||||
}
|
||||
if (map.containsKey("0") || ("1").equals(result.getClerkState())) {
|
||||
result.setClerkAllowEdit(false);
|
||||
}
|
||||
result.setCommodity(ConvertUtil.entityToVoList(playClerkCommodityService.selectAll(), PlayClerkCommodityQueryVo.class));
|
||||
result.setArea(userInfo.getProvince() + "-" + userInfo.getCity());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +118,36 @@ public class PlayClerkUserInfoServiceImpl extends ServiceImpl<PlayClerkUserInfoM
|
||||
@Override
|
||||
public IPage<PlayClerkUserInfoEntity> selectPlayClerkUserInfoByPage(PlayClerkUserInfoQueryVo vo) {
|
||||
Page<PlayClerkUserInfoEntity> page = new Page<>(vo.getPageNum(), vo.getPageSize());
|
||||
return this.baseMapper.selectPage(page, new LambdaQueryWrapper<>());
|
||||
|
||||
MPJLambdaWrapper<PlayClerkUserInfoEntity> lambdaQueryWrapper = new MPJLambdaWrapper<PlayClerkUserInfoEntity>()
|
||||
//查询主表全部字段
|
||||
.selectAll(PlayClerkUserInfoEntity.class)
|
||||
//等级表
|
||||
.selectAs(PlayClerkLevelInfoEntity::getName, "levelName").leftJoin(PlayClerkLevelInfoEntity.class, PlayClerkLevelInfoEntity::getId, PlayClerkUserInfoEntity::getLevelId);
|
||||
//服务项目表
|
||||
|
||||
|
||||
if (StrUtil.isNotBlank(vo.getNickname())) {
|
||||
lambdaQueryWrapper.like(PlayClerkUserInfoEntity::getNickname, vo.getNickname());
|
||||
}
|
||||
if (StrUtil.isNotBlank(vo.getTypeId())) {
|
||||
lambdaQueryWrapper.eq(PlayClerkUserInfoEntity::getTypeId, vo.getTypeId());
|
||||
}
|
||||
if (StrUtil.isNotBlank(vo.getLevelId())) {
|
||||
lambdaQueryWrapper.eq(PlayClerkUserInfoEntity::getLevelId, vo.getLevelId());
|
||||
}
|
||||
if (StrUtil.isNotBlank(vo.getSex())) {
|
||||
lambdaQueryWrapper.eq(PlayClerkUserInfoEntity::getSex, vo.getSex());
|
||||
}
|
||||
if (StrUtil.isNotBlank(vo.getProvince())) {
|
||||
lambdaQueryWrapper.eq(PlayClerkUserInfoEntity::getProvince, vo.getProvince());
|
||||
}
|
||||
if (StrUtil.isNotBlank(vo.getClerkState())) {
|
||||
lambdaQueryWrapper.eq(PlayClerkUserInfoEntity::getClerkState, vo.getClerkState());
|
||||
}
|
||||
|
||||
return this.baseMapper.selectJoinPage(page, PlayClerkUserInfoEntity.class, lambdaQueryWrapper);
|
||||
// return this.baseMapper.selectPage(page, lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,7 +51,7 @@ public interface IPlayCustomUserInfoService extends IService<PlayCustomUserInfoE
|
||||
*
|
||||
* @param id UUID
|
||||
* @param token TOKEN
|
||||
* @author 杭州世平信息科技有限公司-xuhq
|
||||
* @author admin
|
||||
* @since 2024/4/9 14:33
|
||||
**/
|
||||
void updateTokenById(String id, String token);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.starry.admin.modules.monitor.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.starry.admin.common.domain.LoginUser;
|
||||
@@ -41,15 +42,15 @@ public class UserOnlineController {
|
||||
List<UserOnline> userOnlineList = new ArrayList<>();
|
||||
for (String key : keys) {
|
||||
LoginUser user = redisCache.getCacheObject(key);
|
||||
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) {
|
||||
if (StrUtil.isNotBlank(ipaddr) && StrUtil.isNotBlank(userName)) {
|
||||
if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) {
|
||||
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
|
||||
}
|
||||
} else if (StringUtils.isNotEmpty(ipaddr)) {
|
||||
} else if (StrUtil.isNotBlank(ipaddr)) {
|
||||
if (StringUtils.equals(ipaddr, user.getIpaddr())) {
|
||||
userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
|
||||
}
|
||||
} else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser())) {
|
||||
} else if (StrUtil.isNotBlank(userName) && StringUtils.isNotNull(user.getUser())) {
|
||||
if (StringUtils.equals(userName, user.getUsername())) {
|
||||
userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
|
||||
}
|
||||
|
||||
@@ -106,6 +106,11 @@ public class SysTenantEntity extends BaseEntity<SysTenantEntity> {
|
||||
*/
|
||||
private Date tenantTime;
|
||||
|
||||
/**
|
||||
* 租户权限标识
|
||||
*/
|
||||
private String tenantKey;
|
||||
|
||||
/**
|
||||
* 微信公众号ID
|
||||
*/
|
||||
|
||||
@@ -15,6 +15,16 @@ import java.util.List;
|
||||
* @author admin
|
||||
*/
|
||||
public interface ISysTenantService extends IService<SysTenantEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* 根据租户权限标识查询租户
|
||||
*
|
||||
* @param tenantKey 租户权限标识
|
||||
* @return 租户表
|
||||
*/
|
||||
SysTenantEntity selectByTenantKey(String tenantKey);
|
||||
|
||||
/**
|
||||
* 查询租户表
|
||||
*
|
||||
|
||||
@@ -58,6 +58,14 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
|
||||
@Resource
|
||||
private RedisCache redisCache;
|
||||
|
||||
|
||||
@Override
|
||||
public SysTenantEntity selectByTenantKey(String tenantKey) {
|
||||
LambdaQueryWrapper<SysTenantEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(SysTenantEntity::getTenantKey, tenantKey);
|
||||
return this.baseMapper.selectOne(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询租户表
|
||||
*
|
||||
|
||||
@@ -12,6 +12,8 @@ import com.starry.admin.modules.play.module.vo.PlayUserInfoQueryVo;
|
||||
* @since 2024-03-30
|
||||
*/
|
||||
public interface IPlayUserInfoService extends IService<PlayUserInfoEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* 查询账号
|
||||
*
|
||||
|
||||
@@ -26,6 +26,8 @@ public class PlayUserInfoServiceImpl extends ServiceImpl<PlayUserInfoMapper, Pla
|
||||
@Resource
|
||||
private PlayUserInfoMapper playUserInfoMapper;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询账号
|
||||
*
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.starry.admin.modules.system.service.LoginService;
|
||||
import com.starry.admin.modules.system.service.SysMenuService;
|
||||
import com.starry.admin.modules.system.vo.LoginVo;
|
||||
import com.starry.admin.modules.system.vo.RouterVo;
|
||||
import com.starry.admin.modules.system.vo.TenantLoginVo;
|
||||
import com.starry.admin.utils.SecurityUtils;
|
||||
import com.starry.common.redis.CaptchaService;
|
||||
import com.starry.common.result.R;
|
||||
@@ -110,4 +111,21 @@ public class LoginController {
|
||||
Map<String, Object> tokenMap = jwtToken.createToken(userInfo);
|
||||
return R.ok(tokenMap);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "租户登录")
|
||||
@PostMapping(value = "tenant/login")
|
||||
public R TenantLoginVo(@RequestBody TenantLoginVo loginVo) {
|
||||
// 只有开启了验证码功能才需要验证
|
||||
if (needAuthCode) {
|
||||
String msg = captchaService.checkImageCode(loginVo.getNonceStr(), loginVo.getValue());
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
return R.error(msg);
|
||||
}
|
||||
}
|
||||
// 用户登录
|
||||
LoginUser userInfo = loginService.tenantLogin(loginVo.getTenantkey(), loginVo.getUserName(), loginVo.getPassWord());
|
||||
Map<String, Object> tokenMap = jwtToken.createToken(userInfo);
|
||||
return R.ok(tokenMap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public interface ISysAdministrativeAreaDictInfoService extends IService<SysAdmin
|
||||
*
|
||||
* @param level 行政区域等级(1:省级别,2:城市级别:4:区县级别)
|
||||
* @return List<AdministrativeAreaQueryReturnVo>
|
||||
* @author 杭州世平信息科技有限公司-xuhq
|
||||
* @author admin
|
||||
* @since 2024/4/10 14:47
|
||||
**/
|
||||
List<AdministrativeAreaQueryReturnVo> selectTree(String level);
|
||||
|
||||
@@ -36,6 +36,17 @@ public interface LoginService {
|
||||
*/
|
||||
Set<String> getRolePermission(SysUserEntity user);
|
||||
|
||||
|
||||
/**
|
||||
* 租户登录功能
|
||||
*
|
||||
* @param tenantkey 租户标识
|
||||
* @param username 用户名
|
||||
* @param password 密码
|
||||
* @return 生成的JWT的token
|
||||
*/
|
||||
LoginUser tenantLogin(String tenantkey, String username, String password);
|
||||
|
||||
/**
|
||||
* 登录功能
|
||||
*
|
||||
@@ -51,5 +62,5 @@ public interface LoginService {
|
||||
* @param userName 用户名
|
||||
* @return 获取信息
|
||||
*/
|
||||
LoginUser getLoginUserInfo(String userName);
|
||||
LoginUser getLoginUserInfo( String userName);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.starry.admin.manager.AsyncManager;
|
||||
import com.starry.admin.manager.factory.AsyncFactory;
|
||||
import com.starry.admin.modules.platform.entity.SysTenantEntity;
|
||||
import com.starry.admin.modules.platform.service.ISysTenantService;
|
||||
import com.starry.admin.modules.play.service.IPlayUserInfoService;
|
||||
import com.starry.admin.modules.system.entity.SysUserEntity;
|
||||
import com.starry.admin.modules.system.service.LoginService;
|
||||
import com.starry.admin.modules.system.service.SysMenuService;
|
||||
@@ -56,6 +57,9 @@ public class LoginServiceImpl implements LoginService {
|
||||
@Resource
|
||||
private ISysTenantService SysTenantService;
|
||||
|
||||
@Resource
|
||||
private IPlayUserInfoService playUserInfoService;
|
||||
|
||||
@Override
|
||||
public String login(String username, String password) {
|
||||
String token = null;
|
||||
@@ -102,6 +106,12 @@ public class LoginServiceImpl implements LoginService {
|
||||
return roles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoginUser tenantLogin(String tenantId, String username, String password) {
|
||||
LoginUser userInfo = this.getLoginUserInfo(username);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoginUser newLogin(String username, String password) {
|
||||
// 用户名或密码为空 错误
|
||||
@@ -111,15 +121,13 @@ public class LoginServiceImpl implements LoginService {
|
||||
throw new ServiceException("用户/密码必须填写");
|
||||
}
|
||||
// 密码如果不在指定范围内 错误
|
||||
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|
||||
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH) {
|
||||
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH || password.length() > UserConstants.PASSWORD_MAX_LENGTH) {
|
||||
// 登录记录日志
|
||||
AsyncManager.me().execute(AsyncFactory.recordLoginLog(username, Constants.LOGIN_FAIL, "用户密码不在指定范围"));
|
||||
throw new ServiceException("用户密码不在指定范围");
|
||||
}
|
||||
// 用户名不在指定范围内 错误
|
||||
if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|
||||
|| username.length() > UserConstants.USERNAME_MAX_LENGTH) {
|
||||
if (username.length() < UserConstants.USERNAME_MIN_LENGTH || username.length() > UserConstants.USERNAME_MAX_LENGTH) {
|
||||
// 登录记录日志
|
||||
AsyncManager.me().execute(AsyncFactory.recordLoginLog(username, Constants.LOGIN_FAIL, "用户名不在指定范围"));
|
||||
throw new ServiceException("用户名不在指定范围");
|
||||
@@ -162,6 +170,7 @@ public class LoginServiceImpl implements LoginService {
|
||||
public LoginUser getLoginUserInfo(String userName) {
|
||||
SysUserEntity sysUser = sysUserService.selectUserByUserName(userName);
|
||||
if (StringUtils.isNotNull(sysUser)) {
|
||||
// SecurityUtils.setTenantId(sysUser.getTenantId());
|
||||
// 角色集合
|
||||
Set<String> roles = this.getRolePermission(sysUser);
|
||||
// 权限集合
|
||||
|
||||
@@ -58,7 +58,7 @@ public class SysAdministrativeAreaDictInfoServiceImpl extends ServiceImpl<SysAdm
|
||||
* @param data 数据,key=区域编码,value=区域列表
|
||||
* @param list 区域略表
|
||||
* @return List<com.starry.admin.modules.system.entity.SysAdministrativeAreaDictInfoEntity>
|
||||
* @author 杭州世平信息科技有限公司-xuhq
|
||||
* @author admin
|
||||
* @since 2024/4/10 15:14
|
||||
**/
|
||||
public List<AdministrativeAreaQueryReturnVo> assembleTree(Map<String, List<SysAdministrativeAreaDictInfoEntity>> data, List<SysAdministrativeAreaDictInfoEntity> list) {
|
||||
|
||||
@@ -128,7 +128,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenuEntity
|
||||
List<String> perms = baseMapper.selectMenuPermsByUserId(userId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (String perm : perms) {
|
||||
if (StrUtil.isNotEmpty(perm)) {
|
||||
if (StrUtil.isNotBlank(perm)) {
|
||||
permsSet.addAll(Arrays.asList(perm.trim().split(",")));
|
||||
}
|
||||
}
|
||||
@@ -319,7 +319,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenuEntity
|
||||
*/
|
||||
public String getComponent(SysMenuEntity menu) {
|
||||
String component = UserConstants.LAYOUT;
|
||||
if (StringUtils.isNotEmpty(menu.getComponent()) && !isMenuFrame(menu)) {
|
||||
if (StrUtil.isNotBlank(menu.getComponent()) && !isMenuFrame(menu)) {
|
||||
component = menu.getComponent();
|
||||
} else if (StringUtils.isEmpty(menu.getComponent()) && menu.getParentId().intValue() != 0 && isInnerLink(menu)) {
|
||||
component = UserConstants.INNER_LINK;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.starry.admin.modules.system.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author huoqiang
|
||||
* @since 2021/9/6
|
||||
*/
|
||||
@Data
|
||||
public class TenantLoginVo implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@NotNull(message = "租户标识不能为空")
|
||||
private String tenantkey;
|
||||
|
||||
@ApiModelProperty(value = "用户名")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty(value = "密码")
|
||||
private String passWord;
|
||||
|
||||
@ApiModelProperty(value = "验证码随机字符串")
|
||||
private String nonceStr;
|
||||
|
||||
@ApiModelProperty(value = "验证值")
|
||||
private String value;
|
||||
}
|
||||
@@ -1,30 +1,40 @@
|
||||
package com.starry.admin.modules.weichat.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.starry.admin.common.aspect.ClerkUserLogin;
|
||||
import com.starry.admin.common.conf.ThreadLocalRequestDetail;
|
||||
import com.starry.admin.common.exception.CustomException;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoEntity;
|
||||
import com.starry.admin.modules.clear.module.entity.*;
|
||||
import com.starry.admin.modules.clear.module.vo.PlayClerkCommodityEditVo;
|
||||
import com.starry.admin.modules.clear.module.vo.PlayClerkCommodityQueryVo;
|
||||
import com.starry.admin.modules.clear.service.IPlayClerkClassificationInfoService;
|
||||
import com.starry.admin.modules.clear.service.IPlayClerkCommodityService;
|
||||
import com.starry.admin.modules.clear.service.IPlayClerkLevelInfoService;
|
||||
import com.starry.admin.modules.clear.service.IPlayClerkUserInfoService;
|
||||
import com.starry.admin.modules.clear.service.impl.PlayClerkDataReviewInfoServiceImpl;
|
||||
import com.starry.admin.modules.clear.service.impl.PlayClerkUserInfoServiceImpl;
|
||||
import com.starry.admin.modules.weichat.entity.PlayClerkUserAddVo;
|
||||
import com.starry.admin.modules.weichat.entity.PlayClerkUserBindCodeVo;
|
||||
import com.starry.admin.modules.weichat.entity.PlayClerkUserSendCodeVo;
|
||||
import com.starry.admin.modules.weichat.entity.*;
|
||||
import com.starry.admin.utils.SecurityUtils;
|
||||
import com.starry.common.redis.RedisCache;
|
||||
import com.starry.common.result.R;
|
||||
import com.starry.common.utils.ConvertUtil;
|
||||
import com.starry.common.utils.VerificationCodeUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
@@ -38,12 +48,53 @@ public class WxClerkController {
|
||||
@Resource
|
||||
RedisCache redisCache;
|
||||
|
||||
|
||||
@Resource
|
||||
private PlayClerkUserInfoServiceImpl playClerkUserInfoService;
|
||||
|
||||
@Resource
|
||||
private PlayClerkDataReviewInfoServiceImpl dataReviewInfoService;
|
||||
|
||||
@Resource
|
||||
private IPlayClerkLevelInfoService playClerkLevelInfoService;
|
||||
|
||||
@Resource
|
||||
private IPlayClerkClassificationInfoService playClerkClassificationInfoService;
|
||||
|
||||
@Resource
|
||||
private IPlayClerkUserInfoService clerkUserInfoService;
|
||||
|
||||
@Resource
|
||||
private IPlayClerkCommodityService playClerkCommodityService;
|
||||
|
||||
|
||||
@ClerkUserLogin
|
||||
@GetMapping("/user/queryById")
|
||||
public R sendCode(@RequestParam("id") String id) {
|
||||
PlayClerkUserInfoEntity entity = clerkUserInfoService.selectById(id);
|
||||
if (entity == null) {
|
||||
throw new CustomException("用户不存在");
|
||||
}
|
||||
return R.ok(clerkUserInfoService.getVo(entity));
|
||||
}
|
||||
|
||||
@ClerkUserLogin
|
||||
@GetMapping("/user/deleteNotReviewInfo")
|
||||
public R deleteNotReviewInfo(@RequestParam("id") String id) {
|
||||
PlayClerkUserInfoEntity entity = clerkUserInfoService.selectById(id);
|
||||
if (entity == null) {
|
||||
throw new CustomException("用户不存在");
|
||||
}
|
||||
LambdaQueryWrapper<PlayClerkDataReviewInfoEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PlayClerkDataReviewInfoEntity::getPlayUserId, entity.getOpenid());
|
||||
dataReviewInfoService.remove(queryWrapper);
|
||||
return R.ok("成功");
|
||||
}
|
||||
|
||||
|
||||
@ClerkUserLogin
|
||||
@PostMapping("/user/sendCode")
|
||||
public R sendCode(@VisibleForTesting @RequestBody PlayClerkUserSendCodeVo vo) {
|
||||
public R sendCode(@Valid @RequestBody PlayClerkUserSendCodeVo vo) {
|
||||
String codeKey = "login_codes:" + SecurityUtils.getTenantId() + "_" + SecureUtil.md5(vo.getAreaCode() + vo.getPhone());
|
||||
String code = VerificationCodeUtils.getVerificationCode(4);
|
||||
redisCache.setCacheObject(codeKey, code, 5L, TimeUnit.MINUTES);
|
||||
@@ -53,26 +104,277 @@ public class WxClerkController {
|
||||
|
||||
@ClerkUserLogin
|
||||
@PostMapping("/user/bindCode")
|
||||
public R bindCode(@VisibleForTesting @RequestBody PlayClerkUserBindCodeVo vo) {
|
||||
public R bindCode(@Valid @RequestBody PlayClerkUserBindCodeVo vo) {
|
||||
String codeKey = "login_codes:" + SecurityUtils.getTenantId() + "_" + SecureUtil.md5(vo.getAreaCode() + vo.getPhone());
|
||||
String code = redisCache.getCacheObject(codeKey);
|
||||
if (code == null || !code.equals(vo.getCode())) {
|
||||
throw new CustomException("验证码错误");
|
||||
}
|
||||
redisCache.deleteObject(codeKey);
|
||||
// 账号绑定操作
|
||||
String id = ThreadLocalRequestDetail.getClerkUserInfo().getId();
|
||||
PlayClerkUserInfoEntity clerkUserInfoEntity = new PlayClerkUserInfoEntity();
|
||||
clerkUserInfoEntity.setId(id);
|
||||
clerkUserInfoEntity.setPhone(vo.getPhone());
|
||||
playClerkUserInfoService.update(clerkUserInfoEntity);
|
||||
// 删除验证码缓存
|
||||
redisCache.deleteObject(codeKey);
|
||||
|
||||
return R.ok("成功");
|
||||
}
|
||||
|
||||
@ClerkUserLogin
|
||||
@PostMapping("/user/add")
|
||||
public R userAdd(@Valid @RequestBody PlayClerkUserAddVo vo) {
|
||||
PlayClerkUserInfoEntity entity = ThreadLocalRequestDetail.getClerkUserInfo();
|
||||
BeanUtils.copyProperties(vo, entity);
|
||||
entity.setPlayUserId("0001");
|
||||
playClerkUserInfoService.update(entity);
|
||||
public R userAdd(@Valid @RequestBody PlayClerkUserByWxAddVo vo) {
|
||||
String playUserId = ThreadLocalRequestDetail.getClerkUserInfo().getId();
|
||||
PlayClerkUserInfoEntity userInfo = playClerkUserInfoService.selectById(playUserId);
|
||||
if (userInfo == null) {
|
||||
throw new CustomException("系统错误,用户不存在");
|
||||
}
|
||||
if (userInfo.getClerkState().equals("1")) {
|
||||
throw new CustomException("当前用户已经是店员");
|
||||
}
|
||||
PlayClerkDataReviewInfoEntity dataReviewInfo = new PlayClerkDataReviewInfoEntity();
|
||||
dataReviewInfo.setPlayUserId(userInfo.getId());
|
||||
dataReviewInfo.setState("0");
|
||||
dataReviewInfo.setDataType("0");
|
||||
|
||||
if (!dataReviewInfoService.queryList(dataReviewInfo).isEmpty()) {
|
||||
throw new CustomException("已有申请未审核");
|
||||
}
|
||||
dataReviewInfo.setContent(JSONObject.toJSONString(vo));
|
||||
dataReviewInfo.setAddTime(new Date());
|
||||
dataReviewInfoService.create(dataReviewInfo);
|
||||
return R.ok("申请成功");
|
||||
}
|
||||
|
||||
|
||||
@ClerkUserLogin
|
||||
@PostMapping("/user/updateAvatar")
|
||||
public R updateAvatar(@Valid @RequestBody PlayClerkUserAvatarVo vo) {
|
||||
PlayClerkUserInfoEntity userInfo = ThreadLocalRequestDetail.getClerkUserInfo();
|
||||
|
||||
PlayClerkDataReviewInfoEntity dataReviewInfo = new PlayClerkDataReviewInfoEntity();
|
||||
dataReviewInfo.setPlayUserId(userInfo.getId());
|
||||
dataReviewInfo.setState("0");
|
||||
dataReviewInfo.setDataType("1");
|
||||
|
||||
if (!dataReviewInfoService.queryList(dataReviewInfo).isEmpty()) {
|
||||
throw new CustomException("已有申请未审核");
|
||||
}
|
||||
dataReviewInfo.setContent(JSONObject.toJSONString(vo));
|
||||
dataReviewInfo.setAddTime(new Date());
|
||||
dataReviewInfoService.create(dataReviewInfo);
|
||||
return R.ok("申请成功");
|
||||
}
|
||||
|
||||
@ClerkUserLogin
|
||||
@PostMapping("/user/updateAlbum")
|
||||
public R updateAlbum(@Valid @RequestBody PlayClerkUserAlbumVo vo) {
|
||||
PlayClerkUserInfoEntity userInfo = ThreadLocalRequestDetail.getClerkUserInfo();
|
||||
PlayClerkDataReviewInfoEntity dataReviewInfo = new PlayClerkDataReviewInfoEntity();
|
||||
dataReviewInfo.setPlayUserId(userInfo.getId());
|
||||
dataReviewInfo.setState("0");
|
||||
dataReviewInfo.setDataType("2");
|
||||
if (!dataReviewInfoService.queryList(dataReviewInfo).isEmpty()) {
|
||||
throw new CustomException("已有申请未审核");
|
||||
}
|
||||
dataReviewInfo.setContent(JSONObject.toJSONString(vo));
|
||||
dataReviewInfoService.create(dataReviewInfo);
|
||||
return R.ok("申请成功");
|
||||
}
|
||||
|
||||
@ClerkUserLogin
|
||||
@PostMapping("/user/updateAudio")
|
||||
public R updateAudio(@Valid @RequestBody PlayClerkUserAudioVo vo) {
|
||||
PlayClerkUserInfoEntity userInfo = ThreadLocalRequestDetail.getClerkUserInfo();
|
||||
PlayClerkDataReviewInfoEntity dataReviewInfo = new PlayClerkDataReviewInfoEntity();
|
||||
dataReviewInfo.setPlayUserId(userInfo.getId());
|
||||
dataReviewInfo.setState("0");
|
||||
dataReviewInfo.setDataType("3");
|
||||
if (!dataReviewInfoService.queryList(dataReviewInfo).isEmpty()) {
|
||||
throw new CustomException("已有申请未审核");
|
||||
}
|
||||
dataReviewInfo.setContent(JSONObject.toJSONString(vo));
|
||||
dataReviewInfoService.create(dataReviewInfo);
|
||||
return R.ok("申请成功");
|
||||
}
|
||||
|
||||
|
||||
@ClerkUserLogin
|
||||
@PostMapping("/user/updateOnlineState")
|
||||
public R updateAudio(@Valid @RequestBody PlayClerkUserOnlineStateVo vo) {
|
||||
String userId = ThreadLocalRequestDetail.getClerkUserInfo().getId();
|
||||
PlayClerkUserInfoEntity entity = new PlayClerkUserInfoEntity();
|
||||
entity.setOnlineState(vo.getOnlineState());
|
||||
entity.setId(userId);
|
||||
playClerkUserInfoService.update(entity);
|
||||
return R.ok("修改成功");
|
||||
}
|
||||
|
||||
@ClerkUserLogin
|
||||
@PostMapping("/user/updateCommodity")
|
||||
public R updateAudio(@Valid @RequestBody PlayClerkCommodityEditVo vo) {
|
||||
playClerkCommodityService.startStopClerkItem(vo.getCommodityType(), vo.getEnablingState());
|
||||
return R.ok("成功");
|
||||
}
|
||||
|
||||
|
||||
@ClerkUserLogin
|
||||
@PostMapping("/user/updateOther")
|
||||
public R updateOther(@Valid @RequestBody PlayClerkUserOtherVo vo) {
|
||||
PlayClerkUserInfoEntity userInfo = ConvertUtil.entityToVo(vo, PlayClerkUserInfoEntity.class);
|
||||
userInfo.setId(ThreadLocalRequestDetail.getClerkUserInfo().getId());
|
||||
playClerkUserInfoService.update(userInfo);
|
||||
return R.ok("申请成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询陪玩服务项目列表
|
||||
*/
|
||||
@GetMapping("/user/listAllCommodity")
|
||||
public R listAllCommodity() {
|
||||
List<PlayClerkCommodityEntity> list = playClerkCommodityService.selectAll();
|
||||
return R.ok(ConvertUtil.entityToVoList(list, PlayClerkCommodityQueryVo.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取店员列表
|
||||
*
|
||||
* @param vo PlayClerkUserInfoQueryVo
|
||||
* @return 店员礼列表
|
||||
*/
|
||||
|
||||
@PostMapping("/user/queryByPage")
|
||||
public R queryByPage(@RequestBody PlayClerkUserInfoQueryVo vo) {
|
||||
IPage<PlayClerkUserInfoEntity> page = playClerkUserInfoService.selectPlayClerkUserInfoByPage(vo);
|
||||
List<PlayClerkUserListResultVo> resultVos = new ArrayList<>();
|
||||
for (PlayClerkUserInfoEntity record : page.getRecords()) {
|
||||
PlayClerkUserListResultVo item = ConvertUtil.entityToVo(record, PlayClerkUserListResultVo.class);
|
||||
List<String> list = playClerkCommodityService.selectByUser(record.getId()).stream().map(PlayClerkCommodityEntity::getCommodityType).collect(Collectors.toList());
|
||||
item.setCommodity(list);
|
||||
resultVos.add(item);
|
||||
}
|
||||
|
||||
IPage<PlayClerkUserListResultVo> resultPage = new Page<>();
|
||||
resultPage.setRecords(resultVos);
|
||||
// 设置分页参数
|
||||
resultPage.setCurrent(page.getCurrent());
|
||||
resultPage.setSize(page.getSize());
|
||||
resultPage.setTotal(resultVos.size()); // 假设total和实际情况一致
|
||||
return R.ok(resultPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店员礼物信息
|
||||
*
|
||||
* @param id 店员ID
|
||||
* @return 店员礼物
|
||||
*/
|
||||
|
||||
@GetMapping("/user/queryGiftById")
|
||||
public R queryGiftById(@RequestParam("id") String id) {
|
||||
PlayClerkUserInfoEntity entity = clerkUserInfoService.selectById(id);
|
||||
if (entity == null) {
|
||||
throw new CustomException("用户不存在");
|
||||
}
|
||||
List<PlayGiftInfoEntity> list = new ArrayList<>();
|
||||
list.add(new PlayGiftInfoEntity(IdUtil.fastSimpleUUID(), "礼物1", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", 0, "0"));
|
||||
list.add(new PlayGiftInfoEntity(IdUtil.fastSimpleUUID(), "礼物2", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", 1, "0"));
|
||||
list.add(new PlayGiftInfoEntity(IdUtil.fastSimpleUUID(), "礼物3", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", 2, "1"));
|
||||
list.add(new PlayGiftInfoEntity(IdUtil.fastSimpleUUID(), "礼物4", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", 3, "1"));
|
||||
list.add(new PlayGiftInfoEntity(IdUtil.fastSimpleUUID(), "礼物5", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", 4, "1"));
|
||||
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取店员价格
|
||||
*
|
||||
* @param id 店员ID
|
||||
* @return 店员价格
|
||||
*/
|
||||
@GetMapping("/user/queryPriceById")
|
||||
public R queryDetailById(@RequestParam("id") String id) {
|
||||
PlayClerkUserInfoEntity entity = clerkUserInfoService.selectById(id);
|
||||
if (entity == null) {
|
||||
throw new CustomException("用户不存在");
|
||||
}
|
||||
return R.ok(playClerkCommodityService.selectByUser(entity.getId()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分页获取店员动态
|
||||
*
|
||||
* @param id 店员ID
|
||||
* @return 店员动态
|
||||
*/
|
||||
@GetMapping("/user/queryTrendsById")
|
||||
public R queryTrendsById(@RequestParam("id") String id) {
|
||||
PlayClerkUserInfoEntity entity = clerkUserInfoService.selectById(id);
|
||||
if (entity == null) {
|
||||
throw new CustomException("用户不存在");
|
||||
}
|
||||
List<PlayClarkUserTrendsInfoEntity> entities = new ArrayList<>();
|
||||
entities.add(new PlayClarkUserTrendsInfoEntity(IdUtil.fastSimpleUUID(), "动态1", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/0596854e16ae4a268eab4c08e2a9f762.mp3", new Date()));
|
||||
entities.add(new PlayClarkUserTrendsInfoEntity(IdUtil.fastSimpleUUID(), "动态2", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/0596854e16ae4a268eab4c08e2a9f762.mp3", new Date()));
|
||||
entities.add(new PlayClarkUserTrendsInfoEntity(IdUtil.fastSimpleUUID(), "动态3", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/0596854e16ae4a268eab4c08e2a9f762.mp3", new Date()));
|
||||
entities.add(new PlayClarkUserTrendsInfoEntity(IdUtil.fastSimpleUUID(), "动态4", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/0596854e16ae4a268eab4c08e2a9f762.mp3", new Date()));
|
||||
entities.add(new PlayClarkUserTrendsInfoEntity(IdUtil.fastSimpleUUID(), "动态5", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/0596854e16ae4a268eab4c08e2a9f762.mp3", new Date()));
|
||||
entities.add(new PlayClarkUserTrendsInfoEntity(IdUtil.fastSimpleUUID(), "动态6", "0", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", new Date()));
|
||||
entities.add(new PlayClarkUserTrendsInfoEntity(IdUtil.fastSimpleUUID(), "动态7", "0", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", new Date()));
|
||||
entities.add(new PlayClarkUserTrendsInfoEntity(IdUtil.fastSimpleUUID(), "动态8", "0", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", new Date()));
|
||||
|
||||
IPage<PlayClarkUserTrendsInfoEntity> resultPage = new Page<>();
|
||||
resultPage.setRecords(entities);
|
||||
// 设置分页参数
|
||||
resultPage.setCurrent(1);
|
||||
resultPage.setSize(1);
|
||||
resultPage.setTotal(5); // 假设total和实际情况一致
|
||||
return R.ok(resultPage);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分页获取店员评价
|
||||
*
|
||||
* @param id 店员ID
|
||||
* @return 店员评价
|
||||
*/
|
||||
@GetMapping("/user/queryEvaluateById")
|
||||
public R queryEvaluateById(@RequestParam("id") String id) {
|
||||
PlayClerkUserInfoEntity entity = clerkUserInfoService.selectById(id);
|
||||
if (entity == null) {
|
||||
throw new CustomException("用户不存在");
|
||||
}
|
||||
|
||||
List<PlayClarkUserEvaluateInfoEntity> entities = new ArrayList<>();
|
||||
entities.add(new PlayClarkUserEvaluateInfoEntity(IdUtil.fastSimpleUUID(), IdUtil.fastSimpleUUID(), "评价人1昵称", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", "评价内容", new Date(), IdUtil.fastSimpleUUID(), "店员昵称", IdUtil.fastSimpleUUID(), "文字语音条", "一小时"));
|
||||
entities.add(new PlayClarkUserEvaluateInfoEntity(IdUtil.fastSimpleUUID(), IdUtil.fastSimpleUUID(), "评价人2昵称", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", "评价内容", new Date(), IdUtil.fastSimpleUUID(), "店员昵称", IdUtil.fastSimpleUUID(), "文字语音条", "一小时"));
|
||||
entities.add(new PlayClarkUserEvaluateInfoEntity(IdUtil.fastSimpleUUID(), IdUtil.fastSimpleUUID(), "评价人3昵称", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", "评价内容", new Date(), IdUtil.fastSimpleUUID(), "店员昵称", IdUtil.fastSimpleUUID(), "文字语音条", "一小时"));
|
||||
entities.add(new PlayClarkUserEvaluateInfoEntity(IdUtil.fastSimpleUUID(), IdUtil.fastSimpleUUID(), "评价人4昵称", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", "评价内容", new Date(), IdUtil.fastSimpleUUID(), "店员昵称", IdUtil.fastSimpleUUID(), "文字语音条", "一小时"));
|
||||
entities.add(new PlayClarkUserEvaluateInfoEntity(IdUtil.fastSimpleUUID(), IdUtil.fastSimpleUUID(), "评价人5昵称", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", "评价内容", new Date(), IdUtil.fastSimpleUUID(), "店员昵称", IdUtil.fastSimpleUUID(), "文字语音条", "一小时"));
|
||||
|
||||
IPage<PlayClarkUserEvaluateInfoEntity> resultPage = new Page<>();
|
||||
resultPage.setRecords(entities);
|
||||
// 设置分页参数
|
||||
resultPage.setCurrent(1);
|
||||
resultPage.setSize(1);
|
||||
resultPage.setTotal(5); // 假设total和实际情况一致
|
||||
return R.ok(resultPage);
|
||||
}
|
||||
|
||||
@GetMapping("/level/queryAll")
|
||||
public R userAdd() {
|
||||
return R.ok(playClerkLevelInfoService.selectAll());
|
||||
}
|
||||
|
||||
@GetMapping("/class/queryAll")
|
||||
public R queryClassAll() {
|
||||
return R.ok(playClerkClassificationInfoService.selectAll());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,33 @@
|
||||
package com.starry.admin.modules.weichat.controller;
|
||||
|
||||
import cn.hutool.core.io.FastByteArrayOutputStream;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.starry.admin.common.exception.CustomException;
|
||||
import com.starry.admin.common.oss.service.IOssFileService;
|
||||
import com.starry.admin.modules.system.service.ISysAdministrativeAreaDictInfoService;
|
||||
import com.starry.admin.modules.weichat.service.WxAccessTokenService;
|
||||
import com.starry.admin.modules.weichat.utils.WxFileUtils;
|
||||
import com.starry.admin.utils.SecurityUtils;
|
||||
import com.starry.common.result.R;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
|
||||
/**
|
||||
* @author 杭州世平信息科技有限公司-xuhq
|
||||
* @author admin
|
||||
* @since 2024/4/10 16:18
|
||||
**/
|
||||
@Slf4j
|
||||
@@ -18,12 +35,72 @@ import javax.annotation.Resource;
|
||||
@RequestMapping("/wx/common/")
|
||||
public class WxCommonController {
|
||||
|
||||
@Resource
|
||||
private IOssFileService ossFileService;
|
||||
|
||||
@Resource
|
||||
private ISysAdministrativeAreaDictInfoService areaDictInfoService;
|
||||
|
||||
|
||||
@Resource
|
||||
WxAccessTokenService wxAccessTokenService;
|
||||
|
||||
|
||||
@GetMapping("area/tree")
|
||||
public R list() {
|
||||
public R areaTree() {
|
||||
return R.ok(areaDictInfoService.selectTree("2"));
|
||||
}
|
||||
|
||||
@PostMapping("file/upload")
|
||||
public R fileUpload(@RequestParam("file") MultipartFile file) throws IOException {
|
||||
String fileAddress = ossFileService.upload(file.getInputStream(), SecurityUtils.getTenantId(), file.getOriginalFilename());
|
||||
return R.ok(fileAddress);
|
||||
}
|
||||
|
||||
@GetMapping("audio/upload")
|
||||
public R audioUpload(@RequestParam("mediaId") String mediaId) throws IOException, WxErrorException {
|
||||
if (StrUtil.isBlankIfStr(mediaId)) {
|
||||
throw new CustomException("mediaId不能为空");
|
||||
}
|
||||
String accessToken = wxAccessTokenService.getAccessToken();
|
||||
// 下载录音文件,并转化为InputStream
|
||||
InputStream inputStream = WxFileUtils.getTemporaryMaterial(accessToken, mediaId);
|
||||
|
||||
try {
|
||||
FastByteArrayOutputStream read = IoUtil.read(inputStream, false);
|
||||
String str = new String(read.toByteArray(), StandardCharsets.UTF_8);
|
||||
JSONObject jsonObject = JSONObject.parseObject(str);
|
||||
if (jsonObject.containsKey("errcode")) {
|
||||
throw new CustomException("获取微信素材异常" + jsonObject.getString("errmsg"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取微信素材异常,", e);
|
||||
throw new CustomException("获取微信素材异常");
|
||||
}
|
||||
|
||||
File tempFile = FileUtil.createTempFile("wx_" + SecurityUtils.getTenantId(), IdUtil.fastSimpleUUID() + ".tmp", null).toFile();
|
||||
// 可以在这里对临时文件进行操作
|
||||
log.debug("tempFile = {}", tempFile.getPath());
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream(tempFile)) {
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead;
|
||||
// 读取InputStream并写入到FileOutputStream
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
fileOutputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
}
|
||||
if (FileUtil.size(tempFile) <= 0) {
|
||||
throw new CustomException("音频文件上传失败,文件不存在");
|
||||
}
|
||||
//将下载的微信素材文件,转化为MP3文件
|
||||
File targetFile = FileUtil.createTempFile("wx_" + SecurityUtils.getTenantId(), IdUtil.fastSimpleUUID() + ".mp3", null).toFile();
|
||||
log.debug("targetFile = {}", targetFile.getPath());
|
||||
WxFileUtils.audioConvert2Mp3(tempFile, targetFile);
|
||||
//将MP3文件上传到OSS
|
||||
String fileAddress = ossFileService.upload(Files.newInputStream(targetFile.toPath()), SecurityUtils.getTenantId(), IdUtil.fastSimpleUUID() + ".mp3");
|
||||
//删除临时文件
|
||||
FileUtil.del(tempFile);
|
||||
FileUtil.del(targetFile);
|
||||
return R.ok(fileAddress);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.starry.admin.modules.weichat.controller;
|
||||
|
||||
|
||||
import com.starry.admin.modules.clear.service.IPlayClerkLevelInfoService;
|
||||
import com.starry.admin.modules.clear.service.impl.PlayClerkUserInfoServiceImpl;
|
||||
import com.starry.common.result.R;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/wx/custom/")
|
||||
public class WxCustomController {
|
||||
|
||||
|
||||
@Resource
|
||||
private PlayClerkUserInfoServiceImpl playClerkUserInfoService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.starry.admin.modules.weichat.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.starry.admin.common.exception.CustomException;
|
||||
import com.starry.admin.modules.platform.entity.SysTenantEntity;
|
||||
import com.starry.admin.modules.platform.service.impl.SysTenantServiceImpl;
|
||||
import com.starry.admin.utils.SecurityUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.config.impl.WxMpMapConfigImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class WxCustomService {
|
||||
|
||||
@Resource
|
||||
private WxMpService wxMpService;
|
||||
|
||||
@Resource
|
||||
private SysTenantServiceImpl tenantService;
|
||||
|
||||
|
||||
public WxMpService proxyWxMpService() {
|
||||
String tenantId = SecurityUtils.getTenantId();
|
||||
if (StrUtil.isBlankIfStr(tenantId)) {
|
||||
throw new CustomException("系统错误,租户ID不能为空");
|
||||
}
|
||||
SysTenantEntity entity = tenantService.selectSysTenantByTenantId(tenantId);
|
||||
if (entity == null) {
|
||||
throw new CustomException("系统错误,租户ID不能为空");
|
||||
}
|
||||
WxMpMapConfigImpl config = new WxMpMapConfigImpl();
|
||||
config.setAppId(entity.getAppId());
|
||||
config.setSecret(entity.getSecret());
|
||||
wxMpService.addConfigStorage(entity.getAppId(), config);
|
||||
return wxMpService.switchoverTo(entity.getAppId());
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.starry.admin.modules.weichat.controller;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.starry.admin.common.aspect.ClerkUserLogin;
|
||||
import com.starry.admin.common.aspect.CustomUserLogin;
|
||||
import com.starry.admin.common.conf.ThreadLocalRequestDetail;
|
||||
import com.starry.admin.common.exception.CustomException;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoEntity;
|
||||
import com.starry.admin.modules.clear.service.IPlayClerkUserInfoService;
|
||||
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
|
||||
@@ -15,10 +15,11 @@ import com.starry.admin.modules.weichat.entity.WxUserLoginVo;
|
||||
import com.starry.admin.modules.weichat.entity.WxUserQueryAddressVo;
|
||||
import com.starry.admin.modules.weichat.service.WxOauthService;
|
||||
import com.starry.admin.modules.weichat.service.WxTokenService;
|
||||
import com.starry.admin.utils.SecurityUtils;
|
||||
import com.starry.common.redis.RedisCache;
|
||||
import com.starry.common.result.R;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.common.bean.WxJsapiSignature;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -40,7 +41,7 @@ public class WxOauthController {
|
||||
|
||||
|
||||
@Resource
|
||||
private WxMpService wxMpService;
|
||||
private WxCustomService wxCustomService;
|
||||
|
||||
@Resource
|
||||
private IPlayCustomUserInfoService customUserInfoService;
|
||||
@@ -54,6 +55,20 @@ public class WxOauthController {
|
||||
@Resource
|
||||
private WxOauthService wxOauthService;
|
||||
|
||||
@Resource
|
||||
private RedisCache redisCache;
|
||||
|
||||
|
||||
@PostMapping("/getConfigAddress")
|
||||
public R getConfigAddress(@RequestBody WxUserQueryAddressVo vo) throws WxErrorException {
|
||||
// 默认回调地址
|
||||
String defaultAddress = "http://july.hucs.top/api/wx/oauth2/clerkLoginCallback";
|
||||
if (!StrUtil.isBlankIfStr(vo.getUrl())) {
|
||||
defaultAddress = vo.getUrl();
|
||||
}
|
||||
WxJsapiSignature wxJsapiSignature = wxCustomService.proxyWxMpService().createJsapiSignature(defaultAddress);
|
||||
return R.ok(wxJsapiSignature);
|
||||
}
|
||||
|
||||
@PostMapping("/getClerkLoginAddress")
|
||||
public R getClerkLoginAddress(@RequestBody WxUserQueryAddressVo vo) {
|
||||
@@ -62,7 +77,7 @@ public class WxOauthController {
|
||||
if (!StrUtil.isBlankIfStr(vo.getUrl())) {
|
||||
defaultAddress = vo.getUrl();
|
||||
}
|
||||
String url = wxMpService.getOAuth2Service().buildAuthorizationUrl(defaultAddress, "snsapi_userinfo", "STATE");
|
||||
String url = wxCustomService.proxyWxMpService().getOAuth2Service().buildAuthorizationUrl(defaultAddress, "snsapi_userinfo", "STATE");
|
||||
return R.ok(url);
|
||||
}
|
||||
|
||||
@@ -76,23 +91,34 @@ public class WxOauthController {
|
||||
public R clerkLogin(@Valid @RequestBody WxUserLoginVo vo) {
|
||||
String userId = wxOauthService.clarkUserLogin(vo.getCode());
|
||||
PlayClerkUserInfoEntity entity = clerkUserInfoService.selectById(userId);
|
||||
// 线程塞入租户ID
|
||||
SecurityUtils.setTenantId(Convert.toStr(entity.getTenantId()));
|
||||
JSONObject jsonObject = JSONObject.from(entity);
|
||||
String tokenForMiniUser = tokenService.createWxUserToken(entity.getId());
|
||||
jsonObject.put("tokenValue", TOKEN_PREFIX + tokenForMiniUser);
|
||||
if (entity == null) {
|
||||
throw new CustomException("用户不存在");
|
||||
}
|
||||
// 缓存租户信息
|
||||
String redisKey = "TENANT_INFO:" + entity.getId();
|
||||
redisCache.setCacheObject(redisKey, entity.getTenantId());
|
||||
String tokenValue = tokenService.createWxUserToken(entity.getId());
|
||||
JSONObject jsonObject = JSONObject.from(clerkUserInfoService.getVo(entity));
|
||||
jsonObject.put("tokenValue", TOKEN_PREFIX + tokenValue);
|
||||
jsonObject.put("tokenName", CLERK_USER_LOGIN_TOKEN);
|
||||
jsonObject.put("loginDate", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
clerkUserInfoService.updateTokenById(entity.getId(), tokenValue);
|
||||
return R.ok(jsonObject);
|
||||
}
|
||||
|
||||
@PostMapping("/clark/loginById")
|
||||
public R loginById(@Valid @RequestBody WxUserLoginVo vo) {
|
||||
PlayClerkUserInfoEntity entity = clerkUserInfoService.selectById(vo.getCode());
|
||||
JSONObject jsonObject = JSONObject.from(entity);
|
||||
if (entity == null) {
|
||||
throw new CustomException("用户不存在");
|
||||
}
|
||||
// 缓存租户信息
|
||||
String redisKey = "TENANT_INFO:" + entity.getId();
|
||||
redisCache.setCacheObject(redisKey, entity.getTenantId());
|
||||
JSONObject jsonObject = JSONObject.from(clerkUserInfoService.getVo(entity));
|
||||
String tokenValue = tokenService.createWxUserToken(entity.getId());
|
||||
jsonObject.put("tokenValue", tokenValue);
|
||||
jsonObject.put("tokenName", TOKEN_PREFIX + CLERK_USER_LOGIN_TOKEN);
|
||||
jsonObject.put("tokenValue", TOKEN_PREFIX + tokenValue);
|
||||
jsonObject.put("tokenName", CLERK_USER_LOGIN_TOKEN);
|
||||
jsonObject.put("loginDate", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
clerkUserInfoService.updateTokenById(entity.getId(), tokenValue);
|
||||
return R.ok(jsonObject);
|
||||
@@ -113,7 +139,7 @@ public class WxOauthController {
|
||||
if (!StrUtil.isBlankIfStr(vo.getUrl())) {
|
||||
defaultAddress = vo.getUrl();
|
||||
}
|
||||
String url = wxMpService.getOAuth2Service().buildAuthorizationUrl(defaultAddress, "snsapi_userinfo", "STATE");
|
||||
String url = wxCustomService.proxyWxMpService().getOAuth2Service().buildAuthorizationUrl(defaultAddress, "snsapi_userinfo", "STATE");
|
||||
return R.ok(url);
|
||||
}
|
||||
|
||||
@@ -127,6 +153,12 @@ public class WxOauthController {
|
||||
public R customLogin(@Valid @RequestBody WxUserLoginVo vo) {
|
||||
String userId = wxOauthService.customUserLogin(vo.getCode());
|
||||
PlayCustomUserInfoEntity entity = customUserInfoService.selectById(userId);
|
||||
if (entity == null) {
|
||||
throw new CustomException("用户不存在");
|
||||
}
|
||||
// 缓存租户信息
|
||||
String redisKey = "TENANT_INFO:" + entity.getId();
|
||||
redisCache.setCacheObject(redisKey, entity.getTenantId());
|
||||
JSONObject jsonObject = JSONObject.from(entity);
|
||||
String tokenValue = tokenService.createWxUserToken(entity.getId());
|
||||
jsonObject.put("tokenValue", TOKEN_PREFIX + tokenValue);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.starry.admin.modules.weichat.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 店员相册实体
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024/4/11 11:19
|
||||
**/
|
||||
|
||||
@Data
|
||||
public class PlayClerkUserAlbumVo {
|
||||
|
||||
@NotNull(message = "照片不能为空")
|
||||
@Size(min = 1, max = 5, message = "照片必须为1-5张")
|
||||
private List<String> album;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.starry.admin.modules.weichat.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 店员录音文件
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024/4/11 11:19
|
||||
**/
|
||||
@Data
|
||||
public class PlayClerkUserAudioVo {
|
||||
|
||||
/**
|
||||
* 录音
|
||||
*/
|
||||
@NotNull(message = "录音文件不能为空")
|
||||
private String audio;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.starry.admin.modules.weichat.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 店员头像信息
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024/4/11 11:19
|
||||
**/
|
||||
@Data
|
||||
public class PlayClerkUserAvatarVo {
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
@NotNull(message = "头像不能为空")
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 头像框
|
||||
*/
|
||||
private String avatarFrameId;
|
||||
|
||||
}
|
||||
@@ -4,13 +4,17 @@ import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 微信端申请成为店员
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Data
|
||||
public class PlayClerkUserAddVo {
|
||||
public class PlayClerkUserByWxAddVo {
|
||||
|
||||
|
||||
/**
|
||||
@@ -20,57 +24,40 @@ public class PlayClerkUserAddVo {
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 店员等级
|
||||
*/
|
||||
@NotBlank(message = "等级不能为空")
|
||||
private String levelId;
|
||||
|
||||
/**
|
||||
* 店员性别(1:男:0:女)
|
||||
* 店员性别(0:未知;1:男;2:女)
|
||||
*/
|
||||
@NotNull(message = "性别不能为空")
|
||||
private Integer sex;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
@NotBlank(message = "头像不能为空")
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 音频
|
||||
*/
|
||||
@NotBlank(message = "音频不能为空")
|
||||
private String audioFrequency;
|
||||
|
||||
/**
|
||||
* 星座
|
||||
*/
|
||||
@NotBlank(message = "星座不能为空")
|
||||
private String constellation;
|
||||
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* 个性签名
|
||||
*/
|
||||
@NotBlank(message = "签名不能为空")
|
||||
private String signature;
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 年龄
|
||||
*/
|
||||
@NotNull(message = "年龄不能为空")
|
||||
private Long age;
|
||||
@NotNull(message = "性别不能为空")
|
||||
private Integer age;
|
||||
|
||||
/**
|
||||
* 微信号码
|
||||
*/
|
||||
@NotNull(message = "微信号码不能为空")
|
||||
private String weiChatCode;
|
||||
|
||||
|
||||
/**
|
||||
* 手机号码区号
|
||||
*/
|
||||
@NotBlank(message = "手机号码区号不能为空")
|
||||
private String areaCode;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
@NotBlank(message = "手机号码不能为空")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 所在国家
|
||||
*/
|
||||
@NotBlank(message = "国家不能为空")
|
||||
private String country;
|
||||
private String country = "中国";
|
||||
|
||||
/**
|
||||
* 所在省份
|
||||
@@ -84,6 +71,17 @@ public class PlayClerkUserAddVo {
|
||||
@NotBlank(message = "城市不能为空")
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 音频
|
||||
*/
|
||||
@NotBlank(message = "音频不能为空")
|
||||
private String audio;
|
||||
|
||||
|
||||
@NotNull(message = "album不能为空")
|
||||
@Size(min = 1, max = 5, message = "照片必须为1-5张")
|
||||
private List<String> album;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.starry.admin.modules.weichat.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
|
||||
/**
|
||||
* 微信端申请成为店员
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Data
|
||||
public class PlayClerkUserByWxEditVo {
|
||||
|
||||
|
||||
/**
|
||||
* 店员昵称
|
||||
*/
|
||||
@NotBlank(message = "昵称不能为空")
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 店员性别(0:未知;1:男;2:女)
|
||||
*/
|
||||
@NotNull(message = "性别不能为空")
|
||||
private Integer sex;
|
||||
|
||||
/**
|
||||
* 年龄
|
||||
*/
|
||||
@NotNull(message = "性别不能为空")
|
||||
private Integer age;
|
||||
|
||||
/**
|
||||
* 微信号码
|
||||
*/
|
||||
@NotNull(message = "微信号码不能为空")
|
||||
private Integer weiChatCode;
|
||||
|
||||
|
||||
/**
|
||||
* 手机号码区号
|
||||
*/
|
||||
@NotBlank(message = "手机号码区号不能为空")
|
||||
private String areaCode;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
@NotBlank(message = "手机号码不能为空")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 所在国家
|
||||
*/
|
||||
private String country = "中国";
|
||||
|
||||
/**
|
||||
* 所在省份
|
||||
*/
|
||||
@NotBlank(message = "省份不能为空")
|
||||
private String province;
|
||||
|
||||
/**
|
||||
* 所在城市
|
||||
*/
|
||||
@NotBlank(message = "城市不能为空")
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 音频
|
||||
*/
|
||||
@NotBlank(message = "音频不能为空")
|
||||
private String audioFrequency;
|
||||
|
||||
/**
|
||||
* 图片1
|
||||
**/
|
||||
private String image1;
|
||||
|
||||
/**
|
||||
* 图片2
|
||||
**/
|
||||
private String image2;
|
||||
|
||||
/**
|
||||
* 图片3
|
||||
**/
|
||||
private String image3;
|
||||
|
||||
/**
|
||||
* 图片4
|
||||
**/
|
||||
private String image4;
|
||||
|
||||
/**
|
||||
* 图片4
|
||||
**/
|
||||
private String image5;
|
||||
|
||||
/**
|
||||
* 微信二维码
|
||||
**/
|
||||
private String weChatCodeImage;
|
||||
|
||||
/**
|
||||
* 支付宝收款码图片
|
||||
**/
|
||||
private String weChatPayImage;
|
||||
|
||||
/**
|
||||
* 支付宝收款码图片
|
||||
**/
|
||||
private String alipayImage;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.starry.admin.modules.weichat.entity;
|
||||
|
||||
import com.starry.admin.modules.clear.module.vo.PlayClerkCommodityQueryVo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 微信端店员登录返回值
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Data
|
||||
public class PlayClerkUserLoginResponseVo {
|
||||
|
||||
/**
|
||||
* UUID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 店员昵称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 头像是否可编辑
|
||||
*/
|
||||
private boolean avatarAllowEdit = true;
|
||||
|
||||
/**
|
||||
* 相册
|
||||
*/
|
||||
private List<String> album = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 相册是否运行编辑
|
||||
*/
|
||||
private boolean albumAllowEdit = true;
|
||||
|
||||
/**
|
||||
* 音频
|
||||
*/
|
||||
private String audio;
|
||||
|
||||
/**
|
||||
* 音频是否可修改
|
||||
*/
|
||||
private boolean audioAllowEdit = true;
|
||||
|
||||
/**
|
||||
* 店员性别(0:未知;1:男;2:女)
|
||||
*/
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 年龄
|
||||
*/
|
||||
private Integer age;
|
||||
|
||||
/**
|
||||
* 个性签名
|
||||
*/
|
||||
private String signature;
|
||||
|
||||
/**
|
||||
* 星座
|
||||
*/
|
||||
private String constellation;
|
||||
|
||||
/**
|
||||
* 地区
|
||||
*/
|
||||
private String area;
|
||||
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
private List<String> labels = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 分类
|
||||
*/
|
||||
private String typeId;
|
||||
|
||||
/**
|
||||
* 微信二维码
|
||||
**/
|
||||
private String weChatCodeImage;
|
||||
|
||||
/**
|
||||
* 微信收款码图片
|
||||
**/
|
||||
private String weChatPayImage;
|
||||
|
||||
/**
|
||||
* 支付宝收款码图片
|
||||
**/
|
||||
private String alipayImage;
|
||||
|
||||
/**
|
||||
* 是否必须实名【1:必须实名,0:非必须实名】
|
||||
*/
|
||||
private String mandatoryRealState;
|
||||
|
||||
/**
|
||||
* 在线状态【1:在线,0:离线】
|
||||
*/
|
||||
private String onlineState;
|
||||
|
||||
/**
|
||||
* 员工状态【1:是陪玩,0:不是陪玩】
|
||||
*/
|
||||
private String clerkState;
|
||||
|
||||
/**
|
||||
* 允许申请陪玩
|
||||
*/
|
||||
private boolean clerkAllowEdit = true;
|
||||
|
||||
/**
|
||||
* 服务项目
|
||||
*/
|
||||
private List<PlayClerkCommodityQueryVo> commodity = new ArrayList<>();
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.starry.admin.modules.weichat.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* 店员在线状态【1:在线,0:离线】
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024/4/11 11:19
|
||||
**/
|
||||
@Data
|
||||
public class PlayClerkUserOnlineStateVo {
|
||||
|
||||
/**
|
||||
* 在线状态
|
||||
*/
|
||||
@NotNull(message = "在线状态不能为空")
|
||||
@Pattern(regexp = "[01]", message = "在线状态必须为0或1")
|
||||
private String onlineState;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.starry.admin.modules.weichat.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 店员录音文件
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024/4/11 11:19
|
||||
**/
|
||||
@Data
|
||||
public class PlayClerkUserOtherVo {
|
||||
|
||||
/**
|
||||
* 店员性别(0:未知;1:男;2:女)
|
||||
*/
|
||||
private Integer sex;
|
||||
|
||||
/**
|
||||
* 年龄
|
||||
*/
|
||||
private Integer age;
|
||||
|
||||
/**
|
||||
* 个性签名
|
||||
*/
|
||||
private String signature;
|
||||
|
||||
|
||||
/**
|
||||
* 星座
|
||||
*/
|
||||
private String constellation;
|
||||
|
||||
/**
|
||||
* 所在国家
|
||||
*/
|
||||
private String country = "中国";
|
||||
|
||||
/**
|
||||
* 所在省份
|
||||
*/
|
||||
private String province;
|
||||
|
||||
/**
|
||||
* 所在城市
|
||||
*/
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
private List<String> labels = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 分类
|
||||
*/
|
||||
private String typeId;
|
||||
|
||||
/**
|
||||
* 微信二维码
|
||||
**/
|
||||
private String weChatCodeImage;
|
||||
|
||||
/**
|
||||
* 微信收款码图片
|
||||
**/
|
||||
private String weChatPayImage;
|
||||
|
||||
/**
|
||||
* 支付宝收款码图片
|
||||
**/
|
||||
private String alipayImage;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.starry.admin.modules.weichat.entity;
|
||||
|
||||
import com.starry.common.domain.BasePageEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 微信端分页查询店员文件
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024/4/11 11:19
|
||||
**/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class PlayClerkUserQueryVo extends BasePageEntity {
|
||||
|
||||
/**
|
||||
* 分类
|
||||
*/
|
||||
private String typeId;
|
||||
/**
|
||||
* 等级
|
||||
**/
|
||||
private String levelId;
|
||||
|
||||
/**
|
||||
* 性别[0:未知;1:男;2:女]
|
||||
**/
|
||||
private Integer sex;
|
||||
|
||||
/**
|
||||
* 省
|
||||
**/
|
||||
private String province;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.starry.admin.modules.weichat.service;
|
||||
|
||||
|
||||
import com.starry.admin.modules.weichat.controller.WxCustomService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 微信公众号开发
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class WxAccessTokenService {
|
||||
|
||||
|
||||
@Resource
|
||||
private WxCustomService wxCustomService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取微信AccessToken
|
||||
*
|
||||
* @return access_token
|
||||
*/
|
||||
public String getAccessToken() throws WxErrorException {
|
||||
String token = wxCustomService.proxyWxMpService().getAccessToken();
|
||||
log.error("token = " + token);
|
||||
//缓存业务处理
|
||||
return token;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,12 +8,12 @@ import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoEntity;
|
||||
import com.starry.admin.modules.clear.service.IPlayClerkUserInfoService;
|
||||
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
|
||||
import com.starry.admin.modules.custom.service.IPlayCustomUserInfoService;
|
||||
import com.starry.admin.modules.weichat.controller.WxCustomService;
|
||||
import com.starry.common.utils.ConvertUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.bean.WxOAuth2UserInfo;
|
||||
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -24,7 +24,7 @@ public class WxOauthService {
|
||||
|
||||
|
||||
@Resource
|
||||
private WxMpService wxMpService;
|
||||
private WxCustomService wxCustomService;
|
||||
|
||||
|
||||
@Resource
|
||||
@@ -33,14 +33,22 @@ public class WxOauthService {
|
||||
@Resource
|
||||
private IPlayClerkUserInfoService clerkUserInfoService;
|
||||
|
||||
@Resource
|
||||
private WxTokenService tokenService;
|
||||
|
||||
|
||||
/**
|
||||
* 微信用户登录
|
||||
* 如果用户不存在,初始化用户并登录
|
||||
*
|
||||
* @param code 微信授权code
|
||||
* @return String 用户ID
|
||||
* @author admin
|
||||
* @since 2024/4/15 11:01
|
||||
**/
|
||||
public String clarkUserLogin(String code) {
|
||||
WxOAuth2AccessToken token = getWxOAuth2AccessToken(code);
|
||||
log.info("token = " + token);
|
||||
String openId = getOpenId(token);
|
||||
WxOAuth2UserInfo userInfo = new WxOAuth2UserInfo();
|
||||
log.info("openId = " + openId);
|
||||
WxOAuth2UserInfo userInfo = getWxOAuth2UserInfo(token);
|
||||
PlayClerkUserInfoEntity item = clerkUserInfoService.selectByOpenid(openId);
|
||||
if (item == null) {
|
||||
PlayClerkUserInfoEntity entity = ConvertUtil.entityToVo(userInfo, PlayClerkUserInfoEntity.class);
|
||||
@@ -49,8 +57,6 @@ public class WxOauthService {
|
||||
clerkUserInfoService.create(entity);
|
||||
return entity.getId();
|
||||
} else {
|
||||
item.setAvatar(userInfo.getHeadImgUrl());
|
||||
clerkUserInfoService.update(item);
|
||||
return item.getId();
|
||||
}
|
||||
}
|
||||
@@ -95,7 +101,7 @@ public class WxOauthService {
|
||||
}
|
||||
synchronized (code.intern()) {
|
||||
try {
|
||||
return wxMpService.getOAuth2Service().getAccessToken(code);
|
||||
return wxCustomService.proxyWxMpService().getOAuth2Service().getAccessToken(code);
|
||||
} catch (WxErrorException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -134,7 +140,7 @@ public class WxOauthService {
|
||||
throw new ServiceException("获取微信授权异常,WxOAuth2AccessToken不能为空");
|
||||
}
|
||||
try {
|
||||
return wxMpService.getOAuth2Service().getUserInfo(token, null);
|
||||
return wxCustomService.proxyWxMpService().getOAuth2Service().getUserInfo(token, null);
|
||||
} catch (WxErrorException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -49,14 +49,12 @@ public class WxTokenService {
|
||||
protected static final long MILLIS_SECOND = 1000;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据微信用户id创建token
|
||||
*
|
||||
* @param userId 微信用户ID
|
||||
* @return String token
|
||||
* @author 杭州世平信息科技有限公司-xuhq
|
||||
* @author admin
|
||||
* @since 2024/4/10 11:21
|
||||
**/
|
||||
public String createWxUserToken(String userId) {
|
||||
@@ -74,13 +72,16 @@ public class WxTokenService {
|
||||
*
|
||||
* @param token token
|
||||
* @return String 微信用户ID
|
||||
* @author 杭州世平信息科技有限公司-xuhq
|
||||
* @author admin
|
||||
* @since 2024/4/10 11:24
|
||||
**/
|
||||
public String getWxUserIdByToken(String token) {
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
throw new RuntimeException("token不能为空");
|
||||
}
|
||||
if (token.startsWith(Constants.TOKEN_PREFIX)) {
|
||||
token = token.replace(Constants.TOKEN_PREFIX, "");
|
||||
}
|
||||
Claims claims = parseToken(token);
|
||||
return claims.get(Constants.LOGIN_USER_KEY_WX).toString();
|
||||
}
|
||||
@@ -91,10 +92,10 @@ public class WxTokenService {
|
||||
* @param token token
|
||||
* @param identity 用户身份(0:租户,1:顾客)
|
||||
* @return String 微信用户租户ID
|
||||
* @author 杭州世平信息科技有限公司-xuhq
|
||||
* @author admin
|
||||
* @since 2024/4/10 11:24
|
||||
**/
|
||||
public String getWxUserTenantIdByToken(String token, String identity) {
|
||||
public String getWxUserTenantIdByToken(String token) {
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
throw new RuntimeException("token不能为空");
|
||||
}
|
||||
@@ -205,7 +206,7 @@ public class WxTokenService {
|
||||
// */
|
||||
// private String getToken(HttpServletRequest request) {
|
||||
// String token = request.getHeader(header);
|
||||
// if (StringUtils.isNotEmpty(token) && token.startsWith(Constants.TOKEN_PREFIX)) {
|
||||
// if (StrUtil.isNotBlank(token) && token.startsWith(Constants.TOKEN_PREFIX)) {
|
||||
// token = token.replace(Constants.TOKEN_PREFIX, "");
|
||||
// }
|
||||
// return token;
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.starry.admin.modules.weichat.utils;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.starry.admin.common.exception.CustomException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import ws.schild.jave.Encoder;
|
||||
import ws.schild.jave.MultimediaObject;
|
||||
import ws.schild.jave.encode.AudioAttributes;
|
||||
import ws.schild.jave.encode.EncodingAttributes;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class WxFileUtils {
|
||||
|
||||
|
||||
/**
|
||||
* 下载微信临时素材文件
|
||||
*
|
||||
* @param access_token 微信token
|
||||
* @param mediaId 素材ID
|
||||
* @return InputStream
|
||||
* @throws IOException IOException
|
||||
*/
|
||||
public static InputStream getTemporaryMaterial(String access_token, String mediaId) throws IOException {
|
||||
String url = "https://api.weixin.qq.com/cgi-bin/media/get?" + access_token + "=ACCESS_TOKEN&media_id=" + mediaId;
|
||||
// 请求参数
|
||||
HashMap<String, String> param = new HashMap<>();
|
||||
param.put("media_id", mediaId);
|
||||
// 获取到http连接对象
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
StringEntity stringEntity = new StringEntity(JSONObject.toJSONString(param));
|
||||
httpPost.setEntity(stringEntity);
|
||||
// 打开链接发送请求 获取到返回的流
|
||||
CloseableHttpClient build = HttpClients.custom().build();
|
||||
CloseableHttpResponse execute = build.execute(httpPost);
|
||||
return execute.getEntity().getContent();
|
||||
}
|
||||
|
||||
public static void audioConvert2Mp3(File source, File target) {
|
||||
if (FileUtil.isEmpty(source)) {
|
||||
log.error("从微信下载的临时素材文件为空");
|
||||
throw new CustomException("音频文件上传失败");
|
||||
}
|
||||
FileUtil.touch("/tmp/jave/ffmpeg-amd64-3.5.0/");
|
||||
AudioAttributes audio = new AudioAttributes();
|
||||
audio.setCodec("libmp3lame");
|
||||
audio.setBitRate(128000);
|
||||
audio.setChannels(2);
|
||||
audio.setSamplingRate(44100);
|
||||
EncodingAttributes attrs = new EncodingAttributes();
|
||||
attrs.setOutputFormat("mp3");
|
||||
attrs.setAudioAttributes(audio);
|
||||
Encoder encoder = new Encoder();
|
||||
MultimediaObject multimediaObject = new MultimediaObject(source);
|
||||
try {
|
||||
encoder.encode(multimediaObject, target, attrs);
|
||||
} catch (Exception ex) {
|
||||
log.error("音频文件格式转化失败", ex);
|
||||
throw new CustomException("音频文件格式转化失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user