Compare commits

...

11 Commits

Author SHA1 Message Date
ChenYan 573ccd5ef8 feat: 2025-01-13 11:47:28 +08:00
yang 511bd96d84 refactor(mcwl): 重构资源模块并移除支付相关代码- 移除了 AliPayIntegration 和 OrderTradeController 类
- 更新了 ModelImageController 接口,使用新的 ModelImagePageRes 类作为参数
- 新增了 ModelImagePageRes 类,用于图片分页请求
- 更新了 ModelImageService接口和实现类,支持新的分页查询参数
2025-01-13 11:03:59 +08:00
ChenYan af200b9274 Merge remote-tracking branch 'origin/preview' into preview 2025-01-12 16:00:34 +08:00
ChenYan ca41c38141 Merge branch 'feature/resource' of https://gitea.qinmian.online/CY/mcwl-ai into preview 2025-01-12 15:59:42 +08:00
yang 942bcd8315 Merge branch 'preview' into feature/my-invitation 2025-01-12 15:54:20 +08:00
yang f41111fc6d ceshi1 2025-01-12 15:50:54 +08:00
ChenYan 031d115263 feat: 模型评论模块 2025-01-12 15:36:37 +08:00
yang 7f22f046c8 feat(resource): 添加模特图片列表、详情、删除等功能
- 新增图片列表、详情、删除、修改等接口
- 实现分页查询功能
- 添加用户信息展示
- 优化图片上传和评论相关功能
2025-01-12 15:14:31 +08:00
yang 4d2b660faa refactor(mcwl-resource): 优化 ModelImageServiceImpl 类的代码结构- 导入 List 接口,为后续功能扩展做准备 2025-01-11 15:36:32 +08:00
yang 8c844faca5 Merge branch 'feature/my-invitation' into preview
# Conflicts:
#	mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelImageServiceImpl.java
2025-01-11 15:34:59 +08:00
yang 120e61102d feat(resource): 添加图片评论功能- 新增 ModelImageCommentVo 类用于评论区评论
- 在 ModelImageService 接口中添加 getComment 方法获取评论
- 在 ModelImageServiceImpl 中实现 getComment 方法
- 在 ModelImageController 中添加 getComment 接口
- 优化 ModelImageLike 和 ModelImageCommentLike相关逻辑
2025-01-11 15:33:30 +08:00
29 changed files with 937 additions and 393 deletions

File diff suppressed because one or more lines are too long

View File

@ -144,6 +144,27 @@ public class OrderTradeController extends BaseController {
return map.get("alipay_trade_query_response");
}
/**
*
*/
@GetMapping("/balance")
public void balance() throws Exception {
aliPayIntegration.balance();
}
/**
*
*/
@Anonymous
@PostMapping("/withdraw")
public void withdraw(@RequestBody OrderTradeDto orderTradeDto, HttpServletResponse response) throws Exception {
String outBizNo = UUID.fastUUID().toString(true);
String payerUserId = "2088102167258880";
String payeeUserId = "2088102167258880";
String amount = "100";
aliPayIntegration.transfer(outBizNo, payerUserId, payeeUserId, amount);
}
/**
*

View File

@ -1,42 +0,0 @@
package com.mcwl.web.controller.pay;
import com.alibaba.fastjson.JSONObject;
import com.alipay.easysdk.factory.Factory;
import com.alipay.easysdk.kernel.Config;
import com.alipay.easysdk.payment.facetoface.models.AlipayTradePrecreateResponse;
import com.mcwl.pay.domain.OrderTrade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
*/
@Component
public class AliPayIntegration {
@Autowired
private Config config;
/**
*
*
* @param tradeEntity
* @return url
* @throws Exception
*/
public String pay(OrderTrade tradeEntity) throws Exception {
Factory.setOptions(config);
//调用支付宝的接口
AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace()
.preCreate(tradeEntity.getUserName(),
tradeEntity.getCode(),
tradeEntity.getPaymentAmount().toString());
// AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace().preCreate("订单主题Mac笔记本", "LS123qwe123", "19999");
//参照官方文档响应示例,解析返回结果
String httpBodyStr = payResponse.getHttpBody();
JSONObject jsonObject = JSONObject.parseObject(httpBodyStr);
return jsonObject.getJSONObject("alipay_trade_precreate_response").get("qr_code").toString();
}
}

View File

