Compare commits
11 Commits
81dd9362cd
...
573ccd5ef8
Author | SHA1 | Date |
---|---|---|
|
573ccd5ef8 | |
|
511bd96d84 | |
|
af200b9274 | |
|
ca41c38141 | |
|
942bcd8315 | |
|
f41111fc6d | |
|
031d115263 | |
|
7f22f046c8 | |
|
4d2b660faa | |
|
8c844faca5 | |
|
120e61102d |
File diff suppressed because one or more lines are too long
|
@ -144,6 +144,27 @@ public class OrderTradeController extends BaseController {
|
||||||
return map.get("alipay_trade_query_response");
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付回调接口
|
* 支付回调接口
|
||||||
|
|
|
@ -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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:ChenYan
|
|
||||||
* @Project:McWl
|
|
||||||
* @Package:com.mcwl.web.controller.pay
|
|
||||||
* @Filename:OrderTradeController
|
|
||||||
* @Description 支付模块
|
|
||||||
* @Date:2025/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";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -6,8 +6,10 @@ import com.mcwl.common.core.domain.AjaxResult;
|
||||||
import com.mcwl.common.core.page.TableDataInfo;
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.resource.domain.ModelProduct;
|
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.MallProductVo;
|
||||||
import com.mcwl.resource.service.ModelService;
|
import com.mcwl.resource.service.ModelService;
|
||||||
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import com.mcwl.web.controller.common.OssUtil;
|
import com.mcwl.web.controller.common.OssUtil;
|
||||||
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.*;
|
||||||
|
@ -29,8 +31,8 @@ import java.util.List;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/model")
|
@RequestMapping("/model")
|
||||||
public class MallProductController extends BaseController {
|
public class MallProductController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private ISysUserService sysUserService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ModelService modelService;
|
private ModelService modelService;
|
||||||
|
@ -82,14 +84,12 @@ public class MallProductController extends BaseController {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询商品列表
|
* 模型列表
|
||||||
*/
|
*/
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
public TableDataInfo list(@RequestBody ModelProduct mallProduct)
|
public TableDataInfo list(@RequestBody ModelImagePageRes imagePageRes) {
|
||||||
{
|
|
||||||
startPage();
|
return modelService.listByPage(imagePageRes);
|
||||||
List<ModelProduct> list = modelService.selectMallProductList(mallProduct);
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,16 @@ package com.mcwl.web.controller.resource;
|
||||||
|
|
||||||
import com.mcwl.common.core.domain.AjaxResult;
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
import com.mcwl.resource.domain.ModelComment;
|
import com.mcwl.resource.domain.ModelComment;
|
||||||
|
import com.mcwl.resource.domain.vo.ModelCommentVo;
|
||||||
import com.mcwl.resource.service.ModelCommentLikeService;
|
import com.mcwl.resource.service.ModelCommentLikeService;
|
||||||
import com.mcwl.resource.service.ModelCommentService;
|
import com.mcwl.resource.service.ModelCommentService;
|
||||||
import com.mcwl.resource.service.ModelLikeService;
|
import com.mcwl.resource.service.ModelLikeService;
|
||||||
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.*;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:ChenYan
|
* @Author:ChenYan
|
||||||
* @Project:McWl
|
* @Project:McWl
|
||||||
|
@ -27,10 +31,12 @@ public class ModelCommentController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ModelCommentLikeService modelCommentLikeService;
|
private ModelCommentLikeService modelCommentLikeService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模型点赞/取消
|
* 模型点赞/取消
|
||||||
*/
|
*/
|
||||||
@GetMapping("/imageLike/{imageId}")
|
@GetMapping("/modelLike/{modelId}")
|
||||||
public AjaxResult like(@PathVariable Long imageId) {
|
public AjaxResult like(@PathVariable Long imageId) {
|
||||||
modelLikeService.like(imageId);
|
modelLikeService.like(imageId);
|
||||||
return AjaxResult.success();
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,23 +2,32 @@ package com.mcwl.web.controller.resource;
|
||||||
|
|
||||||
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.entity.SysUser;
|
||||||
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.common.utils.oss.OssUtil;
|
import com.mcwl.common.utils.oss.OssUtil;
|
||||||
import com.mcwl.resource.domain.ModelImage;
|
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.ModelImageCommentRes;
|
||||||
|
import com.mcwl.resource.domain.dto.ModelImagePageRes;
|
||||||
import com.mcwl.resource.domain.dto.ModelImageRes;
|
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.ModelImageCommentLikeService;
|
||||||
|
import com.mcwl.resource.service.ModelImageCommentService;
|
||||||
import com.mcwl.resource.service.ModelImageLikeService;
|
import com.mcwl.resource.service.ModelImageLikeService;
|
||||||
import com.mcwl.resource.service.ModelImageService;
|
import com.mcwl.resource.service.ModelImageService;
|
||||||
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
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.util.Date;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片
|
||||||
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/modelImage")
|
@RequestMapping("/modelImage")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@ -30,6 +39,55 @@ public class ModelImageController {
|
||||||
|
|
||||||
private final ModelImageCommentLikeService modelImageCommentLikeService;
|
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}")
|
@GetMapping("/imageLike/{imageId}")
|
||||||
public AjaxResult like(@PathVariable Long imageId) {
|
public AjaxResult like(@PathVariable @NotNull(message = "图片id不能为空") Long imageId) {
|
||||||
modelImageLikeService.like(imageId);
|
modelImageLikeService.like(imageId);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
@ -74,12 +132,28 @@ public class ModelImageController {
|
||||||
* 图片评论点赞/取消
|
* 图片评论点赞/取消
|
||||||
*/
|
*/
|
||||||
@GetMapping("/commentLike/{commentId}")
|
@GetMapping("/commentLike/{commentId}")
|
||||||
public AjaxResult commentLike(@PathVariable Long commentId) {
|
public AjaxResult commentLike(@PathVariable @NotNull(message = "评论id不能为空") Long commentId) {
|
||||||
modelImageCommentLikeService.like(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package com.mcwl.common.core.page;
|
||||||
|
|
||||||
import com.mcwl.common.utils.StringUtils;
|
import com.mcwl.common.utils.StringUtils;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页数据
|
* 分页数据
|
||||||
*
|
*
|
||||||
|
@ -10,9 +12,11 @@ import com.mcwl.common.utils.StringUtils;
|
||||||
public class PageDomain
|
public class PageDomain
|
||||||
{
|
{
|
||||||
/** 当前记录起始索引 */
|
/** 当前记录起始索引 */
|
||||||
|
@NotNull(message = "当前记录起始索引不能为空")
|
||||||
private Integer pageNum;
|
private Integer pageNum;
|
||||||
|
|
||||||
/** 每页显示记录数 */
|
/** 每页显示记录数 */
|
||||||
|
@NotNull(message = "每页显示记录数不能为空")
|
||||||
private Integer pageSize;
|
private Integer pageSize;
|
||||||
|
|
||||||
/** 排序列 */
|
/** 排序列 */
|
||||||
|
|
|
@ -27,6 +27,11 @@
|
||||||
<artifactId>mcwl-common</artifactId>
|
<artifactId>mcwl-common</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mcwl</groupId>
|
||||||
|
<artifactId>mcwl-system</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
|
|
@ -19,6 +19,12 @@ import java.util.Date;
|
||||||
* @apiNote
|
* @apiNote
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
|
|
@ -28,6 +28,10 @@ public class ModelImage extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
@TableId
|
@TableId
|
||||||
private Long id;
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
/**
|
/**
|
||||||
* 图片地址(最多8张,切割)
|
* 图片地址(最多8张,切割)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -7,6 +7,10 @@ import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ModelImageRes {
|
public class ModelImageRes {
|
||||||
|
/**
|
||||||
|
* 图片id
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
/**
|
/**
|
||||||
* 图片地址(最多8张,切割)
|
* 图片地址(最多8张,切割)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.mcwl.resource.domain.ModelImageComment;
|
import com.mcwl.resource.domain.ModelImageComment;
|
||||||
import com.mcwl.resource.domain.ModelImageCommentLike;
|
import com.mcwl.resource.domain.ModelImageCommentLike;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ModelImageCommentLikeMapper extends BaseMapper<ModelImageCommentLike> {
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.mcwl.resource.domain.ModelImage;
|
import com.mcwl.resource.domain.ModelImage;
|
||||||
import com.mcwl.resource.domain.ModelImageLike;
|
import com.mcwl.resource.domain.ModelImageLike;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ModelImageLikeMapper extends BaseMapper<ModelImageLike> {
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,11 @@ package com.mcwl.resource.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.mcwl.resource.domain.ModelComment;
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:ChenYan
|
* @Author:ChenYan
|
||||||
|
@ -14,4 +19,11 @@ import com.mcwl.resource.domain.ModelComment;
|
||||||
public interface ModelCommentService extends IService<ModelComment> {
|
public interface ModelCommentService extends IService<ModelComment> {
|
||||||
void comment(ModelComment modelComment);
|
void comment(ModelComment modelComment);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取评论
|
||||||
|
* @param imageId 图片id
|
||||||
|
* @return 评论区
|
||||||
|
*/
|
||||||
|
List<ModelCommentVo> getComment(Long imageId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,14 +3,25 @@ package com.mcwl.resource.service;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.mcwl.common.core.domain.AjaxResult;
|
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.ModelImage;
|
||||||
import com.mcwl.resource.domain.ModelProduct;
|
import com.mcwl.resource.domain.ModelProduct;
|
||||||
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
|
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.dto.ModelImageRes;
|
||||||
import com.mcwl.resource.domain.vo.MallProductVo;
|
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||||
|
import com.mcwl.resource.domain.vo.ModelImageCommentVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public interface ModelImageService extends IService<ModelImage> {
|
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 评论对象
|
* @param modelImageCommentRes 评论对象
|
||||||
*/
|
*/
|
||||||
void comment(ModelImageCommentRes modelImageCommentRes);
|
void comment(ModelImageCommentRes modelImageCommentRes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取评论
|
||||||
|
* @param imageId 图片id
|
||||||
|
* @return 评论区
|
||||||
|
*/
|
||||||
|
List<ModelImageCommentVo> getComment(Long imageId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
* @param imagePageRes 分页参数
|
||||||
|
* @return 分页数据
|
||||||
|
*/
|
||||||
|
TableDataInfo listByPage(ModelImagePageRes imagePageRes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,11 @@ package com.mcwl.resource.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.common.domain.IdsParam;
|
import com.mcwl.common.domain.IdsParam;
|
||||||
import com.mcwl.resource.domain.ModelProduct;
|
import com.mcwl.resource.domain.ModelProduct;
|
||||||
import com.mcwl.resource.domain.ModelVersion;
|
import com.mcwl.resource.domain.ModelVersion;
|
||||||
|
import com.mcwl.resource.domain.dto.ModelImagePageRes;
|
||||||
import com.mcwl.resource.domain.vo.MallProductVo;
|
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -19,17 +21,10 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface ModelService extends IService<ModelProduct> {
|
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> selectByUserId(MallProductVo mallProductVo);
|
||||||
|
|
||||||
Page<ModelProduct> pageLike(MallProductVo mallProductVo, List<Long> list);
|
Page<ModelProduct> pageLike(MallProductVo mallProductVo, List<Long> list);
|
||||||
|
|
||||||
|
TableDataInfo listByPage(ModelImagePageRes imagePageRes);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,33 @@
|
||||||
package com.mcwl.resource.service.impl;
|
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.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
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.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.entity.SysUser;
|
||||||
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.common.core.redis.RedisCache;
|
import com.mcwl.common.core.redis.RedisCache;
|
||||||
import com.mcwl.common.domain.IdsParam;
|
import com.mcwl.common.domain.IdsParam;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
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.ModelProduct;
|
||||||
|
import com.mcwl.resource.domain.dto.ModelImagePageRes;
|
||||||
import com.mcwl.resource.domain.vo.MallProductVo;
|
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||||
|
import com.mcwl.resource.domain.vo.ModelImageVo;
|
||||||
import com.mcwl.resource.mapper.MallProductMapper;
|
import com.mcwl.resource.mapper.MallProductMapper;
|
||||||
|
|
||||||
import com.mcwl.resource.service.ModelService;
|
import com.mcwl.resource.service.ModelService;
|
||||||
|
import com.mcwl.system.service.ISysUserService;
|
||||||
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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
||||||
/**模型 业务实现层
|
/**模型 业务实现层
|
||||||
|
@ -33,32 +45,10 @@ public class MallProductServiceImpl extends ServiceImpl<MallProductMapper,ModelP
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MallProductMapper postMapper;
|
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
|
@Override
|
||||||
public Page<ModelProduct> selectByUserId(MallProductVo mallProductVo) {
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,27 @@
|
||||||
package com.mcwl.resource.service.impl;
|
package com.mcwl.resource.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
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.core.domain.entity.SysUser;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.resource.domain.ModelComment;
|
import com.mcwl.resource.domain.ModelComment;
|
||||||
import com.mcwl.resource.domain.ModelImageComment;
|
import com.mcwl.resource.domain.ModelImageComment;
|
||||||
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
|
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.ModelCommentMapper;
|
||||||
import com.mcwl.resource.mapper.ModelImageCommentMapper;
|
import com.mcwl.resource.mapper.ModelImageCommentMapper;
|
||||||
import com.mcwl.resource.mapper.ModelImageMapper;
|
import com.mcwl.resource.mapper.ModelImageMapper;
|
||||||
import com.mcwl.resource.service.ModelCommentService;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,6 +35,8 @@ import java.util.Objects;
|
||||||
@Service
|
@Service
|
||||||
public class ModelCommentServiceImpl extends ServiceImpl<ModelCommentMapper, ModelComment> implements ModelCommentService {
|
public class ModelCommentServiceImpl extends ServiceImpl<ModelCommentMapper, ModelComment> implements ModelCommentService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysUserService sysUserService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ModelCommentMapper modelCommentMapper;
|
private ModelCommentMapper modelCommentMapper;
|
||||||
|
|
||||||
|
@ -48,4 +58,89 @@ public class ModelCommentServiceImpl extends ServiceImpl<ModelCommentMapper, Mod
|
||||||
modelCommentMapper.insert(modelComment);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class ModelImageCommentLikeServiceImpl extends ServiceImpl<ModelImageComm
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void like(Long commentId) {
|
public void like(Long commentId) {
|
||||||
ModelImageComment modelImageComment = modelImageCommentMapper.selectById(commentId);
|
ModelImageComment modelImageComment = modelImageCommentMapper.selectById(commentId);
|
||||||
if (Objects.isNull(modelImageComment)) {
|
if (Objects.isNull(modelImageComment)) {
|
||||||
throw new ServiceException("该评论不存在");
|
throw new ServiceException("该评论不存在");
|
||||||
|
@ -36,14 +36,12 @@ public class ModelImageCommentLikeServiceImpl extends ServiceImpl<ModelImageComm
|
||||||
ModelImageCommentLike modelImageCommentLike = baseMapper.getLikeImageComment(userId, commentId);
|
ModelImageCommentLike modelImageCommentLike = baseMapper.getLikeImageComment(userId, commentId);
|
||||||
if (Objects.nonNull(modelImageCommentLike)) {
|
if (Objects.nonNull(modelImageCommentLike)) {
|
||||||
if (Objects.equals(modelImageCommentLike.getDelFlag(), "0")) {
|
if (Objects.equals(modelImageCommentLike.getDelFlag(), "0")) {
|
||||||
modelImageCommentLike.setDelFlag("1");
|
|
||||||
modelImageComment.setLikeNum(modelImageComment.getLikeNum() - 1);
|
modelImageComment.setLikeNum(modelImageComment.getLikeNum() - 1);
|
||||||
} else {
|
} else {
|
||||||
modelImageCommentLike.setDelFlag("0");
|
|
||||||
modelImageComment.setLikeNum(modelImageComment.getLikeNum() + 1);
|
modelImageComment.setLikeNum(modelImageComment.getLikeNum() + 1);
|
||||||
}
|
}
|
||||||
// 更新点赞记录
|
// 更新点赞记录
|
||||||
baseMapper.updateById(modelImageCommentLike);
|
baseMapper.updateDelFlagById(userId, commentId);
|
||||||
// 更新图片评论点赞数
|
// 更新图片评论点赞数
|
||||||
modelImageCommentMapper.updateById(modelImageComment);
|
modelImageCommentMapper.updateById(modelImageComment);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -34,14 +34,12 @@ public class ModelImageLikeServiceImpl extends ServiceImpl<ModelImageLikeMapper,
|
||||||
ModelImageLike modelImageLike = baseMapper.getLikeImage(userId, imageId);
|
ModelImageLike modelImageLike = baseMapper.getLikeImage(userId, imageId);
|
||||||
if (Objects.nonNull(modelImageLike)) {
|
if (Objects.nonNull(modelImageLike)) {
|
||||||
if (Objects.equals(modelImageLike.getDelFlag(), "0")) {
|
if (Objects.equals(modelImageLike.getDelFlag(), "0")) {
|
||||||
modelImageLike.setDelFlag("1");
|
|
||||||
modelImage.setLikeNum(modelImage.getLikeNum() - 1);
|
modelImage.setLikeNum(modelImage.getLikeNum() - 1);
|
||||||
} else {
|
} else {
|
||||||
modelImageLike.setDelFlag("0");
|
|
||||||
modelImage.setLikeNum(modelImage.getLikeNum() + 1);
|
modelImage.setLikeNum(modelImage.getLikeNum() + 1);
|
||||||
}
|
}
|
||||||
// 更新点赞记录
|
// 更新点赞记录
|
||||||
baseMapper.updateById(modelImageLike);
|
baseMapper.updateDelFlagById(userId, imageId);
|
||||||
// 更新图片点赞数
|
// 更新图片点赞数
|
||||||
modelImageMapper.updateById(modelImage);
|
modelImageMapper.updateById(modelImage);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,19 +1,34 @@
|
||||||
package com.mcwl.resource.service.impl;
|
package com.mcwl.resource.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
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.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.SecurityUtils;
|
||||||
|
import com.mcwl.common.utils.StringUtils;
|
||||||
import com.mcwl.resource.domain.ModelImage;
|
import com.mcwl.resource.domain.ModelImage;
|
||||||
import com.mcwl.resource.domain.ModelImageComment;
|
import com.mcwl.resource.domain.ModelImageComment;
|
||||||
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
|
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.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.ModelImageCommentMapper;
|
||||||
import com.mcwl.resource.mapper.ModelImageMapper;
|
import com.mcwl.resource.mapper.ModelImageMapper;
|
||||||
import com.mcwl.resource.service.ModelImageService;
|
import com.mcwl.resource.service.ModelImageService;
|
||||||
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -24,30 +39,48 @@ public class ModelImageServiceImpl extends ServiceImpl<ModelImageMapper, ModelIm
|
||||||
|
|
||||||
private final ModelImageMapper modelImageMapper;
|
private final ModelImageMapper modelImageMapper;
|
||||||
|
|
||||||
|
private final ISysUserService sysUserService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void comment(ModelImageCommentRes modelImageCommentRes) {
|
public void comment(ModelImageCommentRes modelImageCommentRes) {
|
||||||
Long parentId = modelImageCommentRes.getParentId();
|
Long parentId = modelImageCommentRes.getParentId();
|
||||||
ModelImageComment mic = modelImageCommentMapper.selectById(parentId);
|
|
||||||
|
|
||||||
if (Objects.nonNull(parentId) && Objects.isNull(mic)) {
|
if (Objects.nonNull(parentId)) {
|
||||||
return;
|
ModelImageComment mic = modelImageCommentMapper.selectById(parentId);
|
||||||
|
if (Objects.isNull(mic)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelImageComment modelImageComment = new ModelImageComment();
|
ModelImageComment modelImageComment = new ModelImageComment();
|
||||||
BeanUtil.copyProperties(modelImageCommentRes, modelImageComment);
|
BeanUtil.copyProperties(modelImageCommentRes, modelImageComment);
|
||||||
modelImageComment.setUserId(SecurityUtils.getUserId());
|
modelImageComment.setUserId(SecurityUtils.getUserId());
|
||||||
modelImageComment.setCreateBy(SecurityUtils.getUsername());
|
modelImageComment.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
modelImageComment.setCreateTime(new Date());
|
||||||
modelImageComment.setUpdateBy(SecurityUtils.getUsername());
|
modelImageComment.setUpdateBy(SecurityUtils.getUsername());
|
||||||
modelImageComment.setUpdateTime(new Date());
|
modelImageComment.setUpdateTime(new Date());
|
||||||
modelImageCommentMapper.insert(modelImageComment);
|
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
|
@Override
|
||||||
public void publish(ModelImageRes modelImageRes) {
|
public void publish(ModelImageRes modelImageRes) {
|
||||||
|
|
||||||
ModelImage modelImage = new ModelImage();
|
ModelImage modelImage = new ModelImage();
|
||||||
BeanUtil.copyProperties(modelImageRes, modelImage);
|
BeanUtil.copyProperties(modelImageRes, modelImage);
|
||||||
|
modelImage.setUserId(SecurityUtils.getUserId());
|
||||||
modelImage.setCreateBy(SecurityUtils.getUsername());
|
modelImage.setCreateBy(SecurityUtils.getUsername());
|
||||||
modelImage.setUpdateBy(SecurityUtils.getUsername());
|
modelImage.setUpdateBy(SecurityUtils.getUsername());
|
||||||
modelImage.setUpdateTime(new Date());
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,16 @@
|
||||||
remark
|
remark
|
||||||
from model_image_comment_like
|
from model_image_comment_like
|
||||||
</sql>
|
</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">
|
<select id="getLikeImageComment" resultMap="ModelImageCommentLikeResult">
|
||||||
<include refid="selectModelImageCommentLikeVo"/>
|
<include refid="selectModelImageCommentLikeVo"/>
|
||||||
where user_id = #{userId}
|
where user_id = #{userId}
|
||||||
and model_image_comment_id = #{imageId}
|
and model_image_comment_id = #{commentId}
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -29,6 +29,11 @@
|
||||||
remark
|
remark
|
||||||
from model_image_like
|
from model_image_like
|
||||||
</sql>
|
</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">
|
<select id="getLikeImage" resultMap="ModelImageLikeResult">
|
||||||
<include refid="selectModelImageLikeVo"/>
|
<include refid="selectModelImageLikeVo"/>
|
||||||
|
|
Loading…
Reference in New Issue