Merge branch 'preview' of https://gitea.qinmian.online/CY/mcwl-ai into preview
commit
206d13ef24
|
@ -1,30 +1,30 @@
|
||||||
package com.mcwl.web.controller.communityCenter;
|
//package com.mcwl.web.controller.communityCenter;
|
||||||
|
//
|
||||||
|
//
|
||||||
import com.mcwl.communityCenter.service.AIService;
|
//import com.mcwl.communityCenter.service.AIService;
|
||||||
import com.mcwl.communityCenter.webSocket.ChatWebSocket;
|
//import com.mcwl.communityCenter.webSocket.ChatWebSocket;
|
||||||
import lombok.RequiredArgsConstructor;
|
//import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
//import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
//import org.springframework.web.bind.annotation.RestController;
|
||||||
import reactor.core.publisher.Flux;
|
//import reactor.core.publisher.Flux;
|
||||||
|
//
|
||||||
@RequiredArgsConstructor
|
//@RequiredArgsConstructor
|
||||||
@RestController
|
//@RestController
|
||||||
@RequestMapping("/chat")
|
//@RequestMapping("/chat")
|
||||||
public class ChatController {
|
//public class ChatController {
|
||||||
|
//
|
||||||
private final AIService aiService;
|
// private final AIService aiService;
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* ai
|
// * ai
|
||||||
*/
|
// */
|
||||||
@GetMapping("/ai")
|
// @GetMapping("/ai")
|
||||||
public Flux<String> switchUserMode(String msg) throws Exception {
|
// public Flux<String> switchUserMode(String msg) throws Exception {
|
||||||
return aiService.getDeepSeekResponseStream(msg);
|
// return aiService.getDeepSeekResponseStream(msg);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
|
@ -4,6 +4,8 @@ package com.mcwl.web.controller.memberCenter;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import com.mcwl.common.core.domain.AjaxResult;
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
import com.mcwl.common.core.domain.R;
|
import com.mcwl.common.core.domain.R;
|
||||||
|
import com.mcwl.common.core.page.PageDomain;
|
||||||
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.memberCenter.domain.Member;
|
import com.mcwl.memberCenter.domain.Member;
|
||||||
import com.mcwl.memberCenter.domain.MemberPromotion;
|
import com.mcwl.memberCenter.domain.MemberPromotion;
|
||||||
|
@ -17,10 +19,12 @@ import com.mcwl.memberCenter.service.MemberService;
|
||||||
import com.mcwl.memberCenter.service.PromotionService;
|
import com.mcwl.memberCenter.service.PromotionService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@ -39,8 +43,6 @@ public class PromotionController {
|
||||||
|
|
||||||
private final MemberPromotionService memberPromotionService;
|
private final MemberPromotionService memberPromotionService;
|
||||||
|
|
||||||
private final MemberService memberService;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建活动
|
* 创建活动
|
||||||
|
@ -67,76 +69,34 @@ public class PromotionController {
|
||||||
/**
|
/**
|
||||||
* 活动列表
|
* 活动列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("promotionList")
|
@PostMapping("promotionList")
|
||||||
@ApiOperation(value = "活动列表")
|
@ApiOperation(value = "活动列表")
|
||||||
public R<List<Promotion>> promotionList() {
|
public TableDataInfo getPromotionList(@Valid @RequestBody PageDomain pageDomain) {
|
||||||
List<Promotion> promotionList = promotionService.lambdaQuery()
|
|
||||||
.gt(Promotion::getEndTime, new Date())
|
return promotionService.getPromotionList(pageDomain);
|
||||||
.list();
|
|
||||||
return R.ok(promotionList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前用户参与的活动
|
* 获取当前用户参与的活动
|
||||||
*/
|
*/
|
||||||
@GetMapping("myPromotionList")
|
@PostMapping("myPromotionList")
|
||||||
@ApiOperation(value = "获取当前用户参与的活动")
|
@ApiOperation(value = "获取当前用户参与的活动")
|
||||||
public R<List<MemberPromotion>> myPromotionList() {
|
public TableDataInfo myPromotionList(@Valid @RequestBody PageDomain pageDomain) {
|
||||||
// 获取当前用户
|
|
||||||
Long userId = SecurityUtils.getUserId();
|
return promotionService.getMyPromotionList(pageDomain);
|
||||||
List<MemberPromotion> memberPromotionList = memberPromotionService.lambdaQuery()
|
|
||||||
.eq(MemberPromotion::getUserId, userId)
|
|
||||||
.list();
|
|
||||||
return R.ok(memberPromotionList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参与活动
|
* 参与活动
|
||||||
*/
|
*/
|
||||||
@PostMapping("joinPromotion")
|
@GetMapping("joinPromotion")
|
||||||
@ApiOperation(value = "参与活动")
|
@ApiOperation(value = "参与活动")
|
||||||
public R<Object> joinPromotion(@RequestBody @Valid JoinPromotionDto joinPromotionDto) {
|
public R<Object> joinPromotion(@Valid
|
||||||
// 用户id
|
@NotNull(message = "活动ID不能为空")
|
||||||
Long userId = joinPromotionDto.getUserId();
|
@ApiParam("活动ID")
|
||||||
// 活动id
|
Long promotionId) {
|
||||||
Long promotionId = joinPromotionDto.getPromotionId();
|
|
||||||
// 按活动id查询活动信息
|
|
||||||
Promotion promotion = promotionService.getById(promotionId);
|
|
||||||
|
|
||||||
if (!Optional.ofNullable(promotion).isPresent()) {
|
return promotionService.joinPromotion(promotionId);
|
||||||
return R.fail("活动不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (promotion.getStartTime().after(new Date())) {
|
|
||||||
return R.fail("活动未开始");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 活动是否过期
|
|
||||||
if (promotion.getEndTime().before(new Date())) {
|
|
||||||
return R.fail("活动已过期");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取当前用户是否参与过该活动
|
|
||||||
if (isJoinPromotion(userId, promotionId)) {
|
|
||||||
return R.fail("您已参与过该活动");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 是否在活动期间内订阅或续订会员
|
|
||||||
// if (!isSubscribe(userId, promotion)) {
|
|
||||||
// return AjaxResult.warn("请在活动期间内订阅或续期会员后参加该活动");
|
|
||||||
// }
|
|
||||||
|
|
||||||
Member member = memberService.getUseUserMemberByUserId(userId);
|
|
||||||
|
|
||||||
String memberLevelIds = promotion.getMemberLevelIds();
|
|
||||||
if (!memberLevelIds.contains(member.getMemberLevelId().toString())) {
|
|
||||||
return R.fail("无法参与该活动,请查看活动条件");
|
|
||||||
}
|
|
||||||
MemberPromotion memberPromotion = getMemberPromotion(userId, promotionId);
|
|
||||||
memberPromotionService.save(memberPromotion);
|
|
||||||
|
|
||||||
|
|
||||||
return R.ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private boolean isSubscribe(Long userId, Promotion promotion) {
|
// private boolean isSubscribe(Long userId, Promotion promotion) {
|
||||||
|
@ -153,26 +113,5 @@ public class PromotionController {
|
||||||
// return true;
|
// return true;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private boolean isJoinPromotion(Long userId, Long promotionId) {
|
|
||||||
MemberPromotion memberPromotion = memberPromotionService.lambdaQuery()
|
|
||||||
.eq(MemberPromotion::getUserId, userId)
|
|
||||||
.eq(MemberPromotion::getPromotionId, promotionId)
|
|
||||||
.one();
|
|
||||||
return memberPromotion != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static MemberPromotion getMemberPromotion(Long userId, Long promotionId) {
|
|
||||||
MemberPromotion memberPromotion = new MemberPromotion();
|
|
||||||
memberPromotion.setUserId(userId);
|
|
||||||
memberPromotion.setPromotionId(promotionId);
|
|
||||||
memberPromotion.setStatus(PromotionEnum.PARTICIPATE);
|
|
||||||
memberPromotion.setParticipationTime(new Date());
|
|
||||||
memberPromotion.setCreateBy(SecurityUtils.getUsername());
|
|
||||||
memberPromotion.setCreateTime(new Date());
|
|
||||||
memberPromotion.setUpdateBy(SecurityUtils.getUsername());
|
|
||||||
memberPromotion.setUpdateTime(new Date());
|
|
||||||
return memberPromotion;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,25 @@
|
||||||
package com.mcwl.web.controller.myInvitation;
|
package com.mcwl.web.controller.myInvitation;
|
||||||
|
|
||||||
|
|
||||||
import com.mcwl.common.core.domain.AjaxResult;
|
|
||||||
import com.mcwl.common.core.domain.R;
|
import com.mcwl.common.core.domain.R;
|
||||||
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.myInvitation.domain.Invitation;
|
import com.mcwl.myInvitation.domain.Invitation;
|
||||||
import com.mcwl.myInvitation.domain.dto.EarningsDisplayDto;
|
import com.mcwl.myInvitation.domain.dto.EarningsDisplayDto;
|
||||||
import com.mcwl.myInvitation.service.InvitationService;
|
import com.mcwl.myInvitation.service.InvitationService;
|
||||||
import com.mcwl.myInvitation.domain.vo.EarningsDisplayVO;
|
import com.mcwl.myInvitation.domain.vo.EarningsDisplayVO;
|
||||||
|
import com.mcwl.system.domain.dto.WithdrawalPageRes;
|
||||||
|
import com.mcwl.system.service.ISysUserPayAccountLogService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import static com.mcwl.common.core.domain.AjaxResult.success;
|
import static com.mcwl.common.core.domain.AjaxResult.success;
|
||||||
|
|
||||||
|
@ -39,6 +35,8 @@ public class InvitationController {
|
||||||
|
|
||||||
private final InvitationService invitationService;
|
private final InvitationService invitationService;
|
||||||
|
|
||||||
|
private final ISysUserPayAccountLogService sysUserPayAccountLogService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取邀请码
|
* 获取邀请码
|
||||||
|
@ -103,4 +101,29 @@ public class InvitationController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 累计收入金额
|
||||||
|
*/
|
||||||
|
@GetMapping("totalAmount")
|
||||||
|
@ApiOperation(value = "累计收入金额")
|
||||||
|
public R<Double> totalAmount() {
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
Double totalAmount = invitationService.getTotalAmount(userId);
|
||||||
|
if (Objects.isNull(totalAmount)) {
|
||||||
|
totalAmount = 0.0;
|
||||||
|
}
|
||||||
|
return R.ok(totalAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提现记录
|
||||||
|
*/
|
||||||
|
@PostMapping("withdrawalRecord")
|
||||||
|
@ApiOperation(value = "提现记录")
|
||||||
|
public TableDataInfo withdrawalRecord(@Valid @RequestBody WithdrawalPageRes withdrawalPageRes) {
|
||||||
|
|
||||||
|
return sysUserPayAccountLogService.getWithdrawalRecord(withdrawalPageRes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,9 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -171,8 +173,9 @@ public class AliPayController extends BaseController {
|
||||||
@ApiOperation(value = "提现")
|
@ApiOperation(value = "提现")
|
||||||
public R<String> fetch(@Valid
|
public R<String> fetch(@Valid
|
||||||
@NotNull(message = "提现金额不能为空")
|
@NotNull(message = "提现金额不能为空")
|
||||||
Double amount) throws Exception {
|
@Pattern(regexp = "^(0|(?!0\\d)[1-9]\\d*)(\\.\\d{2})?$", message = "金额格式错误(必须保留两位小数)")
|
||||||
if (amount < 0.1) {
|
String amount) throws Exception {
|
||||||
|
if (Double.parseDouble(amount) < 0.1) {
|
||||||
return R.fail("提现金额最小为0.1");
|
return R.fail("提现金额最小为0.1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,13 @@ import com.mcwl.common.core.domain.R;
|
||||||
import com.mcwl.resource.domain.Collect;
|
import com.mcwl.resource.domain.Collect;
|
||||||
import com.mcwl.resource.service.impl.CollectServiceImpl;
|
import com.mcwl.resource.service.impl.CollectServiceImpl;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 收藏
|
* 收藏
|
||||||
|
@ -24,6 +28,12 @@ public class CollectController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CollectServiceImpl collectService;
|
private CollectServiceImpl collectService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加收藏
|
||||||
|
* @param collect
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "添加收藏")
|
||||||
@PostMapping("/addCollect")
|
@PostMapping("/addCollect")
|
||||||
public R addCollect(@RequestBody Collect collect){
|
public R addCollect(@RequestBody Collect collect){
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
package com.mcwl.web.controller.resource;
|
||||||
|
|
||||||
|
import com.mcwl.common.core.domain.R;
|
||||||
|
import com.mcwl.resource.domain.DownloadRecord;
|
||||||
|
import com.mcwl.resource.domain.vo.PageVo;
|
||||||
|
import com.mcwl.resource.service.impl.DownloadRecordServiceImpl;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件下载记录
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/3/6
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Api(tags = "文件下载记录")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/downloadRecord")
|
||||||
|
public class DownloadRecordController {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DownloadRecordServiceImpl downloadRecordService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增下载记录
|
||||||
|
* @param downloadRecord
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "新增下载记录")
|
||||||
|
@PostMapping("/addDownloadRecord")
|
||||||
|
public R addDownloadRecord(@RequestBody DownloadRecord downloadRecord){
|
||||||
|
|
||||||
|
return downloadRecordService.addDownloadRecord(downloadRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询下载记录
|
||||||
|
* @param pageVo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "下载记录")
|
||||||
|
@PostMapping("/selectDownloadRecord")
|
||||||
|
public R selectDownloadRecord(@RequestBody PageVo pageVo){
|
||||||
|
|
||||||
|
return downloadRecordService.selectDownloadRecord(pageVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改下载状态
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "修改下载状态")
|
||||||
|
@PostMapping("/updateDownloadRecord")
|
||||||
|
public R updateDownloadRecord(@RequestBody DownloadRecord downloadRecord){
|
||||||
|
|
||||||
|
return downloadRecordService.updateDownloadRecord(downloadRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除下载记录
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "批量删除下载记录")
|
||||||
|
@GetMapping("/deleteDownloadRecord")
|
||||||
|
public R deleteDownloadRecord(@RequestParam String ids){
|
||||||
|
|
||||||
|
return downloadRecordService.deleteDownloadRecord(ids);
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,8 @@ import com.mcwl.common.core.domain.AjaxResult;
|
||||||
import com.mcwl.common.utils.obs.ObsUtils;
|
import com.mcwl.common.utils.obs.ObsUtils;
|
||||||
import com.mcwl.resource.service.impl.FileServiceImpl;
|
import com.mcwl.resource.service.impl.FileServiceImpl;
|
||||||
import com.mcwl.web.controller.common.OssUtil;
|
import com.mcwl.web.controller.common.OssUtil;
|
||||||
|
import com.obs.services.ObsClient;
|
||||||
|
import com.obs.services.model.*;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -11,8 +13,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,6 +39,9 @@ public class FileController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ObsUtils obsUtils;
|
private ObsUtils obsUtils;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ObsClient obsClient;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*
|
*
|
||||||
* 图片
|
* 图片
|
||||||
|
@ -128,4 +135,120 @@ public class FileController {
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启动上传任务
|
||||||
|
*/
|
||||||
|
@GetMapping("/getUploadId/{objectKey}")
|
||||||
|
public String getUploadId(@PathVariable("objectKey")String objectKey) {
|
||||||
|
InitiateMultipartUploadRequest request = new InitiateMultipartUploadRequest("<桶名称>", objectKey);
|
||||||
|
ObjectMetadata metadata = new ObjectMetadata();
|
||||||
|
metadata.addUserMetadata("property", "property-value");
|
||||||
|
metadata.setContentType("text/plain");
|
||||||
|
request.setMetadata(metadata);
|
||||||
|
InitiateMultipartUploadResult result = obsClient.initiateMultipartUpload(request);
|
||||||
|
String uploadId = result.getUploadId();
|
||||||
|
return uploadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分片上传
|
||||||
|
*/
|
||||||
|
@PostMapping("/chunk")
|
||||||
|
public Map<String,String> splitFileUpload(
|
||||||
|
@RequestParam("objectKey")String objectKey,
|
||||||
|
@RequestParam("file") MultipartFile file,
|
||||||
|
@RequestParam("chunk") int chunk,
|
||||||
|
@RequestParam("uploadId") String uploadId) throws Exception {
|
||||||
|
File file1 = multipartFileToFile(file);
|
||||||
|
Map<String,String> map = uploadChunk(uploadId, file1, chunk, objectKey);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合并上传
|
||||||
|
*/
|
||||||
|
@PostMapping("/completeUpload")
|
||||||
|
public CompleteMultipartUploadResult completeUpload(
|
||||||
|
@RequestParam("objectKey")String objectKey,
|
||||||
|
@RequestParam("uploadId") String uploadId,
|
||||||
|
@RequestBody List<Map<String,String>> mapList
|
||||||
|
) {
|
||||||
|
List<PartEtag> partEtags = new ArrayList<>();
|
||||||
|
for(Map<String,String> map: mapList ){
|
||||||
|
PartEtag part1 = new PartEtag();
|
||||||
|
part1.setPartNumber(Integer.valueOf(map.get("partNumber")));
|
||||||
|
part1.seteTag(map.get("etag"));
|
||||||
|
partEtags.add(part1);
|
||||||
|
}
|
||||||
|
CompleteMultipartUploadRequest request = new CompleteMultipartUploadRequest(
|
||||||
|
"<桶名称>", objectKey, uploadId, partEtags);
|
||||||
|
CompleteMultipartUploadResult result = obsClient.completeMultipartUpload(request);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消任务上传
|
||||||
|
*/
|
||||||
|
@GetMapping("/cancelUpload")
|
||||||
|
public void cancelUpload(
|
||||||
|
@RequestParam("objectKey")String objectKey,
|
||||||
|
@RequestParam("uploadId") String uploadId
|
||||||
|
){
|
||||||
|
AbortMultipartUploadRequest request = new AbortMultipartUploadRequest("<桶名称>", objectKey, uploadId);
|
||||||
|
obsClient.abortMultipartUpload(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String,String> uploadChunk(String uploadId, File file,int chunk, String objectKey){
|
||||||
|
// Endpoint以北京四为例,其他地区请按实际情况填写。
|
||||||
|
Map<String,String> map = new HashMap<>();
|
||||||
|
UploadPartRequest request = new UploadPartRequest("<桶名称>", objectKey);
|
||||||
|
request.setUploadId(uploadId);
|
||||||
|
request.setPartNumber(chunk);
|
||||||
|
request.setFile(file);
|
||||||
|
request.setPartSize(5 * 1024 * 1024L);
|
||||||
|
UploadPartResult result = obsClient.uploadPart(request);
|
||||||
|
map.put("etag",result.getEtag());
|
||||||
|
map.put("partNumber",String.valueOf(result.getPartNumber()));
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MultipartFile 转 File
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static File multipartFileToFile(MultipartFile file) throws Exception {
|
||||||
|
|
||||||
|
File toFile = null;
|
||||||
|
if (file.equals("") || file.getSize() <= 0) {
|
||||||
|
file = null;
|
||||||
|
} else {
|
||||||
|
InputStream ins = null;
|
||||||
|
ins = file.getInputStream();
|
||||||
|
toFile = new File(file.getOriginalFilename());
|
||||||
|
inputStreamToFile(ins, toFile);
|
||||||
|
ins.close();
|
||||||
|
}
|
||||||
|
return toFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取流文件
|
||||||
|
private static void inputStreamToFile(InputStream ins, File file) {
|
||||||
|
try {
|
||||||
|
OutputStream os = new FileOutputStream(file);
|
||||||
|
int bytesRead = 0;
|
||||||
|
byte[] buffer = new byte[8192];
|
||||||
|
while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) {
|
||||||
|
os.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
os.close();
|
||||||
|
ins.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.resource.domain.ModelVersion;
|
import com.mcwl.resource.domain.ModelVersion;
|
||||||
import com.mcwl.resource.service.ModelVersionService;
|
import com.mcwl.resource.service.ModelVersionService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -96,7 +95,7 @@ public class ModelVersionController extends BaseController {
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "下载模型文件")
|
@ApiOperation(value = "下载模型文件")
|
||||||
@GetMapping("/modelFileDownload")
|
@GetMapping("/modelFileDownload")
|
||||||
public R modelFileDownload(@RequestParam Long id){
|
public R modelFileDownload(@RequestParam Long id){
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.mcwl.web.controller.resource;
|
package com.mcwl.web.controller.resource;
|
||||||
|
|
||||||
import com.mcwl.common.core.controller.BaseController;
|
import com.mcwl.common.core.controller.BaseController;
|
||||||
import com.mcwl.common.core.domain.AjaxResult;
|
|
||||||
import com.mcwl.common.core.domain.R;
|
import com.mcwl.common.core.domain.R;
|
||||||
import com.mcwl.common.core.page.TableDataInfo;
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.resource.domain.ToActivity;
|
import com.mcwl.resource.domain.ToActivity;
|
||||||
|
@ -26,7 +25,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Api(tags = "活动")
|
@Api(tags = "活动")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("ToActivity")
|
@RequestMapping("/ToActivity")
|
||||||
public class ToActivityController extends BaseController {
|
public class ToActivityController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ToActivityService toActivityService;
|
private ToActivityService toActivityService;
|
||||||
|
@ -38,7 +37,7 @@ public class ToActivityController extends BaseController {
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
public TableDataInfo list(@RequestBody ToActivity toActivity)
|
public TableDataInfo list(@RequestBody ToActivity toActivity)
|
||||||
{
|
{
|
||||||
// startPage();
|
|
||||||
List<ToActivity> list = toActivityService.selectToActivityList(toActivity);
|
List<ToActivity> list = toActivityService.selectToActivityList(toActivity);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import com.mcwl.common.core.domain.R;
|
||||||
import com.mcwl.resource.domain.WorkFlowVersion;
|
import com.mcwl.resource.domain.WorkFlowVersion;
|
||||||
import com.mcwl.resource.service.WorkFlowVersionService;
|
import com.mcwl.resource.service.WorkFlowVersionService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
@ -47,7 +46,7 @@ public class WorkFlowVersionController {
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty("下载工作流")
|
@ApiOperation("下载工作流")
|
||||||
@GetMapping("/workFlowFileDownload")
|
@GetMapping("/workFlowFileDownload")
|
||||||
public R workFlowFileDownload(@RequestParam Long id){
|
public R workFlowFileDownload(@RequestParam Long id){
|
||||||
|
|
||||||
|
|
|
@ -97,15 +97,8 @@ spring:
|
||||||
# 连接池的最大数据库连接数
|
# 连接池的最大数据库连接数
|
||||||
max-active: 1000
|
max-active: 1000
|
||||||
# #连接池最大阻塞等待时间(使用负值表示没有限制)
|
# #连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||||
max-wait: -1ms # 默认使用的数据库索引
|
max-wait: -1ms
|
||||||
#ai配置
|
time-between-eviction-runs: 6000
|
||||||
ai:
|
|
||||||
dashscope:
|
|
||||||
base-url: https://api.deepseek.com/chat/completions
|
|
||||||
api-key: sk-5d1f611b6ba74b90ae9e3dff5aaa508a
|
|
||||||
chat:
|
|
||||||
options:
|
|
||||||
model: deepseek-chat
|
|
||||||
|
|
||||||
|
|
||||||
# token配置
|
# token配置
|
||||||
|
|
|
@ -91,13 +91,14 @@ spring:
|
||||||
lettuce:
|
lettuce:
|
||||||
pool:
|
pool:
|
||||||
# 连接池中的最小空闲连接
|
# 连接池中的最小空闲连接
|
||||||
min-idle: 0
|
min-idle: 5
|
||||||
# 连接池中的最大空闲连接
|
# 连接池中的最大空闲连接
|
||||||
max-idle: 8
|
max-idle: 10
|
||||||
# 连接池的最大数据库连接数
|
# 连接池的最大数据库连接数
|
||||||
max-active: 8
|
max-active: 1000
|
||||||
# #连接池最大阻塞等待时间(使用负值表示没有限制)
|
# #连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||||
max-wait: -1ms
|
max-wait: -1ms
|
||||||
|
time-between-eviction-runs: 6000
|
||||||
|
|
||||||
|
|
||||||
# token配置
|
# token配置
|
||||||
|
|
|
@ -57,9 +57,9 @@ spring:
|
||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
# 单个文件大小
|
# 单个文件大小
|
||||||
max-file-size: 1024MB
|
max-file-size: 40GB
|
||||||
# 设置总上传的文件大小
|
# 设置总上传的文件大小
|
||||||
max-request-size: 1024MB
|
max-request-size: 40GB
|
||||||
# 服务模块
|
# 服务模块
|
||||||
devtools:
|
devtools:
|
||||||
restart:
|
restart:
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class ObsUtils {
|
||||||
now.getYear() + "/" +
|
now.getYear() + "/" +
|
||||||
now.getMonth() + "/" +
|
now.getMonth() + "/" +
|
||||||
now.getDayOfMonth() + "/"
|
now.getDayOfMonth() + "/"
|
||||||
+ uuid + "_"
|
+ uuid + "/"
|
||||||
+ name;
|
+ name;
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,17 +38,17 @@
|
||||||
<!-- <artifactId>dashscope-sdk-java</artifactId>-->
|
<!-- <artifactId>dashscope-sdk-java</artifactId>-->
|
||||||
<!-- <version>2.18.3</version>-->
|
<!-- <version>2.18.3</version>-->
|
||||||
<!-- </dependency>-->
|
<!-- </dependency>-->
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>com.alibaba.cloud.ai</groupId>
|
<!-- <groupId>com.alibaba.cloud.ai</groupId>-->
|
||||||
<artifactId>spring-ai-alibaba-starter</artifactId>
|
<!-- <artifactId>spring-ai-alibaba-starter</artifactId>-->
|
||||||
<version>1.0.0-M5.1</version>
|
<!-- <version>1.0.0-M5.1</version>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
|
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>io.projectreactor.netty</groupId>
|
<!-- <groupId>io.projectreactor.netty</groupId>-->
|
||||||
<artifactId>reactor-netty-http</artifactId>
|
<!-- <artifactId>reactor-netty-http</artifactId>-->
|
||||||
<version>1.1.6</version> <!-- 使用与你的 Spring Boot 版本兼容的版本 -->
|
<!-- <version>1.1.6</version> <!– 使用与你的 Spring Boot 版本兼容的版本 –>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -1,32 +1,32 @@
|
||||||
package com.mcwl.communityCenter.config;
|
//package com.mcwl.communityCenter.config;
|
||||||
|
//
|
||||||
import com.mcwl.communityCenter.webSocket.ChatWebSocket;
|
//import com.mcwl.communityCenter.webSocket.ChatWebSocket;
|
||||||
import com.mcwl.communityCenter.webSocket.HumanWebSocket;
|
//import com.mcwl.communityCenter.webSocket.HumanWebSocket;
|
||||||
import org.springframework.context.annotation.Bean;
|
//import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
//import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.socket.config.annotation.EnableWebSocket;
|
//import org.springframework.web.socket.config.annotation.EnableWebSocket;
|
||||||
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
|
//import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
|
||||||
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
|
//import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
|
||||||
|
//
|
||||||
@Configuration
|
//@Configuration
|
||||||
@EnableWebSocket
|
//@EnableWebSocket
|
||||||
public class WebSocketConfig implements WebSocketConfigurer {
|
//public class WebSocketConfig implements WebSocketConfigurer {
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
|
// public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
|
||||||
registry.addHandler(chatWebSocket(), "/chat")
|
// registry.addHandler(chatWebSocket(), "/chat")
|
||||||
.addHandler(humanWebSocket(), "/chat/human")
|
// .addHandler(humanWebSocket(), "/chat/human")
|
||||||
.setAllowedOrigins("*");
|
// .setAllowedOrigins("*");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Bean
|
// @Bean
|
||||||
public ChatWebSocket chatWebSocket() {
|
// public ChatWebSocket chatWebSocket() {
|
||||||
return new ChatWebSocket();
|
// return new ChatWebSocket();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Bean
|
// @Bean
|
||||||
public HumanWebSocket humanWebSocket() {
|
// public HumanWebSocket humanWebSocket() {
|
||||||
return new HumanWebSocket();
|
// return new HumanWebSocket();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
|
@ -1,84 +1,84 @@
|
||||||
package com.mcwl.communityCenter.service.impl;
|
//package com.mcwl.communityCenter.service.impl;
|
||||||
|
//
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
//import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
//import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
//import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.mcwl.common.utils.StringUtils;
|
//import com.mcwl.common.utils.StringUtils;
|
||||||
import com.mcwl.communityCenter.domain.DeepSeekRequest;
|
//import com.mcwl.communityCenter.domain.DeepSeekRequest;
|
||||||
import com.mcwl.communityCenter.service.AIService;
|
//import com.mcwl.communityCenter.service.AIService;
|
||||||
import lombok.RequiredArgsConstructor;
|
//import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
//import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.MediaType;
|
//import org.springframework.http.MediaType;
|
||||||
import org.springframework.stereotype.Service;
|
//import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
//import org.springframework.web.reactive.function.client.WebClient;
|
||||||
import reactor.core.publisher.Flux;
|
//import reactor.core.publisher.Flux;
|
||||||
import reactor.core.publisher.Mono;
|
//import reactor.core.publisher.Mono;
|
||||||
import reactor.core.publisher.SignalType;
|
//import reactor.core.publisher.SignalType;
|
||||||
|
//
|
||||||
import java.util.ArrayList;
|
//import java.util.ArrayList;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
//import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
//
|
||||||
@Service
|
//@Service
|
||||||
@RequiredArgsConstructor
|
//@RequiredArgsConstructor
|
||||||
public class AIServiceImpl implements AIService {
|
//public class AIServiceImpl implements AIService {
|
||||||
|
//
|
||||||
@Value("${spring.ai.dashscope.base-url}")
|
// @Value("${spring.ai.dashscope.base-url}")
|
||||||
private String DEEPSEEK_API_URL;
|
// private String DEEPSEEK_API_URL;
|
||||||
@Value("${spring.ai.dashscope.api-key}")
|
// @Value("${spring.ai.dashscope.api-key}")
|
||||||
private String API_KEY;
|
// private String API_KEY;
|
||||||
@Value("${spring.ai.dashscope.chat.options.model}")
|
// @Value("${spring.ai.dashscope.chat.options.model}")
|
||||||
private String apiModel;
|
// private String apiModel;
|
||||||
|
//
|
||||||
|
//
|
||||||
private final ObjectMapper objectMapper;
|
// private final ObjectMapper objectMapper;
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public Flux<String> getDeepSeekResponseStream(String message) {
|
// public Flux<String> getDeepSeekResponseStream(String message) {
|
||||||
WebClient client = WebClient.builder()
|
// WebClient client = WebClient.builder()
|
||||||
.baseUrl(DEEPSEEK_API_URL)
|
// .baseUrl(DEEPSEEK_API_URL)
|
||||||
.defaultHeader("Authorization", "Bearer " + API_KEY)
|
// .defaultHeader("Authorization", "Bearer " + API_KEY)
|
||||||
.build();
|
// .build();
|
||||||
|
//
|
||||||
// 构建请求体(推荐使用对象映射)
|
// // 构建请求体(推荐使用对象映射)
|
||||||
DeepSeekRequest request = new DeepSeekRequest();
|
// DeepSeekRequest request = new DeepSeekRequest();
|
||||||
request.setModel(apiModel);
|
// request.setModel(apiModel);
|
||||||
// 添加对话历史
|
// // 添加对话历史
|
||||||
request.addMessage("user", message);
|
// request.addMessage("user", message);
|
||||||
request.setMaxTokens(500);
|
// request.setMaxTokens(500);
|
||||||
request.setTemperature(0.7);
|
// request.setTemperature(0.7);
|
||||||
request.setStream(true);
|
// request.setStream(true);
|
||||||
|
//
|
||||||
return client.post()
|
// return client.post()
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
// .contentType(MediaType.APPLICATION_JSON)
|
||||||
.bodyValue(request)
|
// .bodyValue(request)
|
||||||
.retrieve()
|
// .retrieve()
|
||||||
.bodyToFlux(String.class) // 原始数据流
|
// .bodyToFlux(String.class) // 原始数据流
|
||||||
.takeUntil(data -> data.contains("[DONE]")) // 遇到结束标记停止
|
// .takeUntil(data -> data.contains("[DONE]")) // 遇到结束标记停止
|
||||||
.flatMap(json -> parseContentFromJson(json)) // 解析内容
|
// .flatMap(json -> parseContentFromJson(json)) // 解析内容
|
||||||
.onErrorResume(e -> Flux.just(""));// 错误处理
|
// .onErrorResume(e -> Flux.just(""));// 错误处理
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
// 辅助方法:从 JSON 中提取 content
|
// // 辅助方法:从 JSON 中提取 content
|
||||||
private Mono<String> parseContentFromJson(String json) {
|
// private Mono<String> parseContentFromJson(String json) {
|
||||||
try {
|
// try {
|
||||||
JsonNode root = objectMapper.readTree(json);
|
// JsonNode root = objectMapper.readTree(json);
|
||||||
String reasoning_content = root.path("choices")
|
// String reasoning_content = root.path("choices")
|
||||||
.get(0)
|
// .get(0)
|
||||||
.path("delta")
|
// .path("delta")
|
||||||
.path("reasoning_content")
|
// .path("reasoning_content")
|
||||||
.asText("");
|
// .asText("");
|
||||||
String content = root.path("choices")
|
// String content = root.path("choices")
|
||||||
.get(0)
|
// .get(0)
|
||||||
.path("delta")
|
// .path("delta")
|
||||||
.path("content")
|
// .path("content")
|
||||||
.asText("");
|
// .asText("");
|
||||||
System.out.print(StringUtils.isNotEmpty(reasoning_content) ? reasoning_content : content);
|
// System.out.print(StringUtils.isNotEmpty(reasoning_content) ? reasoning_content : content);
|
||||||
return Mono.just(StringUtils.isNotEmpty(reasoning_content) ? reasoning_content : content);
|
// return Mono.just(StringUtils.isNotEmpty(reasoning_content) ? reasoning_content : content);
|
||||||
} catch (JsonProcessingException e) {
|
// } catch (JsonProcessingException e) {
|
||||||
return Mono.error(e);
|
// return Mono.error(e);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,82 +1,82 @@
|
||||||
package com.mcwl.communityCenter.webSocket;
|
//package com.mcwl.communityCenter.webSocket;
|
||||||
|
//
|
||||||
import com.mcwl.communityCenter.service.AIService;
|
//import com.mcwl.communityCenter.service.AIService;
|
||||||
import com.mcwl.communityCenter.service.HumanService;
|
//import com.mcwl.communityCenter.service.HumanService;
|
||||||
import lombok.NoArgsConstructor;
|
//import lombok.NoArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.socket.CloseStatus;
|
//import org.springframework.web.socket.CloseStatus;
|
||||||
import org.springframework.web.socket.TextMessage;
|
//import org.springframework.web.socket.TextMessage;
|
||||||
import org.springframework.web.socket.WebSocketSession;
|
//import org.springframework.web.socket.WebSocketSession;
|
||||||
import org.springframework.web.socket.handler.AbstractWebSocketHandler;
|
//import org.springframework.web.socket.handler.AbstractWebSocketHandler;
|
||||||
import reactor.core.Disposable;
|
//import reactor.core.Disposable;
|
||||||
import reactor.core.publisher.Flux;
|
//import reactor.core.publisher.Flux;
|
||||||
|
//
|
||||||
import javax.websocket.server.ServerEndpoint;
|
//import javax.websocket.server.ServerEndpoint;
|
||||||
import java.io.IOException;
|
//import java.io.IOException;
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
//import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
//
|
||||||
@ServerEndpoint("/chat")
|
//@ServerEndpoint("/chat")
|
||||||
@NoArgsConstructor
|
//@NoArgsConstructor
|
||||||
public class ChatWebSocket extends AbstractWebSocketHandler {
|
//public class ChatWebSocket extends AbstractWebSocketHandler {
|
||||||
private final Map<String, Boolean> userModes = new ConcurrentHashMap<>();
|
// private final Map<String, Boolean> userModes = new ConcurrentHashMap<>();
|
||||||
|
//
|
||||||
// 存储会话与订阅的映射关系
|
// // 存储会话与订阅的映射关系
|
||||||
private final Map<String, Disposable> sessionSubscriptions = new ConcurrentHashMap<>();
|
// private final Map<String, Disposable> sessionSubscriptions = new ConcurrentHashMap<>();
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private AIService aiService;
|
// private AIService aiService;
|
||||||
|
//
|
||||||
// 构造函数注入服务...
|
// // 构造函数注入服务...
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
|
// public void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
|
||||||
String userId = session.getId();
|
// String userId = session.getId();
|
||||||
String userMessage = message.getPayload();
|
// String userMessage = message.getPayload();
|
||||||
|
//
|
||||||
// AI 流式响应模式
|
// // AI 流式响应模式
|
||||||
Flux<String> responseStream = aiService.getDeepSeekResponseStream(userMessage);
|
// Flux<String> responseStream = aiService.getDeepSeekResponseStream(userMessage);
|
||||||
|
//
|
||||||
// 订阅响应流并存储 Disposable
|
// // 订阅响应流并存储 Disposable
|
||||||
Disposable disposable = responseStream
|
// Disposable disposable = responseStream
|
||||||
.doOnNext(chunk -> sendText(session, chunk)) // 发送每个数据块到客户端
|
// .doOnNext(chunk -> sendText(session, chunk)) // 发送每个数据块到客户端
|
||||||
.doOnComplete(() -> sendText(session, "[END]")) // 当流处理完成时,发送结束标记
|
// .doOnComplete(() -> sendText(session, "[END]")) // 当流处理完成时,发送结束标记
|
||||||
.doOnError(e -> sendText(session, "[ERROR] " + e.getMessage()))
|
// .doOnError(e -> sendText(session, "[ERROR] " + e.getMessage()))
|
||||||
.subscribe();
|
// .subscribe();
|
||||||
|
//
|
||||||
sessionSubscriptions.put(userId, disposable);
|
// sessionSubscriptions.put(userId, disposable);
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
|
// public void afterConnectionEstablished(WebSocketSession session) throws Exception {
|
||||||
super.afterConnectionEstablished(session);
|
// super.afterConnectionEstablished(session);
|
||||||
// userModes.put(session.getId(), false);
|
//// userModes.put(session.getId(), false);
|
||||||
session.sendMessage(new TextMessage("[AI] 您好,请问有什么问题?"));
|
// session.sendMessage(new TextMessage("[AI] 您好,请问有什么问题?"));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) {
|
// public void afterConnectionClosed(WebSocketSession session, CloseStatus status) {
|
||||||
// 清理订阅资源
|
// // 清理订阅资源
|
||||||
String sessionId = session.getId();
|
// String sessionId = session.getId();
|
||||||
Disposable disposable = sessionSubscriptions.remove(sessionId);
|
// Disposable disposable = sessionSubscriptions.remove(sessionId);
|
||||||
if (disposable != null && disposable.isDisposed()) {
|
// if (disposable != null && disposable.isDisposed()) {
|
||||||
disposable.dispose();
|
// disposable.dispose();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
// 线程安全的发送方法
|
// // 线程安全的发送方法
|
||||||
private void sendText(WebSocketSession session, String text) {
|
// private void sendText(WebSocketSession session, String text) {
|
||||||
try {
|
// try {
|
||||||
if (session.isOpen()) {
|
// if (session.isOpen()) {
|
||||||
synchronized (session) { // WebSocketSession 非线程安全
|
// synchronized (session) { // WebSocketSession 非线程安全
|
||||||
session.sendMessage(new TextMessage(text));
|
// session.sendMessage(new TextMessage(text));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
System.out.println("WebSocket 发送失败: " + e.getMessage());
|
// System.out.println("WebSocket 发送失败: " + e.getMessage());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,55 +1,55 @@
|
||||||
package com.mcwl.communityCenter.webSocket;
|
//package com.mcwl.communityCenter.webSocket;
|
||||||
|
//
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
//import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.communityCenter.service.HumanService;
|
//import com.mcwl.communityCenter.service.HumanService;
|
||||||
import lombok.NoArgsConstructor;
|
//import lombok.NoArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.socket.CloseStatus;
|
//import org.springframework.web.socket.CloseStatus;
|
||||||
import org.springframework.web.socket.TextMessage;
|
//import org.springframework.web.socket.TextMessage;
|
||||||
import org.springframework.web.socket.WebSocketSession;
|
//import org.springframework.web.socket.WebSocketSession;
|
||||||
import org.springframework.web.socket.handler.AbstractWebSocketHandler;
|
//import org.springframework.web.socket.handler.AbstractWebSocketHandler;
|
||||||
import reactor.core.Disposable;
|
//import reactor.core.Disposable;
|
||||||
|
//
|
||||||
import javax.websocket.server.ServerEndpoint;
|
//import javax.websocket.server.ServerEndpoint;
|
||||||
import java.io.IOException;
|
//import java.io.IOException;
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
//import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
//
|
||||||
@ServerEndpoint("/chat/human")
|
//@ServerEndpoint("/chat/human")
|
||||||
@NoArgsConstructor
|
//@NoArgsConstructor
|
||||||
public class HumanWebSocket extends AbstractWebSocketHandler {
|
//public class HumanWebSocket extends AbstractWebSocketHandler {
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private HumanService humanService;
|
// private HumanService humanService;
|
||||||
|
//
|
||||||
// 构造函数注入服务...
|
// // 构造函数注入服务...
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
|
// public void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
|
||||||
String userId = session.getId();
|
// String userId = session.getId();
|
||||||
String userMessage = message.getPayload();
|
// String userMessage = message.getPayload();
|
||||||
|
//
|
||||||
humanService.handleHumanMessage(userId, userMessage);
|
// humanService.handleHumanMessage(userId, userMessage);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
|
// public void afterConnectionEstablished(WebSocketSession session) throws Exception {
|
||||||
super.afterConnectionEstablished(session);
|
// super.afterConnectionEstablished(session);
|
||||||
humanService.transferToHuman(SecurityUtils.getUserId().toString(), session);
|
// humanService.transferToHuman(SecurityUtils.getUserId().toString(), session);
|
||||||
System.out.println("客服:" + SecurityUtils.getUsername() + " 已上线");
|
// System.out.println("客服:" + SecurityUtils.getUsername() + " 已上线");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
// 线程安全的发送方法
|
// // 线程安全的发送方法
|
||||||
private void sendText(WebSocketSession session, String text) {
|
// private void sendText(WebSocketSession session, String text) {
|
||||||
try {
|
// try {
|
||||||
if (session.isOpen()) {
|
// if (session.isOpen()) {
|
||||||
synchronized (session) { // WebSocketSession 非线程安全
|
// synchronized (session) { // WebSocketSession 非线程安全
|
||||||
session.sendMessage(new TextMessage(text));
|
// session.sendMessage(new TextMessage(text));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
System.out.println("WebSocket 发送失败: " + e.getMessage());
|
// System.out.println("WebSocket 发送失败: " + e.getMessage());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
|
@ -79,7 +79,7 @@ public class RedisConfig extends CachingConfigurerSupport
|
||||||
* @return RedisConnectionFactory
|
* @return RedisConnectionFactory
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public RedisConnectionFactory redisConnectionFactory() {
|
public LettuceConnectionFactory redisConnectionFactory() {
|
||||||
RedisStandaloneConfiguration standaloneConfig = new RedisStandaloneConfiguration("1.13.246.108", 6370);
|
RedisStandaloneConfiguration standaloneConfig = new RedisStandaloneConfiguration("1.13.246.108", 6370);
|
||||||
standaloneConfig.setPassword(RedisPassword.of("MuYu_Cloud@Redis"));
|
standaloneConfig.setPassword(RedisPassword.of("MuYu_Cloud@Redis"));
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.mcwl.memberCenter.domain.vo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.mcwl.common.core.domain.BaseEntity;
|
||||||
|
import com.mcwl.memberCenter.enums.PromotionEnum;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 促销活动vo
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel(description = "促销活动")
|
||||||
|
public class PromotionVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动id
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "活动id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动名称
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "活动名称")
|
||||||
|
private String activityName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否参与
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "是否参与")
|
||||||
|
private Integer isJoin;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动的详细描述
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "活动的详细描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动开始时间
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "活动开始时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date startTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动结束时间
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "活动结束时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date endTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,8 +1,24 @@
|
||||||
package com.mcwl.memberCenter.service;
|
package com.mcwl.memberCenter.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.common.core.domain.R;
|
||||||
|
import com.mcwl.common.core.page.PageDomain;
|
||||||
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.memberCenter.domain.MemberPromotion;
|
import com.mcwl.memberCenter.domain.MemberPromotion;
|
||||||
import com.mcwl.memberCenter.domain.Promotion;
|
import com.mcwl.memberCenter.domain.Promotion;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface PromotionService extends IService<Promotion> {
|
public interface PromotionService extends IService<Promotion> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取促销活动列表
|
||||||
|
* @return TableDataInfo
|
||||||
|
*/
|
||||||
|
TableDataInfo getPromotionList(PageDomain pageDomain);
|
||||||
|
|
||||||
|
|
||||||
|
TableDataInfo getMyPromotionList(PageDomain pageDomain);
|
||||||
|
|
||||||
|
R<Object> joinPromotion(Long promotionId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,210 @@
|
||||||
package com.mcwl.memberCenter.service.impl;
|
package com.mcwl.memberCenter.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.common.constant.HttpStatus;
|
||||||
|
import com.mcwl.common.core.domain.R;
|
||||||
|
import com.mcwl.common.core.page.PageDomain;
|
||||||
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
|
import com.mcwl.memberCenter.domain.Member;
|
||||||
import com.mcwl.memberCenter.domain.MemberPromotion;
|
import com.mcwl.memberCenter.domain.MemberPromotion;
|
||||||
import com.mcwl.memberCenter.domain.Promotion;
|
import com.mcwl.memberCenter.domain.Promotion;
|
||||||
|
import com.mcwl.memberCenter.domain.vo.PromotionVo;
|
||||||
|
import com.mcwl.memberCenter.enums.PromotionEnum;
|
||||||
import com.mcwl.memberCenter.mapper.MemberPromotionMapper;
|
import com.mcwl.memberCenter.mapper.MemberPromotionMapper;
|
||||||
import com.mcwl.memberCenter.mapper.PromotionMapper;
|
import com.mcwl.memberCenter.mapper.PromotionMapper;
|
||||||
import com.mcwl.memberCenter.service.MemberPromotionService;
|
import com.mcwl.memberCenter.service.MemberPromotionService;
|
||||||
|
import com.mcwl.memberCenter.service.MemberService;
|
||||||
import com.mcwl.memberCenter.service.PromotionService;
|
import com.mcwl.memberCenter.service.PromotionService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class PromotionServiceImpl extends ServiceImpl<PromotionMapper, Promotion> implements PromotionService {
|
public class PromotionServiceImpl extends ServiceImpl<PromotionMapper, Promotion> implements PromotionService {
|
||||||
|
|
||||||
|
private final MemberPromotionService memberPromotionService;
|
||||||
|
|
||||||
|
private final MemberService memberService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取促销活动列表
|
||||||
|
*
|
||||||
|
* @return TableDataInfo
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TableDataInfo getPromotionList(PageDomain pageDomain) {
|
||||||
|
|
||||||
|
// 封装用户参加的促销活动, key为促销活动id, value为用户参加的促销活动
|
||||||
|
Map<Long, MemberPromotion> map = new HashMap<>();
|
||||||
|
|
||||||
|
// 获取用户参加的促销活动
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
List<MemberPromotion> memberPromotionList = memberPromotionService.lambdaQuery()
|
||||||
|
.eq(MemberPromotion::getUserId, userId)
|
||||||
|
.eq(MemberPromotion::getStatus, PromotionEnum.PARTICIPATE)
|
||||||
|
.list();
|
||||||
|
for (MemberPromotion memberPromotion : memberPromotionList) {
|
||||||
|
map.put(memberPromotion.getPromotionId(), memberPromotion);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询促销活动列表
|
||||||
|
Page<Promotion> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
|
||||||
|
|
||||||
|
LambdaQueryWrapper<Promotion> lqw = new LambdaQueryWrapper<>();
|
||||||
|
lqw.gt(Promotion::getEndTime, new Date());
|
||||||
|
|
||||||
|
baseMapper.selectPage(page, lqw);
|
||||||
|
|
||||||
|
// 封装数据
|
||||||
|
List<PromotionVo> promotionVoList = new ArrayList<>();
|
||||||
|
page.getRecords().forEach(promotion -> {
|
||||||
|
PromotionVo promotionVo = new PromotionVo();
|
||||||
|
BeanUtil.copyProperties(promotion, promotionVo);
|
||||||
|
if (map.containsKey(promotion.getId())) {
|
||||||
|
promotionVo.setIsJoin(1);
|
||||||
|
} else {
|
||||||
|
promotionVo.setIsJoin(0);
|
||||||
|
}
|
||||||
|
promotionVoList.add(promotionVo);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 封装分页结果
|
||||||
|
TableDataInfo rspData = new TableDataInfo();
|
||||||
|
rspData.setCode(HttpStatus.SUCCESS);
|
||||||
|
rspData.setMsg("查询成功");
|
||||||
|
rspData.setRows(promotionVoList);
|
||||||
|
rspData.setTotal(page.getTotal());
|
||||||
|
|
||||||
|
return rspData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户参加的促销活动
|
||||||
|
*
|
||||||
|
* @param pageDomain 分页参数
|
||||||
|
* @return TableDataInfo
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TableDataInfo getMyPromotionList(PageDomain pageDomain) {
|
||||||
|
|
||||||
|
// 获取当前用户
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
|
||||||
|
|
||||||
|
List<Long> memberPromotionIds = new ArrayList<>();
|
||||||
|
// 默认添加一个不存在的id, 防止List为空时in查询出错
|
||||||
|
memberPromotionIds.add(-1L);
|
||||||
|
|
||||||
|
// 查询用户参加的促销活动
|
||||||
|
List<MemberPromotion> memberPromotionList = memberPromotionService.lambdaQuery()
|
||||||
|
.eq(MemberPromotion::getUserId, userId)
|
||||||
|
.eq(MemberPromotion::getStatus, PromotionEnum.PARTICIPATE)
|
||||||
|
.list();
|
||||||
|
for (MemberPromotion memberPromotion : memberPromotionList) {
|
||||||
|
memberPromotionIds.add(memberPromotion.getPromotionId());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询促销活动列表
|
||||||
|
Page<Promotion> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
|
||||||
|
|
||||||
|
LambdaQueryWrapper<Promotion> lqw = new LambdaQueryWrapper<>();
|
||||||
|
lqw.in(Promotion::getId, memberPromotionIds);
|
||||||
|
baseMapper.selectPage(page, lqw);
|
||||||
|
|
||||||
|
// 封装数据
|
||||||
|
List<PromotionVo> promotionVoList = new ArrayList<>();
|
||||||
|
page.getRecords().forEach(promotion -> {
|
||||||
|
PromotionVo promotionVo = new PromotionVo();
|
||||||
|
BeanUtil.copyProperties(promotion, promotionVo);
|
||||||
|
promotionVoList.add(promotionVo);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// 封装分页结果
|
||||||
|
TableDataInfo rspData = new TableDataInfo();
|
||||||
|
rspData.setCode(HttpStatus.SUCCESS);
|
||||||
|
rspData.setMsg("查询成功");
|
||||||
|
rspData.setRows(promotionVoList);
|
||||||
|
rspData.setTotal(page.getTotal());
|
||||||
|
|
||||||
|
return rspData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户参加促销活动
|
||||||
|
*
|
||||||
|
* @param promotionId 促销活动id
|
||||||
|
* @return R
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public R<Object> joinPromotion(Long promotionId) {
|
||||||
|
|
||||||
|
// 用户id
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
|
||||||
|
// 按活动id查询活动信息
|
||||||
|
Promotion promotion = baseMapper.selectById(promotionId);
|
||||||
|
|
||||||
|
if (!Optional.ofNullable(promotion).isPresent()) {
|
||||||
|
return R.fail(HttpStatus.WARN,"活动不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (promotion.getStartTime().after(new Date())) {
|
||||||
|
return R.fail(HttpStatus.WARN,"活动未开始");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 活动是否过期
|
||||||
|
if (promotion.getEndTime().before(new Date())) {
|
||||||
|
return R.fail(HttpStatus.WARN,"活动已过期");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前用户是否参与过该活动
|
||||||
|
if (isJoinPromotion(userId, promotionId)) {
|
||||||
|
return R.fail(HttpStatus.WARN,"您已参与过该活动");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 是否在活动期间内订阅或续订会员
|
||||||
|
// if (!isSubscribe(userId, promotion)) {
|
||||||
|
// return AjaxResult.warn("请在活动期间内订阅或续期会员后参加该活动");
|
||||||
|
// }
|
||||||
|
|
||||||
|
Member member = memberService.getUseUserMemberByUserId(userId);
|
||||||
|
String memberLevelId = Objects.isNull(member) ? "-1" : member.getMemberLevelId().toString();
|
||||||
|
|
||||||
|
String memberLevelIds = promotion.getMemberLevelIds();
|
||||||
|
if (!memberLevelIds.contains(memberLevelId)) {
|
||||||
|
return R.fail(HttpStatus.WARN,"会员等级不够,无法参与该活动,请查看活动条件");
|
||||||
|
}
|
||||||
|
MemberPromotion memberPromotion = getMemberPromotion(userId, promotionId);
|
||||||
|
memberPromotionService.save(memberPromotion);
|
||||||
|
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean isJoinPromotion(Long userId, Long promotionId) {
|
||||||
|
MemberPromotion memberPromotion = memberPromotionService.lambdaQuery()
|
||||||
|
.eq(MemberPromotion::getUserId, userId)
|
||||||
|
.eq(MemberPromotion::getPromotionId, promotionId)
|
||||||
|
.one();
|
||||||
|
return memberPromotion != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static MemberPromotion getMemberPromotion(Long userId, Long promotionId) {
|
||||||
|
MemberPromotion memberPromotion = new MemberPromotion();
|
||||||
|
memberPromotion.setUserId(userId);
|
||||||
|
memberPromotion.setPromotionId(promotionId);
|
||||||
|
memberPromotion.setStatus(PromotionEnum.PARTICIPATE);
|
||||||
|
memberPromotion.setParticipationTime(new Date());
|
||||||
|
return memberPromotion;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,15 @@
|
||||||
package com.mcwl.memberCenter.task;
|
package com.mcwl.memberCenter.task;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.mcwl.common.constant.QueueConstants;
|
import com.mcwl.common.constant.QueueConstants;
|
||||||
import com.mcwl.common.core.domain.entity.SysUser;
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
import com.mcwl.memberCenter.domain.Benefit;
|
import com.mcwl.memberCenter.domain.*;
|
||||||
import com.mcwl.memberCenter.domain.Member;
|
|
||||||
import com.mcwl.memberCenter.domain.MemberBenefit;
|
|
||||||
import com.mcwl.memberCenter.domain.MemberLevel;
|
|
||||||
import com.mcwl.memberCenter.enums.MemberBenefitTypeEnum;
|
import com.mcwl.memberCenter.enums.MemberBenefitTypeEnum;
|
||||||
import com.mcwl.memberCenter.enums.MemberEnum;
|
import com.mcwl.memberCenter.enums.MemberEnum;
|
||||||
import com.mcwl.memberCenter.service.BenefitService;
|
import com.mcwl.memberCenter.enums.PromotionEnum;
|
||||||
import com.mcwl.memberCenter.service.MemberBenefitService;
|
import com.mcwl.memberCenter.service.*;
|
||||||
import com.mcwl.memberCenter.service.MemberLevelService;
|
|
||||||
import com.mcwl.memberCenter.service.MemberService;
|
|
||||||
import com.mcwl.system.service.ISysUserService;
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
@ -38,9 +35,13 @@ public class UserMemberTask {
|
||||||
|
|
||||||
private final BenefitService benefitService;
|
private final BenefitService benefitService;
|
||||||
|
|
||||||
|
private final PromotionService promotionService;
|
||||||
|
|
||||||
|
private final MemberPromotionService memberPromotionService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 积分清零提醒 月底前五天 0 0 9 L-5 * ?
|
* 积分重置提醒 月底前五天 0 0 9 L-5 * ?
|
||||||
*/
|
*/
|
||||||
public void emptyPointsRemindTask() {
|
public void emptyPointsRemindTask() {
|
||||||
List<Member> memberList = memberService.getUseUserMember();
|
List<Member> memberList = memberService.getUseUserMember();
|
||||||
|
@ -56,6 +57,7 @@ public class UserMemberTask {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 已弃用
|
||||||
* 清空积分 每月月底前两天 0 0 0 L-2 * ?
|
* 清空积分 每月月底前两天 0 0 0 L-2 * ?
|
||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@ -116,7 +118,7 @@ public class UserMemberTask {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员积分赠送 每月1号 0 0 0 1 * ?
|
* 重置会员积分 每月1号 0 0 0 1 * ?
|
||||||
*/
|
*/
|
||||||
public void givePointsTask() {
|
public void givePointsTask() {
|
||||||
List<Member> memberList = memberService.getUseUserMember();
|
List<Member> memberList = memberService.getUseUserMember();
|
||||||
|
@ -129,6 +131,45 @@ public class UserMemberTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员参与的促销活动是否过期 每天晚上0点检查 0 0 0 * * ?
|
||||||
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void checkPromotionExpiredTask() {
|
||||||
|
|
||||||
|
int pageNum = 1;
|
||||||
|
int pageSize = 1000;
|
||||||
|
|
||||||
|
// 根据活动结束日期小于当前时间,获取活动id
|
||||||
|
List<Long> promotionIdList = new ArrayList<>();
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
Page<Promotion> page = new Page<>(pageNum, pageSize);
|
||||||
|
|
||||||
|
promotionService.lambdaQuery()
|
||||||
|
.lt(Promotion::getEndTime, new Date()) // 活动结束日期小于当前时间
|
||||||
|
.orderByAsc(Promotion::getId)
|
||||||
|
.page(page);
|
||||||
|
List<Promotion> promotionList = page.getRecords();
|
||||||
|
if (promotionList.isEmpty()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (Promotion promotion : promotionList) {
|
||||||
|
promotionIdList.add(promotion.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
memberPromotionService.lambdaUpdate()
|
||||||
|
.set(MemberPromotion::getStatus, PromotionEnum.EXPIRED)
|
||||||
|
.eq(MemberPromotion::getStatus, PromotionEnum.PARTICIPATE)
|
||||||
|
.in(MemberPromotion::getPromotionId, promotionIdList)
|
||||||
|
.update();
|
||||||
|
pageNum++;
|
||||||
|
promotionIdList.clear();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据会员等级获取积分
|
* 根据会员等级获取积分
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,12 +19,9 @@ public class Commission extends BaseEntity {
|
||||||
@TableId
|
@TableId
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
// 消费者id
|
// 用户id
|
||||||
private Long consumeId;
|
private Long userId;
|
||||||
|
|
||||||
// 提成金额
|
// 提成金额
|
||||||
private Double amount;
|
private Double amount;
|
||||||
|
|
||||||
// 支付状态
|
|
||||||
private Integer payStatus;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,11 +45,10 @@ public class ConsumeServiceImpl extends ServiceImpl<ConsumeMapper, Consume> impl
|
||||||
// commission.setUserId(sysUser.getParentId());
|
// commission.setUserId(sysUser.getParentId());
|
||||||
|
|
||||||
// 设置消费者id
|
// 设置消费者id
|
||||||
commission.setConsumeId(consume.getUserId());
|
commission.setUserId(consume.getUserId());
|
||||||
|
|
||||||
// TODO 设置佣金,目前固定2.0
|
// TODO 设置佣金,目前固定2.0
|
||||||
commission.setAmount(2.0);
|
commission.setAmount(2.0);
|
||||||
commission.setPayStatus(0);
|
|
||||||
|
|
||||||
commissionService.save(commission);
|
commissionService.save(commission);
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,9 @@
|
||||||
|
|
||||||
|
|
||||||
<select id="getTotalAmount" resultType="java.lang.Double">
|
<select id="getTotalAmount" resultType="java.lang.Double">
|
||||||
select sum(com.amount)
|
select sum(amount)
|
||||||
from inv_invitation inv
|
from inv_commission
|
||||||
join inv_consume con
|
where user_id = #{userId}
|
||||||
on inv.user_invite_id = con.user_id
|
|
||||||
join inv_commission com on com.consume_id = con.id
|
|
||||||
where inv.user_id = #{userId}
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getEarningsDisplay" resultType="com.mcwl.myInvitation.domain.dto.EarningsDisplay">
|
<select id="getEarningsDisplay" resultType="com.mcwl.myInvitation.domain.dto.EarningsDisplay">
|
||||||
|
|
|
@ -355,6 +355,7 @@ public class AliPayServiceImpl implements AliPayService {
|
||||||
System.out.println(response.getBody());
|
System.out.println(response.getBody());
|
||||||
|
|
||||||
if (response.isSuccess()) {
|
if (response.isSuccess()) {
|
||||||
|
|
||||||
return R.ok("提现成功");
|
return R.ok("提现成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
||||||
|
|
||||||
// 保存提成表
|
// 保存提成表
|
||||||
Commission commission = new Commission();
|
Commission commission = new Commission();
|
||||||
commission.setConsumeId(inviterUserId);
|
commission.setUserId(inviterUserId);
|
||||||
commission.setAmount(amount);
|
commission.setAmount(amount);
|
||||||
commissionService.save(commission);
|
commissionService.save(commission);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
package com.mcwl.resource.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载记录表
|
||||||
|
*
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/3/6
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
@TableName("download_record")
|
||||||
|
@Builder
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DownloadRecord {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "主键ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载作品ID
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "下载作品ID")
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载人ID
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "下载人ID")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作品类型(0模型 1工作流)
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "作品类型(0模型 1工作流)")
|
||||||
|
private Long productType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件名字
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "文件名字")
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 封面图
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "封面图")
|
||||||
|
private String cover;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作者名字
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "作者名字")
|
||||||
|
private String authorName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网站地址
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "网站地址")
|
||||||
|
private String website;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件大小
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "文件大小")
|
||||||
|
private String fileSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态(下载中,已暂停,下载完成)
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "状态(下载中,已暂停,下载完成)")
|
||||||
|
private Long status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建日期
|
||||||
|
*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
|
@ApiModelProperty(value = "创建日期")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
}
|
|
@ -11,8 +11,6 @@ import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模型表
|
* 模型表
|
||||||
* @Author:ChenYan
|
* @Author:ChenYan
|
||||||
|
@ -144,13 +142,13 @@ public class ModelProduct extends BaseEntity {
|
||||||
private Double productPrice;
|
private Double productPrice;
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 翻译后标签
|
// * 翻译后标签
|
||||||
*/
|
// */
|
||||||
@ApiModelProperty(value = "翻译后标签")
|
// @ApiModelProperty(value = "翻译后标签")
|
||||||
@TableField(exist = false)
|
// @TableField(exist = false)
|
||||||
private List<String> styleList;
|
// private List<String> styleList;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -161,11 +159,12 @@ public class ModelProduct extends BaseEntity {
|
||||||
private Integer isAttention;
|
private Integer isAttention;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**R
|
||||||
* 是否点赞 0未点赞 1点赞
|
* 是否点赞 0未点赞 1点赞
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "是否点赞 0未点赞 1点赞")
|
@ApiModelProperty(value = "是否点赞 0未点赞 1点赞")
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Integer isLike;
|
private Integer isLike;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,5 +194,11 @@ public class ModelVersion extends BaseEntity {
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private ArrayList<String> highList;
|
private ArrayList<String> highList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否收藏
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "是否收藏")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Integer isCollect = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,4 +97,11 @@ public class WorkFlowVersion {
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "文件大小")
|
@ApiModelProperty(value = "文件大小")
|
||||||
private String fileSize;
|
private String fileSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否收藏
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
@ApiModelProperty(value = "是否收藏")
|
||||||
|
private Integer isCollect =1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,4 +15,6 @@ import org.apache.ibatis.annotations.Param;
|
||||||
public interface CollectMapper extends BaseMapper<Collect> {
|
public interface CollectMapper extends BaseMapper<Collect> {
|
||||||
Collect selectCollect(@Param("userId") Long userId, @Param("productId") Long productId, @Param("productType") Long productType);
|
Collect selectCollect(@Param("userId") Long userId, @Param("productId") Long productId, @Param("productType") Long productType);
|
||||||
|
|
||||||
|
Collect selectCollectById(@Param("modelId") Long modelId, @Param("userIdMax") Long userIdMax, @Param("type") Integer type);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.mcwl.resource.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mcwl.resource.domain.DownloadRecord;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/3/6
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface DownloadRecordMapper extends BaseMapper<DownloadRecord> {
|
||||||
|
void updateDownloadRecord(DownloadRecord downloadRecord);
|
||||||
|
|
||||||
|
}
|
|
@ -12,4 +12,6 @@ import com.mcwl.resource.domain.Collect;
|
||||||
|
|
||||||
public interface CollectService {
|
public interface CollectService {
|
||||||
R addCollect(Collect collect);
|
R addCollect(Collect collect);
|
||||||
|
|
||||||
|
Collect selectCollectById(Long modelId, Long userIdMax,Integer type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.mcwl.resource.service;
|
||||||
|
|
||||||
|
import com.mcwl.common.core.domain.R;
|
||||||
|
import com.mcwl.resource.domain.DownloadRecord;
|
||||||
|
import com.mcwl.resource.domain.vo.PageVo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/3/6
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public interface DownloadRecordService {
|
||||||
|
R addDownloadRecord(DownloadRecord downloadRecord);
|
||||||
|
|
||||||
|
R selectDownloadRecord(PageVo pageVo);
|
||||||
|
|
||||||
|
R updateDownloadRecord(DownloadRecord downloadRecord);
|
||||||
|
|
||||||
|
R deleteDownloadRecord(String ids);
|
||||||
|
}
|
|
@ -8,6 +8,8 @@ import com.mcwl.resource.service.CollectService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 收藏实现层
|
* 收藏实现层
|
||||||
* @author DaiZibo
|
* @author DaiZibo
|
||||||
|
@ -26,7 +28,8 @@ public class CollectServiceImpl implements CollectService {
|
||||||
public R addCollect(Collect collect) {
|
public R addCollect(Collect collect) {
|
||||||
|
|
||||||
Collect collect1 = collectMapper.selectCollect(SecurityUtils.getUserId(),collect.getProductId(),collect.getProductType());
|
Collect collect1 = collectMapper.selectCollect(SecurityUtils.getUserId(),collect.getProductId(),collect.getProductType());
|
||||||
|
collect.setUserId(SecurityUtils.getUserId());
|
||||||
|
collect.setCreateTime(new Date());
|
||||||
if (collect1 == null){
|
if (collect1 == null){
|
||||||
//执行收藏
|
//执行收藏
|
||||||
collectMapper.insert(collect);
|
collectMapper.insert(collect);
|
||||||
|
@ -38,4 +41,10 @@ public class CollectServiceImpl implements CollectService {
|
||||||
return R.ok(1);
|
return R.ok(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collect selectCollectById(Long modelId, Long userIdMax,Integer type) {
|
||||||
|
|
||||||
|
return collectMapper.selectCollectById(modelId,userIdMax,type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,138 @@
|
||||||
|
package com.mcwl.resource.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.mcwl.common.core.domain.R;
|
||||||
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
|
import com.mcwl.common.utils.StringUtils;
|
||||||
|
import com.mcwl.resource.domain.*;
|
||||||
|
import com.mcwl.resource.domain.vo.PageVo;
|
||||||
|
import com.mcwl.resource.mapper.*;
|
||||||
|
import com.mcwl.resource.service.DownloadRecordService;
|
||||||
|
import com.mcwl.system.mapper.SysUserMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载记录实现层
|
||||||
|
*
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/3/6
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class DownloadRecordServiceImpl implements DownloadRecordService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DownloadRecordMapper downloadRecordMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ModelVersionMapper modelVersionMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WorkFlowVersionMapper workFlowVersionMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WorkFlowMapper workFlowMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysUserMapper sysUserMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ModelMapper modelMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R addDownloadRecord(DownloadRecord downloadRecord) {
|
||||||
|
|
||||||
|
//获取下载人
|
||||||
|
downloadRecord.setUserId(SecurityUtils.getUserId());
|
||||||
|
downloadRecord.setCreateTime(new Date());
|
||||||
|
|
||||||
|
//获取作品信息
|
||||||
|
if (downloadRecord.getProductType() == 0){
|
||||||
|
|
||||||
|
//查询文件/名称信息
|
||||||
|
ModelVersion modelVersion = modelVersionMapper.selectById(downloadRecord.getProductId());
|
||||||
|
downloadRecord.setFileName(modelVersion.getFileName());
|
||||||
|
downloadRecord.setFileSize(modelVersion.getFileSize());
|
||||||
|
|
||||||
|
//根据版本查找封面信息
|
||||||
|
ModelProduct modelProduct = modelMapper.selectById(modelVersion.getModelId());
|
||||||
|
downloadRecord.setCover(modelProduct.getSurfaceUrl());
|
||||||
|
|
||||||
|
//查询作者信息
|
||||||
|
SysUser sysUser = sysUserMapper.selectUserById(modelProduct.getUserId());
|
||||||
|
downloadRecord.setAuthorName(sysUser.getNickName());
|
||||||
|
|
||||||
|
}else {
|
||||||
|
|
||||||
|
//查询文件/名称信息
|
||||||
|
WorkFlowVersion workFlowVersion = workFlowVersionMapper.selectById(downloadRecord.getProductId());
|
||||||
|
downloadRecord.setFileName(workFlowVersion.getFileName());
|
||||||
|
downloadRecord.setFileSize(workFlowVersion.getFileSize());
|
||||||
|
|
||||||
|
//根据版本查找封面信息
|
||||||
|
WorkFlow workFlow = workFlowMapper.selectById(workFlowVersion.getWorkFlowId());
|
||||||
|
downloadRecord.setCover(workFlow.getCoverPath());
|
||||||
|
|
||||||
|
//查询作者信息
|
||||||
|
SysUser sysUser = sysUserMapper.selectUserById(workFlow.getUserId());
|
||||||
|
downloadRecord.setAuthorName(sysUser.getNickName());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadRecordMapper.insert(downloadRecord);
|
||||||
|
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R selectDownloadRecord(PageVo pageVo) {
|
||||||
|
|
||||||
|
//分页查询数据
|
||||||
|
Page<DownloadRecord> page = new Page<>();
|
||||||
|
page.setSize(pageVo.getPageSize());
|
||||||
|
page.setPages(pageVo.getPageNumber());
|
||||||
|
|
||||||
|
LambdaQueryWrapper<DownloadRecord> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(DownloadRecord::getUserId,SecurityUtils.getUserId());
|
||||||
|
wrapper.eq(pageVo.getType() != null,DownloadRecord::getProductType,pageVo.getType());
|
||||||
|
|
||||||
|
Page<DownloadRecord> downloadRecordPage = downloadRecordMapper.selectPage(page, wrapper);
|
||||||
|
|
||||||
|
return R.ok(downloadRecordPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R updateDownloadRecord(DownloadRecord downloadRecord) {
|
||||||
|
|
||||||
|
downloadRecordMapper.updateDownloadRecord(downloadRecord);
|
||||||
|
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R deleteDownloadRecord(String ids) {
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(ids)) {
|
||||||
|
List<Long> idList = Arrays.stream(ids.split(","))
|
||||||
|
.filter(StringUtils::isNotBlank)
|
||||||
|
.map(Long::valueOf)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (!idList.isEmpty()) {
|
||||||
|
downloadRecordMapper.deleteBatchIds(idList);
|
||||||
|
}
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
return R.fail("请选择要删除的数据");
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 文件实现层
|
||||||
* @author DaiZibo
|
* @author DaiZibo
|
||||||
* @date 2025/2/14
|
* @date 2025/2/14
|
||||||
* @apiNote
|
* @apiNote
|
||||||
|
|
|
@ -467,6 +467,8 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
|
||||||
log.info("开始拉取文件...");
|
log.info("开始拉取文件...");
|
||||||
HashMap<String, String> hashMap = new HashMap<>();
|
HashMap<String, String> hashMap = new HashMap<>();
|
||||||
hashMap.put("objectKey",key);
|
hashMap.put("objectKey",key);
|
||||||
|
log.info("整体版本数据:{}",modelVersion);
|
||||||
|
log.info("拉取文件数据:{}",key);
|
||||||
hashMap.put("type",DictInit.getDictValue(DictConstants.MODEL_TYPE,modelProduct.getModelType()+""));
|
hashMap.put("type",DictInit.getDictValue(DictConstants.MODEL_TYPE,modelProduct.getModelType()+""));
|
||||||
String s = HttpUtils.pythonPost("http://1.13.246.108:8188/api/experiment/models/upload", hashMap);
|
String s = HttpUtils.pythonPost("http://1.13.246.108:8188/api/experiment/models/upload", hashMap);
|
||||||
log.info("文件拉取结果:{}",s);
|
log.info("文件拉取结果:{}",s);
|
||||||
|
@ -502,16 +504,17 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
|
||||||
|
|
||||||
|
|
||||||
//标签
|
//标签
|
||||||
if (StringUtils.isNotEmpty(modelProduct.getTags())){
|
// if (StringUtils.isNotEmpty(modelProduct.getTags())){
|
||||||
ArrayList<String> strings = new ArrayList<>();
|
// ArrayList<String> strings = new ArrayList<>();
|
||||||
String[] split = modelProduct.getTags().split(",");
|
// String[] split = modelProduct.getTags().split(",");
|
||||||
for (String s : split) {
|
// for (String s : split) {
|
||||||
if (s != ""){
|
// if (s != ""){
|
||||||
strings.add(s);
|
// strings.add(s);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
modelProduct.setStyleList(strings);
|
// modelProduct.setStyleList(strings);
|
||||||
}
|
// }
|
||||||
|
// modelProduct.setStyleList(new ArrayList<>());
|
||||||
|
|
||||||
//功能
|
//功能
|
||||||
if (StringUtils.isNotEmpty(modelProduct.getFunctions())){
|
if (StringUtils.isNotEmpty(modelProduct.getFunctions())){
|
||||||
|
|
|
@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.mcwl.common.constant.DictConstants;
|
import com.mcwl.common.constant.DictConstants;
|
||||||
import com.mcwl.common.core.domain.R;
|
import com.mcwl.common.core.domain.R;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.common.utils.StringUtils;
|
import com.mcwl.common.utils.StringUtils;
|
||||||
|
import com.mcwl.resource.domain.Collect;
|
||||||
import com.mcwl.resource.domain.ModelVersion;
|
import com.mcwl.resource.domain.ModelVersion;
|
||||||
|
import com.mcwl.resource.mapper.ModelMapper;
|
||||||
import com.mcwl.resource.mapper.ModelVersionMapper;
|
import com.mcwl.resource.mapper.ModelVersionMapper;
|
||||||
import com.mcwl.resource.service.ModelVersionService;
|
import com.mcwl.resource.service.ModelVersionService;
|
||||||
import com.mcwl.system.init.DictInit;
|
import com.mcwl.system.init.DictInit;
|
||||||
|
@ -29,6 +32,12 @@ public class ModelVersionServiceImpl extends ServiceImpl< ModelVersionMapper,Mo
|
||||||
@Autowired
|
@Autowired
|
||||||
private ModelVersionService modelVersionService;
|
private ModelVersionService modelVersionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CollectServiceImpl collectService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ModelMapper modelMapper;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ModelVersionMapper modelVersionMapper;
|
private ModelVersionMapper modelVersionMapper;
|
||||||
|
@ -87,9 +96,23 @@ public class ModelVersionServiceImpl extends ServiceImpl< ModelVersionMapper,Mo
|
||||||
|
|
||||||
List<ModelVersion> modelVersions = baseMapper.selectList(modelVersionLambdaQueryWrapper);
|
List<ModelVersion> modelVersions = baseMapper.selectList(modelVersionLambdaQueryWrapper);
|
||||||
|
|
||||||
// for (ModelVersion modelVersion : modelVersions) {
|
Long userIdMax = SecurityUtils.getUserIdMax();
|
||||||
//
|
if (userIdMax != 0){
|
||||||
// }
|
|
||||||
|
for (ModelVersion modelVersion : modelVersions) {
|
||||||
|
modelVersion.setFilePath("");
|
||||||
|
modelVersion.setEncryptionFilePath("");
|
||||||
|
//模型字典 0 工作流字典 1
|
||||||
|
Integer type = 0;
|
||||||
|
//校验是否收藏
|
||||||
|
Collect collect = collectService.selectCollectById(modelVersion.getModelId(),userIdMax,type);
|
||||||
|
if (collect != null ){
|
||||||
|
modelVersion.setIsCollect(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return modelVersions;
|
return modelVersions;
|
||||||
}
|
}
|
||||||
|
@ -98,11 +121,19 @@ public class ModelVersionServiceImpl extends ServiceImpl< ModelVersionMapper,Mo
|
||||||
public R modelFileDownload(Long id) {
|
public R modelFileDownload(Long id) {
|
||||||
|
|
||||||
ModelVersion modelVersion = modelVersionMapper.selectById(id);
|
ModelVersion modelVersion = modelVersionMapper.selectById(id);
|
||||||
|
|
||||||
|
if (modelVersion == null){
|
||||||
|
return R.fail("文件为空");
|
||||||
|
}
|
||||||
|
|
||||||
if (modelVersion.getAllowDownloadImage().equals(0)){
|
if (modelVersion.getAllowDownloadImage().equals(0)){
|
||||||
return R.fail("此文件不可下载");
|
return R.fail("此文件不可下载");
|
||||||
}
|
}
|
||||||
|
|
||||||
return R.ok();
|
if (modelVersion.getIsEncrypt() == 1){
|
||||||
|
return R.ok(modelVersion.getEncryptionFilePath());
|
||||||
|
}
|
||||||
|
return R.ok(modelVersion.getFilePath(),modelVersion.getFileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -334,6 +334,7 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
|
||||||
|
|
||||||
LambdaQueryWrapper<WorkFlow> lambdaQueryWrapper = Wrappers.<WorkFlow>lambdaQuery()
|
LambdaQueryWrapper<WorkFlow> lambdaQueryWrapper = Wrappers.<WorkFlow>lambdaQuery()
|
||||||
.like(StringUtils.isNotBlank(pageVo.getName()), WorkFlow::getWorkflowName, pageVo.getName())
|
.like(StringUtils.isNotBlank(pageVo.getName()), WorkFlow::getWorkflowName, pageVo.getName())
|
||||||
|
.eq(WorkFlow::getAuditStatus,1)
|
||||||
.eq(WorkFlow::getDelFlag, 0);
|
.eq(WorkFlow::getDelFlag, 0);
|
||||||
|
|
||||||
if (pageVo.getOrder() == 1) {
|
if (pageVo.getOrder() == 1) {
|
||||||
|
|
|
@ -2,6 +2,8 @@ package com.mcwl.resource.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.mcwl.common.core.domain.R;
|
import com.mcwl.common.core.domain.R;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
|
import com.mcwl.resource.domain.Collect;
|
||||||
import com.mcwl.resource.domain.WorkFlow;
|
import com.mcwl.resource.domain.WorkFlow;
|
||||||
import com.mcwl.resource.domain.WorkFlowVersion;
|
import com.mcwl.resource.domain.WorkFlowVersion;
|
||||||
import com.mcwl.resource.mapper.WorkFlowMapper;
|
import com.mcwl.resource.mapper.WorkFlowMapper;
|
||||||
|
@ -14,6 +16,7 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工作流版本 业务实现层
|
* 工作流版本 业务实现层
|
||||||
|
*
|
||||||
* @author DaiZibo
|
* @author DaiZibo
|
||||||
* @date 2025/1/9
|
* @date 2025/1/9
|
||||||
* @apiNote
|
* @apiNote
|
||||||
|
@ -28,33 +31,50 @@ public class WorkFlowVersionServiceImpl implements WorkFlowVersionService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private WorkFlowMapper workFlowMapper;
|
private WorkFlowMapper workFlowMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CollectServiceImpl collectService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R<List<WorkFlowVersion>> selectVersionByWorkId(Long workId) {
|
public R<List<WorkFlowVersion>> selectVersionByWorkId(Long workId) {
|
||||||
|
|
||||||
LambdaQueryWrapper<WorkFlowVersion> workFlowVersionLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<WorkFlowVersion> workFlowVersionLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
workFlowVersionLambdaQueryWrapper.eq(WorkFlowVersion::getDelFlag,0);
|
workFlowVersionLambdaQueryWrapper.eq(WorkFlowVersion::getDelFlag, 0);
|
||||||
workFlowVersionLambdaQueryWrapper.eq(WorkFlowVersion::getWorkFlowId,workId);
|
workFlowVersionLambdaQueryWrapper.eq(WorkFlowVersion::getWorkFlowId, workId);
|
||||||
|
|
||||||
List<WorkFlowVersion> workFlowVersions = workFlowVersionMapper.selectList(workFlowVersionLambdaQueryWrapper);
|
List<WorkFlowVersion> workFlowVersions = workFlowVersionMapper.selectList(workFlowVersionLambdaQueryWrapper);
|
||||||
|
Long userIdMax = SecurityUtils.getUserIdMax();
|
||||||
|
if (userIdMax != 0) {
|
||||||
|
for (WorkFlowVersion workFlowVersion : workFlowVersions) {
|
||||||
|
workFlowVersion.setFilePath("");
|
||||||
|
//模型字典 0 工作流字典 1
|
||||||
|
Integer type = 0;
|
||||||
|
//校验是否收藏
|
||||||
|
Collect collect = collectService.selectCollectById(workFlowVersion.getWorkFlowId(), userIdMax, type);
|
||||||
|
if (collect != null) {
|
||||||
|
workFlowVersion.setIsCollect(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return R.ok(workFlowVersions);
|
return R.ok(workFlowVersions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R workFlowFileDownload(Long id) {
|
public R workFlowFileDownload(Long id) {
|
||||||
|
|
||||||
//查找数据
|
//查找数据
|
||||||
WorkFlowVersion workFlowVersion = workFlowVersionMapper.selectById(id);
|
WorkFlowVersion workFlowVersion = workFlowVersionMapper.selectById(id);
|
||||||
if (workFlowVersion == null){
|
if (workFlowVersion == null) {
|
||||||
return R.fail("文件不存在");
|
return R.fail("文件不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkFlow workFlow = workFlowMapper.selectById(workFlowVersion.getWorkFlowId());
|
WorkFlow workFlow = workFlowMapper.selectById(workFlowVersion.getWorkFlowId());
|
||||||
if (workFlow.getDownload().equals(1)){
|
if (workFlow.getDownload().equals(1)) {
|
||||||
return R.fail("该文件不允许下载");
|
return R.fail("该文件不允许下载");
|
||||||
}
|
}
|
||||||
|
|
||||||
return R.ok(workFlowVersion.getFilePath());
|
return R.ok(workFlowVersion.getFilePath(), workFlowVersion.getFileName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,4 +10,10 @@
|
||||||
FROM collect where product_id = #{productId} and user_id = #{userId} and product_type = #{productType}
|
FROM collect where product_id = #{productId} and user_id = #{userId} and product_type = #{productType}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectCollectById" resultType="com.mcwl.resource.domain.Collect">
|
||||||
|
select
|
||||||
|
id,product_id,user_id,product_type
|
||||||
|
FROM collect where product_id = #{modelId} and user_id = #{userIdMax} and product_type = #{type}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.mcwl.resource.mapper.DownloadRecordMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<update id="updateDownloadRecord">
|
||||||
|
UPDATE download_record
|
||||||
|
SET file_size = #{fileSize},
|
||||||
|
status = #{status}
|
||||||
|
WHERE id = #{id}
|
||||||
|
</update>
|
||||||
|
</mapper>
|
|
@ -93,6 +93,7 @@
|
||||||
LEFT JOIN sys_user as u
|
LEFT JOIN sys_user as u
|
||||||
on m.user_id = u.user_id
|
on m.user_id = u.user_id
|
||||||
WHERE m.del_flag = 0
|
WHERE m.del_flag = 0
|
||||||
|
and audit_status = 1
|
||||||
<if test="name != null and name != ''">
|
<if test="name != null and name != ''">
|
||||||
and m.model_name like CONCAT('%', #{name}, '%')
|
and m.model_name like CONCAT('%', #{name}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.mcwl.system.domain.dto;
|
||||||
|
|
||||||
|
import com.mcwl.common.core.page.PageDomain;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提现明细分页请求对象
|
||||||
|
*/
|
||||||
|
@ApiModel(description = "提现明细分页请求对象")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class WithdrawalPageRes extends PageDomain {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "用户id")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,8 +1,13 @@
|
||||||
package com.mcwl.system.service;
|
package com.mcwl.system.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.common.core.page.PageDomain;
|
||||||
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.system.domain.SysUserPayAccount;
|
import com.mcwl.system.domain.SysUserPayAccount;
|
||||||
import com.mcwl.system.domain.SysUserPayAccountLog;
|
import com.mcwl.system.domain.SysUserPayAccountLog;
|
||||||
|
import com.mcwl.system.domain.dto.WithdrawalPageRes;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户提现 服务层
|
* 用户提现 服务层
|
||||||
|
@ -12,4 +17,10 @@ import com.mcwl.system.domain.SysUserPayAccountLog;
|
||||||
public interface ISysUserPayAccountLogService extends IService<SysUserPayAccountLog> {
|
public interface ISysUserPayAccountLogService extends IService<SysUserPayAccountLog> {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前用户的提现记录
|
||||||
|
* @param withdrawalPageRes 分页参数
|
||||||
|
* @return TableDataInfo
|
||||||
|
*/
|
||||||
|
TableDataInfo getWithdrawalRecord(WithdrawalPageRes withdrawalPageRes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,53 @@
|
||||||
package com.mcwl.system.service.impl;
|
package com.mcwl.system.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.mcwl.common.constant.HttpStatus;
|
||||||
|
import com.mcwl.common.core.page.PageDomain;
|
||||||
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.system.domain.SysUserPayAccount;
|
import com.mcwl.system.domain.SysUserPayAccount;
|
||||||
import com.mcwl.system.domain.SysUserPayAccountLog;
|
import com.mcwl.system.domain.SysUserPayAccountLog;
|
||||||
|
import com.mcwl.system.domain.dto.WithdrawalPageRes;
|
||||||
import com.mcwl.system.mapper.SysUserPayAccountLogMapper;
|
import com.mcwl.system.mapper.SysUserPayAccountLogMapper;
|
||||||
import com.mcwl.system.mapper.SysUserPayAccountMapper;
|
import com.mcwl.system.mapper.SysUserPayAccountMapper;
|
||||||
import com.mcwl.system.service.ISysUserPayAccountLogService;
|
import com.mcwl.system.service.ISysUserPayAccountLogService;
|
||||||
import com.mcwl.system.service.ISysUserPayAccountService;
|
import com.mcwl.system.service.ISysUserPayAccountService;
|
||||||
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户提现
|
* 用户提现
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class SysUserPayAccountLogServiceImpl extends ServiceImpl<SysUserPayAccountLogMapper, SysUserPayAccountLog> implements ISysUserPayAccountLogService {
|
public class SysUserPayAccountLogServiceImpl extends ServiceImpl<SysUserPayAccountLogMapper, SysUserPayAccountLog> implements ISysUserPayAccountLogService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前用户的提现记录
|
||||||
|
* @param withdrawalPageRes 分页参数
|
||||||
|
* @return TableDataInfo
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TableDataInfo getWithdrawalRecord(WithdrawalPageRes withdrawalPageRes) {
|
||||||
|
|
||||||
|
Long userId = withdrawalPageRes.getUserId();
|
||||||
|
userId = Objects.isNull(userId) ? SecurityUtils.getUserId() : userId;
|
||||||
|
|
||||||
|
Page<SysUserPayAccountLog> page = new Page<>(withdrawalPageRes.getPageNum(), withdrawalPageRes.getPageSize());
|
||||||
|
|
||||||
|
baseMapper.selectPage(page, new LambdaQueryWrapper<SysUserPayAccountLog>()
|
||||||
|
.select(SysUserPayAccountLog::getAmount, SysUserPayAccountLog::getAccount, SysUserPayAccountLog::getCreateTime)
|
||||||
|
.eq(SysUserPayAccountLog::getUserId, userId));
|
||||||
|
|
||||||
|
TableDataInfo rspData = new TableDataInfo();
|
||||||
|
rspData.setCode(HttpStatus.SUCCESS);
|
||||||
|
rspData.setMsg("查询成功");
|
||||||
|
rspData.setRows(page.getRecords());
|
||||||
|
rspData.setTotal(page.getTotal());
|
||||||
|
return rspData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -612,9 +612,10 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
@Override
|
@Override
|
||||||
public SysUser selectUserInfoById(Long userId) {
|
public SysUser selectUserInfoById(Long userId) {
|
||||||
SysUser sysUser = userMapper.selectUserInfoById(userId);
|
SysUser sysUser = userMapper.selectUserInfoById(userId);
|
||||||
|
if (sysUser.getInviterUserId() != null){
|
||||||
SysUser sysUser1 = selectUserById(sysUser.getInviterUserId());
|
SysUser sysUser1 = selectUserById(sysUser.getInviterUserId());
|
||||||
sysUser.setInvitationName(sysUser1.getNickName());
|
sysUser.setInvitationName(sysUser1.getNickName());
|
||||||
|
}
|
||||||
return sysUser;
|
return sysUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue