From 745af316b6f14cc97f6cb64d56eda4cb68960c3e Mon Sep 17 00:00:00 2001 From: peng <peng.com> Date: 星期二, 17 六月 2025 10:54:22 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev --- framework/src/main/java/cn/lili/mybatis/BaseIdAndDeleteEntity.java | 40 + framework/src/main/java/cn/lili/modules/lmk/domain/form/WxVideoForm.java | 6 buyer-api/src/main/java/cn/lili/controller/lmk/ShareController.java | 44 + framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoVO.java | 10 buyer-api/src/main/java/cn/lili/controller/lmk/VideoController.java | 6 framework/src/main/java/cn/lili/modules/lmk/domain/entity/Share.java | 40 + framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java | 25 framework/src/main/java/cn/lili/modules/lmk/domain/query/ShareQuery.java | 22 framework/src/main/java/cn/lili/modules/lmk/service/impl/ShareServiceImpl.java | 151 ++++++ framework/src/main/java/cn/lili/modules/member/service/MemberService.java | 4 framework/src/main/java/cn/lili/modules/search/service/EsGoodsSearchService.java | 10 framework/src/main/resources/mapper/lmk/VideoGoodsMapper.xml | 7 framework/src/main/java/cn/lili/modules/lmk/domain/query/VideoGoodsEsQuery.java | 28 + framework/src/main/java/cn/lili/modules/lmk/service/VideoGoodsService.java | 14 framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoGoodsServiceImpl.java | 22 framework/src/main/java/cn/lili/modules/lmk/domain/form/ShareForm.java | 49 ++ framework/src/main/java/cn/lili/modules/lmk/domain/vo/WxVideoVO.java | 2 buyer-api/src/main/java/cn/lili/controller/passport/connect/MiniProgramBuyerController.java | 7 framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoGoodsDetailVO.java | 30 + framework/src/main/resources/mapper/lmk/VideoMapper.xml | 33 + framework/src/main/java/cn/lili/modules/lmk/service/ShareClickRecordService.java | 65 ++ framework/src/main/java/cn/lili/modules/lmk/domain/vo/ShareVO.java | 47 ++ framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java | 7 framework/src/main/java/cn/lili/modules/lmk/mapper/ShareClickRecordMapper.java | 34 + framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java | 13 framework/src/main/java/cn/lili/modules/lmk/domain/entity/VideoGoods.java | 45 + framework/src/main/java/cn/lili/modules/lmk/domain/query/ShareClickRecordQuery.java | 22 buyer-api/src/main/java/cn/lili/controller/goods/GoodsBuyerController.java | 8 framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoGoodsPublishVO.java | 21 framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java | 37 + framework/src/main/resources/mapper/lmk/ShareMapper.xml | 47 ++ framework/src/main/java/cn/lili/modules/connect/service/ConnectService.java | 11 framework/src/main/resources/mapper/lmk/ShareClickRecordMapper.xml | 44 + framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java | 24 + framework/src/main/java/cn/lili/modules/lmk/service/impl/ShareClickRecordServiceImpl.java | 119 +++++ framework/src/main/java/cn/lili/modules/lmk/domain/vo/ShareClickRecordVO.java | 43 + framework/src/main/java/cn/lili/modules/lmk/mapper/VideoGoodsMapper.java | 17 framework/src/main/java/cn/lili/modules/lmk/domain/entity/ShareClickRecord.java | 35 + framework/src/main/java/cn/lili/modules/lmk/mapper/ShareMapper.java | 34 + framework/src/main/java/cn/lili/modules/lmk/service/ShareService.java | 74 +++ framework/src/main/java/cn/lili/modules/lmk/domain/form/ShareClickRecordForm.java | 38 + framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java | 1 42 files changed, 1,309 insertions(+), 27 deletions(-) diff --git a/buyer-api/src/main/java/cn/lili/controller/goods/GoodsBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/goods/GoodsBuyerController.java index 087404b..c5d3d25 100644 --- a/buyer-api/src/main/java/cn/lili/controller/goods/GoodsBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/goods/GoodsBuyerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.goods; +import cn.lili.base.Result; import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultUtil; import cn.lili.common.exception.ServiceException; @@ -11,6 +12,7 @@ import cn.lili.modules.goods.entity.vos.GoodsVO; import cn.lili.modules.goods.service.GoodsService; import cn.lili.modules.goods.service.GoodsSkuService; +import cn.lili.modules.lmk.domain.query.VideoGoodsEsQuery; import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.entity.dos.EsGoodsRelatedInfo; import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO; @@ -115,6 +117,12 @@ return ResultUtil.data(goodsSearchService.searchGoodsByPage(goodsSearchParams, pageVO)); } + @ApiOperation(value = "鍟嗗搧鍒嗛〉-鍙戝竷瑙嗛鏃跺叧鑱斿晢鍝�") + @GetMapping("/video/es") + public Result videoGoodsEsPage(VideoGoodsEsQuery query) { + return goodsSearchService.videoGoodsEsPage(query); + } + @ApiOperation(value = "浠嶦S涓幏鍙栫浉鍏冲晢鍝佸搧鐗屽悕绉帮紝鍒嗙被鍚嶇О鍙婂睘鎬�") @GetMapping("/es/related") public ResultMessage<EsGoodsRelatedInfo> getGoodsRelatedByPageFromEs(EsGoodsSearchDTO goodsSearchParams, PageVO pageVO) { diff --git a/buyer-api/src/main/java/cn/lili/controller/lmk/ShareController.java b/buyer-api/src/main/java/cn/lili/controller/lmk/ShareController.java new file mode 100644 index 0000000..f620ab8 --- /dev/null +++ b/buyer-api/src/main/java/cn/lili/controller/lmk/ShareController.java @@ -0,0 +1,44 @@ +package cn.lili.controller.lmk; + +import cn.lili.base.Result; +import cn.lili.group.Add; +import cn.lili.modules.lmk.domain.form.ShareClickRecordForm; +import cn.lili.modules.lmk.domain.form.ShareForm; +import cn.lili.modules.lmk.service.ShareService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 鍒嗕韩璁板綍 鍓嶇鎺у埗鍣� + * + * @author xp + * @since 2025-06-16 + */ +@Validated +@RequiredArgsConstructor +@Api(value = "鍒嗕韩璁板綍", tags = "鍒嗕韩璁板綍绠$悊") +@RestController +@RequestMapping("/buyer/lmk/share") +public class ShareController { + + private final ShareService shareService; + + + @PostMapping + @ApiOperation(value = "娣诲姞鍒嗕韩", notes = "娣诲姞鍒嗕韩") + public Result add(@RequestBody @Validated(Add.class) ShareForm form) { + return shareService.add(form); + } + + @PostMapping("/click/record") + @ApiOperation(value = "娣诲姞鍒嗕韩璁块棶璁板綍", notes = "娣诲姞鍒嗕韩璁块棶璁板綍") + public Result addShareClick(@RequestBody @Validated(Add.class) ShareClickRecordForm form) { + return shareService.addShareClick(form); + } +} diff --git a/buyer-api/src/main/java/cn/lili/controller/lmk/VideoController.java b/buyer-api/src/main/java/cn/lili/controller/lmk/VideoController.java index 9792dd0..b790050 100644 --- a/buyer-api/src/main/java/cn/lili/controller/lmk/VideoController.java +++ b/buyer-api/src/main/java/cn/lili/controller/lmk/VideoController.java @@ -75,6 +75,12 @@ return videoService.healthRecommendVideo(query); } + @GetMapping("/goods/detail/{videoId}") + @ApiOperation(value = "瑙嗛鍟嗗搧鏌ョ湅", notes = "瑙嗛鍟嗗搧鏌ョ湅") + public Result getGoodsDetail(@PathVariable("videoId") String videoId) { + return videoService.getGoodsDetail(videoId); + } + @PostMapping("/view/record") @ApiOperation(value = "淇濆瓨瑙傜湅璁板綍", notes = "淇濆瓨瑙傜湅璁板綍") public Result saveViewRecord(@RequestBody VideoFootPrintForm form) { diff --git a/buyer-api/src/main/java/cn/lili/controller/passport/connect/MiniProgramBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/passport/connect/MiniProgramBuyerController.java index a3c1a6a..1e3b9e7 100644 --- a/buyer-api/src/main/java/cn/lili/controller/passport/connect/MiniProgramBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/passport/connect/MiniProgramBuyerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.passport.connect; +import cn.lili.base.Result; import cn.lili.common.enums.ResultUtil; import cn.lili.common.security.token.Token; import cn.lili.common.vo.ResultMessage; @@ -47,6 +48,12 @@ return ResultUtil.data(this.connectService.miniProgramAutoLogin(params)); } + @GetMapping("/silent-login") + @ApiOperation(value = "灏忕▼搴忛潤榛樼櫥褰�--涓嶈幏鍙栫敤鎴蜂俊鎭�") + public Result silentLogin(String code) { + return this.connectService.silentLogin(code); + } + @GetMapping("/subscribeMessage") @ApiOperation(value = "娑堟伅璁㈤槄") public ResultMessage<List<WechatMPMessage>> autoLogin() { diff --git a/framework/src/main/java/cn/lili/modules/connect/service/ConnectService.java b/framework/src/main/java/cn/lili/modules/connect/service/ConnectService.java index 94fc569..a9356e8 100644 --- a/framework/src/main/java/cn/lili/modules/connect/service/ConnectService.java +++ b/framework/src/main/java/cn/lili/modules/connect/service/ConnectService.java @@ -1,5 +1,6 @@ package cn.lili.modules.connect.service; +import cn.lili.base.Result; import cn.lili.cache.CachePrefix; import cn.lili.common.security.token.Token; import cn.lili.modules.connect.entity.Connect; @@ -105,4 +106,12 @@ * @param type 骞冲彴绫诲瀷 */ void loginBindUser(String userId, String unionId, String type); -} \ No newline at end of file + + /** + * 灏忕▼搴忛潤榛樼櫥褰� + * + * @param code + * @return + */ + Result silentLogin(String code); +} diff --git a/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java b/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java index 6758887..b281073 100644 --- a/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; +import cn.lili.base.Result; import cn.lili.cache.Cache; import cn.lili.common.enums.ClientTypeEnum; import cn.lili.common.enums.ResultCode; @@ -81,6 +82,8 @@ */ @Autowired private RocketmqCustomProperties rocketmqCustomProperties; + + static String DEFAULT_PASSWORD = "111111"; @Override @Transactional(rollbackFor = Exception.class) @@ -243,6 +246,25 @@ } } + @Override + public Result silentLogin(String code) { + JSONObject res = this.getConnect(code); + String unionId = res.getStr("unionid"); + String openId = res.getStr("openid"); + Member user = memberService.findByUUID(openId); + // 涓嶅瓨鍦ㄥ氨娉ㄥ唽 + if (Objects.isNull(user)) { + user = new Member(); + user.setUuId(openId); + user.setUsername(UuidUtils.getUUID()); + user.setNickName("寰俊鐢ㄦ埛"); + user.setPassword(DEFAULT_PASSWORD); + user.setFace("https://i.loli.net/2020/11/19/LyN6JF7zZRskdIe.png"); + memberService.registerHandler(user); + } + Token token = memberTokenGenerate.createToken(user, Boolean.TRUE); + return Result.ok().data(token); + } /** * 绗笁鏂硅仈鍚堢櫥闄� @@ -389,4 +411,4 @@ } -} \ No newline at end of file +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/entity/Share.java b/framework/src/main/java/cn/lili/modules/lmk/domain/entity/Share.java new file mode 100644 index 0000000..84e057d --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/entity/Share.java @@ -0,0 +1,40 @@ +package cn.lili.modules.lmk.domain.entity; + +import cn.lili.mybatis.BaseIdAndDeleteEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.time.LocalDateTime; +import java.util.Date; + +/** + * 鍒嗕韩璁板綍 + * + * @author xp + * @since 2025-06-16 + */ +@Data +@TableName("lmk_share") +public class Share extends BaseIdAndDeleteEntity { + + private static final long serialVersionUID = 1L; + + @TableField("share_type") + /** 鍝釜涓氬姟鐨勫垎浜� */ + private String shareType; + + @TableField("ref_id") + /** 涓氬姟id */ + private String refId; + + @TableField("share_user") + /** 鍒嗕韩浜� */ + private String shareUser; + + @TableField("share_time") + /** 鍒嗕韩鏃堕棿 */ + private Date shareTime; + + +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/entity/ShareClickRecord.java b/framework/src/main/java/cn/lili/modules/lmk/domain/entity/ShareClickRecord.java new file mode 100644 index 0000000..52c8a04 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/entity/ShareClickRecord.java @@ -0,0 +1,35 @@ +package cn.lili.modules.lmk.domain.entity; + +import cn.lili.mybatis.BaseIdAndDeleteEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.util.Date; + +/** + * 鍒嗕韩鐐瑰嚮璁板綍 + * + * @author xp + * @since 2025-06-16 + */ +@Data +@TableName("lmk_share_click_record") +public class ShareClickRecord extends BaseIdAndDeleteEntity { + + private static final long serialVersionUID = 1L; + + @TableField("share_id") + /** 鍒嗕韩id */ + private String shareId; + + @TableField("user_id") + /** 璋佺偣浜嗚繖涓垎浜� */ + private String userId; + + @TableField("click_time") + /** 鐐瑰嚮鏃堕棿 */ + private Date clickTime; + + +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/entity/VideoGoods.java b/framework/src/main/java/cn/lili/modules/lmk/domain/entity/VideoGoods.java new file mode 100644 index 0000000..1993606 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/entity/VideoGoods.java @@ -0,0 +1,45 @@ +package cn.lili.modules.lmk.domain.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 瑙嗛鍟嗗搧涓棿琛� + * + * @author xp + * @since 2025-06-15 + */ +@Data +@TableName("lmk_video_goods") +public class VideoGoods { + + private static final long serialVersionUID = 1L; + + @TableId + @ApiModelProperty(value = "鍞竴鏍囪瘑", hidden = true) + private String id; + + @TableField("video_id") + /** 瑙嗛id */ + private String videoId; + + @TableField("goods_id") + /** 鍟嗗搧id */ + private String goodsId; + + @TableField("order_num") + /** 鎺掑簭 */ + private Integer orderNum; + + @TableField("goods_num") + /** 鍟嗗搧鏁伴噺 */ + private Integer goodsNum; + + @TableField(fill = FieldFill.INSERT) + @ApiModelProperty(value = "鍒犻櫎鏍囧織 true/false 鍒犻櫎/鏈垹闄�", hidden = true) + private Boolean deleteFlag; +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/form/ShareClickRecordForm.java b/framework/src/main/java/cn/lili/modules/lmk/domain/form/ShareClickRecordForm.java new file mode 100644 index 0000000..a8b6aff --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/form/ShareClickRecordForm.java @@ -0,0 +1,38 @@ +package cn.lili.modules.lmk.domain.form; + +import cn.lili.group.Update; +import cn.lili.group.Add; +import cn.lili.base.AbsForm; +import cn.lili.modules.lmk.domain.entity.ShareClickRecord; +import org.springframework.beans.BeanUtils; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import org.springframework.lang.NonNull; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.util.Date; + +/** + * 鍒嗕韩鐐瑰嚮璁板綍琛ㄥ崟 + * + * @author xp + * @since 2025-06-16 + */ +@Data +@ApiModel(value = "ShareClickRecord琛ㄥ崟", description = "鍒嗕韩鐐瑰嚮璁板綍琛ㄥ崟") +public class ShareClickRecordForm extends AbsForm { + + @NotBlank(message = "鍒嗕韩id涓嶈兘涓虹┖", groups = {Add.class, Update.class}) + @ApiModelProperty("鍒嗕韩id") + private String shareId; + + public static ShareClickRecord getEntityByForm(@NonNull ShareClickRecordForm form, ShareClickRecord entity) { + if(entity == null) { + entity = new ShareClickRecord(); + } + BeanUtils.copyProperties(form, entity); + return entity; + } + +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/form/ShareForm.java b/framework/src/main/java/cn/lili/modules/lmk/domain/form/ShareForm.java new file mode 100644 index 0000000..5eca51f --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/form/ShareForm.java @@ -0,0 +1,49 @@ +package cn.lili.modules.lmk.domain.form; + +import cn.lili.group.Update; +import cn.lili.group.Add; +import cn.lili.base.AbsForm; +import cn.lili.modules.lmk.domain.entity.Share; +import org.springframework.beans.BeanUtils; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import org.springframework.lang.NonNull; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.util.Date; + +/** + * 鍒嗕韩璁板綍琛ㄥ崟 + * + * @author xp + * @since 2025-06-16 + */ +@Data +@ApiModel(value = "Share琛ㄥ崟", description = "鍒嗕韩璁板綍琛ㄥ崟") +public class ShareForm extends AbsForm { + + @NotBlank(message = "涓氬姟绫诲瀷涓嶈兘涓虹┖", groups = {Add.class, Update.class}) + @ApiModelProperty("鍝釜涓氬姟鐨勫垎浜�") + private String shareType; + + @NotBlank(message = "涓氬姟id涓嶈兘涓虹┖", groups = {Add.class, Update.class}) + @ApiModelProperty("涓氬姟id") + private String refId; + + @NotBlank(message = "鍒嗕韩浜轰笉鑳戒负绌�", groups = {Add.class, Update.class}) + @ApiModelProperty("鍒嗕韩浜�") + private String shareUser; + + @ApiModelProperty("鍒嗕韩鏃堕棿") + private Date shareTime; + + public static Share getEntityByForm(@NonNull ShareForm form, Share entity) { + if(entity == null) { + entity = new Share(); + } + BeanUtils.copyProperties(form, entity); + return entity; + } + +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/form/WxVideoForm.java b/framework/src/main/java/cn/lili/modules/lmk/domain/form/WxVideoForm.java index ab5fce0..4a884ca 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/domain/form/WxVideoForm.java +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/form/WxVideoForm.java @@ -4,6 +4,8 @@ import cn.lili.group.Add; import cn.lili.base.AbsForm; import cn.lili.modules.lmk.domain.entity.Video; +import cn.lili.modules.lmk.domain.vo.VideoGoodsPublishVO; +import cn.lili.modules.lmk.domain.vo.VideoGoodsVO; import org.hibernate.validator.constraints.Length; import org.springframework.beans.BeanUtils; @@ -53,8 +55,8 @@ private List<WxVideoTagForm> tags = new ArrayList<>(2); // @NotBlank(message = "鍟嗗搧id涓嶈兘涓虹┖", groups = {Add.class, Update.class}) - @ApiModelProperty("鍟嗗搧id") - private String goodsId; + @ApiModelProperty("鍟嗗搧鍒楄〃") + private List<VideoGoodsPublishVO> goodsList; @ApiModelProperty("瑙嗛濉厖妯″紡") private String videoFit; diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/query/ShareClickRecordQuery.java b/framework/src/main/java/cn/lili/modules/lmk/domain/query/ShareClickRecordQuery.java new file mode 100644 index 0000000..9b1a36c --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/query/ShareClickRecordQuery.java @@ -0,0 +1,22 @@ +package cn.lili.modules.lmk.domain.query; + +import cn.lili.base.AbsQuery; +import java.util.List; +import org.springframework.lang.NonNull; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 鍒嗕韩鐐瑰嚮璁板綍鏌ヨ + * + * @author xp + * @since 2025-06-16 + */ +@Data +@ApiModel(value = "ShareClickRecord鏌ヨ鍙傛暟", description = "鍒嗕韩鐐瑰嚮璁板綍鏌ヨ鍙傛暟") +public class ShareClickRecordQuery extends AbsQuery { +} + diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/query/ShareQuery.java b/framework/src/main/java/cn/lili/modules/lmk/domain/query/ShareQuery.java new file mode 100644 index 0000000..4f0d067 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/query/ShareQuery.java @@ -0,0 +1,22 @@ +package cn.lili.modules.lmk.domain.query; + +import cn.lili.base.AbsQuery; +import java.util.List; +import org.springframework.lang.NonNull; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 鍒嗕韩璁板綍鏌ヨ + * + * @author xp + * @since 2025-06-16 + */ +@Data +@ApiModel(value = "Share鏌ヨ鍙傛暟", description = "鍒嗕韩璁板綍鏌ヨ鍙傛暟") +public class ShareQuery extends AbsQuery { +} + diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/query/VideoGoodsEsQuery.java b/framework/src/main/java/cn/lili/modules/lmk/domain/query/VideoGoodsEsQuery.java new file mode 100644 index 0000000..96d18e9 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/query/VideoGoodsEsQuery.java @@ -0,0 +1,28 @@ +package cn.lili.modules.lmk.domain.query; + +import cn.lili.base.AbsQuery; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 鍙戝竷瑙嗛鏃讹紝鍏宠仈鍟嗗搧鐨勬煡璇� + * + * @author锛歺p + * @date锛�2025/6/13 10:04 + */ +@Data +@ApiModel("鍙戝竷瑙嗛鏃讹紝鍏宠仈鍟嗗搧鐨勬煡璇�") +public class VideoGoodsEsQuery { + + @ApiModelProperty("鎼滅储鍏抽敭璇�") + private String keyword; + + @ApiModelProperty("鏌ヨ嚜瀹跺簵閾虹殑鍟嗗搧") + private Boolean searchFromSelfStore; + + + private int pageNumber; + + private int pageSize; +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/ShareClickRecordVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/ShareClickRecordVO.java new file mode 100644 index 0000000..bcfea1b --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/ShareClickRecordVO.java @@ -0,0 +1,43 @@ +package cn.lili.modules.lmk.domain.vo; + +import cn.lili.base.AbsVo; +import cn.lili.modules.lmk.domain.entity.ShareClickRecord; +import java.util.List; +import org.springframework.lang.NonNull; +import org.springframework.beans.BeanUtils; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.util.Date; + +/** + * 鍒嗕韩鐐瑰嚮璁板綍灞曠ず + * + * @author xp + * @since 2025-06-16 + */ +@Data +@ApiModel(value = "鍒嗕韩鐐瑰嚮璁板綍鍝嶅簲鏁版嵁", description = "鍒嗕韩鐐瑰嚮璁板綍鍝嶅簲鏁版嵁") +public class ShareClickRecordVO extends AbsVo { + + /** 鍒嗕韩id */ + @ApiModelProperty("鍒嗕韩id") + private String shareId; + + /** 璋佺偣浜嗚繖涓垎浜� */ + @ApiModelProperty("璋佺偣浜嗚繖涓垎浜�") + private String userId; + + /** 鐐瑰嚮鏃堕棿 */ + @ApiModelProperty("鐐瑰嚮鏃堕棿") + private Date clickTime; + + public static ShareClickRecordVO getVoByEntity(@NonNull ShareClickRecord entity, ShareClickRecordVO vo) { + if(vo == null) { + vo = new ShareClickRecordVO(); + } + BeanUtils.copyProperties(entity, vo); + return vo; + } + +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/ShareVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/ShareVO.java new file mode 100644 index 0000000..0efdae6 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/ShareVO.java @@ -0,0 +1,47 @@ +package cn.lili.modules.lmk.domain.vo; + +import cn.lili.base.AbsVo; +import cn.lili.modules.lmk.domain.entity.Share; +import java.util.List; +import org.springframework.lang.NonNull; +import org.springframework.beans.BeanUtils; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.util.Date; + +/** + * 鍒嗕韩璁板綍灞曠ず + * + * @author xp + * @since 2025-06-16 + */ +@Data +@ApiModel(value = "鍒嗕韩璁板綍鍝嶅簲鏁版嵁", description = "鍒嗕韩璁板綍鍝嶅簲鏁版嵁") +public class ShareVO extends AbsVo { + + /** 鍝釜涓氬姟鐨勫垎浜� */ + @ApiModelProperty("鍝釜涓氬姟鐨勫垎浜�") + private String shareType; + + /** 涓氬姟id */ + @ApiModelProperty("涓氬姟id") + private String refId; + + /** 鍒嗕韩浜� */ + @ApiModelProperty("鍒嗕韩浜�") + private String shareUser; + + /** 鍒嗕韩鏃堕棿 */ + @ApiModelProperty("鍒嗕韩鏃堕棿") + private Date shareTime; + + public static ShareVO getVoByEntity(@NonNull Share entity, ShareVO vo) { + if(vo == null) { + vo = new ShareVO(); + } + BeanUtils.copyProperties(entity, vo); + return vo; + } + +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoGoodsDetailVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoGoodsDetailVO.java new file mode 100644 index 0000000..e765747 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoGoodsDetailVO.java @@ -0,0 +1,30 @@ +package cn.lili.modules.lmk.domain.vo; + +import cn.lili.base.AbsVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author锛歺p + * @date锛�2025/6/16 9:11 + */ +@Data +@ApiModel("瑙嗛鍟嗗搧璇︽儏") +public class VideoGoodsDetailVO { + + @ApiModelProperty("鍟嗗搧id") + private String goodsId; + + @ApiModelProperty("鍟嗗搧鍚嶇О") + private String goodsName; + + @ApiModelProperty("浠锋牸") + private String price; + + @ApiModelProperty("缂╃暐鍥�") + private String thumbnail; + + @ApiModelProperty("鍟嗗搧鏁伴噺") + private Integer goodsNum; +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoGoodsPublishVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoGoodsPublishVO.java new file mode 100644 index 0000000..3d970f2 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoGoodsPublishVO.java @@ -0,0 +1,21 @@ +package cn.lili.modules.lmk.domain.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author锛歺p + * @date锛�2025/6/15 19:10 + */ +@Data +@ApiModel("鍙戝竷瑙嗛-鍟嗗搧淇℃伅") +public class VideoGoodsPublishVO { + + @ApiModelProperty("鍟嗗搧id") + private String goodsId; + + @ApiModelProperty("鍟嗗搧鏁伴噺") + private Integer goodsNum; + +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoVO.java index 8c217e8..0fc6690 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoVO.java +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoVO.java @@ -67,15 +67,7 @@ /** 鍟嗗搧id */ @ApiModelProperty("鍟嗗搧id") - private String goodsId; - - /** 鍟嗗搧鏌ョ湅娆℃暟 */ - @ApiModelProperty("鍟嗗搧鏌ョ湅娆℃暟") - private Long goodsViewNum; - - /** 鍟嗗搧涓嬪崟娆℃暟 */ - @ApiModelProperty("鍟嗗搧涓嬪崟娆℃暟") - private Long goodsOrderNum; + private List<VideoGoodsDetailVO> goodsList; /** 鏄惁鎺ㄨ崘 */ @ApiModelProperty("鏄惁鎺ㄨ崘") diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/WxVideoVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/WxVideoVO.java index 179415f..d324ee0 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/WxVideoVO.java +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/WxVideoVO.java @@ -73,7 +73,7 @@ /** 鍟嗗搧淇℃伅 */ @ApiModelProperty("鍟嗗搧淇℃伅") - private VideoGoodsVO goods; + private List<VideoGoodsDetailVO> goodsList; @ApiModelProperty("褰撳墠鐢ㄦ埛鏄惁鏀惰棌浜嗚瑙嗛") private Boolean collected = Boolean.FALSE; diff --git a/framework/src/main/java/cn/lili/modules/lmk/mapper/ShareClickRecordMapper.java b/framework/src/main/java/cn/lili/modules/lmk/mapper/ShareClickRecordMapper.java new file mode 100644 index 0000000..88772b7 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/mapper/ShareClickRecordMapper.java @@ -0,0 +1,34 @@ +package cn.lili.modules.lmk.mapper; + +import cn.lili.modules.lmk.domain.entity.ShareClickRecord; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import cn.lili.modules.lmk.domain.vo.ShareClickRecordVO; +import cn.lili.modules.lmk.domain.form.ShareClickRecordForm; +import cn.lili.modules.lmk.domain.query.ShareClickRecordQuery; +import java.util.List; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 鍒嗕韩鐐瑰嚮璁板綍 Mapper 鎺ュ彛 + * + * @author xp + * @since 2025-06-16 + */ +@Mapper +public interface ShareClickRecordMapper extends BaseMapper<ShareClickRecord> { + + /** + * id鏌ユ壘鍒嗕韩鐐瑰嚮璁板綍 + * @param id + * @return + */ + ShareClickRecordVO getById(String id); + + /** + * 鍒嗛〉 + */ + IPage getPage(IPage page, @Param("query") ShareClickRecordQuery query); + +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/mapper/ShareMapper.java b/framework/src/main/java/cn/lili/modules/lmk/mapper/ShareMapper.java new file mode 100644 index 0000000..932837b --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/mapper/ShareMapper.java @@ -0,0 +1,34 @@ +package cn.lili.modules.lmk.mapper; + +import cn.lili.modules.lmk.domain.entity.Share; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import cn.lili.modules.lmk.domain.vo.ShareVO; +import cn.lili.modules.lmk.domain.form.ShareForm; +import cn.lili.modules.lmk.domain.query.ShareQuery; +import java.util.List; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 鍒嗕韩璁板綍 Mapper 鎺ュ彛 + * + * @author xp + * @since 2025-06-16 + */ +@Mapper +public interface ShareMapper extends BaseMapper<Share> { + + /** + * id鏌ユ壘鍒嗕韩璁板綍 + * @param id + * @return + */ + ShareVO getById(String id); + + /** + * 鍒嗛〉 + */ + IPage getPage(IPage page, @Param("query") ShareQuery query); + +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoGoodsMapper.java b/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoGoodsMapper.java new file mode 100644 index 0000000..8143ad6 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoGoodsMapper.java @@ -0,0 +1,17 @@ +package cn.lili.modules.lmk.mapper; + +import cn.lili.modules.lmk.domain.entity.VideoGoods; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 瑙嗛鍟嗗搧涓棿琛� Mapper 鎺ュ彛 + * + * @author xp + * @since 2025-06-15 + */ +@Mapper +public interface VideoGoodsMapper extends BaseMapper<VideoGoods> { + + +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java b/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java index ee30dd5..a7396bd 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java +++ b/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java @@ -2,10 +2,7 @@ import cn.lili.modules.lmk.domain.entity.Video; import cn.lili.modules.lmk.domain.query.*; -import cn.lili.modules.lmk.domain.vo.CollectTypeNumVO; -import cn.lili.modules.lmk.domain.vo.VideoAccountVO; -import cn.lili.modules.lmk.domain.vo.VideoVO; -import cn.lili.modules.lmk.domain.vo.WxEditVideoVO; +import cn.lili.modules.lmk.domain.vo.*; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import org.apache.ibatis.annotations.Mapper; @@ -122,4 +119,12 @@ IPage healthPage(IPage page, @Param("query") HealthVideoQuery query); IPage kitchenPage(IPage page, @Param("query") KitchenVideoQuery query); + + /** + * 鑾峰彇瑙嗛鎮寕鍟嗗搧 + * + * @param videoId + * @return + */ + List<VideoGoodsDetailVO> getVideoGoods(@Param("id") String videoId); } diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/ShareClickRecordService.java b/framework/src/main/java/cn/lili/modules/lmk/service/ShareClickRecordService.java new file mode 100644 index 0000000..e5e4891 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/service/ShareClickRecordService.java @@ -0,0 +1,65 @@ +package cn.lili.modules.lmk.service; + +import cn.lili.modules.lmk.domain.entity.ShareClickRecord; +import com.baomidou.mybatisplus.extension.service.IService; +import cn.lili.base.Result; +import cn.lili.modules.lmk.domain.form.ShareClickRecordForm; +import cn.lili.modules.lmk.domain.query.ShareClickRecordQuery; +import java.util.List; + +/** + * 鍒嗕韩鐐瑰嚮璁板綍 鏈嶅姟绫� + * + * @author xp + * @since 2025-06-16 + */ +public interface ShareClickRecordService extends IService<ShareClickRecord> { + + /** + * 娣诲姞 + * @param form + * @return + */ + Result add(ShareClickRecordForm form); + + /** + * 淇敼 + * @param form + * @return + */ + Result update(ShareClickRecordForm form); + + /** + * 鎵归噺鍒犻櫎 + * @param ids + * @return + */ + Result remove(List<String> ids); + + /** + * id鍒犻櫎 + * @param id + * @return + */ + Result removeById(String id); + + /** + * 鍒嗛〉鏌ヨ + * @param query + * @return + */ + Result page(ShareClickRecordQuery query); + + /** + * 鏍规嵁id鏌ユ壘 + * @param id + * @return + */ + Result detail(String id); + + /** + * 鍒楄〃 + * @return + */ + Result all(); +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/ShareService.java b/framework/src/main/java/cn/lili/modules/lmk/service/ShareService.java new file mode 100644 index 0000000..3cf7753 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/service/ShareService.java @@ -0,0 +1,74 @@ +package cn.lili.modules.lmk.service; + +import cn.lili.modules.lmk.domain.entity.Share; +import cn.lili.modules.lmk.domain.form.ShareClickRecordForm; +import com.baomidou.mybatisplus.extension.service.IService; +import cn.lili.base.Result; +import cn.lili.modules.lmk.domain.form.ShareForm; +import cn.lili.modules.lmk.domain.query.ShareQuery; +import java.util.List; + +/** + * 鍒嗕韩璁板綍 鏈嶅姟绫� + * + * @author xp + * @since 2025-06-16 + */ +public interface ShareService extends IService<Share> { + + /** + * 娣诲姞 + * @param form + * @return + */ + Result add(ShareForm form); + + /** + * 淇敼 + * @param form + * @return + */ + Result update(ShareForm form); + + /** + * 鎵归噺鍒犻櫎 + * @param ids + * @return + */ + Result remove(List<String> ids); + + /** + * id鍒犻櫎 + * @param id + * @return + */ + Result removeById(String id); + + /** + * 鍒嗛〉鏌ヨ + * @param query + * @return + */ + Result page(ShareQuery query); + + /** + * 鏍规嵁id鏌ユ壘 + * @param id + * @return + */ + Result detail(String id); + + /** + * 鍒楄〃 + * @return + */ + Result all(); + + /** + * 娣诲姞鍒嗕韩璁块棶璁板綍 + * + * @param form + * @return + */ + Result addShareClick(ShareClickRecordForm form); +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/VideoGoodsService.java b/framework/src/main/java/cn/lili/modules/lmk/service/VideoGoodsService.java new file mode 100644 index 0000000..e2363c0 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/service/VideoGoodsService.java @@ -0,0 +1,14 @@ +package cn.lili.modules.lmk.service; + +import cn.lili.modules.lmk.domain.entity.VideoGoods; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 瑙嗛鍟嗗搧涓棿琛� 鏈嶅姟绫� + * + * @author xp + * @since 2025-06-15 + */ +public interface VideoGoodsService extends IService<VideoGoods> { + +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java b/framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java index 5028bbf..8e44942 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java +++ b/framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java @@ -230,4 +230,11 @@ Result delKitchen(String id); + /** + * 瑙嗛鍟嗗搧鏌ョ湅 + * + * @param videoId + * @return + */ + Result getGoodsDetail(String videoId); } diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/ShareClickRecordServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/ShareClickRecordServiceImpl.java new file mode 100644 index 0000000..a3fd375 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/ShareClickRecordServiceImpl.java @@ -0,0 +1,119 @@ +package cn.lili.modules.lmk.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import cn.lili.modules.lmk.domain.entity.ShareClickRecord; +import cn.lili.modules.lmk.mapper.ShareClickRecordMapper; +import cn.lili.modules.lmk.service.ShareClickRecordService; +import cn.lili.base.Result; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import cn.lili.modules.lmk.domain.form.ShareClickRecordForm; +import cn.lili.modules.lmk.domain.vo.ShareClickRecordVO; +import cn.lili.modules.lmk.domain.query.ShareClickRecordQuery; +import org.springframework.stereotype.Service; +import lombok.RequiredArgsConstructor; +import cn.lili.utils.PageUtil; +import org.springframework.beans.BeanUtils; +import org.springframework.util.Assert; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * 鍒嗕韩鐐瑰嚮璁板綍 鏈嶅姟瀹炵幇绫� + * + * @author xp + * @since 2025-06-16 + */ +@Service +@RequiredArgsConstructor +public class ShareClickRecordServiceImpl extends ServiceImpl<ShareClickRecordMapper, ShareClickRecord> implements ShareClickRecordService { + + private final ShareClickRecordMapper shareClickRecordMapper; + + /** + * 娣诲姞 + * @param form + * @return + */ + @Override + public Result add(ShareClickRecordForm form) { + ShareClickRecord entity = ShareClickRecordForm.getEntityByForm(form, null); + baseMapper.insert(entity); + return Result.ok("娣诲姞鎴愬姛"); + } + + /** + * 淇敼 + * @param form + * @return + */ + @Override + public Result update(ShareClickRecordForm form) { + ShareClickRecord entity = baseMapper.selectById(form.getId()); + + // 涓虹┖鎶汭llegalArgumentException锛屽仛鍏ㄥ眬寮傚父澶勭悊 + Assert.notNull(entity, "璁板綍涓嶅瓨鍦�"); + BeanUtils.copyProperties(form, entity); + baseMapper.updateById(entity); + return Result.ok("淇敼鎴愬姛"); + } + + /** + * 鎵归噺鍒犻櫎 + * @param ids + * @return + */ + @Override + public Result remove(List<String> ids) { + baseMapper.deleteBatchIds(ids); + return Result.ok("鍒犻櫎鎴愬姛"); + } + + /** + * id鍒犻櫎 + * @param id + * @return + */ + @Override + public Result removeById(String id) { + baseMapper.deleteById(id); + return Result.ok("鍒犻櫎鎴愬姛"); + } + + /** + * 鍒嗛〉鏌ヨ + * @param query + * @return + */ + @Override + public Result page(ShareClickRecordQuery query) { + IPage<ShareClickRecordVO> page = PageUtil.getPage(query, ShareClickRecordVO.class); + baseMapper.getPage(page, query); + return Result.ok().data(page.getRecords()).total(page.getTotal()); + } + + /** + * 鏍规嵁id鏌ユ壘 + * @param id + * @return + */ + @Override + public Result detail(String id) { + ShareClickRecordVO vo = baseMapper.getById(id); + Assert.notNull(vo, "璁板綍涓嶅瓨鍦�"); + return Result.ok().data(vo); + } + + /** + * 鍒楄〃 + * @return + */ + @Override + public Result all() { + List<ShareClickRecord> entities = baseMapper.selectList(null); + List<ShareClickRecordVO> vos = entities.stream() + .map(entity -> ShareClickRecordVO.getVoByEntity(entity, null)) + .collect(Collectors.toList()); + return Result.ok().data(vos); + } +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/ShareServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/ShareServiceImpl.java new file mode 100644 index 0000000..bf52b55 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/ShareServiceImpl.java @@ -0,0 +1,151 @@ +package cn.lili.modules.lmk.service.impl; + +import cn.lili.common.security.context.UserContext; +import cn.lili.modules.lmk.domain.entity.ShareClickRecord; +import cn.lili.modules.lmk.domain.form.ShareClickRecordForm; +import cn.lili.modules.lmk.service.ShareClickRecordService; +import com.baomidou.mybatisplus.core.metadata.IPage; +import cn.lili.modules.lmk.domain.entity.Share; +import cn.lili.modules.lmk.mapper.ShareMapper; +import cn.lili.modules.lmk.service.ShareService; +import cn.lili.base.Result; +import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import cn.lili.modules.lmk.domain.form.ShareForm; +import cn.lili.modules.lmk.domain.vo.ShareVO; +import cn.lili.modules.lmk.domain.query.ShareQuery; +import org.springframework.stereotype.Service; +import lombok.RequiredArgsConstructor; +import cn.lili.utils.PageUtil; +import org.springframework.beans.BeanUtils; +import org.springframework.util.Assert; + +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 鍒嗕韩璁板綍 鏈嶅姟瀹炵幇绫� + * + * @author xp + * @since 2025-06-16 + */ +@Service +@RequiredArgsConstructor +public class ShareServiceImpl extends ServiceImpl<ShareMapper, Share> implements ShareService { + + private final ShareMapper shareMapper; + private final ShareClickRecordService shareClickRecordService; + + /** + * 娣诲姞 + * @param form + * @return + */ + @Override + public Result add(ShareForm form) { + // 娌″垎浜繃鎵嶆柊澧� + boolean exists = new LambdaQueryChainWrapper<>(baseMapper) + .eq(Share::getShareType, form.getShareType()) + .eq(Share::getRefId, form.getRefId()) + .eq(Share::getShareUser, form.getShareUser()) + .exists(); + if (! exists) { + Share entity = ShareForm.getEntityByForm(form, null); + entity.setShareTime(new Date()); + baseMapper.insert(entity); + } + return Result.ok(); + } + + /** + * 淇敼 + * @param form + * @return + */ + @Override + public Result update(ShareForm form) { + Share entity = baseMapper.selectById(form.getId()); + + // 涓虹┖鎶汭llegalArgumentException锛屽仛鍏ㄥ眬寮傚父澶勭悊 + Assert.notNull(entity, "璁板綍涓嶅瓨鍦�"); + BeanUtils.copyProperties(form, entity); + baseMapper.updateById(entity); + return Result.ok("淇敼鎴愬姛"); + } + + /** + * 鎵归噺鍒犻櫎 + * @param ids + * @return + */ + @Override + public Result remove(List<String> ids) { + baseMapper.deleteBatchIds(ids); + return Result.ok("鍒犻櫎鎴愬姛"); + } + + /** + * id鍒犻櫎 + * @param id + * @return + */ + @Override + public Result removeById(String id) { + baseMapper.deleteById(id); + return Result.ok("鍒犻櫎鎴愬姛"); + } + + /** + * 鍒嗛〉鏌ヨ + * @param query + * @return + */ + @Override + public Result page(ShareQuery query) { + IPage<ShareVO> page = PageUtil.getPage(query, ShareVO.class); + baseMapper.getPage(page, query); + return Result.ok().data(page.getRecords()).total(page.getTotal()); + } + + /** + * 鏍规嵁id鏌ユ壘 + * @param id + * @return + */ + @Override + public Result detail(String id) { + ShareVO vo = baseMapper.getById(id); + Assert.notNull(vo, "璁板綍涓嶅瓨鍦�"); + return Result.ok().data(vo); + } + + /** + * 鍒楄〃 + * @return + */ + @Override + public Result all() { + List<Share> entities = baseMapper.selectList(null); + List<ShareVO> vos = entities.stream() + .map(entity -> ShareVO.getVoByEntity(entity, null)) + .collect(Collectors.toList()); + return Result.ok().data(vos); + } + + @Override + public Result addShareClick(ShareClickRecordForm form) { + // 娌℃湁璁块棶杩囨墠娣诲姞 + boolean exists = new LambdaQueryChainWrapper<>(shareClickRecordService.getBaseMapper()) + .eq(ShareClickRecord::getUserId, UserContext.getCurrentUserId()) + .eq(ShareClickRecord::getShareId, form.getShareId()) + .exists(); + if (! exists) { + ShareClickRecord record = ShareClickRecordForm.getEntityByForm(form, null); + record.setUserId(UserContext.getCurrentUserId()); + record.setClickTime(new Date()); + shareClickRecordService.save(record); + } + return Result.ok(); + } +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoGoodsServiceImpl.java new file mode 100644 index 0000000..dff92fa --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoGoodsServiceImpl.java @@ -0,0 +1,22 @@ +package cn.lili.modules.lmk.service.impl; + +import cn.lili.modules.lmk.domain.entity.VideoGoods; +import cn.lili.modules.lmk.mapper.VideoGoodsMapper; +import cn.lili.modules.lmk.service.VideoGoodsService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +/** + * 瑙嗛鍟嗗搧涓棿琛� 鏈嶅姟瀹炵幇绫� + * + * @author xp + * @since 2025-06-15 + */ +@Service +@RequiredArgsConstructor +public class VideoGoodsServiceImpl extends ServiceImpl<VideoGoodsMapper, VideoGoods> implements VideoGoodsService { + + private final VideoGoodsMapper videoGoodsMapper; + +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java index 444f83a..4fee572 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java @@ -55,6 +55,7 @@ private final MemberService memberService; private final VideoAccountService videoAccountService; private final KitchenVideoTypeRefService kitchenVideoTypeRefService; + private final VideoGoodsService videoGoodsService; /** @@ -187,8 +188,21 @@ return videoTagRef; }).collect(Collectors.toList()); videoTagRefService.saveBatch(videoTagRefs); - // 3.淇濆瓨瑙嗛鏂囦欢淇℃伅 + // 3. 淇濆瓨瑙嗛鏂囦欢淇℃伅 lmkFileService.addByForm(form.getFileInfo()); + // 4. 澶勭悊閫夋嫨鐨勫晢鍝� + if (CollectionUtils.isNotEmpty(form.getGoodsList())) { + List<VideoGoods> videoGoods = new ArrayList<>(2); + for (int i = 0; i < form.getGoodsList().size(); i++) { + VideoGoods e = new VideoGoods(); + e.setVideoId(video.getId()); + e.setGoodsId(form.getGoodsList().get(i).getGoodsId()); + e.setGoodsNum(form.getGoodsList().get(i).getGoodsNum()); + e.setOrderNum(i); + videoGoods.add(e); + } + videoGoodsService.saveBatch(videoGoods); + } return Result.ok("鍙戝竷鎴愬姛锛岃棰戝鏍镐腑~"); } @@ -202,7 +216,7 @@ if (page.getTotal() > 0) { Map<String, List<SimpleVideoTagVO>> tagMap = videoTagRefService.getTagsByVideoIds( page.getRecords().stream().map(VideoVO::getId).collect(Collectors.toList()) - ).stream().collect(Collectors.groupingBy(SimpleVideoTagVO::getVideoId));; + ).stream().collect(Collectors.groupingBy(SimpleVideoTagVO::getVideoId)); // 3. 鑾峰彇瑙嗛涓存椂璁块棶鍦板潃銆佽缃棰戞爣绛� page.getRecords().forEach(v -> { v.setTagList(tagMap.get(v.getId())); @@ -300,7 +314,6 @@ List<String> subscribes = mySubscribeService.getSubscribesByUserId(UserContext.getCurrentUserId()); // 3. 鑾峰彇瑙嗛涓存椂璁块棶鍦板潃銆佽缃棰戞爣绛俱�佹垜鏄惁鏀惰棌銆佷綔鑰呮槸鍚﹀叧娉� page.getRecords().forEach(v -> { - v.setGoods(new VideoGoodsVO()); v.setTagList(tagMap.get(v.getId())); v.setCollected(CollectionUtils.isNotEmpty(collectMap.get(v.getId()))); if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) { @@ -409,6 +422,12 @@ } @Override + public Result getGoodsDetail(String videoId) { + List<VideoGoodsDetailVO> goodsList = baseMapper.getVideoGoods(videoId); + return Result.ok().data(goodsList); + } + + @Override @Transactional(rollbackFor = Exception.class) public Result homePageInfoEdit(VideoHomePageInfoForm form) { new LambdaUpdateChainWrapper<>(memberService.getBaseMapper()) diff --git a/framework/src/main/java/cn/lili/modules/member/service/MemberService.java b/framework/src/main/java/cn/lili/modules/member/service/MemberService.java index 20983da..a3ba9b1 100644 --- a/framework/src/main/java/cn/lili/modules/member/service/MemberService.java +++ b/framework/src/main/java/cn/lili/modules/member/service/MemberService.java @@ -338,4 +338,6 @@ QRLoginResultVo loginWithSession(String token); Member findByUUID(String uuid); -} \ No newline at end of file + + void registerHandler(Member user); +} diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java index 5cf289a..489d7ea 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java @@ -313,6 +313,7 @@ * @param member */ @Transactional + @Override public void registerHandler(Member member) { member.setId(SnowFlake.getIdStr()); //淇濆瓨浼氬憳 diff --git a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsSearchService.java b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsSearchService.java index 61930be..76b8d7b 100644 --- a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsSearchService.java +++ b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsSearchService.java @@ -1,6 +1,8 @@ package cn.lili.modules.search.service; +import cn.lili.base.Result; import cn.lili.common.vo.PageVO; +import cn.lili.modules.lmk.domain.query.VideoGoodsEsQuery; import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.entity.dos.EsGoodsRelatedInfo; import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO; @@ -59,4 +61,12 @@ * @return 鍟嗗搧绱㈠紩 */ EsGoodsIndex getEsGoodsById(String id); + + /** + * 鍟嗗搧鍒嗛〉锛屽彂甯冭棰戞椂鍏宠仈鍟嗗搧鐨勬煡璇� + * + * @param query + * @return + */ + Result videoGoodsEsPage(VideoGoodsEsQuery query); } diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index f752e4c..11aa047 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -3,12 +3,15 @@ import cn.hutool.core.convert.Convert; import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.util.ArrayUtil; +import cn.lili.base.Result; import cn.lili.cache.Cache; import cn.lili.cache.CachePrefix; import cn.lili.common.exception.ServiceException; +import cn.lili.common.security.context.UserContext; import cn.lili.common.vo.PageVO; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; +import cn.lili.modules.lmk.domain.query.VideoGoodsEsQuery; import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.entity.dos.EsGoodsRelatedInfo; import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO; @@ -29,6 +32,7 @@ import org.elasticsearch.index.query.functionscore.FieldValueFactorFunctionBuilder; import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder; import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders; +import org.elasticsearch.index.search.MultiMatchQuery; import org.elasticsearch.search.aggregations.*; import org.elasticsearch.search.aggregations.bucket.nested.ParsedNested; import org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms; @@ -38,6 +42,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.data.elasticsearch.core.*; import org.springframework.data.elasticsearch.core.query.NativeSearchQuery; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; @@ -176,6 +181,38 @@ return this.restTemplate.get(id, EsGoodsIndex.class); } + @Override + public Result videoGoodsEsPage(VideoGoodsEsQuery q) { + // 鍒ゆ柇鍟嗗搧绱㈠紩鏄惁瀛樺湪 + if (!restTemplate.indexOps(EsGoodsIndex.class).exists()) { + return Result.ok(); + } + // 鏍规嵁閿�閲忓�掑簭鎺掑垪 + Pageable pageable = PageRequest.of(q.getPageNumber(), q.getPageSize(), Sort.by("buyCount").descending()); + + NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder(); + queryBuilder.withPageable(pageable); + + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + + // 鍏抽敭璇嶅尮閰嶅晢鍝佸悕绉般�佸晢鍝佺紪鍙� + if (!StringUtils.isEmpty(q.getKeyword())) { + boolQuery.must(QueryBuilders.multiMatchQuery(q.getKeyword(), "goodsName", "sn")); + } + + if (q.getSearchFromSelfStore()) { + // 濡傛灉鍙煡鑷搴楅摵鍟嗗搧 + boolQuery.must(QueryBuilders.termQuery("storeId", UserContext.getCurrentUser().getStoreId())); + } + + queryBuilder.withQuery(boolQuery); + + NativeSearchQuery query = queryBuilder.build(); + SearchHits<EsGoodsIndex> searchHits = restTemplate.search(query, EsGoodsIndex.class); + List<EsGoodsIndex> data = searchHits.stream().map(hit -> hit.getContent()).collect(Collectors.toList()); + return Result.ok().data(data).total(searchHits.getTotalHits()); + } + /** * 杞崲鎼滅储缁撴灉涓鸿仛鍚堝晢鍝佸睍绀轰俊鎭� * diff --git a/framework/src/main/java/cn/lili/mybatis/BaseIdAndDeleteEntity.java b/framework/src/main/java/cn/lili/mybatis/BaseIdAndDeleteEntity.java new file mode 100644 index 0000000..7ca9902 --- /dev/null +++ b/framework/src/main/java/cn/lili/mybatis/BaseIdAndDeleteEntity.java @@ -0,0 +1,40 @@ +package cn.lili.mybatis; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + + +/** + * 鏁版嵁搴撳熀纭�瀹炰綋绫� + * + * @author Chopper + * @version v1.0 + * @since 2020/8/20 14:34 + */ +@Data +@JsonIgnoreProperties(value = { "handler", "fieldHandler"}) +@AllArgsConstructor +@NoArgsConstructor +public abstract class BaseIdAndDeleteEntity implements Serializable { + + private static final long serialVersionUID = 1L; + + + @TableId + @ApiModelProperty(value = "鍞竴鏍囪瘑", hidden = true) + private String id; + + + @TableField(fill = FieldFill.INSERT) + @ApiModelProperty(value = "鍒犻櫎鏍囧織 true/false 鍒犻櫎/鏈垹闄�", hidden = true) + private Boolean deleteFlag; + +} diff --git a/framework/src/main/resources/mapper/lmk/ShareClickRecordMapper.xml b/framework/src/main/resources/mapper/lmk/ShareClickRecordMapper.xml new file mode 100644 index 0000000..d55f048 --- /dev/null +++ b/framework/src/main/resources/mapper/lmk/ShareClickRecordMapper.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="cn.lili.modules.lmk.mapper.ShareClickRecordMapper"> + + <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 --> + <resultMap id="BaseResultMap" type="cn.lili.modules.lmk.domain.vo.ShareClickRecordVO"> + <id column="id" property="id"/> + <result column="share_id" property="shareId" /> + <result column="user_id" property="userId" /> + <result column="click_time" property="clickTime" /> + </resultMap> + + + + + + + + <select id="getById" resultMap="BaseResultMap"> + SELECT + LSCR.share_id, + LSCR.user_id, + LSCR.click_time, + LSCR.id + FROM + lmk_share_click_record LSCR + WHERE + LSCR.id = #{id} AND LSCR.delete_flag = 0 + </select> + + + <select id="getPage" resultMap="BaseResultMap"> + SELECT + LSCR.share_id, + LSCR.user_id, + LSCR.click_time, + LSCR.id + FROM + lmk_share_click_record LSCR + WHERE + LSCR.delete_flag = 0 + </select> + +</mapper> diff --git a/framework/src/main/resources/mapper/lmk/ShareMapper.xml b/framework/src/main/resources/mapper/lmk/ShareMapper.xml new file mode 100644 index 0000000..a16a2cb --- /dev/null +++ b/framework/src/main/resources/mapper/lmk/ShareMapper.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="cn.lili.modules.lmk.mapper.ShareMapper"> + + <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 --> + <resultMap id="BaseResultMap" type="cn.lili.modules.lmk.domain.vo.ShareVO"> + <id column="id" property="id"/> + <result column="share_type" property="shareType" /> + <result column="ref_id" property="refId" /> + <result column="share_user" property="shareUser" /> + <result column="share_time" property="shareTime" /> + </resultMap> + + + + + + + + <select id="getById" resultMap="BaseResultMap"> + SELECT + LS.share_type, + LS.ref_id, + LS.share_user, + LS.share_time, + LS.id + FROM + lmk_share LS + WHERE + LS.id = #{id} AND LS.delete_flag = 0 + </select> + + + <select id="getPage" resultMap="BaseResultMap"> + SELECT + LS.share_type, + LS.ref_id, + LS.share_user, + LS.share_time, + LS.id + FROM + lmk_share LS + WHERE + LS.delete_flag = 0 + </select> + +</mapper> diff --git a/framework/src/main/resources/mapper/lmk/VideoGoodsMapper.xml b/framework/src/main/resources/mapper/lmk/VideoGoodsMapper.xml new file mode 100644 index 0000000..ed34fd8 --- /dev/null +++ b/framework/src/main/resources/mapper/lmk/VideoGoodsMapper.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="cn.lili.modules.lmk.mapper.VideoGoodsMapper"> + + + +</mapper> diff --git a/framework/src/main/resources/mapper/lmk/VideoMapper.xml b/framework/src/main/resources/mapper/lmk/VideoMapper.xml index d848b6a..aa28b05 100644 --- a/framework/src/main/resources/mapper/lmk/VideoMapper.xml +++ b/framework/src/main/resources/mapper/lmk/VideoMapper.xml @@ -11,10 +11,7 @@ <result column="video_file_key" property="videoFileKey" /> <result column="video_fit" property="videoFit" /> <result column="title" property="title" /> - <result column="goods_id" property="goodsId" /> - <result column="goods_view_num" property="goodsViewNum" /> <result column="video_duration" property="videoDuration" /> - <result column="goods_order_num" property="goodsOrderNum" /> <result column="recommend" property="recommend" /> <result column="status" property="status" /> <result column="play_num" property="playNum" /> @@ -26,7 +23,34 @@ <result column="video_content_type" property="videoContentType" /> <result column="video_type" property="videoType" /> <result column="video_imgs" property="videoImgs" /> + <collection property="goodsList" column="id" select="getVideoGoods" ofType="cn.lili.modules.lmk.domain.vo.VideoGoodsDetailVO"/> </resultMap> + + <resultMap id="VideoGoodsMap" type="cn.lili.modules.lmk.domain.vo.VideoGoodsDetailVO"> + <result column="goods_id" property="goodsId"/> + <result column="goods_num" property="goodsNum"/> + <result column="goods_name" property="goodsName"/> + <result column="thumbnail" property="thumbnail"/> + <result column="price" property="price"/> + </resultMap> + + <select id="getVideoGoods" parameterType="string" resultMap="VideoGoodsMap"> + SELECT + LVG.goods_id, + LVG.goods_num, + LVG.order_num, + LG.goods_name, + LG.thumbnail, + LG.price + FROM + lmk_video_goods LVG + INNER JOIN li_goods LG ON LVG.goods_id = LG.id AND LG.market_enable = 'UPPER' AND LG.delete_flag = 0 + WHERE + LVG.video_id = #{id} AND LVG.delete_flag = 0 + ORDER BY + LVG.order_num ASC + </select> + <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 --> <resultMap id="KitchenVideoMap" type="cn.lili.modules.lmk.domain.vo.KitchenVideoVO"> <id column="id" property="id"/> @@ -36,7 +60,6 @@ <result column="video_file_key" property="videoFileKey" /> <result column="video_fit" property="videoFit" /> <result column="title" property="title" /> - <result column="goods_id" property="goodsId" /> <result column="goods_view_num" property="goodsViewNum" /> <result column="video_duration" property="videoDuration" /> <result column="goods_order_num" property="goodsOrderNum" /> @@ -69,6 +92,7 @@ <result column="video_content_type" property="videoContentType" /> <result column="video_type" property="videoType" /> <result column="video_imgs" property="videoImgs" /> + <collection property="goodsList" column="id" select="getVideoGoods" ofType="cn.lili.modules.lmk.domain.vo.VideoGoodsDetailVO"/> </resultMap> @@ -379,7 +403,6 @@ <result column="video_fit" property="videoFit" /> <result column="title" property="title" /> <result column="video_duration" property="videoDuration" /> - <result column="goods_id" property="goodsId" /> </resultMap> <select id="wxDetail" resultMap="WxEditResultMap"> -- Gitblit v1.8.0