@ -1,179 +0,0 @@
package com.mcwl.web.controller.pay;
import cn.hutool.extra.qrcode.QrCodeUtil;
import com.alipay.easysdk.factory.Factory;
import com.alipay.easysdk.payment.common.models.AlipayTradeQueryResponse;
import com.mcwl.common.JSONUtils;
import com.mcwl.common.annotation.Anonymous;
import com.mcwl.common.core.controller.BaseController;
import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.common.domain.IdsParam;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.pay.domain.OrderTrade;
import com.mcwl.pay.service.OrderTradeService;
import lombok.extern.slf4j.Slf4j;
import com.alipay.easysdk.kernel.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @AuthorChenYan
* @ProjectMcWl
* @Packagecom.mcwl.web.controller.pay
* @FilenameOrderTradeController
* @Description
* @Date2025/1/3 14:46
*/
@Slf4j
@RestController
@RequestMapping("/web/pay")
@Validated
public class OrderTradeController extends BaseController {
@Autowired
private Config config;
@Autowired
private OrderTradeService orderTradeService;
@Autowired
private AliPayIntegration aliPayIntegration;
/**
*
*/
@GetMapping("/list")
public TableDataInfo list(OrderTrade orderTrade)
{
startPage();
List<OrderTrade> list = orderTradeService.selectMallProductList(orderTrade);
return getDataTable(list);
}
/**
*
*/
@PostMapping("/add")
public AjaxResult add(@RequestBody OrderTrade orderTrade)
{
// 获取当前用户
Long userId = SecurityUtils.getUserId();
if (userId == null) {
return AjaxResult.warn("用户未登录");
}
orderTrade.setUserId(userId);
orderTrade.setCreateBy(getUsername());
return toAjax(orderTradeService.insertMallProduct(orderTrade));
}
/**
*
*/
@PostMapping("/upda")
public AjaxResult upda(@RequestBody OrderTrade orderTrade)
{
// 获取当前用户
Long userId = SecurityUtils.getUserId();
if (userId == null) {
return AjaxResult.warn("用户未登录");
}
orderTrade.setUserId(userId);
orderTrade.setUpdateBy(getUsername());
return toAjax(orderTradeService.updateMallProduct(orderTrade));
}
/**
*
*/
@PostMapping
public AjaxResult remove(@RequestBody IdsParam ids)
{
orderTradeService.deleteMallProductByIds(ids);
return success();
}
/**
*
*
* @param tradeEntity
* @param response
* @throws Exception
*/
@Anonymous
@PostMapping("/doPay")
public void doPay(@RequestBody OrderTrade tradeEntity, HttpServletResponse response) throws Exception {
String qrUrl = aliPayIntegration.pay(tradeEntity);
QrCodeUtil.generate(qrUrl, 300, 300, "png", response.getOutputStream());
}
@GetMapping("/queryTradeStatus")
public Object queryTradeStatus(@RequestParam String outTradeNo) throws Exception {
Factory.setOptions(config);
AlipayTradeQueryResponse query = Factory.Payment.Common().query(outTradeNo);
Map<String, Object> map = JSONUtils.jsonToMap(query.getHttpBody());
// 返回交易结果, 是否交易成功需要根据该对象中的 trade_status 来确定
// trade_status 的枚举值如下, 请见 https://opendocs.alipay.com/apis/api_1/alipay.trade.query
// WAIT_BUYER_PAY交易创建等待买家付款
// TRADE_CLOSED未付款交易超时关闭或支付完成后全额退款
// TRADE_SUCCESS交易支付成功
// TRADE_FINISHED交易结束不可退款
// 当 trade_status 等于 TRADE_SUCCESS 或 TRADE_FINISHED 时, 表示支付成功
return map.get("alipay_trade_query_response");
}
/**
*
* @param request
* @return
* @throws Exception
*/
@Anonymous
@PostMapping("/notify") // 注意这里必须是POST接口
public String payNotify(HttpServletRequest request) throws Exception {
log.info("已经进入回调接口");
if (request.getParameter("trade_status").equals("TRADE_SUCCESS")) {
System.out.println("=========支付宝异步回调========");
Map<String, String> params = new HashMap<>();
Map<String, String[]> requestParams = request.getParameterMap();
for (String name : requestParams.keySet()) {
params.put(name, request.getParameter(name));
// System.out.println(name + " = " + request.getParameter(name));
}
String tradeNo = params.get("out_trade_no");
String gmtPayment = params.get("gmt_payment");
String alipayTradeNo = params.get("trade_no");
// 支付宝验签
if (Factory.Payment.Common().verifyNotify(params)) {
// 验签通过
System.out.println("交易名称: " + params.get("subject"));
System.out.println("交易状态: " + params.get("trade_status"));
System.out.println("支付宝交易凭证号: " + params.get("trade_no"));
System.out.println("商户订单号: " + params.get("out_trade_no"));
System.out.println("交易金额: " + params.get("total_amount"));
System.out.println("买家在支付宝唯一id: " + params.get("buyer_id"));
System.out.println("买家付款时间: " + params.get("gmt_payment"));
System.out.println("买家付款金额: " + params.get("buyer_pay_amount"));
// 更新订单状态
}
}
return "success";
}
}

View File

@ -6,8 +6,10 @@ import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.resource.domain.ModelProduct;
import com.mcwl.resource.domain.dto.ModelImagePageRes;
import com.mcwl.resource.domain.vo.MallProductVo;
import com.mcwl.resource.service.ModelService;
import com.mcwl.system.service.ISysUserService;
import com.mcwl.web.controller.common.OssUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -29,8 +31,8 @@ import java.util.List;
@RestController
@RequestMapping("/model")
public class MallProductController extends BaseController {
@Autowired
private ISysUserService sysUserService;
@Autowired
private ModelService modelService;
@ -82,14 +84,12 @@ public class MallProductController extends BaseController {
/**
*
*
*/
@PostMapping("/list")
public TableDataInfo list(@RequestBody ModelProduct mallProduct)
{
startPage();
List<ModelProduct> list = modelService.selectMallProductList(mallProduct);
return getDataTable(list);
public TableDataInfo list(@RequestBody ModelImagePageRes imagePageRes) {
return modelService.listByPage(imagePageRes);
}

View File

@ -2,12 +2,16 @@ package com.mcwl.web.controller.resource;
import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.resource.domain.ModelComment;
import com.mcwl.resource.domain.vo.ModelCommentVo;
import com.mcwl.resource.service.ModelCommentLikeService;
import com.mcwl.resource.service.ModelCommentService;
import com.mcwl.resource.service.ModelLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @AuthorChenYan
* @ProjectMcWl
@ -27,10 +31,12 @@ public class ModelCommentController {
@Autowired
private ModelCommentLikeService modelCommentLikeService;
/**
* /
*/
@GetMapping("/imageLike/{imageId}")
@GetMapping("/modelLike/{modelId}")
public AjaxResult like(@PathVariable Long imageId) {
modelLikeService.like(imageId);
return AjaxResult.success();
@ -57,8 +63,24 @@ public class ModelCommentController {
/**
*
*/
@GetMapping("/comment/{modelId}")
public AjaxResult getComment(@PathVariable @NotNull(message = "模型id不能为空") Long modelId) {
List<ModelCommentVo> modelCommentList = modelCommentService.getComment(modelId);
return AjaxResult.success(modelCommentList);
}
/**
*
*/
@GetMapping("/commentDelete/{commentId}")
public AjaxResult commentDelete(@PathVariable @NotNull(message = "评论id不能为空") Long commentId) {
modelCommentService.removeById(commentId);
return AjaxResult.success();
}
}

View File

@ -2,23 +2,32 @@ package com.mcwl.web.controller.resource;
import cn.hutool.core.bean.BeanUtil;
import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.core.domain.entity.SysUser;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.oss.OssUtil;
import com.mcwl.resource.domain.ModelImage;
import com.mcwl.resource.domain.ModelImageCommentLike;
import com.mcwl.resource.domain.ModelImageLike;
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
import com.mcwl.resource.domain.dto.ModelImagePageRes;
import com.mcwl.resource.domain.dto.ModelImageRes;
import com.mcwl.resource.domain.vo.ModelImageCommentVo;
import com.mcwl.resource.domain.vo.ModelImageVo;
import com.mcwl.resource.service.ModelImageCommentLikeService;
import com.mcwl.resource.service.ModelImageCommentService;
import com.mcwl.resource.service.ModelImageLikeService;
import com.mcwl.resource.service.ModelImageService;
import com.mcwl.system.service.ISysUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.Date;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Objects;
/**
*
*/
@RestController
@RequestMapping("/modelImage")
@RequiredArgsConstructor
@ -30,6 +39,55 @@ public class ModelImageController {
private final ModelImageCommentLikeService modelImageCommentLikeService;
private final ModelImageCommentService modelImageCommentService;
private final ISysUserService sysUserService;
/**
*
*/
@PostMapping("/list")
public TableDataInfo list(@RequestBody ModelImagePageRes imagePageRes) {
return modelImageService.listByPage(imagePageRes);
}
/**
*
*/
@GetMapping("/detail/{imageId}")
public AjaxResult detail(@PathVariable @NotNull(message = "图片id不能为空") Long imageId) {
ModelImageVo modelImageVo = new ModelImageVo();
ModelImage modelImage = modelImageService.getById(imageId);
if (Objects.nonNull(modelImage)) {
BeanUtil.copyProperties(modelImage, modelImageVo);
SysUser sysUser = sysUserService.selectUserById(modelImage.getUserId());
modelImageVo.setUserId(SecurityUtils.getUserId());
modelImageVo.setUserName(SecurityUtils.getUsername());
modelImageVo.setUserAvatar(sysUser.getAvatar());
}
return AjaxResult.success(modelImageVo);
}
/**
*
*/
@GetMapping("/delete/{imageId}")
public AjaxResult delete(@PathVariable @NotNull(message = "图片id不能为空") Long imageId) {
modelImageService.removeById(imageId);
return AjaxResult.success();
}
/**
*
*/
@PostMapping("/update")
public AjaxResult update(@RequestBody ModelImageRes modelImageRes) {
modelImageService.updateById(modelImageRes);
return AjaxResult.success();
}
/**
*
@ -55,7 +113,7 @@ public class ModelImageController {
* /
*/
@GetMapping("/imageLike/{imageId}")
public AjaxResult like(@PathVariable Long imageId) {
public AjaxResult like(@PathVariable @NotNull(message = "图片id不能为空") Long imageId) {
modelImageLikeService.like(imageId);
return AjaxResult.success();
}
@ -74,12 +132,28 @@ public class ModelImageController {
* /
*/
@GetMapping("/commentLike/{commentId}")
public AjaxResult commentLike(@PathVariable Long commentId) {
public AjaxResult commentLike(@PathVariable @NotNull(message = "评论id不能为空") Long commentId) {
modelImageCommentLikeService.like(commentId);
return AjaxResult.error();
return AjaxResult.success();
}
/**
*
*/
@GetMapping("/commentDelete/{commentId}")
public AjaxResult commentDelete(@PathVariable @NotNull(message = "评论id不能为空") Long commentId) {
modelImageCommentService.removeById(commentId);
return AjaxResult.success();
}
/**
*
*/
@GetMapping("/comment/{imageId}")
public AjaxResult getComment(@PathVariable @NotNull(message = "图片id不能为空") Long imageId) {
List<ModelImageCommentVo> modelImageCommentVoList = modelImageService.getComment(imageId);
return AjaxResult.success(modelImageCommentVoList);
}
}

View File

@ -2,6 +2,8 @@ package com.mcwl.common.core.page;
import com.mcwl.common.utils.StringUtils;
import javax.validation.constraints.NotNull;
/**
*
*
@ -10,9 +12,11 @@ import com.mcwl.common.utils.StringUtils;
public class PageDomain
{
/** 当前记录起始索引 */
@NotNull(message = "当前记录起始索引不能为空")
private Integer pageNum;
/** 每页显示记录数 */
@NotNull(message = "每页显示记录数不能为空")
private Integer pageSize;
/** 排序列 */

View File

@ -27,6 +27,11 @@
<artifactId>mcwl-common</artifactId>
</dependency>
<dependency>
<groupId>com.mcwl</groupId>
<artifactId>mcwl-system</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>

View File

@ -19,6 +19,12 @@ import java.util.Date;
* @apiNote
*/
@Builder
@NoArgsConstructor
@AllArgsConstructor

View File

@ -28,6 +28,10 @@ public class ModelImage extends BaseEntity {
*/
@TableId
private Long id;
/**
* ID
*/
private Long userId;
/**
* 8
*/

View File

@ -0,0 +1,37 @@
package com.mcwl.resource.domain.dto;
import com.mcwl.common.core.page.PageDomain;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import java.util.Date;
/**
*
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class ModelImagePageRes extends PageDomain {
/**
* id
*/
private Long userId;
/**
*
*/
private Integer status;
/**
*
*/
private Date startTime;
/**
*
*/
private Date endTime;
}

View File

@ -7,6 +7,10 @@ import javax.validation.constraints.NotBlank;
@Data
public class ModelImageRes {
/**
* id
*/
private Long id;
/**
* 8
*/

View File

@ -0,0 +1,66 @@
package com.mcwl.resource.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
*
*/
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Data
public class ModelCommentVo {
/**
* id
*/
private Long userId;
/**
*
*/
private String userName;
/**
*
*/
private String userAvatar;
/**
* id
*/
private Long commentId;
/**
*
*/
private String content;
/**
*
*/
private List<ModelCommentVo> contentList = new ArrayList<>();
/**
*
*/
private Integer likeNum;
/**
*
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
}

View File

@ -0,0 +1,66 @@
package com.mcwl.resource.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
*
*/
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Data
public class ModelImageCommentVo {
/**
* id
*/
private Long userId;
/**
*
*/
private String userName;
/**
*
*/
private String userAvatar;
/**
* id
*/
private Long commentId;
/**
*
*/
private String content;
/**
*
*/
private List<ModelImageCommentVo> contentList = new ArrayList<>();
/**
*
*/
private Integer likeNum;
/**
*
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
}

View File

@ -0,0 +1,74 @@
package com.mcwl.resource.domain.vo;
import lombok.Data;
@Data
public class ModelImageVo {
/**
* ID
*/
private Long id;
/**
* ID
*/
private Long userId;
/**
*
*/
private String userName;
/**
*
*/
private String userAvatar;
/**
* 8
*/
private String imagePaths;
/**
*
*/
private Integer hasWatermark;
/**
*
*/
private Integer isMemberDownload;
/**
*
*/
private Integer isNotDownloadable;
/**
*
*/
private Integer hideGenInfo;
/**
* 30
*/
private String title;
/**
*
*/
private String tags;
/**
* 500
*/
private String description;
/**
* 线
*/
private Integer onlineGenNum;
/**
*
*/
private Integer downloadNum;
/**
*
*/
private Integer returnNum;
/**
*
*/
private Integer likeNum;
}

View File

@ -0,0 +1,74 @@
package com.mcwl.resource.domain.vo;
import lombok.Data;
@Data
public class ModelVo {
/**
* ID
*/
private Long id;
/**
* ID
*/
private Long userId;
/**
*
*/
private String userName;
/**
*
*/
private String userAvatar;
/**
* 8
*/
private String imagePaths;
/**
*
*/
private Integer hasWatermark;
/**
*
*/
private Integer isMemberDownload;
/**
*
*/
private Integer isNotDownloadable;
/**
*
*/
private Integer hideGenInfo;
/**
* 30
*/
private String title;
/**
*
*/
private String tags;
/**
* 500
*/
private String description;
/**
* 线
*/
private Integer onlineGenNum;
/**
*
*/
private Integer downloadNum;
/**
*
*/
private Integer returnNum;
/**
*
*/
private Integer likeNum;
}

View File

@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mcwl.resource.domain.ModelImageComment;
import com.mcwl.resource.domain.ModelImageCommentLike;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface ModelImageCommentLikeMapper extends BaseMapper<ModelImageCommentLike> {
ModelImageCommentLike getLikeImageComment(Long userId, Long commentId);
ModelImageCommentLike getLikeImageComment(@Param("userId") Long userId, @Param("commentId") Long commentId);
void updateDelFlagById(@Param("userId") Long userId, @Param("commentId") Long commentId);
}

View File

@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mcwl.resource.domain.ModelImage;
import com.mcwl.resource.domain.ModelImageLike;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface ModelImageLikeMapper extends BaseMapper<ModelImageLike> {
ModelImageLike getLikeImage(Long userId, Long imageId);
ModelImageLike getLikeImage(@Param("userId") Long userId, @Param("imageId") Long imageId);
void updateDelFlagById(@Param("userId") Long userId, @Param("imageId") Long imageId);
}

View File

@ -2,6 +2,11 @@ package com.mcwl.resource.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mcwl.resource.domain.ModelComment;
import com.mcwl.resource.domain.vo.ModelCommentVo;
import com.mcwl.resource.domain.vo.ModelImageCommentVo;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @AuthorChenYan
@ -14,4 +19,11 @@ import com.mcwl.resource.domain.ModelComment;
public interface ModelCommentService extends IService<ModelComment> {
void comment(ModelComment modelComment);
/**
*
* @param imageId id
* @return
*/
List<ModelCommentVo> getComment(Long imageId);
}

View File

@ -3,14 +3,25 @@ package com.mcwl.resource.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.core.page.PageDomain;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.resource.domain.ModelImage;
import com.mcwl.resource.domain.ModelProduct;
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
import com.mcwl.resource.domain.dto.ModelImagePageRes;
import com.mcwl.resource.domain.dto.ModelImageRes;
import com.mcwl.resource.domain.vo.MallProductVo;
import com.mcwl.resource.domain.vo.ModelImageCommentVo;
import java.util.List;
public interface ModelImageService extends IService<ModelImage> {
/**
* id
* @param modelImageRes
*/
void updateById(ModelImageRes modelImageRes);
/**
*
@ -23,4 +34,18 @@ public interface ModelImageService extends IService<ModelImage> {
* @param modelImageCommentRes
*/
void comment(ModelImageCommentRes modelImageCommentRes);
/**
*
* @param imageId id
* @return
*/
List<ModelImageCommentVo> getComment(Long imageId);
/**
*
* @param imagePageRes
* @return
*/
TableDataInfo listByPage(ModelImagePageRes imagePageRes);
}

View File

@ -2,9 +2,11 @@ package com.mcwl.resource.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.common.domain.IdsParam;
import com.mcwl.resource.domain.ModelProduct;
import com.mcwl.resource.domain.ModelVersion;
import com.mcwl.resource.domain.dto.ModelImagePageRes;
import com.mcwl.resource.domain.vo.MallProductVo;
import java.util.List;
@ -19,17 +21,10 @@ import java.util.List;
*/
public interface ModelService extends IService<ModelProduct> {
List<ModelProduct> selectMallProductList(ModelProduct sysJob);
int insertMallProduct(ModelProduct mallProduct);
int updateMallProduct(ModelProduct mallProduct);
void deleteMallProductByIds(IdsParam ids);
Page<ModelProduct> selectByUserId(MallProductVo mallProductVo);
Page<ModelProduct> pageLike(MallProductVo mallProductVo, List<Long> list);
TableDataInfo listByPage(ModelImagePageRes imagePageRes);
}

View File

@ -1,21 +1,33 @@
package com.mcwl.resource.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mcwl.common.constant.HttpStatus;
import com.mcwl.common.core.domain.entity.SysUser;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.common.core.redis.RedisCache;
import com.mcwl.common.domain.IdsParam;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.StringUtils;
import com.mcwl.resource.domain.ModelImage;
import com.mcwl.resource.domain.ModelProduct;
import com.mcwl.resource.domain.dto.ModelImagePageRes;
import com.mcwl.resource.domain.vo.MallProductVo;
import com.mcwl.resource.domain.vo.ModelImageVo;
import com.mcwl.resource.mapper.MallProductMapper;
import com.mcwl.resource.service.ModelService;
import com.mcwl.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
@ -33,32 +45,10 @@ public class MallProductServiceImpl extends ServiceImpl<MallProductMapper,ModelP
@Autowired
private MallProductMapper postMapper;
@Autowired
private ISysUserService sysUserService;
@Override
public List<ModelProduct> selectMallProductList(ModelProduct mallProduct) {
QueryWrapper<ModelProduct> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(ModelProduct::getModelName, mallProduct.getModelName());
queryWrapper.lambda().eq(ModelProduct::getOriginalAuthorName, mallProduct.getOriginalAuthorName());
return postMapper.selectList(queryWrapper);
}
@Override
public int insertMallProduct(ModelProduct mallProduct) {
return postMapper.insert(mallProduct);
}
@Override
public int updateMallProduct(ModelProduct mallProduct) {
return postMapper.updateById(mallProduct);
}
@Override
public void deleteMallProductByIds(IdsParam ids) {
postMapper.deleteBatchIds(ids.getIds());
}
@Override
public Page<ModelProduct> selectByUserId(MallProductVo mallProductVo) {
@ -95,4 +85,58 @@ public class MallProductServiceImpl extends ServiceImpl<MallProductMapper,ModelP
}
/**
*
*
* @param imagePageRes
* @return
*/
@Override
public TableDataInfo listByPage(ModelImagePageRes imagePageRes) {
Page<ModelProduct> page = new Page<>(imagePageRes.getPageNum(), imagePageRes.getPageSize());
if (StringUtils.isEmpty(imagePageRes.getOrderByColumn())) {
imagePageRes.setOrderByColumn("create_time");
}
// 设置排序
boolean isAsc = Objects.equals(imagePageRes.getIsAsc(), "asc");
OrderItem orderItem = new OrderItem(imagePageRes.getOrderByColumn(), isAsc);
page.addOrder(orderItem);
LambdaQueryWrapper<ModelProduct> lqw = new LambdaQueryWrapper<>();
lqw.eq(imagePageRes.getStatus() != null, ModelProduct::getAuditSatus, imagePageRes.getStatus())
.eq(imagePageRes.getUserId() != null, ModelProduct::getUserId, imagePageRes.getUserId())
.eq(imagePageRes.getPageNum() != null, ModelProduct::getUserId, imagePageRes.getUserId())
.ge(imagePageRes.getStartTime() != null, ModelProduct::getCreateTime, imagePageRes.getStartTime())
.le(imagePageRes.getEndTime() != null, ModelProduct::getCreateTime, imagePageRes.getEndTime());
postMapper.selectPage(page, lqw);
// 获取分页数据
List<ModelProduct> modelImageList = page.getRecords();
// Model数据转为ModelPageVo
List<ModelImageVo> modelImageVoList = new ArrayList<>();
for (ModelProduct modelImage : modelImageList) {
ModelImageVo modelImageVo = new ModelImageVo();
BeanUtil.copyProperties(modelImage, modelImageVo);
// 获取用户信息
SysUser sysUser = sysUserService.selectUserById(modelImage.getUserId());
modelImageVo.setUserId(sysUser.getUserId());
modelImageVo.setUserName(sysUser.getUserName());
modelImageVo.setUserAvatar(sysUser.getAvatar());
modelImageVoList.add(modelImageVo);
}
// 封装分页数据
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(HttpStatus.SUCCESS);
rspData.setMsg("查询成功");
rspData.setRows(modelImageVoList);
rspData.setTotal(page.getTotal());
return rspData;
}
}

View File

@ -1,19 +1,27 @@
package com.mcwl.resource.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mcwl.common.core.domain.entity.SysUser;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.resource.domain.ModelComment;
import com.mcwl.resource.domain.ModelImageComment;
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
import com.mcwl.resource.domain.vo.ModelCommentVo;
import com.mcwl.resource.domain.vo.ModelImageCommentVo;
import com.mcwl.resource.mapper.ModelCommentMapper;
import com.mcwl.resource.mapper.ModelImageCommentMapper;
import com.mcwl.resource.mapper.ModelImageMapper;
import com.mcwl.resource.service.ModelCommentService;
import com.mcwl.system.service.ISysUserService;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
@ -27,6 +35,8 @@ import java.util.Objects;
@Service
public class ModelCommentServiceImpl extends ServiceImpl<ModelCommentMapper, ModelComment> implements ModelCommentService {
@Autowired
private ISysUserService sysUserService;
@Autowired
private ModelCommentMapper modelCommentMapper;
@ -48,4 +58,89 @@ public class ModelCommentServiceImpl extends ServiceImpl<ModelCommentMapper, Mod
modelCommentMapper.insert(modelComment);
}
@Override
public List<ModelCommentVo> getComment(Long imageId) {
List<ModelCommentVo> modelCommentVoList = new ArrayList<>();
// 查询所有父评论
LambdaQueryWrapper<ModelComment> lqw = new LambdaQueryWrapper<>();
lqw.eq(ModelComment::getModelId, imageId)
.isNull(ModelComment::getParentId)
.orderByDesc(ModelComment::getCreateTime);
// 添加父评论
List<ModelComment> modelCommentList = modelCommentMapper.selectList(lqw);
for (ModelComment modelComment : modelCommentList) {
ModelCommentVo modelCommentVo = getModelCommentVo(modelComment);
modelCommentVoList.add(modelCommentVo);
}
return modelCommentVoList;
}
/**
* ModelCommentVo
*
* @param modelComment
* @return ModelCommentVo
*/
@NotNull
private ModelCommentVo getModelCommentVo(ModelComment modelComment) {
Long userId = modelComment.getUserId();
SysUser sysUser = sysUserService.selectUserById(userId);
// 构建ModelCommentVo对象
ModelCommentVo modelCommentVo = new ModelCommentVo();
modelCommentVo.setUserId(userId);
modelCommentVo.setUserName(sysUser.getUserName());
modelCommentVo.setUserAvatar(sysUser.getAvatar());
modelCommentVo.setCommentId(modelComment.getId());
modelCommentVo.setContent(modelComment.getContent());
// 查询子评论
modelCommentVo.setContentList(getContentList(modelComment.getId()));
modelCommentVo.setLikeNum(modelComment.getLikeNum());
modelCommentVo.setCreateTime(modelComment.getCreateTime());
return modelCommentVo;
}
/**
*
*
* @param modelCommentId id
* @return List<ModelCommentVo>
*/
private List<ModelCommentVo> getContentList(Long modelCommentId) {
List<ModelCommentVo> modelCommentVoList = new ArrayList<>();
if (Objects.isNull(modelCommentId)) {
return modelCommentVoList;
}
// 查询子评论
LambdaQueryWrapper<ModelComment> lqw = new LambdaQueryWrapper<ModelComment>()
.eq(ModelComment::getParentId, modelCommentId)
.orderByDesc(ModelComment::getCreateTime);
List<ModelComment> modelCommentList = modelCommentMapper.selectList(lqw);
for (ModelComment modelComment : modelCommentList) {
Long userId = modelComment.getUserId();
SysUser sysUser = sysUserService.selectUserById(userId);
ModelCommentVo modelCommentVo = new ModelCommentVo();
modelCommentVo.setUserId(userId);
modelCommentVo.setUserName(sysUser.getUserName());
modelCommentVo.setUserAvatar(sysUser.getAvatar());
modelCommentVo.setCommentId(modelComment.getId());
modelCommentVo.setContent(modelComment.getContent());
modelCommentVo.setLikeNum(modelComment.getLikeNum());
modelCommentVo.setCreateTime(modelComment.getCreateTime());
modelCommentVoList.add(modelCommentVo);
}
return modelCommentVoList;
}
}

View File

@ -36,14 +36,12 @@ public class ModelImageCommentLikeServiceImpl extends ServiceImpl<ModelImageComm
ModelImageCommentLike modelImageCommentLike = baseMapper.getLikeImageComment(userId, commentId);
if (Objects.nonNull(modelImageCommentLike)) {
if (Objects.equals(modelImageCommentLike.getDelFlag(), "0")) {
modelImageCommentLike.setDelFlag("1");
modelImageComment.setLikeNum(modelImageComment.getLikeNum() - 1);
} else {
modelImageCommentLike.setDelFlag("0");
modelImageComment.setLikeNum(modelImageComment.getLikeNum() + 1);
}
// 更新点赞记录
baseMapper.updateById(modelImageCommentLike);
baseMapper.updateDelFlagById(userId, commentId);
// 更新图片评论点赞数
modelImageCommentMapper.updateById(modelImageComment);
return;

View File

@ -34,14 +34,12 @@ public class ModelImageLikeServiceImpl extends ServiceImpl<ModelImageLikeMapper,
ModelImageLike modelImageLike = baseMapper.getLikeImage(userId, imageId);
if (Objects.nonNull(modelImageLike)) {
if (Objects.equals(modelImageLike.getDelFlag(), "0")) {
modelImageLike.setDelFlag("1");
modelImage.setLikeNum(modelImage.getLikeNum() - 1);
} else {
modelImageLike.setDelFlag("0");
modelImage.setLikeNum(modelImage.getLikeNum() + 1);
}
// 更新点赞记录
baseMapper.updateById(modelImageLike);
baseMapper.updateDelFlagById(userId, imageId);
// 更新图片点赞数
modelImageMapper.updateById(modelImage);
return;

View File

@ -1,19 +1,34 @@
package com.mcwl.resource.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mcwl.common.constant.HttpStatus;
import com.mcwl.common.core.domain.entity.SysUser;
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.StringUtils;
import com.mcwl.resource.domain.ModelImage;
import com.mcwl.resource.domain.ModelImageComment;
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
import com.mcwl.resource.domain.dto.ModelImagePageRes;
import com.mcwl.resource.domain.dto.ModelImageRes;
import com.mcwl.resource.domain.vo.ModelImageCommentVo;
import com.mcwl.resource.domain.vo.ModelImageVo;
import com.mcwl.resource.mapper.ModelImageCommentMapper;
import com.mcwl.resource.mapper.ModelImageMapper;
import com.mcwl.resource.service.ModelImageService;
import com.mcwl.system.service.ISysUserService;
import lombok.RequiredArgsConstructor;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@Service
@ -24,30 +39,48 @@ public class ModelImageServiceImpl extends ServiceImpl<ModelImageMapper, ModelIm
private final ModelImageMapper modelImageMapper;
private final ISysUserService sysUserService;
@Override
public void comment(ModelImageCommentRes modelImageCommentRes) {
Long parentId = modelImageCommentRes.getParentId();
ModelImageComment mic = modelImageCommentMapper.selectById(parentId);
if (Objects.nonNull(parentId) && Objects.isNull(mic)) {
if (Objects.nonNull(parentId)) {
ModelImageComment mic = modelImageCommentMapper.selectById(parentId);
if (Objects.isNull(mic)) {
return;
}
}
ModelImageComment modelImageComment = new ModelImageComment();
BeanUtil.copyProperties(modelImageCommentRes, modelImageComment);
modelImageComment.setUserId(SecurityUtils.getUserId());
modelImageComment.setCreateBy(SecurityUtils.getUsername());
modelImageComment.setCreateTime(new Date());
modelImageComment.setUpdateBy(SecurityUtils.getUsername());
modelImageComment.setUpdateTime(new Date());
modelImageCommentMapper.insert(modelImageComment);
}
@Override
public void updateById(ModelImageRes modelImageRes) {
if (Objects.isNull(modelImageRes.getId())) {
return;
}
ModelImage modelImage = new ModelImage();
BeanUtil.copyProperties(modelImageRes, modelImage);
modelImage.setUpdateBy(SecurityUtils.getUsername());
modelImage.setUpdateTime(new Date());
modelImageMapper.updateById(modelImage);
}
@Override
public void publish(ModelImageRes modelImageRes) {
ModelImage modelImage = new ModelImage();
BeanUtil.copyProperties(modelImageRes, modelImage);
modelImage.setUserId(SecurityUtils.getUserId());
modelImage.setCreateBy(SecurityUtils.getUsername());
modelImage.setUpdateBy(SecurityUtils.getUsername());
modelImage.setUpdateTime(new Date());
@ -56,4 +89,147 @@ public class ModelImageServiceImpl extends ServiceImpl<ModelImageMapper, ModelIm
}
/**
*
*
* @param imageId id
* @return
*/
@Override
public List<ModelImageCommentVo> getComment(Long imageId) {
List<ModelImageCommentVo> modelImageCommentVoList = new ArrayList<>();
// 查询所有父评论
LambdaQueryWrapper<ModelImageComment> lqw = new LambdaQueryWrapper<>();
lqw.eq(ModelImageComment::getModelImageId, imageId)
.isNull(ModelImageComment::getParentId)
.orderByDesc(ModelImageComment::getCreateTime);
// 添加父评论
List<ModelImageComment> modelImageCommentList = modelImageCommentMapper.selectList(lqw);
for (ModelImageComment modelImageComment : modelImageCommentList) {
ModelImageCommentVo modelImageCommentVo = getModelImageCommentVo(modelImageComment);
modelImageCommentVoList.add(modelImageCommentVo);
}
return modelImageCommentVoList;
}
/**
*
*
* @param imagePageRes
* @return
*/
@Override
public TableDataInfo listByPage(ModelImagePageRes imagePageRes) {
Page<ModelImage> page = new Page<>(imagePageRes.getPageNum(), imagePageRes.getPageSize());
if (StringUtils.isEmpty(imagePageRes.getOrderByColumn())) {
imagePageRes.setOrderByColumn("create_time");
}
// 设置排序
boolean isAsc = Objects.equals(imagePageRes.getIsAsc(), "asc");
OrderItem orderItem = new OrderItem(imagePageRes.getOrderByColumn(), isAsc);
page.addOrder(orderItem);
LambdaQueryWrapper<ModelImage> lqw = new LambdaQueryWrapper<>();
lqw.eq(imagePageRes.getStatus() != null, ModelImage::getStatus, imagePageRes.getStatus())
.eq(imagePageRes.getUserId() != null, ModelImage::getUserId, imagePageRes.getUserId())
.ge(imagePageRes.getStartTime() != null, ModelImage::getCreateTime, imagePageRes.getStartTime())
.le(imagePageRes.getEndTime() != null, ModelImage::getCreateTime, imagePageRes.getEndTime());
modelImageMapper.selectPage(page, lqw);
// 获取分页数据
List<ModelImage> modelImageList = page.getRecords();
// ModelImage数据转为ModelImagePageVo
List<ModelImageVo> modelImageVoList = new ArrayList<>();
for (ModelImage modelImage : modelImageList) {
ModelImageVo modelImageVo = new ModelImageVo();
BeanUtil.copyProperties(modelImage, modelImageVo);
// 获取用户信息
SysUser sysUser = sysUserService.selectUserById(modelImage.getUserId());
modelImageVo.setUserId(sysUser.getUserId());
modelImageVo.setUserName(sysUser.getUserName());
modelImageVo.setUserAvatar(sysUser.getAvatar());
modelImageVoList.add(modelImageVo);
}
// 封装分页数据
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(HttpStatus.SUCCESS);
rspData.setMsg("查询成功");
rspData.setRows(modelImageVoList);
rspData.setTotal(page.getTotal());
return rspData;
}
/**
* ModelImageCommentVo
*
* @param modelImageComment
* @return ModelImageCommentVo
*/
@NotNull
private ModelImageCommentVo getModelImageCommentVo(ModelImageComment modelImageComment) {
Long userId = modelImageComment.getUserId();
SysUser sysUser = sysUserService.selectUserById(userId);
// 构建ModelImageCommentVo对象
ModelImageCommentVo modelImageCommentVo = new ModelImageCommentVo();
modelImageCommentVo.setUserId(userId);
modelImageCommentVo.setUserName(sysUser.getUserName());
modelImageCommentVo.setUserAvatar(sysUser.getAvatar());
modelImageCommentVo.setCommentId(modelImageComment.getId());
modelImageCommentVo.setContent(modelImageComment.getContent());
// 查询子评论
modelImageCommentVo.setContentList(getContentList(modelImageComment.getId()));
modelImageCommentVo.setLikeNum(modelImageComment.getLikeNum());
modelImageCommentVo.setCreateTime(modelImageComment.getCreateTime());
return modelImageCommentVo;
}
/**
*
*
* @param modelImageCommentId id
* @return List<ModelImageCommentVo>
*/
private List<ModelImageCommentVo> getContentList(Long modelImageCommentId) {
List<ModelImageCommentVo> modelImageCommentVoList = new ArrayList<>();
if (Objects.isNull(modelImageCommentId)) {
return modelImageCommentVoList;
}
// 查询子评论
LambdaQueryWrapper<ModelImageComment> lqw = new LambdaQueryWrapper<ModelImageComment>()
.eq(ModelImageComment::getParentId, modelImageCommentId)
.orderByDesc(ModelImageComment::getCreateTime);
List<ModelImageComment> modelImageCommentList = modelImageCommentMapper.selectList(lqw);
for (ModelImageComment modelImageComment : modelImageCommentList) {
Long userId = modelImageComment.getUserId();
SysUser sysUser = sysUserService.selectUserById(userId);
ModelImageCommentVo modelImageCommentVo = new ModelImageCommentVo();
modelImageCommentVo.setUserId(userId);
modelImageCommentVo.setUserName(sysUser.getUserName());
modelImageCommentVo.setUserAvatar(sysUser.getAvatar());
modelImageCommentVo.setCommentId(modelImageComment.getId());
modelImageCommentVo.setContent(modelImageComment.getContent());
modelImageCommentVo.setLikeNum(modelImageComment.getLikeNum());
modelImageCommentVo.setCreateTime(modelImageComment.getCreateTime());
modelImageCommentVoList.add(modelImageCommentVo);
}
return modelImageCommentVoList;
}
}

View File

@ -29,10 +29,16 @@
remark
from model_image_comment_like
</sql>
<update id="updateDelFlagById">
update model_image_comment_like
set del_flag = !del_flag
where user_id = #{userId} and model_image_comment_id = #{commentId}
</update>
<select id="getLikeImageComment" resultMap="ModelImageCommentLikeResult">
<include refid="selectModelImageCommentLikeVo"/>
where user_id = #{userId}
and model_image_comment_id = #{imageId}
and model_image_comment_id = #{commentId}
</select>
</mapper>

View File

@ -29,6 +29,11 @@
remark
from model_image_like
</sql>
<update id="updateDelFlagById">
update model_image_like
set del_flag = !del_flag
where user_id = #{userId} and model_image_id = #{imageId}
</update>
<select id="getLikeImage" resultMap="ModelImageLikeResult">
<include refid="selectModelImageLikeVo"/>