新增方法product

master
张腾 2024-09-03 22:34:01 +08:00
parent ca2f41bca0
commit dc6e65081e
9 changed files with 332 additions and 0 deletions

11
.idea/aws.xml 100644
View File

@ -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>

View File

@ -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;
/**
* @Authorweiran
* @Packagecom.muyu.system.controller
* @Projectcloud-modules-system
* @nameProductController
* @Date2024/9/3 21:26
*/
@Log4j2
@RestController
@RequestMapping("/product")
@Tag(name = "产品接口控制层",description = "进行产品接口管理、查看等相关操作")
public class ProductController {
@Autowired
private ProductService productService;
}

View File

@ -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;
/**
* @Authorweiran
* @Packagecom.muyu.cloud.market.domin
* @Projectcloud-market
* @nameProduct
* @Date2024/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;
}

View File

@ -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;
/**
* @Authorweiran
* @Packagecom.muyu.cloud.market.domin
* @Projectcloud-market
* @nameUserProductCount
* @Date2024/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;
}
}

View File

@ -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;
/**
* @Authorweiran
* @Packagecom.muyu.system.mapper
* @Projectcloud-modules-system
* @nameProductMapper
* @Date2024/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);
}

View File

@ -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;
/**
* @Authorweiran
* @Packagecom.muyu.system.service
* @Projectcloud-modules-system
* @nameProductService
* @Date2024/9/3 21:27
*/
public interface ProductService extends IService<Product> {
/**
*
* @return
*/
List<Product> findproductList();
void insertuserproduct(Long userId, Integer productId);
}

View File

@ -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;
/**
* @Authorweiran
* @Packagecom.muyu.system.service.impl
* @Projectcloud-modules-system
* @nameProductServiceImpl
* @Date2024/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);
}
}

View File

@ -10,10 +10,12 @@ import com.muyu.common.datascope.annotation.DataScope;
import com.muyu.common.security.utils.SecurityUtils; import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.SysRole; import com.muyu.common.system.domain.SysRole;
import com.muyu.common.system.domain.SysUser; import com.muyu.common.system.domain.SysUser;
import com.muyu.system.domain.Product;
import com.muyu.system.domain.SysPost; import com.muyu.system.domain.SysPost;
import com.muyu.system.domain.SysUserPost; import com.muyu.system.domain.SysUserPost;
import com.muyu.system.domain.SysUserRole; import com.muyu.system.domain.SysUserRole;
import com.muyu.system.mapper.*; import com.muyu.system.mapper.*;
import com.muyu.system.service.ProductService;
import com.muyu.system.service.SysUserService; import com.muyu.system.service.SysUserService;
import com.muyu.system.service.SysConfigService; import com.muyu.system.service.SysConfigService;
import jakarta.validation.Validator; import jakarta.validation.Validator;
@ -50,6 +52,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
private SysUserPostMapper userPostMapper; private SysUserPostMapper userPostMapper;
@Autowired @Autowired
private SysConfigService configService; private SysConfigService configService;
@Autowired
private ProductService productService;
/** /**
* *
@ -264,6 +268,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
ur.setRoleId(2L); ur.setRoleId(2L);
list.add(ur); list.add(ur);
userRoleMapper.batchUserRole(list); userRoleMapper.batchUserRole(list);
//查询所有接口信息
List<Product> productList = productService.findproductList();
for (Product product : productList) {
productService.insertuserproduct(userId,product.getProductId());
}
return i > 0; return i > 0;
} }

View File

@ -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>