新增方法product
parent
ca2f41bca0
commit
dc6e65081e
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="accountSettings">
|
||||
<option name="activeRegion" value="us-east-1" />
|
||||
<option name="recentlyUsedRegions">
|
||||
<list>
|
||||
<option value="us-east-1" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -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;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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<Product> {
|
||||
|
||||
/**
|
||||
* 查询所有接口信息
|
||||
* @return
|
||||
*/
|
||||
List<Product> findproductList();
|
||||
|
||||
void insertuserproduct(@Param("userId") Long userId, @Param("productId") Integer productId);
|
||||
}
|
|
@ -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<Product> {
|
||||
|
||||
/**
|
||||
* 查询所有接口信息
|
||||
* @return
|
||||
*/
|
||||
List<Product> findproductList();
|
||||
|
||||
void insertuserproduct(Long userId, Integer productId);
|
||||
}
|
|
@ -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<ProductMapper, Product> implements ProductService{
|
||||
@Autowired
|
||||
private ProductMapper productMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有接口信息
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Product> findproductList() {
|
||||
return productMapper.findproductList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertuserproduct(Long userId, Integer productId) {
|
||||
productMapper.insertuserproduct(userId,productId);
|
||||
}
|
||||
}
|
|
@ -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<SysUserMapper, SysUser> impl
|
|||
private SysUserPostMapper userPostMapper;
|
||||
@Autowired
|
||||
private SysConfigService configService;
|
||||
@Autowired
|
||||
private ProductService productService;
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
|
@ -264,6 +268,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
ur.setRoleId(2L);
|
||||
list.add(ur);
|
||||
userRoleMapper.batchUserRole(list);
|
||||
//查询所有接口信息
|
||||
List<Product> productList = productService.findproductList();
|
||||
for (Product product : productList) {
|
||||
productService.insertuserproduct(userId,product.getProductId());
|
||||
}
|
||||
return i > 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?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.system.mapper.ProductMapper">
|
||||
<insert id="insertuserproduct">
|
||||
INSERT INTO `h6_cloud_server`.`user_product_count`
|
||||
(`test_id`, `user_id`, `product_id`, `test_count`) VALUES
|
||||
(0, #{userId}, #{productId}, 2);
|
||||
</insert>
|
||||
|
||||
<select id="findproductList" resultType="com.muyu.system.domain.Product">
|
||||
SELECT * from product
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue