diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/src/main/java/com/muyu/system/controller/ProductController.java b/src/main/java/com/muyu/system/controller/ProductController.java new file mode 100644 index 0000000..0ed1418 --- /dev/null +++ b/src/main/java/com/muyu/system/controller/ProductController.java @@ -0,0 +1,27 @@ +package com.muyu.system.controller; + +import com.muyu.system.service.ProductService; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.log4j.Log4j2; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Author:weiran + * @Package:com.muyu.system.controller + * @Project:cloud-modules-system + * @name:ProductController + * @Date:2024/9/3 21:26 + */ +@Log4j2 +@RestController +@RequestMapping("/product") +@Tag(name = "产品接口控制层",description = "进行产品接口管理、查看等相关操作") +public class ProductController { + @Autowired + private ProductService productService; + + + +} diff --git a/src/main/java/com/muyu/system/domain/Product.java b/src/main/java/com/muyu/system/domain/Product.java new file mode 100644 index 0000000..a8cdbb6 --- /dev/null +++ b/src/main/java/com/muyu/system/domain/Product.java @@ -0,0 +1,106 @@ +package com.muyu.system.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.muyu.common.core.web.domain.BaseEntity; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.function.Supplier; + +/** + * @Author:weiran + * @Package:com.muyu.cloud.market.domin + * @Project:cloud-market + * @name:Product + * @Date:2024/8/20 15:04 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@AllArgsConstructor +@NoArgsConstructor +@SuperBuilder +@TableName(value = "product",autoResultMap = true) +public class Product extends BaseEntity { + + /** + * 主键 + */ + @TableId(value = "product_id",type = IdType.AUTO) + private Integer productId; + /** + * 产品名称 + */ + private String productName; + /** + *产品价格 + */ + private BigDecimal productPrice; + /** + *产品介绍 + */ + private String productContent; + /** + *产品上架状态(是否上架 0未上架 1已上架) + */ + private Integer productState; + /** + *产品规格(按次购买/按日期购买)购买多少次 + */ + private String productSpecification; + /** + *产品销量 + */ + private Integer productSales; + /** + * 产品类型 + */ + private String productType; + /** + *产品上架日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Schema(description = "产品上架日期",defaultValue = "2024-8-9 10:47:57",type = "Date") + private Date productShelvesdate; + /** + * 重要路径 + */ + private String apiRouter; + /** + *接口地址 + */ + private String apiAddress; + /** + * 返回格式 + */ + private String returnFormat; + /** + *请求方式 + */ + private String requestMethod; + + /** + * 允许试用次数 + */ + private Integer userCount; + /** + * 是否被购买 + */ + private String remark; + + + + + + + + +} diff --git a/src/main/java/com/muyu/system/domain/UserProductCount.java b/src/main/java/com/muyu/system/domain/UserProductCount.java new file mode 100644 index 0000000..147882e --- /dev/null +++ b/src/main/java/com/muyu/system/domain/UserProductCount.java @@ -0,0 +1,74 @@ +package com.muyu.system.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +/** + * @Author:weiran + * @Package:com.muyu.cloud.market.domin + * @Project:cloud-market + * @name:UserProductCount + * @Date:2024/9/3 10:12 + */ + +@Data +@AllArgsConstructor +@NoArgsConstructor +@SuperBuilder +@TableName(value = "user_product_count",autoResultMap = true) +public class UserProductCount { + /** + * 主键 + */ + @TableId(value = "test_id",type = IdType.AUTO) + private Integer testId; + /** + * 用户Id + */ + private long userId; + /** + * 产品Id + */ + private Integer productId; + /** + * 测试次数 + */ + private Integer testCount; + + public Integer getTestId() { + return testId; + } + + public void setTestId(Integer testId) { + this.testId = testId; + } + + public long getUserId() { + return userId; + } + + public void setUserId(long userId) { + this.userId = userId; + } + + public Integer getProductId() { + return productId; + } + + public void setProductId(Integer productId) { + this.productId = productId; + } + + public Integer getTestCount() { + return testCount; + } + + public void setTestCount(Integer testCount) { + this.testCount = testCount; + } +} diff --git a/src/main/java/com/muyu/system/mapper/ProductMapper.java b/src/main/java/com/muyu/system/mapper/ProductMapper.java new file mode 100644 index 0000000..97903a7 --- /dev/null +++ b/src/main/java/com/muyu/system/mapper/ProductMapper.java @@ -0,0 +1,27 @@ +package com.muyu.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.muyu.system.domain.Product; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @Author:weiran + * @Package:com.muyu.system.mapper + * @Project:cloud-modules-system + * @name:ProductMapper + * @Date:2024/9/3 21:27 + */ +@Mapper +public interface ProductMapper extends BaseMapper { + + /** + * 查询所有接口信息 + * @return + */ + List findproductList(); + + void insertuserproduct(@Param("userId") Long userId, @Param("productId") Integer productId); +} diff --git a/src/main/java/com/muyu/system/service/ProductService.java b/src/main/java/com/muyu/system/service/ProductService.java new file mode 100644 index 0000000..a1b8294 --- /dev/null +++ b/src/main/java/com/muyu/system/service/ProductService.java @@ -0,0 +1,24 @@ +package com.muyu.system.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.muyu.system.domain.Product; + +import java.util.List; + +/** + * @Author:weiran + * @Package:com.muyu.system.service + * @Project:cloud-modules-system + * @name:ProductService + * @Date:2024/9/3 21:27 + */ +public interface ProductService extends IService { + + /** + * 查询所有接口信息 + * @return + */ + List findproductList(); + + void insertuserproduct(Long userId, Integer productId); +} diff --git a/src/main/java/com/muyu/system/service/impl/ProductServiceImpl.java b/src/main/java/com/muyu/system/service/impl/ProductServiceImpl.java new file mode 100644 index 0000000..d9c1f96 --- /dev/null +++ b/src/main/java/com/muyu/system/service/impl/ProductServiceImpl.java @@ -0,0 +1,38 @@ +package com.muyu.system.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.muyu.system.domain.Product; +import com.muyu.system.mapper.ProductMapper; +import com.muyu.system.service.ProductService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @Author:weiran + * @Package:com.muyu.system.service.impl + * @Project:cloud-modules-system + * @name:ProductServiceImpl + * @Date:2024/9/3 21:27 + */ +@Service +public class ProductServiceImpl extends ServiceImpl implements ProductService{ + @Autowired + private ProductMapper productMapper; + + + /** + * 查询所有接口信息 + * @return + */ + @Override + public List findproductList() { + return productMapper.findproductList(); + } + + @Override + public void insertuserproduct(Long userId, Integer productId) { + productMapper.insertuserproduct(userId,productId); + } +} diff --git a/src/main/java/com/muyu/system/service/impl/SysUserServiceImpl.java b/src/main/java/com/muyu/system/service/impl/SysUserServiceImpl.java index 3f860e2..57f66a1 100644 --- a/src/main/java/com/muyu/system/service/impl/SysUserServiceImpl.java +++ b/src/main/java/com/muyu/system/service/impl/SysUserServiceImpl.java @@ -10,10 +10,12 @@ import com.muyu.common.datascope.annotation.DataScope; import com.muyu.common.security.utils.SecurityUtils; import com.muyu.common.system.domain.SysRole; import com.muyu.common.system.domain.SysUser; +import com.muyu.system.domain.Product; import com.muyu.system.domain.SysPost; import com.muyu.system.domain.SysUserPost; import com.muyu.system.domain.SysUserRole; import com.muyu.system.mapper.*; +import com.muyu.system.service.ProductService; import com.muyu.system.service.SysUserService; import com.muyu.system.service.SysConfigService; import jakarta.validation.Validator; @@ -50,6 +52,8 @@ public class SysUserServiceImpl extends ServiceImpl impl private SysUserPostMapper userPostMapper; @Autowired private SysConfigService configService; + @Autowired + private ProductService productService; /** * 根据条件分页查询用户列表 @@ -264,6 +268,11 @@ public class SysUserServiceImpl extends ServiceImpl impl ur.setRoleId(2L); list.add(ur); userRoleMapper.batchUserRole(list); + //查询所有接口信息 + List productList = productService.findproductList(); + for (Product product : productList) { + productService.insertuserproduct(userId,product.getProductId()); + } return i > 0; } diff --git a/src/main/resources/mapper/system/ProductMapper.xml b/src/main/resources/mapper/system/ProductMapper.xml new file mode 100644 index 0000000..a3c306b --- /dev/null +++ b/src/main/resources/mapper/system/ProductMapper.xml @@ -0,0 +1,16 @@ + + + + + + INSERT INTO `h6_cloud_server`.`user_product_count` + (`test_id`, `user_id`, `product_id`, `test_count`) VALUES + (0, #{userId}, #{productId}, 2); + + + +