初始化购物车
parent
7b38972c73
commit
39b92736fa
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-shop-cart</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-shop-cart-common</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,105 @@
|
|||
package com.muyu.shop.cart.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.shop.cart.domain.req.CartInfoQueryReq;
|
||||
import com.muyu.shop.cart.domain.req.CartInfoSaveReq;
|
||||
import com.muyu.shop.cart.domain.req.CartInfoEditReq;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 购物车对象 cart_info
|
||||
*
|
||||
* @author DongZeLiang
|
||||
* @date 2024-03-29
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("cart_info")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "CartInfo", description = "购物车")
|
||||
public class CartInfo extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
@ApiModelProperty(name = "主键", value = "主键")
|
||||
private Long id;
|
||||
|
||||
/** 商品 */
|
||||
@Excel(name = "商品")
|
||||
@ApiModelProperty(name = "商品", value = "商品", required = true)
|
||||
private Long projectId;
|
||||
|
||||
/** SKU */
|
||||
@Excel(name = "SKU")
|
||||
@ApiModelProperty(name = "SKU", value = "SKU", required = true)
|
||||
private String projectSku;
|
||||
|
||||
/** 用户 */
|
||||
@Excel(name = "用户")
|
||||
@ApiModelProperty(name = "用户", value = "用户", required = true)
|
||||
private Long userId;
|
||||
|
||||
/** 数量 */
|
||||
@Excel(name = "数量")
|
||||
@ApiModelProperty(name = "数量", value = "数量", required = true)
|
||||
private Long num;
|
||||
|
||||
/** 是否选中 */
|
||||
@Excel(name = "是否选中")
|
||||
@ApiModelProperty(name = "是否选中", value = "是否选中", required = true)
|
||||
private String isSelected;
|
||||
|
||||
/**
|
||||
* 查询构造器
|
||||
*/
|
||||
public static CartInfo queryBuild( CartInfoQueryReq cartInfoQueryReq){
|
||||
return CartInfo.builder()
|
||||
.projectId(cartInfoQueryReq.getProjectId())
|
||||
.projectSku(cartInfoQueryReq.getProjectSku())
|
||||
.userId(cartInfoQueryReq.getUserId())
|
||||
.num(cartInfoQueryReq.getNum())
|
||||
.isSelected(cartInfoQueryReq.getIsSelected())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加构造器
|
||||
*/
|
||||
public static CartInfo saveBuild(CartInfoSaveReq cartInfoSaveReq){
|
||||
return CartInfo.builder()
|
||||
.projectId(cartInfoSaveReq.getProjectId())
|
||||
.projectSku(cartInfoSaveReq.getProjectSku())
|
||||
.userId(cartInfoSaveReq.getUserId())
|
||||
.num(cartInfoSaveReq.getNum())
|
||||
.isSelected(cartInfoSaveReq.getIsSelected())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改构造器
|
||||
*/
|
||||
public static CartInfo editBuild(Long id, CartInfoEditReq cartInfoEditReq){
|
||||
return CartInfo.builder()
|
||||
.id(id)
|
||||
.projectId(cartInfoEditReq.getProjectId())
|
||||
.projectSku(cartInfoEditReq.getProjectSku())
|
||||
.userId(cartInfoEditReq.getUserId())
|
||||
.num(cartInfoEditReq.getNum())
|
||||
.isSelected(cartInfoEditReq.getIsSelected())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.muyu.shop.cart.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 购物车对象 cart_info
|
||||
*
|
||||
* @author DongZeLiang
|
||||
* @date 2024-03-29
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "CartInfoEditReq", description = "购物车")
|
||||
public class CartInfoEditReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 商品 */
|
||||
@ApiModelProperty(name = "商品", value = "商品", required = true)
|
||||
private Long projectId;
|
||||
|
||||
/** SKU */
|
||||
@ApiModelProperty(name = "SKU", value = "SKU", required = true)
|
||||
private String projectSku;
|
||||
|
||||
/** 用户 */
|
||||
@ApiModelProperty(name = "用户", value = "用户", required = true)
|
||||
private Long userId;
|
||||
|
||||
/** 数量 */
|
||||
@ApiModelProperty(name = "数量", value = "数量", required = true)
|
||||
private Long num;
|
||||
|
||||
/** 是否选中 */
|
||||
@ApiModelProperty(name = "是否选中", value = "是否选中", required = true)
|
||||
private String isSelected;
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.muyu.shop.cart.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 购物车对象 cart_info
|
||||
*
|
||||
* @author DongZeLiang
|
||||
* @date 2024-03-29
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "CartInfoQueryReq", description = "购物车")
|
||||
public class CartInfoQueryReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 商品 */
|
||||
@ApiModelProperty(name = "商品", value = "商品")
|
||||
private Long projectId;
|
||||
|
||||
/** SKU */
|
||||
@ApiModelProperty(name = "SKU", value = "SKU")
|
||||
private String projectSku;
|
||||
|
||||
/** 用户 */
|
||||
@ApiModelProperty(name = "用户", value = "用户")
|
||||
private Long userId;
|
||||
|
||||
/** 数量 */
|
||||
@ApiModelProperty(name = "数量", value = "数量")
|
||||
private Long num;
|
||||
|
||||
/** 是否选中 */
|
||||
@ApiModelProperty(name = "是否选中", value = "是否选中")
|
||||
private String isSelected;
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.muyu.shop.cart.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 购物车对象 cart_info
|
||||
*
|
||||
* @author DongZeLiang
|
||||
* @date 2024-03-29
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "CartInfoSaveReq", description = "购物车")
|
||||
public class CartInfoSaveReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
|
||||
@ApiModelProperty(name = "主键", value = "主键")
|
||||
private Long id;
|
||||
|
||||
/** 商品 */
|
||||
|
||||
@ApiModelProperty(name = "商品", value = "商品", required = true)
|
||||
private Long projectId;
|
||||
|
||||
/** SKU */
|
||||
|
||||
@ApiModelProperty(name = "SKU", value = "SKU", required = true)
|
||||
private String projectSku;
|
||||
|
||||
/** 用户 */
|
||||
|
||||
@ApiModelProperty(name = "用户", value = "用户", required = true)
|
||||
private Long userId;
|
||||
|
||||
/** 数量 */
|
||||
|
||||
@ApiModelProperty(name = "数量", value = "数量", required = true)
|
||||
private Long num;
|
||||
|
||||
/** 是否选中 */
|
||||
|
||||
@ApiModelProperty(name = "是否选中", value = "是否选中", required = true)
|
||||
private String isSelected;
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-shop-cart</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-shop-cart-remote</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- 购物车模块 公共依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-shop-cart-common</artifactId>
|
||||
<version>${muyu.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,116 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-shop-cart</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-shop-cart-server</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-swagger</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 购物车模块 公共依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-shop-cart-common</artifactId>
|
||||
<version>${muyu.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- 加入maven deploy插件,当在deploy时,忽略些model-->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,22 @@
|
|||
package com.muyu.shop.cart;
|
||||
|
||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* 购物车服务
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
public class MuYuShopCartApplication {
|
||||
public static void main (String[] args) {
|
||||
SpringApplication.run(MuYuShopCartApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package com.muyu.shop.cart.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.shop.cart.domain.CartInfo;
|
||||
import com.muyu.shop.cart.domain.req.CartInfoQueryReq;
|
||||
import com.muyu.shop.cart.domain.req.CartInfoSaveReq;
|
||||
import com.muyu.shop.cart.domain.req.CartInfoEditReq;
|
||||
import com.muyu.shop.cart.service.CartInfoService;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 购物车Controller
|
||||
*
|
||||
* @author DongZeLiang
|
||||
* @date 2024-03-29
|
||||
*/
|
||||
@Api(tags = "购物车")
|
||||
@RestController
|
||||
@RequestMapping("/Info")
|
||||
public class CartInfoController extends BaseController {
|
||||
@Autowired
|
||||
private CartInfoService cartInfoService;
|
||||
|
||||
/**
|
||||
* 查询购物车列表
|
||||
*/
|
||||
@ApiOperation("获取购物车列表")
|
||||
@RequiresPermissions("shopCart:Info:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<CartInfo>> list(CartInfoQueryReq cartInfoQueryReq) {
|
||||
startPage();
|
||||
List<CartInfo> list = cartInfoService.list(CartInfo.queryBuild(cartInfoQueryReq));
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出购物车列表
|
||||
*/
|
||||
@ApiOperation("导出购物车列表")
|
||||
@RequiresPermissions("shopCart:Info:export")
|
||||
@Log(title = "购物车", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CartInfo cartInfo) {
|
||||
List<CartInfo> list = cartInfoService.list(cartInfo);
|
||||
ExcelUtil<CartInfo> util = new ExcelUtil<CartInfo>(CartInfo.class);
|
||||
util.exportExcel(response, list, "购物车数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取购物车详细信息
|
||||
*/
|
||||
@ApiOperation("获取购物车详细信息")
|
||||
@RequiresPermissions("shopCart:Info:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
public Result<CartInfo> getInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(cartInfoService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增购物车
|
||||
*/
|
||||
@RequiresPermissions("shopCart:Info:add")
|
||||
@Log(title = "购物车", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@ApiOperation("新增购物车")
|
||||
public Result<String> add(@RequestBody CartInfoSaveReq cartInfoSaveReq) {
|
||||
return toAjax(cartInfoService.save(CartInfo.saveBuild(cartInfoSaveReq)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改购物车
|
||||
*/
|
||||
@RequiresPermissions("shopCart:Info:edit")
|
||||
@Log(title = "购物车", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/{id}")
|
||||
@ApiOperation("修改购物车")
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody CartInfoEditReq cartInfoEditReq) {
|
||||
return toAjax(cartInfoService.updateById(CartInfo.editBuild(id,cartInfoEditReq)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除购物车
|
||||
*/
|
||||
@RequiresPermissions("shopCart:Info:remove")
|
||||
@Log(title = "购物车", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation("删除购物车")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
return toAjax(cartInfoService.removeBatchByIds(ids));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.muyu.shop.cart.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.shop.cart.domain.CartInfo;
|
||||
|
||||
/**
|
||||
* 购物车Mapper接口
|
||||
*
|
||||
* @author DongZeLiang
|
||||
* @date 2024-03-29
|
||||
*/
|
||||
public interface CartInfoMapper extends BaseMapper<CartInfo> {
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.muyu.shop.cart.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.muyu.shop.cart.domain.CartInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* 购物车Service接口
|
||||
*
|
||||
* @author DongZeLiang
|
||||
* @date 2024-03-29
|
||||
*/
|
||||
public interface CartInfoService extends IService<CartInfo> {
|
||||
/**
|
||||
* 查询购物车列表
|
||||
*
|
||||
* @param cartInfo 购物车
|
||||
* @return 购物车集合
|
||||
*/
|
||||
public List<CartInfo> list(CartInfo cartInfo);
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.muyu.shop.cart.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.muyu.common.core.utils.ObjUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.shop.cart.mapper.CartInfoMapper;
|
||||
import com.muyu.shop.cart.domain.CartInfo;
|
||||
import com.muyu.shop.cart.service.CartInfoService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
/**
|
||||
* 购物车Service业务层处理
|
||||
*
|
||||
* @author DongZeLiang
|
||||
* @date 2024-03-29
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CartInfoServiceImpl extends ServiceImpl<CartInfoMapper, CartInfo> implements CartInfoService {
|
||||
|
||||
/**
|
||||
* 查询购物车列表
|
||||
*
|
||||
* @param cartInfo 购物车
|
||||
* @return 购物车
|
||||
*/
|
||||
@Override
|
||||
public List<CartInfo> list(CartInfo cartInfo) {
|
||||
LambdaQueryWrapper<CartInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
|
||||
if (ObjUtils.notNull(cartInfo.getProjectId())){
|
||||
queryWrapper.eq(CartInfo::getProjectId, cartInfo.getProjectId());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(cartInfo.getProjectSku())){
|
||||
queryWrapper.eq(CartInfo::getProjectSku, cartInfo.getProjectSku());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(cartInfo.getUserId())){
|
||||
queryWrapper.eq(CartInfo::getUserId, cartInfo.getUserId());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(cartInfo.getNum())){
|
||||
queryWrapper.eq(CartInfo::getNum, cartInfo.getNum());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(cartInfo.getIsSelected())){
|
||||
queryWrapper.eq(CartInfo::getIsSelected, cartInfo.getIsSelected());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
|
@ -0,0 +1,28 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9506
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: muyu-shop-cart
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
logging:
|
||||
level:
|
||||
com.muyu.shop.cart.mapper: DEBUG
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/muyu-system"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.muyu" level="info"/>
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn"/>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info"/>
|
||||
<appender-ref ref="file_error"/>
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,24 @@
|
|||
<?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="com.muyu.shop.cart.mapper.CartInfoMapper">
|
||||
|
||||
<resultMap type="com.muyu.shop.cart.domain.CartInfo" id="CartInfoResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="projectId" column="project_id" />
|
||||
<result property="projectSku" column="project_sku" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="num" column="num" />
|
||||
<result property="isSelected" column="is_selected" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCartInfoVo">
|
||||
select id, project_id, project_sku, user_id, num, is_selected, remark, create_by, create_time, update_by, update_time from cart_info
|
||||
</sql>
|
||||
</mapper>
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-modules</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-shop-cart</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>muyu-shop-cart-common</module>
|
||||
<module>muyu-shop-cart-remote</module>
|
||||
<module>muyu-shop-cart-server</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -14,6 +14,7 @@
|
|||
<module>muyu-job</module>
|
||||
<module>muyu-file</module>
|
||||
<module>muyu-product</module>
|
||||
<module>muyu-shop-cart</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>muyu-modules</artifactId>
|
||||
|
|
14
pom.xml
14
pom.xml
|
@ -234,6 +234,20 @@
|
|||
<version>${muyu.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 购物车模块 公共依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-shop-cart-common</artifactId>
|
||||
<version>${muyu.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 购物车模块 远程客户端 依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-shop-cart-remote</artifactId>
|
||||
<version>${muyu.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
|
Loading…
Reference in New Issue