修复接口问题

This commit is contained in:
easonzhu 2025-02-22 22:23:07 +08:00
parent fb70723f50
commit 0af2f8f3ef
17 changed files with 112 additions and 48 deletions

View File

@ -5,6 +5,7 @@ import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.syzb.business.entity.AppOrder;
@ -14,16 +15,17 @@ import com.syzb.business.mapper.ModuleUserMapper;
import com.syzb.business.vo.BusinessModuleUserVO;
import com.syzb.business.vo.BusinessOrderVO;
import com.syzb.common.constant.IsOrNot;
import com.syzb.common.util.logger.LoggerUtil;
import com.syzb.group.entity.GroupInfo;
import com.syzb.group.mapper.GroupInfoMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class BusinessDataService {
@ -39,6 +41,9 @@ public class BusinessDataService {
@Resource
private ModuleUserMapper moduleUserMapper;
@Resource
private GroupInfoMapper groupInfoMapper;
@Transactional(rollbackFor = Exception.class)
public void syncOrder() {
QueryWrapper<AppOrder> wrapper = Wrappers.<AppOrder>query()
@ -69,15 +74,14 @@ public class BusinessDataService {
@Transactional(rollbackFor = Exception.class)
public void syncModuleUser() {
QueryWrapper<ModuleUser> wrapper = Wrappers.<ModuleUser>query()
.select("max(update_time) as update_time");
ModuleUser moduleUser = moduleUserMapper.selectOne(wrapper);
LocalDateTime startTime = INIT_SYNC_TIME;
if (moduleUser != null && moduleUser.getUpdateTime() != null) {
startTime = moduleUser.getUpdateTime();
}
.select("module_id", "max(update_time) as update_time")
.groupBy("module_id");
List<ModuleUser> lastModuleUserList = moduleUserMapper.selectList(wrapper);
Map<Integer, LocalDateTime> updateTimeMap = lastModuleUserList.stream().collect(Collectors.toMap(ModuleUser::getModuleId, ModuleUser::getUpdateTime));
LocalDateTime endTime = LocalDateTime.now();
Set<Integer> moduleIds = getModuleIds();
for (Integer moduleId : moduleIds) {
LocalDateTime startTime = updateTimeMap.getOrDefault(moduleId, INIT_SYNC_TIME);
List<BusinessModuleUserVO> moduleUserList = businessApiService.getModuleUserList(moduleId, startTime, endTime);
if (CollUtil.isNotEmpty(moduleUserList)) {
for (BusinessModuleUserVO moduleUserVO : moduleUserList) {
@ -97,10 +101,22 @@ public class BusinessDataService {
}
private Set<Integer> getModuleIds() {
// TODO
Set<Integer> set = new HashSet<>();
set.add(1000);
return set;
Set<Integer> moduleIdSet = new HashSet<>();
LambdaQueryWrapper<GroupInfo> wrapper = Wrappers.<GroupInfo>lambdaQuery()
.select(GroupInfo::getAuthorityId);
List<GroupInfo> authIdList = groupInfoMapper.selectList(wrapper);
authIdList.stream().map(GroupInfo::getAuthorityId).filter(StrUtil::isNotBlank)
.forEach(authId -> {
String[] moduleIdStrArray = authId.split(",");
for (String moduleIdStr : moduleIdStrArray) {
try {
moduleIdSet.add(Integer.valueOf(moduleIdStr));
} catch (NumberFormatException e) {
LoggerUtil.error("权限ID格式错误:" + authId + ":" + e.getMessage());
}
}
});
return moduleIdSet;
}
private AppOrder convertOrder(BusinessOrderVO order, boolean isNew) {

View File

@ -8,7 +8,6 @@ import java.util.Optional;
public enum ProductType {
CUSTOM_PRODUCT(111, "自定义产品"),
ADVISOR_INFO(0, "投顾"), // 仅用于推荐位&Banner
VIEW_PACKAGE(1, "观点包"),
VIEW_SINGLE(2, "单篇观点"),

View File

@ -191,7 +191,6 @@ public class AdvertService {
}
public void validateRecommendExist(ProductType productType, Integer productId) {
// TODO 校验关联数据(投顾\观点\观点包\锦囊\三方产品\套餐产品)
QueryWrapper<Advert> advertWrapper = Wrappers.query();
advertWrapper.eq("product_type", productType.value)
.eq("product_id", productId);

View File

@ -147,7 +147,6 @@ public class RecommendService {
}
public void validateRecommendExist(ProductType productType, Integer productId) {
// TODO 校验关联数据(投顾\观点\观点包\锦囊\三方产品\套餐产品)
QueryWrapper<Recommend> recommendWrapper = Wrappers.query();
recommendWrapper.eq("product_type", productType.value)
.eq("product_id", productId);

View File

@ -1,14 +1,18 @@
package com.syzb.group.query.info;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.syzb.common.vo.BackendUserVO;
import com.syzb.group.constant.GroupInfoStatus;
import com.syzb.group.entity.GroupInfo;
import com.syzb.video.constant.VideoLimitType;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
public class SaveGroupQuery {
@ -62,7 +66,7 @@ public class SaveGroupQuery {
private String paymentUrl;
@ApiModelProperty("权限号")
private String authorityId;
private List<Integer> authorityId;
@ApiModelProperty("成员人数限制")
private Integer memberLimit;
@ -94,7 +98,9 @@ public class SaveGroupQuery {
groupInfo.setOriginalPrice(originalPrice);
groupInfo.setActivityPrice(activityPrice);
groupInfo.setPaymentUrl(paymentUrl);
groupInfo.setAuthorityId(authorityId);
if (CollUtil.isNotEmpty(authorityId)) {
groupInfo.setAuthorityId(StrUtil.join(",", authorityId));
}
groupInfo.setMemberLimit(memberLimit);
groupInfo.setCoverImage(coverImage);
groupInfo.setStatus(GroupInfoStatus.TO_COMMIT.value);
@ -226,11 +232,11 @@ public class SaveGroupQuery {
this.paymentUrl = paymentUrl;
}
public String getAuthorityId() {
public List<Integer> getAuthorityId() {
return authorityId;
}
public void setAuthorityId(String authorityId) {
public void setAuthorityId(List<Integer> authorityId) {
this.authorityId = authorityId;
}

View File

@ -25,7 +25,6 @@ import com.syzb.group.query.message.ReadGroupMessageAppQuery;
import com.syzb.group.query.message.SendGroupMessageAppQuery;
import com.syzb.group.service.GroupInfoService;
import com.syzb.group.service.common.GroupCacheService;
import com.syzb.group.service.common.GroupCommonService;
import com.syzb.group.service.common.GroupMessageService;
import com.syzb.group.vo.GroupVO;
import com.syzb.group.vo.message.GroupMessageReadVO;
@ -53,9 +52,6 @@ public class AppGroupMessageService {
@Resource
private GroupCacheService groupCacheService;
@Resource
private GroupCommonService groupCommonService;
@Resource
private SensitiveWordService sensitiveWordService;
@ -78,8 +74,6 @@ public class AppGroupMessageService {
throw new BizException(ResponseStatus.MESSAGE_PERMISSION_ERROR, "交易圈私聊未开启");
}
String userId = frontUser.getUserId();
// TODO 验证权限
groupCommonService.validateUserPermission(userId, groupVO);
QueryGroupMessageType msgType = QueryGroupMessageType.fromValue(type);
NavigableSet<Integer> sortedSet = groupCacheService.getMessageIdSet(groupId, userId, msgType);
if (lastId != null && lastId != 0) {

View File

@ -51,10 +51,6 @@ public class GroupCommonService {
@Resource
private GroupMessageReadMapper groupMessageReadMapper;
public boolean validateUserPermission(String userId, GroupVO groupVO) {
return true;
}
@Transactional(rollbackFor = Exception.class)
public void saveGroupMessageRead() {
List<GroupMessageReadVO> cacheList = hazelcastInstance.getList(CacheKey.GroupKey.TEMP_READ_LIST);

View File

@ -4,6 +4,7 @@ import com.syzb.common.annotation.Auth;
import com.syzb.common.constant.AccessRole;
import com.syzb.common.result.CommonResult;
import com.syzb.common.result.Pager;
import com.syzb.common.vo.BackendUserVO;
import com.syzb.rbac.query.*;
import com.syzb.rbac.service.UserService;
import com.syzb.rbac.vo.UserDeptVO;
@ -12,10 +13,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
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 java.util.List;
@ -92,4 +90,13 @@ public class UserController {
return CommonResult.success();
}
@ApiOperation("后台重置用户密码")
@PostMapping("/resetUserPassword")
@Auth(role = AccessRole.ADMIN)
public CommonResult<Void> resetUserPassword(@Validated @RequestBody @ApiParam(required = true) ResetUserPasswordQuery query,
@RequestAttribute(value = "backendUser", required = false) BackendUserVO backendUserVO) {
userService.resetUserPassword(query, backendUserVO);
return CommonResult.success(null);
}
}

View File

@ -0,0 +1,33 @@
package com.syzb.rbac.query;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
public class ResetUserPasswordQuery {
@ApiModelProperty("登录ID")
@NotNull
private Integer loginId;
@ApiModelProperty("密码")
@NotBlank
private String password;
public Integer getLoginId() {
return loginId;
}
public void setLoginId(Integer loginId) {
this.loginId = loginId;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}

View File

@ -20,6 +20,7 @@ import com.syzb.common.result.ResponseStatus;
import com.syzb.common.service.CacheService;
import com.syzb.common.service.SensitiveWordService;
import com.syzb.common.util.CodecUtil;
import com.syzb.common.vo.BackendUserVO;
import com.syzb.rbac.constant.RoleEnum;
import com.syzb.rbac.entity.Dept;
import com.syzb.rbac.entity.UserDept;
@ -371,4 +372,19 @@ public class UserService {
updateRoles(userDept, userLogin.getType(), query.getRoleIds());
this.clearCache();
}
@Transactional(rollbackFor = Exception.class)
public void resetUserPassword(ResetUserPasswordQuery query, BackendUserVO backendUserVO) {
UserLogin userInDB = userLoginMapper.selectById(query.getLoginId());
if (userInDB == null) {
throw new BizException(ResponseStatus.USER_STATUS_ERROR);
}
String md5 = CodecUtil.md5(query.getPassword());
UserLogin user = new UserLogin();
user.setLoginId(query.getLoginId());
user.setPassword(md5);
userLoginMapper.updateById(user);
this.clearCache();
}
}

View File

@ -130,7 +130,7 @@ public class SaveVideoInfoQuery implements IVideoUserOperateQuery {
private List<Integer> serialIds;
@ApiModelProperty(value = "自定义权限号", required = true)
private List<String> authIds;
private List<Integer> authIds;
@ApiModelProperty(value = "1 开启企微二维码 2 不开启企微二维码")
private Integer openQw;
@ -423,11 +423,11 @@ public class SaveVideoInfoQuery implements IVideoUserOperateQuery {
this.serialIds = serialIds;
}
public List<String> getAuthIds() {
public List<Integer> getAuthIds() {
return authIds;
}
public void setAuthIds(List<String> authIds) {
public void setAuthIds(List<Integer> authIds) {
this.authIds = authIds;
}

View File

@ -92,7 +92,7 @@ public class AdminVideoCartService {
videoCartMapper.update(dbCart, updateWrapper);
videoCacheService.clearVideoCartCache(videoId);
String productName;
if (!dbCart.getProductType().equals(ProductType.CUSTOM_PRODUCT.value)) {
if (!dbCart.getProductType().equals(ProductType.THIRD_PRODUCT.value)) {
Table<Integer, Integer, MergeProductInfoVO> infoVOTable = mergeProductService.queryMergeProductInfo(Collections.singletonList(dbCart));
MergeProductInfoVO infoVO = infoVOTable.get(dbCart.getProductType(), dbCart.getProductId());
if (infoVO == null) {

View File

@ -305,7 +305,7 @@ public class AdminVideoCustomerService {
Map<Integer, List<VideoLiveUser>> liveUserMap = videoLiveUserList.stream().collect(Collectors.groupingBy(VideoLiveUser::getVideoId));
List<VideoLiveUser> cartProductList = videoLiveUserList.stream().filter(item -> VideoUserRecordType.CART.value.equals(item.getType())).collect(Collectors.toList());
List<VideoLiveUser> selfProductList = cartProductList.stream().filter(cart -> !ProductType.CUSTOM_PRODUCT.value.equals(cart.getProductType())).collect(Collectors.toList());
List<VideoLiveUser> selfProductList = cartProductList.stream().filter(cart -> !ProductType.THIRD_PRODUCT.value.equals(cart.getProductType())).collect(Collectors.toList());
Table<Integer, Integer, MergeProductInfoVO> table = mergeProductService.queryMergeProductInfo(selfProductList);
LambdaQueryWrapper<VideoCart> videoCartWrapper = Wrappers.<VideoCart>lambdaQuery().in(VideoCart::getVideoId, videoIdSet);
@ -345,7 +345,7 @@ public class AdminVideoCustomerService {
Integer productType = cart.getProductType();
Integer videoId = cart.getVideoId();
Integer productId = cart.getProductId();
if (productType.equals(ProductType.CUSTOM_PRODUCT.value)) {
if (productType.equals(ProductType.THIRD_PRODUCT.value)) {
VideoCart targetCart = dbCartList.stream().filter(item -> item.getProductId().equals(productId) && item.getProductType().equals(productType) && item.getVideoId().equals(videoId)).findFirst().orElse(null);
if (targetCart != null) {
return new MergeProductInfoVO(productId, productType, targetCart.getProductName());

View File

@ -611,7 +611,7 @@ public class AdminVideoInfoService {
Map<Integer, List<VideoCart>> cartMap = videoCart.stream().collect(Collectors.groupingBy(VideoCart::getVideoId));
List<VideoCart> selfProducts = cartMap.values().stream()
.flatMap(Collection::stream)
.filter(cart -> !ProductType.CUSTOM_PRODUCT.value.equals(cart.getProductType()))
.filter(cart -> !ProductType.THIRD_PRODUCT.value.equals(cart.getProductType()))
.collect(Collectors.toList());
// 产品
Table<Integer, Integer, MergeProductInfoVO> infoVOTable = mergeProductService.queryMergeProductInfo(selfProducts);
@ -634,7 +634,7 @@ public class AdminVideoInfoService {
if (CollUtil.isNotEmpty(videoCarts)) {
List<VideoCartVO> cartVoList = videoCarts.stream().map(cart -> {
VideoCartVO videoCartVO;
if (cart.getProductType().equals(ProductType.CUSTOM_PRODUCT.value)) {
if (cart.getProductType().equals(ProductType.THIRD_PRODUCT.value)) {
videoCartVO = new VideoCartVO(cart);
} else {
videoCartVO = new VideoCartVO(cart, infoVOTable.get(cart.getProductType(), cart.getProductId()));
@ -942,7 +942,6 @@ public class AdminVideoInfoService {
}
private List<VideoCart> buildVideoCart(List<CartQuery> cartList, Integer videoId) {
// TODO: 2024/4/18 校验产品是否存在并且上架
return cartList.stream().map(cart -> cart.toPO(videoId)).collect(Collectors.toList());
}

View File

@ -46,13 +46,13 @@ public class AppVideoCartService {
return null;
}
List<VideoCart> selfProducts = cartList.stream()
.filter(cart -> !ProductType.CUSTOM_PRODUCT.value.equals(cart.getProductType()))
.filter(cart -> !ProductType.THIRD_PRODUCT.value.equals(cart.getProductType()))
.collect(Collectors.toList());
Table<Integer, Integer, MergeProductInfoVO> infoVOTable = mergeProductService.queryMergeProductInfo(selfProducts);
return cartList.stream()
.map(cart -> {
VideoCartVO videoCartVO;
if (cart.getProductType().equals(ProductType.CUSTOM_PRODUCT.value)) {
if (cart.getProductType().equals(ProductType.THIRD_PRODUCT.value)) {
videoCartVO = new VideoCartVO(cart);
} else {
MergeProductInfoVO infoVO = infoVOTable.get(cart.getProductType(), cart.getProductId());

View File

@ -233,7 +233,7 @@ public class AppVideoInteractionService {
videoCacheService.storeVideoRecordUserToCache(frontUser, VideoUserRecordType.CART.value, videoId, saleUserId, productId, productType);
VideoLive videoInfo = videoCacheService.getVideoInfo(videoId);
String productName = StrUtil.EMPTY;
if (ProductType.CUSTOM_PRODUCT.value.equals(productType)) {
if (ProductType.THIRD_PRODUCT.value.equals(productType)) {
List<VideoCart> videoCarts = videoCacheService.getCartByVideoId(videoId);
List<VideoCart> cartList = videoCarts.stream()
.filter(item -> productId.equals(item.getProductId()) && productType.equals(item.getProductType()))

View File

@ -460,7 +460,7 @@ public class VideoCommonService {
if (list.size() == 1) {
VideoLiveProduct product = list.get(0);
if (ProductType.CUSTOM_PRODUCT.value.equals(product.getProductType())) {
if (ProductType.THIRD_PRODUCT.value.equals(product.getProductType())) {
VideoCart cart = videoCartMapper.selectOne(Wrappers.<VideoCart>lambdaQuery()
.eq(VideoCart::getVideoId, videoId)
.eq(VideoCart::getProductId, product.getProductId())