新增微服务,生成实体类

main
尚志豪123 2024-11-19 01:07:48 +08:00
parent 10b70d44e6
commit 3f99d7f82b
30 changed files with 759 additions and 24 deletions

View File

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.muyu</groupId>
<artifactId>muyu-modules</artifactId>
<version>3.6.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>muyu-goods</artifactId>
<description>
muyu-modules-goods系统模块
</description>
<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.dtflys.forest</groupId>
<artifactId>forest-spring-boot-starter</artifactId>
</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>

View File

@ -0,0 +1,22 @@
package com.muyu.goods;
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 MuYuGoodsApplication {
public static void main (String[] args) {
SpringApplication.run(MuYuGoodsApplication.class, args);
}
}

View File

@ -0,0 +1,22 @@
package com.muyu.goods.controller;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.goods.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
*
*
* @author muyu
*/
@RestController
@RequestMapping("/goods")
public class GoodsController extends BaseController {
@Autowired
private GoodsService configService;
}

View File

@ -0,0 +1,11 @@
package com.muyu.goods.domain;
/**
* @Author
* @Packagecom.muyu.goods.domain
* @Projectcloud-server
* @nameSysConfig
* @Date2024/11/18 16:57
*/
public class Goods {
}

View File

@ -0,0 +1,32 @@
package com.muyu.goods.forest.gaode.api.resp;
import com.alibaba.fastjson2.annotation.JSONField;
import lombok.Data;
import java.util.List;
@Data
public class District {
/** 名称 */
private String name;
/** 编码 */
@JSONField(name = "citycode")
private String code;
/** 级别 */
private String level;
/** 区域编码 */
@JSONField(name = "adcode")
private String areaCode;
/** 中心经纬度 */
private String center;
/**
*
*/
private List<District> districts;
}

View File

@ -0,0 +1,40 @@
package com.muyu.goods.forest.gaode.api.resp;
import com.alibaba.fastjson2.annotation.JSONField;
import lombok.Data;
import java.util.List;
/**
* @author DongZl
* @description:
* @Date 2024/4/11 2:31
*/
@Data
public class DistrictResult {
/**
*
* 0101
*/
private String status;
/**
*
* status0infoOK
*/
private String info;
/**
*
* 10000info
*/
@JSONField(name = "infocode")
private String infoCode;
/**
*
*/
private List<District> districts;
}

View File

@ -0,0 +1,13 @@
package com.muyu.goods.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.goods.domain.Goods;
/**
* @author DongZl
* @description: mybatis
* @Date 2023-11-13 10:05
*/
public interface GoodsMapper extends BaseMapper<Goods> {
}

View File

@ -0,0 +1,14 @@
package com.muyu.goods.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.goods.domain.Goods;
/**
* @author DongZl
* @description: plus
* @Date 2023-11-13 10:06
*/
public interface GoodsService extends IService<Goods> {
}

View File

@ -0,0 +1,21 @@
package com.muyu.goods.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.goods.domain.Goods;
import com.muyu.goods.mapper.GoodsMapper;
import com.muyu.goods.service.GoodsService;
import org.springframework.stereotype.Service;
/**
* @author DongZl
* @description: plus
* @Date 2023-11-13 10:06
*/
@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {
}

View File

@ -0,0 +1,2 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}

View File

@ -0,0 +1,30 @@
# Tomcat
server:
port: 9204
# Spring
spring:
application:
# 应用名称
name: muyu-goods
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 150.158.86.96:8848
namespace: 2204a
config:
# 配置中心地址
server-addr: 150.158.86.96:8848
namespace: 2204a
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
logging:
level:
com.muyu.goods.mapper: DEBUG

View File

@ -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-goods"/>
<!-- 日志输出格式 -->
<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>

View File

@ -0,0 +1,9 @@
<?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.goods.mapper.SysConfigMapper">
</mapper>

View File

@ -91,6 +91,7 @@ public class ProjectInfo extends BaseEntity {
@ApiModelProperty(name = "品牌", value = "品牌") @ApiModelProperty(name = "品牌", value = "品牌")
private Long brandId; private Long brandId;
/** /**
* *
*/ */

View File

@ -0,0 +1,100 @@
package com.muyu.product.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.List;
/**
* @Author
* @Packagecom.muyu.product.domain
* @Projectcloud-server
* @nameProjectUpdInfo
* @Date2024/11/17 14:31
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("project_info")
@EqualsAndHashCode()
@ApiModel(value = "ProjectInfo", description = "商品信息")
public class ProjectUpdInfo 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 = "商品名称")
private String name;
/** 商品描述 */
@Excel(name = "商品描述")
@ApiModelProperty(name = "商品描述", value = "商品描述")
private String introduction;
/** 主类型 */
@Excel(name = "主类型")
@ApiModelProperty(name = "主类型", value = "主类型")
private Long mianType;
/** 父类型 */
@Excel(name = "父类型")
@ApiModelProperty(name = "父类型", value = "父类型")
private Long parentType;
/** 商品类型 */
@Excel(name = "商品类型")
@ApiModelProperty(name = "商品类型", value = "商品类型")
private Long type;
/** 商品图片 */
@Excel(name = "商品图片")
@ApiModelProperty(name = "商品图片", value = "商品图片")
private String image;
/** 商品轮播图 */
@Excel(name = "商品轮播图")
@ApiModelProperty(name = "商品轮播图", value = "商品轮播图")
private String carouselImages;
/** 商品状态 */
@Excel(name = "商品状态")
@ApiModelProperty(name = "商品状态", value = "商品状态")
private String status;
/** 规格 */
@Excel(name = "规格")
@ApiModelProperty(name = "规格", value = "规格")
private Long ruleId;
/** 品牌 */
@Excel(name = "品牌")
@ApiModelProperty(name = "品牌", value = "品牌")
private Long brandId;
/**
*
*/
private List<AttributeInfo> attrValueList;
private List<CategoryInfo> categoryInfoList;
private List<RuleInfo> ruleInfoList;
}

View File

