Compare commits

..

No commits in common. "573ccd5ef8cdc0b001fbab5aa158844e88918fea" and "81dd9362cd6d59682f4526382251f9677cf60605" have entirely different histories.

29 changed files with 391 additions and 935 deletions

File diff suppressed because one or more lines are too long

View File

@ -144,27 +144,6 @@ 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

@ -0,0 +1,42 @@
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

@ -0,0 +1,179 @@
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,10 +6,8 @@ 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.*;
@ -31,8 +29,8 @@ import java.util.List;
@RestController
@RequestMapping("/model")
public class MallProductController extends BaseController {
@Autowired
private ISysUserService sysUserService;
@Autowired
private ModelService modelService;
@ -84,12 +82,14 @@ public class MallProductController extends BaseController {
/**
*
*
*/
@PostMapping("/list")
public TableDataInfo list(@RequestBody ModelImagePageRes imagePageRes) {
return modelService.listByPage(imagePageRes);
public TableDataInfo list(@RequestBody ModelProduct mallProduct)
{
startPage();
List<ModelProduct> list = modelService.selectMallProductList(mallProduct);
return getDataTable(list);
}

View File

@ -2,16 +2,12 @@ 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
@ -31,12 +27,10 @@ public class ModelCommentController {
@Autowired
private ModelCommentLikeService modelCommentLikeService;
/**
* /
*/
@GetMapping("/modelLike/{modelId}")
@GetMapping("/imageLike/{imageId}")
public AjaxResult like(@PathVariable Long imageId) {
modelLikeService.like(imageId);
return AjaxResult.success();
@ -63,24 +57,8 @@ 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,32 +2,23 @@ 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 javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Date;
import java.util.Objects;
/**
*
*/
@RestController
@RequestMapping("/modelImage")
@RequiredArgsConstructor
@ -39,55 +30,6 @@ 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();
}
/**
*
@ -113,7 +55,7 @@ public class ModelImageController {
* /
*/
@GetMapping("/imageLike/{imageId}")
public AjaxResult like(@PathVariable @NotNull(message = "图片id不能为空") Long imageId) {
public AjaxResult like(@PathVariable Long imageId) {
modelImageLikeService.like(imageId);
return AjaxResult.success();
}
@ -132,28 +74,12 @@ public class ModelImageController {
* /
*/
@GetMapping("/commentLike/{commentId}")
public AjaxResult commentLike(@PathVariable @NotNull(message = "评论id不能为空") Long commentId) {
public AjaxResult commentLike(@PathVariable Long commentId) {
modelImageCommentLikeService.like(commentId);
return AjaxResult.success();
return AjaxResult.error();
}
/**
*
*/
@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,8 +2,6 @@ package com.mcwl.common.core.page;
import com.mcwl.common.utils.StringUtils;
import javax.validation.constraints.NotNull;
/**
*
*
@ -12,11 +10,9 @@ import javax.validation.constraints.NotNull;
public class PageDomain
{
/** 当前记录起始索引 */
@NotNull(message = "当前记录起始索引不能为空")
private Integer pageNum;
/** 每页显示记录数 */
@NotNull(message = "每页显示记录数不能为空")
private Integer pageSize;
/** 排序列 */

View File

@ -27,11 +27,6 @@
<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,12 +19,6 @@ import java.util.Date;
* @apiNote
*/
@Builder
@NoArgsConstructor
@AllArgsConstructor

View File

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

View File

@ -1,37 +0,0 @@
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,10 +7,6 @@ import javax.validation.constraints.NotBlank;
@Data
public class ModelImageRes {
/**
* id
*/
private Long id;
/**
* 8
*/

View File

@ -1,66 +0,0 @@
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

@ -1,66 +0,0 @@
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

@ -1,74 +0,0 @@
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

@ -1,74 +0,0 @@
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,11 +4,8 @@ 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(@Param("userId") Long userId, @Param("commentId") Long commentId);
void updateDelFlagById(@Param("userId") Long userId, @Param("commentId") Long commentId);
ModelImageCommentLike getLikeImageComment(Long userId, Long commentId);
}

View File

@ -4,11 +4,8 @@ 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(@Param("userId") Long userId, @Param("imageId") Long imageId);
void updateDelFlagById(@Param("userId") Long userId, @Param("imageId") Long imageId);
ModelImageLike getLikeImage(Long userId, Long imageId);
}

View File

@ -2,11 +2,6 @@ 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
@ -19,11 +14,4 @@ import java.util.List;
public interface ModelCommentService extends IService<ModelComment> {
void comment(ModelComment modelComment);
/**
*
* @param imageId id
* @return
*/
List<ModelCommentVo> getComment(Long imageId);
}

View File

@ -3,25 +3,14 @@ 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);
/**
*
@ -34,18 +23,4 @@ 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,11 +2,9 @@ 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;
@ -21,10 +19,17 @@ 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,33 +1,21 @@
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;
/**
@ -45,10 +33,32 @@ 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) {
@ -85,58 +95,4 @@ 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,27 +1,19 @@
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;
/**
@ -35,8 +27,6 @@ import java.util.Objects;
@Service
public class ModelCommentServiceImpl extends ServiceImpl<ModelCommentMapper, ModelComment> implements ModelCommentService {
@Autowired
private ISysUserService sysUserService;
@Autowired
private ModelCommentMapper modelCommentMapper;
@ -58,89 +48,4 @@ 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

@ -27,7 +27,7 @@ public class ModelImageCommentLikeServiceImpl extends ServiceImpl<ModelImageComm
@Override
@Transactional
public void like(Long commentId) {
public void like(Long commentId) {
ModelImageComment modelImageComment = modelImageCommentMapper.selectById(commentId);
if (Objects.isNull(modelImageComment)) {
throw new ServiceException("该评论不存在");
@ -36,12 +36,14 @@ 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.updateDelFlagById(userId, commentId);
baseMapper.updateById(modelImageCommentLike);
// 更新图片评论点赞数
modelImageCommentMapper.updateById(modelImageComment);
return;

View File

@ -34,12 +34,14 @@ 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.updateDelFlagById(userId, imageId);
baseMapper.updateById(modelImageLike);
// 更新图片点赞数
modelImageMapper.updateById(modelImage);
return;

View File

@ -1,34 +1,19 @@
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
@ -39,48 +24,30 @@ 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)) {
ModelImageComment mic = modelImageCommentMapper.selectById(parentId);
if (Objects.isNull(mic)) {
return;
}
if (Objects.nonNull(parentId) && 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());
@ -89,147 +56,4 @@ 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,16 +29,10 @@
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 = #{commentId}
and model_image_comment_id = #{imageId}
</select>
</mapper>

View File

@ -29,11 +29,6 @@
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"/>