Merge branch 'master' of https://git.we-zone.com/wezone/Ry-master into main
This commit is contained in:
commit
3624db9f23
1
pom.xml
1
pom.xml
|
@ -234,6 +234,7 @@
|
||||||
<module>ruoyi-demo</module>
|
<module>ruoyi-demo</module>
|
||||||
<module>ruoyi-extend</module>
|
<module>ruoyi-extend</module>
|
||||||
<module>ruoyi-oss</module>
|
<module>ruoyi-oss</module>
|
||||||
|
<module>ruoyi-mall</module>
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ token:
|
||||||
# 令牌密钥
|
# 令牌密钥
|
||||||
secret: abcdefghijklmnopqrstuvwxyz
|
secret: abcdefghijklmnopqrstuvwxyz
|
||||||
# 令牌有效期(默认30分钟)
|
# 令牌有效期(默认30分钟)
|
||||||
expireTime: 30
|
expireTime: 300
|
||||||
|
|
||||||
# 重复提交
|
# 重复提交
|
||||||
repeat-submit:
|
repeat-submit:
|
||||||
|
|
|
@ -178,6 +178,22 @@
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.security</groupId>
|
||||||
|
<artifactId>spring-security-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Mysql驱动包 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.ruoyi.common.config;
|
||||||
|
|
||||||
|
import cn.org.atool.fluent.mybatis.spring.MapperFactory;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.relation.ProductCategoryRelationEntity;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mapper配置类
|
||||||
|
* @author Geniou
|
||||||
|
* @create 2021/9/10 12:11
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class MapperConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public MapperFactory mapperFactory() {
|
||||||
|
return new MapperFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ProductCategoryRelationEntity entityRelation() { return new ProductCategoryRelationEntity(); }
|
||||||
|
|
||||||
|
}
|
|
@ -1,62 +0,0 @@
|
||||||
package com.ruoyi.common.core.domain.entity.test;
|
|
||||||
|
|
||||||
import cn.org.atool.fluent.mybatis.annotation.FluentMybatis;
|
|
||||||
import cn.org.atool.fluent.mybatis.base.IEntity;
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品对象 product
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
* @date 2021-09-03
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@FluentMybatis
|
|
||||||
public class Product implements IEntity {
|
|
||||||
|
|
||||||
private static final long serialVersionUID=1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品id
|
|
||||||
*/
|
|
||||||
@TableId(value = "id")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
private Date createDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
private Date updateDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品唯一编号
|
|
||||||
*/
|
|
||||||
private String productCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品名称
|
|
||||||
*/
|
|
||||||
private String productName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单价
|
|
||||||
*/
|
|
||||||
private BigDecimal unitPrice;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 运费
|
|
||||||
*/
|
|
||||||
private BigDecimal freight;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package com.ruoyi.common.core.domain.entity.test;
|
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.entity.mapper.ProductMapper;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品测试
|
|
||||||
* @author Geniou
|
|
||||||
* @create 2021/9/6 18:41
|
|
||||||
*/
|
|
||||||
public class ProductTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ProductMapper productMapper;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.ruoyi.common.core.domain.entity.test.dao.impl;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.dao.base.ProductCategoryBaseDao;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.dao.intf.ProductCategoryDao;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProductCategoryDaoImpl: 数据操作接口实现
|
||||||
|
*
|
||||||
|
* 这只是一个减少手工创建的模板文件
|
||||||
|
* 可以任意添加方法和实现, 更改作者和重定义类名
|
||||||
|
* <p/>@author Powered By Fluent Mybatis
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
public class ProductCategoryDaoImpl extends ProductCategoryBaseDao implements ProductCategoryDao {
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.ruoyi.common.core.domain.entity.test.dao.impl;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.dao.base.ProductCategoryRelationBaseDao;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.dao.intf.ProductCategoryRelationDao;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProductCategoryRelationDaoImpl: 数据操作接口实现
|
||||||
|
*
|
||||||
|
* 这只是一个减少手工创建的模板文件
|
||||||
|
* 可以任意添加方法和实现, 更改作者和重定义类名
|
||||||
|
* <p/>@author Powered By Fluent Mybatis
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
public class ProductCategoryRelationDaoImpl extends ProductCategoryRelationBaseDao implements ProductCategoryRelationDao {
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.ruoyi.common.core.domain.entity.test.dao.impl;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.dao.base.ProductBaseDao;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.dao.intf.ProductDao;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProductDaoImpl: 数据操作接口实现
|
||||||
|
*
|
||||||
|
* 这只是一个减少手工创建的模板文件
|
||||||
|
* 可以任意添加方法和实现, 更改作者和重定义类名
|
||||||
|
* <p/>@author Powered By Fluent Mybatis
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
public class ProductDaoImpl extends ProductBaseDao implements ProductDao {
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.ruoyi.common.core.domain.entity.test.dao.impl;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.dao.base.ProductInventoryBaseDao;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.dao.intf.ProductInventoryDao;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProductInventoryDaoImpl: 数据操作接口实现
|
||||||
|
*
|
||||||
|
* 这只是一个减少手工创建的模板文件
|
||||||
|
* 可以任意添加方法和实现, 更改作者和重定义类名
|
||||||
|
* <p/>@author Powered By Fluent Mybatis
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
public class ProductInventoryDaoImpl extends ProductInventoryBaseDao implements ProductInventoryDao {
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.ruoyi.common.core.domain.entity.test.dao.intf;
|
||||||
|
|
||||||
|
import cn.org.atool.fluent.mybatis.base.IBaseDao;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.entity.ProductCategory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProductCategoryDao: 数据操作接口
|
||||||
|
*
|
||||||
|
* 这只是一个减少手工创建的模板文件
|
||||||
|
* 可以任意添加方法和实现, 更改作者和重定义类名
|
||||||
|
* <p/>@author Powered By Fluent Mybatis
|
||||||
|
*/
|
||||||
|
public interface ProductCategoryDao extends IBaseDao<ProductCategory> {
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.ruoyi.common.core.domain.entity.test.dao.intf;
|
||||||
|
|
||||||
|
import cn.org.atool.fluent.mybatis.base.IBaseDao;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.entity.ProductCategoryRelation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProductCategoryRelationDao: 数据操作接口
|
||||||
|
*
|
||||||
|
* 这只是一个减少手工创建的模板文件
|
||||||
|
* 可以任意添加方法和实现, 更改作者和重定义类名
|
||||||
|
* <p/>@author Powered By Fluent Mybatis
|
||||||
|
*/
|
||||||
|
public interface ProductCategoryRelationDao extends IBaseDao<ProductCategoryRelation> {
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.ruoyi.common.core.domain.entity.test.dao.intf;
|
||||||
|
|
||||||
|
import cn.org.atool.fluent.mybatis.base.IBaseDao;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.entity.Product;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProductDao: 数据操作接口
|
||||||
|
*
|
||||||
|
* 这只是一个减少手工创建的模板文件
|
||||||
|
* 可以任意添加方法和实现, 更改作者和重定义类名
|
||||||
|
* <p/>@author Powered By Fluent Mybatis
|
||||||
|
*/
|
||||||
|
public interface ProductDao extends IBaseDao<Product> {
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.ruoyi.common.core.domain.entity.test.dao.intf;
|
||||||
|
|
||||||
|
import cn.org.atool.fluent.mybatis.base.IBaseDao;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.entity.ProductInventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProductInventoryDao: 数据操作接口
|
||||||
|
*
|
||||||
|
* 这只是一个减少手工创建的模板文件
|
||||||
|
* 可以任意添加方法和实现, 更改作者和重定义类名
|
||||||
|
* <p/>@author Powered By Fluent Mybatis
|
||||||
|
*/
|
||||||
|
public interface ProductInventoryDao extends IBaseDao<ProductInventory> {
|
||||||
|
}
|
|
@ -0,0 +1,128 @@
|
||||||
|
package com.ruoyi.common.core.domain.entity.test.entity;
|
||||||
|
|
||||||
|
import cn.org.atool.fluent.mybatis.annotation.FluentMybatis;
|
||||||
|
import cn.org.atool.fluent.mybatis.annotation.RefMethod;
|
||||||
|
import cn.org.atool.fluent.mybatis.annotation.TableField;
|
||||||
|
import cn.org.atool.fluent.mybatis.annotation.TableId;
|
||||||
|
import cn.org.atool.fluent.mybatis.base.IEntity;
|
||||||
|
import cn.org.atool.fluent.mybatis.base.RichEntity;
|
||||||
|
import cn.org.atool.fluent.mybatis.functions.TableSupplier;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.lang.Class;
|
||||||
|
import java.lang.Long;
|
||||||
|
import java.lang.Override;
|
||||||
|
import java.lang.String;
|
||||||
|
import java.lang.SuppressWarnings;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Product: 数据映射实体定义
|
||||||
|
*
|
||||||
|
* @author Powered By Fluent Mybatis
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({"unchecked"})
|
||||||
|
@Data
|
||||||
|
@Accessors(
|
||||||
|
chain = true
|
||||||
|
)
|
||||||
|
@EqualsAndHashCode(
|
||||||
|
callSuper = false
|
||||||
|
)
|
||||||
|
@FluentMybatis(
|
||||||
|
table = "product",
|
||||||
|
schema = "ruoyi",
|
||||||
|
suffix = ""
|
||||||
|
)
|
||||||
|
public class Product extends RichEntity {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId("id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(
|
||||||
|
value = "create_date_time",
|
||||||
|
insert = "now()"
|
||||||
|
)
|
||||||
|
private Date createDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@TableField(
|
||||||
|
value = "update_date_time",
|
||||||
|
insert = "now()",
|
||||||
|
update = "now()"
|
||||||
|
)
|
||||||
|
private Date updateDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运费
|
||||||
|
*/
|
||||||
|
@TableField("freight")
|
||||||
|
private BigDecimal freight;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品唯一编号
|
||||||
|
*/
|
||||||
|
@TableField("product_code")
|
||||||
|
private String productCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品名称
|
||||||
|
*/
|
||||||
|
@TableField("product_name")
|
||||||
|
private String productName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单价
|
||||||
|
*/
|
||||||
|
@TableField("unit_price")
|
||||||
|
private BigDecimal unitPrice;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Serializable findPk() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final Class<? extends IEntity> entityClass() {
|
||||||
|
return Product.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final Product changeTableBelongTo(TableSupplier supplier) {
|
||||||
|
return super.changeTableBelongTo(supplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final Product changeTableBelongTo(String table) {
|
||||||
|
return super.changeTableBelongTo(table);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实现定义在{@link cn.org.atool.fluent.mybatis.base.IRefs}子类Refs上
|
||||||
|
*/
|
||||||
|
@RefMethod
|
||||||
|
public List<ProductCategory> findProductCategoryList() {
|
||||||
|
return super.invoke("findProductCategoryList", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实现定义在{@link cn.org.atool.fluent.mybatis.base.IRefs}子类Refs上
|
||||||
|
*/
|
||||||
|
@RefMethod("productId = id")
|
||||||
|
public List<ProductInventory> findProductInventoryList() {
|
||||||
|
return super.invoke("findProductInventoryList", true);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,148 @@
|
||||||
|
package com.ruoyi.common.core.domain.entity.test.entity;
|
||||||
|
|
||||||
|
import cn.org.atool.fluent.mybatis.annotation.FluentMybatis;
|
||||||
|
import cn.org.atool.fluent.mybatis.annotation.RefMethod;
|
||||||
|
import cn.org.atool.fluent.mybatis.annotation.TableField;
|
||||||
|
import cn.org.atool.fluent.mybatis.annotation.TableId;
|
||||||
|
import cn.org.atool.fluent.mybatis.base.IEntity;
|
||||||
|
import cn.org.atool.fluent.mybatis.base.RichEntity;
|
||||||
|
import cn.org.atool.fluent.mybatis.functions.TableSupplier;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.lang.Class;
|
||||||
|
import java.lang.Integer;
|
||||||
|
import java.lang.Long;
|
||||||
|
import java.lang.Override;
|
||||||
|
import java.lang.String;
|
||||||
|
import java.lang.SuppressWarnings;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProductCategory: 数据映射实体定义
|
||||||
|
*
|
||||||
|
* @author Powered By Fluent Mybatis
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({"unchecked"})
|
||||||
|
@Data
|
||||||
|
@Accessors(
|
||||||
|
chain = true
|
||||||
|
)
|
||||||
|
@EqualsAndHashCode(
|
||||||
|
callSuper = false
|
||||||
|
)
|
||||||
|
@FluentMybatis(
|
||||||
|
table = "product_category",
|
||||||
|
schema = "ruoyi",
|
||||||
|
suffix = ""
|
||||||
|
)
|
||||||
|
public class ProductCategory extends RichEntity {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
@TableId("id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(
|
||||||
|
value = "create_date_time",
|
||||||
|
insert = "now()"
|
||||||
|
)
|
||||||
|
private Date createDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@TableField(
|
||||||
|
value = "update_date_time",
|
||||||
|
insert = "now()",
|
||||||
|
update = "now()"
|
||||||
|
)
|
||||||
|
private Date updateDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分类名称
|
||||||
|
*/
|
||||||
|
@TableField("category_name")
|
||||||
|
private String categoryName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分类类型(Title-标题,Value-值)
|
||||||
|
*/
|
||||||
|
@TableField("category_type")
|
||||||
|
private String categoryType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 层级
|
||||||
|
*/
|
||||||
|
@TableField("level_no")
|
||||||
|
private Integer levelNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父级分类主键
|
||||||
|
*/
|
||||||
|
@TableField("parent_id")
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序号
|
||||||
|
*/
|
||||||
|
@TableField("sort_num")
|
||||||
|
private Integer sortNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分类状态(Enable-启用,Disable-禁用,Delete-删除)
|
||||||
|
*/
|
||||||
|
@TableField("status_type")
|
||||||
|
private String statusType;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Serializable findPk() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final Class<? extends IEntity> entityClass() {
|
||||||
|
return ProductCategory.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final ProductCategory changeTableBelongTo(TableSupplier supplier) {
|
||||||
|
return super.changeTableBelongTo(supplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final ProductCategory changeTableBelongTo(String table) {
|
||||||
|
return super.changeTableBelongTo(table);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实现定义在{@link cn.org.atool.fluent.mybatis.base.IRefs}子类Refs上
|
||||||
|
*/
|
||||||
|
@RefMethod
|
||||||
|
public List<Product> findProductList() {
|
||||||
|
return super.invoke("findProductList", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实现定义在{@link cn.org.atool.fluent.mybatis.base.IRefs}子类Refs上
|
||||||
|
*/
|
||||||
|
@RefMethod("parentId = id")
|
||||||
|
public List<ProductCategory> findProductCategoryList() {
|
||||||
|
return super.invoke("findProductCategoryList", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实现定义在{@link cn.org.atool.fluent.mybatis.base.IRefs}子类Refs上
|
||||||
|
*/
|
||||||
|
@RefMethod("id = parentId")
|
||||||
|
public ProductCategory findProductCategory() {
|
||||||
|
return super.invoke("findProductCategory", true);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
package com.ruoyi.common.core.domain.entity.test.entity;
|
||||||
|
|
||||||
|
import cn.org.atool.fluent.mybatis.annotation.FluentMybatis;
|
||||||
|
import cn.org.atool.fluent.mybatis.annotation.TableField;
|
||||||
|
import cn.org.atool.fluent.mybatis.base.IEntity;
|
||||||
|
import cn.org.atool.fluent.mybatis.base.RichEntity;
|
||||||
|
import cn.org.atool.fluent.mybatis.functions.TableSupplier;
|
||||||
|
import java.lang.Class;
|
||||||
|
import java.lang.Long;
|
||||||
|
import java.lang.Override;
|
||||||
|
import java.lang.String;
|
||||||
|
import java.lang.SuppressWarnings;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProductCategoryRelation: 数据映射实体定义
|
||||||
|
*
|
||||||
|
* @author Powered By Fluent Mybatis
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({"unchecked"})
|
||||||
|
@Data
|
||||||
|
@Accessors(
|
||||||
|
chain = true
|
||||||
|
)
|
||||||
|
@EqualsAndHashCode(
|
||||||
|
callSuper = false
|
||||||
|
)
|
||||||
|
@FluentMybatis(
|
||||||
|
table = "product_category_relation",
|
||||||
|
schema = "ruoyi",
|
||||||
|
suffix = ""
|
||||||
|
)
|
||||||
|
public class ProductCategoryRelation extends RichEntity {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品分类主键
|
||||||
|
*/
|
||||||
|
@TableField("product_category_id")
|
||||||
|
private Long productCategoryId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品主键
|
||||||
|
*/
|
||||||
|
@TableField("product_id")
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final Class<? extends IEntity> entityClass() {
|
||||||
|
return ProductCategoryRelation.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final ProductCategoryRelation changeTableBelongTo(TableSupplier supplier) {
|
||||||
|
return super.changeTableBelongTo(supplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final ProductCategoryRelation changeTableBelongTo(String table) {
|
||||||
|
return super.changeTableBelongTo(table);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,105 @@
|
||||||
|
package com.ruoyi.common.core.domain.entity.test.entity;
|
||||||
|
|
||||||
|
import cn.org.atool.fluent.mybatis.annotation.FluentMybatis;
|
||||||
|
import cn.org.atool.fluent.mybatis.annotation.RefMethod;
|
||||||
|
import cn.org.atool.fluent.mybatis.annotation.TableField;
|
||||||
|
import cn.org.atool.fluent.mybatis.annotation.TableId;
|
||||||
|
import cn.org.atool.fluent.mybatis.annotation.Version;
|
||||||
|
import cn.org.atool.fluent.mybatis.base.IEntity;
|
||||||
|
import cn.org.atool.fluent.mybatis.base.RichEntity;
|
||||||
|
import cn.org.atool.fluent.mybatis.functions.TableSupplier;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.lang.Class;
|
||||||
|
import java.lang.Integer;
|
||||||
|
import java.lang.Long;
|
||||||
|
import java.lang.Override;
|
||||||
|
import java.lang.String;
|
||||||
|
import java.lang.SuppressWarnings;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProductInventory: 数据映射实体定义
|
||||||
|
*
|
||||||
|
* @author Powered By Fluent Mybatis
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({"unchecked"})
|
||||||
|
@Data
|
||||||
|
@Accessors(
|
||||||
|
chain = true
|
||||||
|
)
|
||||||
|
@EqualsAndHashCode(
|
||||||
|
callSuper = false
|
||||||
|
)
|
||||||
|
@FluentMybatis(
|
||||||
|
table = "product_inventory",
|
||||||
|
schema = "ruoyi",
|
||||||
|
suffix = ""
|
||||||
|
)
|
||||||
|
public class ProductInventory extends RichEntity {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
@TableId("id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 库存数量
|
||||||
|
*/
|
||||||
|
@TableField("inventory_quantity")
|
||||||
|
private Integer inventoryQuantity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 乐观锁
|
||||||
|
*/
|
||||||
|
@TableField(
|
||||||
|
value = "lock_version",
|
||||||
|
insert = "0",
|
||||||
|
update = "`lock_version` + 1"
|
||||||
|
)
|
||||||
|
@Version
|
||||||
|
private Long lockVersion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品主键
|
||||||
|
*/
|
||||||
|
@TableField("product_id")
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 库存状态(Enable-在售,Disable-停售,Delete-删除)
|
||||||
|
*/
|
||||||
|
@TableField("status_type")
|
||||||
|
private String statusType;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Serializable findPk() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final Class<? extends IEntity> entityClass() {
|
||||||
|
return ProductInventory.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final ProductInventory changeTableBelongTo(TableSupplier supplier) {
|
||||||
|
return super.changeTableBelongTo(supplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final ProductInventory changeTableBelongTo(String table) {
|
||||||
|
return super.changeTableBelongTo(table);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实现定义在{@link cn.org.atool.fluent.mybatis.base.IRefs}子类Refs上
|
||||||
|
*/
|
||||||
|
@RefMethod("id = productId")
|
||||||
|
public Product findProduct() {
|
||||||
|
return super.invoke("findProduct", true);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.ruoyi.common.core.domain.entity.test.relation;
|
||||||
|
|
||||||
|
import cn.org.atool.fluent.mybatis.refs.IEntityRelation;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.entity.Product;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.entity.ProductCategory;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.wrapper.ProductCategoryQuery;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.wrapper.ProductCategoryRelationQuery;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.wrapper.ProductQuery;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品与分类关联关系实现
|
||||||
|
* @author Geniou
|
||||||
|
* @create 2021/9/13 19:08
|
||||||
|
*/
|
||||||
|
public class ProductCategoryRelationEntity implements IEntityRelation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link Product#findProductCategoryList}
|
||||||
|
* @param entity
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<ProductCategory> findProductCategoryListOfProduct(Product entity) {
|
||||||
|
return ProductCategoryQuery.defaultQuery()
|
||||||
|
.where.id().in(
|
||||||
|
ProductCategoryRelationQuery.defaultQuery()
|
||||||
|
.select.productCategoryId().end()
|
||||||
|
.where.productId().eq(entity.getId())
|
||||||
|
.end()
|
||||||
|
).end()
|
||||||
|
.to().listEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link ProductCategory#findProductList}
|
||||||
|
* @param entity
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Product> findProductListOfProductCategory(ProductCategory entity) {
|
||||||
|
return ProductQuery.defaultQuery()
|
||||||
|
.where.id().in(
|
||||||
|
ProductCategoryRelationQuery.defaultQuery()
|
||||||
|
.select.productId().end()
|
||||||
|
.where.productCategoryId().eq(entity.getId())
|
||||||
|
.end()
|
||||||
|
).end()
|
||||||
|
.to().listEntity();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.ruoyi.common;
|
||||||
|
|
||||||
|
import cn.org.atool.generator.FileGenerator;
|
||||||
|
import cn.org.atool.generator.annotation.Relation;
|
||||||
|
import cn.org.atool.generator.annotation.RelationType;
|
||||||
|
import cn.org.atool.generator.annotation.Table;
|
||||||
|
import cn.org.atool.generator.annotation.Tables;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代码生成测试
|
||||||
|
* @author Geniou
|
||||||
|
* @create 2021/9/9 12:17
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class GeneratorTest {
|
||||||
|
|
||||||
|
static final String url =
|
||||||
|
"jdbc:mysql://localhost:3306/ruoyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true";
|
||||||
|
static final String basePackage = "com.ruoyi.common.core.domain.entity.test";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void contextLoads() {
|
||||||
|
FileGenerator.build(RelationMTM.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Tables(
|
||||||
|
url = url, username = "root", password = "123456",
|
||||||
|
basePack = basePackage,
|
||||||
|
srcDir = "src\\main\\java\\",
|
||||||
|
tables = {@Table(value = {"product", "product_category", "product_category_relation"}),
|
||||||
|
@Table(value = {"product_inventory"}, version = "lock_version")},
|
||||||
|
gmtCreated = "create_date_time", gmtModified = "update_date_time",
|
||||||
|
relations = {
|
||||||
|
@Relation(source = "product", target = "product_category", type = RelationType.TwoWay_N_N),
|
||||||
|
@Relation(source = "product_category", target = "product_category", type = RelationType.TwoWay_1_N,
|
||||||
|
where = "id = parent_id"),
|
||||||
|
@Relation(source = "product", target = "product_inventory", type = RelationType.TwoWay_1_N,
|
||||||
|
where = "id = product_id")
|
||||||
|
},
|
||||||
|
entitySuffix = ""
|
||||||
|
)
|
||||||
|
static class RelationMTM{}
|
||||||
|
|
||||||
|
}
|
|
@ -1,18 +1,39 @@
|
||||||
package com.ruoyi.demo.controller;
|
package com.ruoyi.demo.controller;
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.entity.mapper.ProductMapper;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.ruoyi.common.core.domain.entity.test.Product;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
import cn.hutool.json.JSONArray;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import cn.org.atool.fluent.mybatis.base.model.FieldType;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.entity.Product;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.entity.ProductCategory;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.entity.ProductCategoryRelation;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.helper.ProductCategoryRelationWrapperHelper;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.helper.ProductWrapperHelper;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.mapper.ProductCategoryMapper;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.mapper.ProductCategoryRelationMapper;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.mapper.ProductMapper;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.wrapper.ProductCategoryRelationQuery;
|
||||||
|
import com.ruoyi.common.core.domain.entity.test.wrapper.ProductQuery;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品测试控制
|
* 商品测试控制
|
||||||
|
@ -23,26 +44,225 @@ import java.util.Date;
|
||||||
@Api(value = "商品测试控制方法", tags = {"商品测试控制方法"})
|
@Api(value = "商品测试控制方法", tags = {"商品测试控制方法"})
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/demo/product")
|
@RequestMapping("/demo/product")
|
||||||
public class ProductTestController {
|
public class ProductTestController extends BaseController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProductMapper productMapper;
|
private ProductMapper productMapper;
|
||||||
|
@Autowired
|
||||||
|
private ProductCategoryMapper productCategoryMapper;
|
||||||
|
@Autowired
|
||||||
|
private ProductCategoryRelationMapper productCategoryRelationMapper;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询测试树表列表
|
* 测试插入
|
||||||
*/
|
*/
|
||||||
@ApiOperation("测试语句")
|
@ApiOperation("测试插入商品")
|
||||||
@GetMapping("/mapperTest")
|
@PostMapping("/insertProduct")
|
||||||
public void list() {
|
public AjaxResult<Long> insertProduct() {
|
||||||
Product product = new Product();
|
Product product = new Product();
|
||||||
product.setProductCode("M10001");
|
|
||||||
product.setProductName("测试商品");
|
String productCode = "P" + RandomUtil.randomNumbers(12);
|
||||||
product.setUnitPrice(BigDecimal.valueOf(2.5));
|
product.setProductCode(productCode);
|
||||||
product.setFreight(BigDecimal.valueOf(1.5));
|
product.setProductName("海口一年级语文");
|
||||||
product.setCreateDateTime(new Date());
|
product.setUnitPrice(BigDecimal.valueOf(12.5));
|
||||||
product.setUpdateDateTime(new Date());
|
product.setFreight(BigDecimal.valueOf(8));
|
||||||
productMapper.insert(product);
|
productMapper.insert(product);
|
||||||
|
|
||||||
|
List<Long> ids = new ArrayList<>();
|
||||||
|
ids.add(7l);
|
||||||
|
ids.add(22l);
|
||||||
|
ids.add(29l);
|
||||||
|
// 查出所有需要关联的商品分类
|
||||||
|
List<ProductCategory> categoryList = productCategoryMapper.listByIds(ids);
|
||||||
|
|
||||||
|
Long productId = product.getId();
|
||||||
|
|
||||||
|
// 遍历商品分类集合,每次创建一条商品与分类关联关系的实体
|
||||||
|
List<ProductCategoryRelation> relations = new ArrayList<>();
|
||||||
|
for (ProductCategory productCategory : categoryList) {
|
||||||
|
ProductCategoryRelation relation = new ProductCategoryRelation();
|
||||||
|
relation.setProductId(productId);
|
||||||
|
relation.setProductCategoryId(productCategory.getId());
|
||||||
|
relations.add(relation);
|
||||||
|
}
|
||||||
|
// 保存中间表
|
||||||
|
productCategoryRelationMapper.insertBatch(relations);
|
||||||
|
return AjaxResult.success(productId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试插入
|
||||||
|
*/
|
||||||
|
@ApiOperation("测试插入商品库存")
|
||||||
|
@PostMapping("/insertProductInventory")
|
||||||
|
public void insertProductInventory() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("测试插入商品分类")
|
||||||
|
@PostMapping("/insertProductCategory")
|
||||||
|
public AjaxResult<Void> insertProductCategory() {
|
||||||
|
List<ProductCategory> categories = new ArrayList<>();
|
||||||
|
|
||||||
|
ProductCategory productCategory = new ProductCategory();
|
||||||
|
productCategory.setCategoryName("适用阶段");
|
||||||
|
productCategory.setCategoryType("Title");
|
||||||
|
productCategory.setLevelNo(1);
|
||||||
|
productCategory.setSortNum(1);
|
||||||
|
categories.add(productCategory);
|
||||||
|
|
||||||
|
ProductCategory productCategory1 = new ProductCategory();
|
||||||
|
productCategory1.setCategoryName("适用区域");
|
||||||
|
productCategory1.setCategoryType("Title");
|
||||||
|
productCategory1.setLevelNo(1);
|
||||||
|
productCategory1.setSortNum(2);
|
||||||
|
categories.add(productCategory1);
|
||||||
|
|
||||||
|
ProductCategory productCategory2 = new ProductCategory();
|
||||||
|
productCategory2.setCategoryName("教辅类型");
|
||||||
|
productCategory2.setCategoryType("Title");
|
||||||
|
productCategory2.setLevelNo(1);
|
||||||
|
productCategory2.setSortNum(3);
|
||||||
|
categories.add(productCategory2);
|
||||||
|
|
||||||
|
return toAjax(productCategoryMapper.insertBatch(categories));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("测试插入商品分类(根据父级)")
|
||||||
|
@PostMapping("/insertProductCategoryByParent")
|
||||||
|
public AjaxResult<Void> insertProductCategoryByParent(@Validated ProductCategory productCategory) {
|
||||||
|
return toAjax(productCategoryMapper.insert(productCategory));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("根据分类查询")
|
||||||
|
@GetMapping("/queryByCategory")
|
||||||
|
public AjaxResult<JSONArray> queryByCategory(@Validated String categoryIdsString) {
|
||||||
|
String[] categoryIds = categoryIdsString.split(",");
|
||||||
|
|
||||||
|
ProductQuery productQuery = productMapper.query();
|
||||||
|
ProductWrapperHelper.QueryWhere queryWhere = productQuery.where;
|
||||||
|
|
||||||
|
for (String categoryId : categoryIds) {
|
||||||
|
queryWhere.exists(productCategoryRelationMapper.query().where.productId().apply("= product.id").productCategoryId()
|
||||||
|
.eq(Long.parseLong(categoryId)).end());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Product> products = productMapper.listEntity(queryWhere.end());
|
||||||
|
return AjaxResult.success(JSONUtil.parseArray(products));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("查询商品所属分类")
|
||||||
|
@GetMapping("/queryProductBelongCategory")
|
||||||
|
public AjaxResult<JSONArray> queryProductBelongCategory(@Validated Long productId) {
|
||||||
|
Product product = productMapper.findById(productId);
|
||||||
|
List<ProductCategory> productCategoryList = product.findProductCategoryList();
|
||||||
|
return AjaxResult.success(JSONUtil.parseArray(productCategoryList));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("查询分类树")
|
||||||
|
@GetMapping("/queryCategoryTree")
|
||||||
|
public AjaxResult<JSONObject> queryCategoryTree(@Validated Long productCategoryId) {
|
||||||
|
ProductCategory productCategory = productCategoryMapper.findById(productCategoryId);
|
||||||
|
JSONObject respBody = buildCategory(productCategory);
|
||||||
|
return AjaxResult.success(respBody);
|
||||||
|
}
|
||||||
|
|
||||||
|
private JSONObject buildCategory(ProductCategory productCategory) {
|
||||||
|
JSONObject categoryJSON = new JSONObject();
|
||||||
|
Long id = productCategory.getId();
|
||||||
|
Integer levelNo = productCategory.getLevelNo();
|
||||||
|
Long parentId = productCategory.getParentId();
|
||||||
|
String categoryName = productCategory.getCategoryName();
|
||||||
|
String categoryType = productCategory.getCategoryType();
|
||||||
|
|
||||||
|
categoryJSON.set("id", id);
|
||||||
|
categoryJSON.set("parentId", parentId);
|
||||||
|
categoryJSON.set("levelNo", levelNo);
|
||||||
|
categoryJSON.set("categoryName", categoryName);
|
||||||
|
categoryJSON.set("categoryType", categoryType);
|
||||||
|
|
||||||
|
List<ProductCategory> childList = productCategory.findProductCategoryList();
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(childList)) {
|
||||||
|
JSONArray childArray = new JSONArray();
|
||||||
|
|
||||||
|
for (ProductCategory childCategory : childList) {
|
||||||
|
JSONObject childJSON = buildCategory(childCategory);
|
||||||
|
childArray.add(childJSON);
|
||||||
|
}
|
||||||
|
categoryJSON.set("child", childArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
return categoryJSON;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试查询
|
||||||
|
*/
|
||||||
|
@ApiOperation("测试查询")
|
||||||
|
@GetMapping("/queryTest")
|
||||||
|
public AjaxResult<Product> query(@Validated Product bo) {
|
||||||
|
Product product = productMapper.findById(bo.getId());
|
||||||
|
return new AjaxResult<Product>().setData(product);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试查询2(根据实体类字段)
|
||||||
|
*/
|
||||||
|
@ApiOperation("测试查询2")
|
||||||
|
@GetMapping("/query2Test")
|
||||||
|
public AjaxResult<List<Product>> query2(@Validated Product bo) {
|
||||||
|
ProductQuery productQuery = productMapper.query().where.eqByEntity(bo).end();
|
||||||
|
List<Product> products = productMapper.listEntity(productQuery);
|
||||||
|
log.info("query2 rows = {}", CollUtil.size(products));
|
||||||
|
return new AjaxResult<List<Product>>().setData(products);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试删除
|
||||||
|
*/
|
||||||
|
@ApiOperation("测试删除")
|
||||||
|
@DeleteMapping("/deleteTest")
|
||||||
|
public AjaxResult<Void> delete(@Validated Product bo) {
|
||||||
|
return toAjax(productMapper.deleteById(bo.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试删除2
|
||||||
|
*/
|
||||||
|
@ApiOperation("测试删除2(根据相关参数)")
|
||||||
|
@DeleteMapping("/delete2Test")
|
||||||
|
public AjaxResult<Void> delete2(@Validated Product bo) {
|
||||||
|
ProductQuery productQuery = productMapper.query().where.eqByEntity(bo).end();
|
||||||
|
int row = productMapper.delete(productQuery);
|
||||||
|
return toAjax(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// static final String url =
|
||||||
|
// "jdbc:mysql://localhost:3306/ruoyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull
|
||||||
|
// &useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true";
|
||||||
|
// static final String basePackage = "com.ruoyi.common.core.domain.entity.test";
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 测试删除2
|
||||||
|
// */
|
||||||
|
// @ApiOperation("生成测试")
|
||||||
|
// @DeleteMapping("/generatorTest")
|
||||||
|
// public AjaxResult<Void> generatorTest() {
|
||||||
|
// FileGenerator.build(Noting.class);
|
||||||
|
// return toAjax(true);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Tables(
|
||||||
|
// url = url, username = "root", password = "123456",
|
||||||
|
// basePack = basePackage,
|
||||||
|
// srcDir = "src/main/java/com/ruoyi/common/core/domain/entity/test",
|
||||||
|
// tables = @Table(value = {"product_category", "product", "product_category_relation"})
|
||||||
|
// )
|
||||||
|
// static class Noting{}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?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">
|
||||||
|
<parent>
|
||||||
|
<artifactId>ruoyi-vue-plus</artifactId>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>ruoyi-mall</artifactId>
|
||||||
|
|
||||||
|
</project>
|
Loading…
Reference in New Issue