基于mall4j产品的二开项目后端
lee
2024-12-18 921461a3f906d74403aeb6a27051deb77eca10fc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
 *
 * https://www.mall4j.com/
 *
 * 未经允许,不可做商业用途!
 *
 * 版权所有,侵权必究!
 */
package com.yami.shop.api.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yami.shop.bean.app.dto.ProductDto;
import com.yami.shop.bean.model.ProdBrowseLog;
import com.yami.shop.common.response.ServerResponseEntity;
import com.yami.shop.common.util.PageParam;
import com.yami.shop.security.api.util.SecurityUtils;
import com.yami.shop.service.ProdBrowseLogService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
 
import javax.validation.Valid;
import java.util.List;
 
 
/**
 * 商品浏览记录表
 *
 * @author LGH
 * @date 2021-11-01 10:43:09
 */
@RestController
@AllArgsConstructor
@RequestMapping("/p/prodBrowseLog" )
@Tag(name = "商品浏览记录表")
public class ProdBrowseLogController {
 
    private final ProdBrowseLogService prodBrowseLogService;
 
    @GetMapping("/page")
    @Operation(summary = "获取商品浏览记录表列表" , description = "分页获取商品浏览记录表列表")
    public ServerResponseEntity<IPage<ProdBrowseLog>> page(PageParam<ProductDto> page) {
        String userId = SecurityUtils.getUser().getUserId();
        IPage<ProdBrowseLog> pageRes = prodBrowseLogService.pageByUserId(page, userId);
        return ServerResponseEntity.success(pageRes);
    }
 
    @PostMapping
    @Operation(summary = "保存商品浏览记录表" , description = "保存商品浏览记录表")
    public ServerResponseEntity<Void> save(@Valid @RequestBody ProdBrowseLog prodBrowseLog) {
        String userId = SecurityUtils.getUser().getUserId();
        prodBrowseLog.setUserId(userId);
        prodBrowseLogService.saveInfo(prodBrowseLog);
        return ServerResponseEntity.success();
    }
 
    @DeleteMapping
    @Operation(summary = "根据prodBrowseLogIds批量删除商品浏览记录" , description = "根据prodBrowseLogIds批量删除商品浏览记录")
    public ServerResponseEntity<Void> deleteByIds(@RequestBody List<Long> prodBrowseLogIds) {
        prodBrowseLogService.deleteByIds(prodBrowseLogIds, SecurityUtils.getUser().getUserId());
        return ServerResponseEntity.success();
    }
 
}