@ -1,8 +1,13 @@
package com.muyu.product.domain.resp; package com.muyu.product.domain.resp;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.muyu.common.core.annotation.Excel;
import com.muyu.product.domain.AttributeGroup; import com.muyu.product.domain.AttributeGroup;
import com.muyu.product.domain.AttributeInfo; import com.muyu.product.domain.AttributeInfo;
import com.muyu.product.domain.BrandInfo; import com.muyu.product.domain.BrandInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
@ -21,6 +26,42 @@ import java.util.List;
@AllArgsConstructor @AllArgsConstructor
public class CategoryParentCommonElementResp { public class CategoryParentCommonElementResp {
/**
*
*/
@TableId(value = "id",type = IdType.AUTO)
@ApiModelProperty(name = "主表",value = "主键")
private Long id;
/**
*
*/
@Excel(name = "品类名称")
@ApiModelProperty(name = "品类名称", value = "品类名称", required = true)
private String name;
/**
*
*/
@Excel(name = "图片")
@ApiModelProperty(name = "图片", value = "图片", required = true)
private String image;
/**
*
*/
@Excel(name = "是否启用")
@ApiModelProperty(name = "是否启用", value = "是否启用", required = true)
private String start;
/**
*
*/
@Excel(name = "介绍")
@ApiModelProperty(name = "介绍",value = "介绍")
private String introduction;
private Long parentId;
/** /**
* *
*/ */

View File

@ -37,6 +37,8 @@ public class RuleInfoResp extends BaseEntity {
*/ */
private List<RuleAttrAddModel> ruleAttrList; private List<RuleAttrAddModel> ruleAttrList;
private Integer state = 0;
public static RuleInfoResp infoBuild (RuleInfo ruleInfo, Function<Long, List<RuleAttrAddModel>> ruleAttrList) { public static RuleInfoResp infoBuild (RuleInfo ruleInfo, Function<Long, List<RuleAttrAddModel>> ruleAttrList) {
return RuleInfoResp.builder() return RuleInfoResp.builder()
.id(ruleInfo.getId()) .id(ruleInfo.getId())

View File

@ -5,9 +5,7 @@ import java.util.function.Supplier;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.muyu.common.security.utils.SecurityUtils; import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.product.domain.AttributeGroup; import com.muyu.product.domain.*;
import com.muyu.product.domain.AttributeInfo;
import com.muyu.product.domain.BrandInfo;
import com.muyu.product.domain.model.CategoryInfoSaveModel; import com.muyu.product.domain.model.CategoryInfoSaveModel;
import com.muyu.product.domain.req.CategoryInfoUpdEditReq; import com.muyu.product.domain.req.CategoryInfoUpdEditReq;
import com.muyu.product.domain.resp.CategoryCommonElementResp; import com.muyu.product.domain.resp.CategoryCommonElementResp;
@ -30,7 +28,6 @@ import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log; import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType; import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions; import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.product.domain.CategoryInfo;
import com.muyu.product.domain.req.CategoryInfoQueryReq; import com.muyu.product.domain.req.CategoryInfoQueryReq;
import com.muyu.product.domain.req.CategoryInfoSaveReq; import com.muyu.product.domain.req.CategoryInfoSaveReq;
import com.muyu.product.domain.req.CategoryInfoEditReq; import com.muyu.product.domain.req.CategoryInfoEditReq;
@ -80,8 +77,9 @@ public class CategoryInfoController extends BaseController {
@RequiresPermissions("product:category:query") @RequiresPermissions("product:category:query")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
public Result<CategoryInfo> getInfo(@PathVariable("id") Long id) { public Result<CategoryParentCommonElementResp> getInfo(@PathVariable("id") Long id) {
return Result.success(categoryInfoService.getById(id)); CategoryParentCommonElementResp categoryById = categoryInfoService.getCategoryById(id);
return Result.success(categoryById);
} }
/** /**
@ -143,8 +141,14 @@ public class CategoryInfoController extends BaseController {
System.out.println("否存在下一级:"+categoryInfo); System.out.println("否存在下一级:"+categoryInfo);
// 判断没有下一删除 // 判断没有下一删除
if (null == categoryInfo){ if (null == categoryInfo){
// 查询是否与商品有关
List<AsCategoryBrand> asCategoryBrand = categoryInfoService.InquireAboutGoods(ids);
// 判断有没有和商品有关
if(0 == asCategoryBrand.size()){
return toAjax(categoryInfoService.removeById(ids)); return toAjax(categoryInfoService.removeById(ids));
} }
return Result.error("与商品有关能进行删除");
}
return Result.error("含有子集不能进行删除"); return Result.error("含有子集不能进行删除");
} }

View File

@ -4,6 +4,7 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.muyu.product.cache.ProjectInfoCache; import com.muyu.product.cache.ProjectInfoCache;
import com.muyu.product.domain.ProjectUpdInfo;
import com.muyu.product.domain.resp.ProjectDetailResp; import com.muyu.product.domain.resp.ProjectDetailResp;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -76,8 +77,12 @@ public class ProjectInfoController extends BaseController {
@RequiresPermissions("product:info:query") @RequiresPermissions("product:info:query")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
public Result<ProjectInfo> getInfo(@PathVariable("id") Long id) { // public Result<ProjectInfo> getInfo(@PathVariable("id") Long id) {
return Result.success(projectInfoCache.get(id)); // return Result.success(projectInfoCache.get(id));
// }
public Result<ProjectUpdInfo> getInfo(@PathVariable("id") Long id) {
ProjectUpdInfo projectUpdInfo = projectInfoService.get(id);
return Result.success(projectUpdInfo);
} }
/** /**

View File

@ -56,6 +56,7 @@ public class RuleInfoController extends BaseController {
} }
TableDataInfo<RuleInfoResp> tableDataInfo = ruleInfoService.queryList(ruleInfoQueryReq); TableDataInfo<RuleInfoResp> tableDataInfo = ruleInfoService.queryList(ruleInfoQueryReq);
return isPage ? Result.success(tableDataInfo) : Result.success(tableDataInfo.getRows()); return isPage ? Result.success(tableDataInfo) : Result.success(tableDataInfo.getRows());
} }
/** /**

View File

@ -2,7 +2,7 @@ package com.muyu.product.mapper;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.product.domain.CategoryInfo; import com.muyu.product.domain.*;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
/** /**
@ -36,5 +36,32 @@ public interface CategoryInfoMapper extends BaseMapper<CategoryInfo> {
* @return * @return
*/ */
CategoryInfo QueryBelowOneLevel(@Param("ids") Long ids); CategoryInfo QueryBelowOneLevel(@Param("ids") Long ids);
/**
*
* @param ids
* @return
*/
List<AsCategoryBrand> InquireAboutGoods(@Param("ids") Long ids);
/**
*
* @param aLong
* @return
*/
AttributeInfo selectCateById(@Param("aLong") Long aLong);
/**
*
* @param aLong
* @return
*/
AttributeGroup selectGroup(@Param("aLong") Long aLong);
/**
*
* @param aLong
* @return
*/
BrandInfo seleteBrand(@Param("aLong") Long aLong);
} }

View File

@ -2,7 +2,9 @@ package com.muyu.product.mapper;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.product.domain.AttributeInfo;
import com.muyu.product.domain.ProjectInfo; import com.muyu.product.domain.ProjectInfo;
import org.apache.ibatis.annotations.Param;
/** /**
* Mapper * Mapper
@ -11,5 +13,10 @@ import com.muyu.product.domain.ProjectInfo;
* @date 2024-02-27 * @date 2024-02-27
*/ */
public interface ProjectInfoMapper extends BaseMapper<ProjectInfo> { public interface ProjectInfoMapper extends BaseMapper<ProjectInfo> {
/**
*
* @param aLong
* @return
*/
AttributeInfo selectProject(@Param("aLong") Long aLong);
} }

View File

@ -2,10 +2,7 @@ package com.muyu.product.service;
import java.util.List; import java.util.List;
import com.muyu.product.domain.AttributeGroup; import com.muyu.product.domain.*;
import com.muyu.product.domain.AttributeInfo;
import com.muyu.product.domain.BrandInfo;
import com.muyu.product.domain.CategoryInfo;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.product.domain.model.CategoryInfoSaveModel; import com.muyu.product.domain.model.CategoryInfoSaveModel;
import com.muyu.product.domain.resp.CategoryCommonElementResp; import com.muyu.product.domain.resp.CategoryCommonElementResp;
@ -94,4 +91,15 @@ public interface CategoryInfoService extends IService<CategoryInfo> {
* @return * @return
*/ */
CategoryInfo QueryBelowOneLevel(Long ids); CategoryInfo QueryBelowOneLevel(Long ids);
/**
*
* @param ids
* @return
*/
List<AsCategoryBrand> InquireAboutGoods(Long ids);
/**
*
*/
CategoryParentCommonElementResp getCategoryById(Long id);
} }

View File

@ -3,6 +3,7 @@ package com.muyu.product.service;
import java.util.List; import java.util.List;
import com.muyu.product.domain.ProjectInfo; import com.muyu.product.domain.ProjectInfo;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.product.domain.ProjectUpdInfo;
import com.muyu.product.domain.req.ProjectInfoSaveReq; import com.muyu.product.domain.req.ProjectInfoSaveReq;
import com.muyu.product.domain.resp.ProjectDetailResp; import com.muyu.product.domain.resp.ProjectDetailResp;
@ -34,4 +35,8 @@ public interface ProjectInfoService extends IService<ProjectInfo> {
* @return * @return
*/ */
ProjectDetailResp getDetailInfo (Long id); ProjectDetailResp getDetailInfo (Long id);
/**
*
*/
ProjectUpdInfo get(Long id);
} }

View File

@ -308,6 +308,65 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
return categoryInfoMapper.QueryBelowOneLevel(ids); return categoryInfoMapper.QueryBelowOneLevel(ids);
} }
/**
*
* @param ids
* @return
*/
@Override
public List<AsCategoryBrand> InquireAboutGoods(Long ids) {
return categoryInfoMapper.InquireAboutGoods(ids);
}
/**
*
*/
@Override
public CategoryParentCommonElementResp getCategoryById(Long id) {
//品类信息
CategoryInfo info = this.getById(id);
// 品类属性中间表
LambdaQueryWrapper<AsCategoryAttribute> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AsCategoryAttribute::getCategoryId,id);
List<AsCategoryAttribute> attributeList = asCategoryAttributeService.list(queryWrapper);
List<Long> longs = attributeList.stream().map(AsCategoryAttribute::getAttributeId).toList();
ArrayList<AttributeInfo> arrayList = new ArrayList<>();
for (Long aLong : longs) {
AttributeInfo attribute = categoryInfoMapper.selectCateById(aLong);
arrayList.add(attribute);
}
// 品类属性组中间表
LambdaQueryWrapper<AsCategoryAttributeGroup> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(AsCategoryAttributeGroup::getCategoryId,id);
List<AsCategoryAttributeGroup> list = asCategoryAttributeGroupService.list(wrapper);
List<Long> toList = list.stream().map(AsCategoryAttributeGroup::getAttributeGroupId).toList();
ArrayList<AttributeGroup> groupArrayList = new ArrayList<>();
for (Long aLong : toList) {
AttributeGroup attributeGroup = categoryInfoMapper.selectGroup(aLong);
groupArrayList.add(attributeGroup);
}
// 品类品牌中间表
LambdaQueryWrapper<AsCategoryBrand> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(AsCategoryBrand::getCategoryId,id);
List<AsCategoryBrand> asCategoryBrands = asCategoryBrandService.list(lambdaQueryWrapper);
List<Long> longList = asCategoryBrands.stream().map(AsCategoryBrand::getBrandId).toList();
ArrayList<BrandInfo> brandArrayList = new ArrayList<>();
for (Long aLong : longList) {
BrandInfo brands = categoryInfoMapper.seleteBrand(aLong);
brandArrayList.add(brands);
}
return CategoryParentCommonElementResp.builder()
.id(info.getId())
.name(info.getName())
.image(info.getImage())
.start(info.getStart())
.introduction(info.getIntroduction())
.parentId(info.getParentId())
.attributeInfoList(arrayList)
.attributeGroupList(groupArrayList)
.brandInfoList(brandArrayList)
.build();
}
/** /**
* ID * ID
* *

View File

@ -47,6 +47,8 @@ public class ProjectInfoServiceImpl extends ServiceImpl<ProjectInfoMapper, Proje
@Autowired @Autowired
private AttributeInfoService attributeInfoService; private AttributeInfoService attributeInfoService;
@Autowired
private ProjectInfoMapper projectInfoMapper;
/** /**
* *
@ -206,11 +208,9 @@ public class ProjectInfoServiceImpl extends ServiceImpl<ProjectInfoMapper, Proje
List<Long> attrIdList = productAttributeList.stream() List<Long> attrIdList = productAttributeList.stream()
.map(AsProductAttributeInfo::getAttributeId) .map(AsProductAttributeInfo::getAttributeId)
.toList(); .toList();
projectAttributeList = attributeInfoService.list( projectAttributeList = attributeInfoService.list(new LambdaQueryWrapper<>() {{
new LambdaQueryWrapper<>() {{
in(AttributeInfo::getId, attrIdList); in(AttributeInfo::getId, attrIdList);
}} }}).stream()
).stream()
.map(TemplateAttributeModel::attributeInfoBuild) .map(TemplateAttributeModel::attributeInfoBuild)
.toList(); .toList();
} }
@ -229,4 +229,41 @@ public class ProjectInfoServiceImpl extends ServiceImpl<ProjectInfoMapper, Proje
.attributeGroupList(templateAttributeGroupList) .attributeGroupList(templateAttributeGroupList)
.build(); .build();
} }
/**
*
*/
@Override
public ProjectUpdInfo get(Long id) {
// CategoryInfo;
// RuleInfo;
// 商品信息
ProjectInfo info = this.getById(id);
// 商品属性表中间表
LambdaQueryWrapper<AsProductAttributeInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AsProductAttributeInfo::getProductId,id);
List<AsProductAttributeInfo> attributeInfoList = asProductAttributeInfoService.list(queryWrapper);
List<Long> longs = attributeInfoList.stream().map(AsProductAttributeInfo::getAttributeId).toList();
ArrayList<AttributeInfo> arrayList = new ArrayList<>();
for (Long aLong : longs) {
AttributeInfo attributeInfo = projectInfoMapper.selectProject(aLong);
arrayList.add(attributeInfo);
}
//
return ProjectUpdInfo.builder()
.id(info.getId())
.name(info.getName())
.introduction(info.getIntroduction())
.mianType(info.getMianType())
.parentType(info.getParentType())
.type(info.getType())
.image(info.getImage())
.carouselImages(info.getCarouselImages())
.status(info.getStatus())
.ruleId(info.getRuleId())
.brandId(info.getBrandId())
.attrValueList(arrayList)
.build();
}
} }

View File

@ -12,6 +12,7 @@ import com.muyu.common.core.text.Convert;
import com.muyu.common.core.utils.ObjUtils; import com.muyu.common.core.utils.ObjUtils;
import com.muyu.common.core.web.page.TableDataInfo; import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.security.utils.SecurityUtils; import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.product.domain.ProjectInfo;
import com.muyu.product.domain.RuleAttrInfo; import com.muyu.product.domain.RuleAttrInfo;
import com.muyu.product.domain.model.RuleAttrAddModel; import com.muyu.product.domain.model.RuleAttrAddModel;
import com.muyu.product.domain.model.RuleInfoAddModel; import com.muyu.product.domain.model.RuleInfoAddModel;
@ -28,6 +29,7 @@ import com.muyu.product.domain.RuleInfo;
import com.muyu.product.service.RuleInfoService; import com.muyu.product.service.RuleInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.util.CollectionUtils;
/** /**
* Service * Service
@ -43,6 +45,8 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
private RuleAttrInfoService ruleAttrInfoService; private RuleAttrInfoService ruleAttrInfoService;
@Autowired @Autowired
private RuleAttrInfoMapper ruleAttrInfoMapper; private RuleAttrInfoMapper ruleAttrInfoMapper;
@Autowired
private ProjectInfoServiceImpl projectInfoService;
/** /**
* *
@ -105,7 +109,14 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
})) }))
.toList(); .toList();
boolean isPage = ruleInfoQueryReq.getParams().get("isPage") == null || Convert.toBool(ruleInfoQueryReq.getParams().get("isPage"), true); boolean isPage = ruleInfoQueryReq.getParams().get("isPage") == null || Convert.toBool(ruleInfoQueryReq.getParams().get("isPage"), true);
ruleInfoRespList.forEach(ruleInfoResp -> {
LambdaQueryWrapper<ProjectInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ProjectInfo::getRuleId,ruleInfoResp.getId());
List<ProjectInfo> projectInfoList = projectInfoService.list(wrapper);
if (!CollectionUtils.isEmpty(projectInfoList) && projectInfoList.size()>0){
ruleInfoResp.setState(1);
}
});
return TableDataInfo.<RuleInfoResp>builder() return TableDataInfo.<RuleInfoResp>builder()
.rows(ruleInfoRespList) .rows(ruleInfoRespList)
.total(isPage ? new PageInfo<>(list).getTotal() : 0) .total(isPage ? new PageInfo<>(list).getTotal() : 0)

View File

@ -37,4 +37,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="QueryBelowOneLevel" resultType="com.muyu.product.domain.CategoryInfo"> <select id="QueryBelowOneLevel" resultType="com.muyu.product.domain.CategoryInfo">
select * from category_info where parent_id =#{ids} select * from category_info where parent_id =#{ids}
</select> </select>
<!-- 查询是否与商品有关-->
<select id="InquireAboutGoods" resultType="com.muyu.product.domain.AsCategoryBrand"
parameterType="java.lang.Long">
select * from as_category_brand where category_id =#{ids}
</select>
<!-- 品类属性中间表-->
<select id="selectCateById" resultType="com.muyu.product.domain.AttributeInfo"
parameterType="java.lang.Long">
select *from attribute_info where id=#{aLong}
</select>
<!-- 品类属性组中间表-->
<select id="selectGroup" resultType="com.muyu.product.domain.AttributeGroup"
parameterType="java.lang.Long">
select * from attribute_group where id=#{aLong}
</select>
<!-- 品类品牌中间表-->
<select id="seleteBrand" resultType="com.muyu.product.domain.BrandInfo" parameterType="java.lang.Long">
select *from brand_info where id=#{aLong}
</select>
</mapper> </mapper>

View File

@ -26,4 +26,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectProjectInfoVo"> <sql id="selectProjectInfoVo">
select id, name, introduction, mian_type, parent_type, type, image, carousel_images, status, rule_id, brand_id, remark, create_by, create_time, update_by, update_time from project_info select id, name, introduction, mian_type, parent_type, type, image, carousel_images, status, rule_id, brand_id, remark, create_by, create_time, update_by, update_time from project_info
</sql> </sql>
<!-- 商品属性表中间表-->
<select id="selectProject" resultType="com.muyu.product.domain.AttributeInfo">
select * from attribute_info where id = #{aLong}
</select>
</mapper> </mapper>

View File

@ -15,6 +15,7 @@
<module>muyu-file</module> <module>muyu-file</module>
<module>muyu-product</module> <module>muyu-product</module>
<module>muyu-shop-cart</module> <module>muyu-shop-cart</module>
<module>muyu-goods</module>
</modules> </modules>
<artifactId>muyu-modules</artifactId> <artifactId>muyu-modules</artifactId>