Merge remote-tracking branch 'origin/master'
# Conflicts: # .idea/encodings.xml # bwie-common/src/main/java/com/bwie/common/pojo/DTO/DTOGoods.java # bwie-common/src/main/java/com/bwie/common/pojo/Facility.java # bwie-common/src/main/java/com/bwie/common/pojo/Goods.java # bwie-common/src/main/java/com/bwie/common/pojo/Shop.java # bwie-common/src/main/java/com/bwie/common/pojo/VO/VOGoods.java # bwie-models/pom.xmlmaster
commit
4aa014098e
|
@ -4,9 +4,7 @@
|
|||
<file url="file://$PROJECT_DIR$/bwie-auth/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/bwie-common/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/bwie-gateway/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/bwie-models/bwie-buy/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/bwie-models/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/bwie-models/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/bwie-mq/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="AliAccessStaticViaInstance" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliArrayNamingShouldHaveBracket" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliControlFlowStatementWithoutBraces" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliDeprecation" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliEqualsAvoidNull" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliLongLiteralsEndingWithLowercaseL" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliMissingOverrideAnnotation" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliWrapperTypeEquality" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,com.github.pagehelper.page.PageMethod,startPage" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="MapOrSetKeyShouldOverrideHashCodeEquals" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
|
@ -1,4 +1,3 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
|
|
|
@ -98,12 +98,23 @@
|
|||
<artifactId>dysmsapi20170525</artifactId>
|
||||
<version>2.0.1</version>
|
||||
</dependency>
|
||||
<!-- oss 图片上传 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.12.0</version>
|
||||
</dependency>
|
||||
<!-- rabbitMQ -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--fastDfs文件上传-->
|
||||
<dependency>
|
||||
<groupId>com.github.tobato</groupId>
|
||||
<artifactId>fastdfs-client</artifactId>
|
||||
<version>1.26.5</version>
|
||||
</dependency>
|
||||
|
||||
<!--短信依赖 5条依赖-->
|
||||
<dependency>
|
||||
|
|
|
@ -5,16 +5,22 @@ import lombok.Data;
|
|||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
<<<<<<< HEAD
|
||||
/**
|
||||
* @author FangShiBa
|
||||
* @date 2023/12/17
|
||||
* @apiNote
|
||||
*/
|
||||
=======
|
||||
import java.util.List;
|
||||
|
||||
>>>>>>> origin/master
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class DTOGoods {
|
||||
<<<<<<< HEAD
|
||||
private Integer goodsId; //商品设备中间id
|
||||
private Integer shopId; //商品id
|
||||
private Integer facilityId; //设备id
|
||||
|
@ -29,5 +35,40 @@ public class DTOGoods {
|
|||
private Integer maintainUserId; //维修员工
|
||||
private String facilityStatic; //设备状态
|
||||
private Integer delId; //删除状态
|
||||
=======
|
||||
|
||||
//商品设备中间id
|
||||
private Integer goodsId;
|
||||
|
||||
//商品id
|
||||
private Integer shopId;
|
||||
//商品名称
|
||||
private String shopName;
|
||||
//商品价格
|
||||
private double shopPrice;
|
||||
|
||||
//商品类型id
|
||||
private Integer typeId;
|
||||
//商品类型名称
|
||||
private String typeName;
|
||||
|
||||
//图片
|
||||
private List<String> pictureUrl;
|
||||
|
||||
//设备id
|
||||
private Integer facilityId;
|
||||
//设备类型
|
||||
private String facilityType;
|
||||
//设备地址
|
||||
private String facilitySite;
|
||||
|
||||
//库存
|
||||
private Integer goodsNum;
|
||||
//上下架(逻辑字段: 0上架, 1下架)
|
||||
private Integer goodsIsDelete;
|
||||
|
||||
|
||||
|
||||
>>>>>>> origin/master
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package com.bwie.common.pojo.DTO;
|
||||
|
||||
import com.bwie.common.pojo.Picture;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class DTOShop {
|
||||
|
||||
//商品id
|
||||
private Integer shopId;
|
||||
//商品名称
|
||||
private String shopName;
|
||||
//商品价格
|
||||
private double shopPrice;
|
||||
//商品类型id
|
||||
private Integer typeId;
|
||||
//商品类型名称
|
||||
private String typeName;
|
||||
|
||||
//图片
|
||||
private List<String> pictureUrl;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -5,16 +5,20 @@ import lombok.Data;
|
|||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
<<<<<<< HEAD
|
||||
/**
|
||||
* @author FangShiBa
|
||||
* @date 2023/12/17
|
||||
* @apiNote
|
||||
*/
|
||||
=======
|
||||
>>>>>>> origin/master
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class Facility {
|
||||
<<<<<<< HEAD
|
||||
private Integer facilityId; //设备编号
|
||||
private String facilityType; //设备类型
|
||||
private String facilitySite; //设备地址
|
||||
|
@ -22,6 +26,25 @@ public class Facility {
|
|||
private Integer maintainUserId; //维修员工
|
||||
private String facilityStatic; //设备状态
|
||||
private Integer delId; //删除状态
|
||||
=======
|
||||
|
||||
//设备编号
|
||||
private Integer facilityId;
|
||||
//设备类型
|
||||
private String facilityType;
|
||||
//设备地址
|
||||
private String facilitySite;
|
||||
//补货员工
|
||||
private Integer replenishmentUserId;
|
||||
//维修员工
|
||||
private Integer maintainUserId;
|
||||
//设备状态
|
||||
private Integer facilityStatic;
|
||||
//删除状态
|
||||
private Integer delId;
|
||||
|
||||
|
||||
>>>>>>> origin/master
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -5,19 +5,38 @@ import lombok.Data;
|
|||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
<<<<<<< HEAD
|
||||
/**
|
||||
* @author FangShiBa
|
||||
* @date 2023/12/17
|
||||
* @apiNote
|
||||
*/
|
||||
=======
|
||||
>>>>>>> origin/master
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class Goods {
|
||||
<<<<<<< HEAD
|
||||
private Integer goodsId; //商品设备中间id
|
||||
private Integer shopId; //商品id
|
||||
private Integer facilityId; //设备id
|
||||
private Integer goodsNum; //库存
|
||||
private Integer goodsIsDelete; //上下架(逻辑字段: 0上架, 1下架)
|
||||
=======
|
||||
|
||||
//商品设备中间id
|
||||
private Integer goodsId;
|
||||
//商品id
|
||||
private Integer shopId;
|
||||
//设备id
|
||||
private Integer facilityId;
|
||||
//库存
|
||||
private Integer goodsNum;
|
||||
//上下架(逻辑字段: 0上架, 1下架)
|
||||
private Integer goodsIsDelete;
|
||||
|
||||
|
||||
>>>>>>> origin/master
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.bwie.common.pojo;
|
||||
|
||||
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class Picture {
|
||||
|
||||
//图片id
|
||||
private Integer pictureId;
|
||||
//图片路径
|
||||
private String pictureUrl;
|
||||
//商品id
|
||||
private Integer shopId;
|
||||
|
||||
|
||||
}
|
|
@ -5,19 +5,36 @@ import lombok.Data;
|
|||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
<<<<<<< HEAD
|
||||
/**
|
||||
* @author FangShiBa
|
||||
* @date 2023/12/17
|
||||
* @apiNote
|
||||
*/
|
||||
=======
|
||||
>>>>>>> origin/master
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class Shop {
|
||||
<<<<<<< HEAD
|
||||
private Integer shopId; //商品id
|
||||
private String shopName; //商品名称
|
||||
private Double shopPrice; //商品价格
|
||||
private Integer typeId; //商品类型id
|
||||
=======
|
||||
|
||||
//商品id
|
||||
private Integer shopId;
|
||||
//商品名称
|
||||
private String shopName;
|
||||
//商品价格
|
||||
private double shopPrice;
|
||||
//商品类型id
|
||||
private Integer typeId;
|
||||
|
||||
|
||||
>>>>>>> origin/master
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.bwie.common.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class Type {
|
||||
|
||||
|
||||
//类型id
|
||||
private Integer typeId;
|
||||
//类型名称
|
||||
private String typeName;
|
||||
|
||||
|
||||
}
|
|
@ -5,16 +5,20 @@ import lombok.Data;
|
|||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
<<<<<<< HEAD
|
||||
/**
|
||||
* @author FangShiBa
|
||||
* @date 2023/12/17
|
||||
* @apiNote
|
||||
*/
|
||||
=======
|
||||
>>>>>>> origin/master
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class VOGoods {
|
||||
<<<<<<< HEAD
|
||||
private Integer goodsId; //商品设备中间id
|
||||
private Integer shopId; //商品id
|
||||
private Integer facilityId; //设备id
|
||||
|
@ -24,4 +28,23 @@ public class VOGoods {
|
|||
|
||||
private Integer pageNum=1;
|
||||
private Integer pageSize=3;
|
||||
=======
|
||||
|
||||
//商品设备中间id
|
||||
private Integer goodsId;
|
||||
//商品id
|
||||
private Integer shopId;
|
||||
//设备id
|
||||
private Integer facilityId;
|
||||
//库存
|
||||
private Integer goodsNum;
|
||||
//上下架(逻辑字段: 0上架, 1下架)
|
||||
private Integer goodsIsDelete;
|
||||
|
||||
//分页
|
||||
private Integer pageNum=1;
|
||||
private Integer pageSize=3;
|
||||
|
||||
|
||||
>>>>>>> origin/master
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package com.bwie.common.pojo.VO;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class VOShop {
|
||||
|
||||
//类型id
|
||||
private Integer typeId;
|
||||
//商品id
|
||||
private Integer shopId;
|
||||
//商品名称
|
||||
private String shopName;
|
||||
//商品价格
|
||||
private double shopPrice;
|
||||
//商品类型名称
|
||||
private String typeName;
|
||||
|
||||
//图片
|
||||
private List<String> pictureUrl;
|
||||
|
||||
//分页
|
||||
private Integer pageNum=1;
|
||||
private Integer pageSize=3;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.bwie.common.utils;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
|
||||
import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @BelongsProject: 0107day02
|
||||
* @BelongsPackage: com.bw.config
|
||||
* @Author: zhupengfei
|
||||
* @CreateTime: 2023-02-01 08:52
|
||||
*/
|
||||
@Component
|
||||
public class FastUtil {
|
||||
private static final Logger log = LoggerFactory.getLogger(FastUtil.class);
|
||||
|
||||
@Resource
|
||||
private FastFileStorageClient storageClient ;
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*/
|
||||
public String upload(MultipartFile multipartFile) throws Exception{
|
||||
String originalFilename = multipartFile.getOriginalFilename().
|
||||
substring(multipartFile.getOriginalFilename().
|
||||
lastIndexOf(".") + 1);
|
||||
StorePath storePath = this.storageClient.uploadImageAndCrtThumbImage(
|
||||
multipartFile.getInputStream(),
|
||||
multipartFile.getSize(),originalFilename , null);
|
||||
return storePath.getFullPath();
|
||||
}
|
||||
/**
|
||||
* 删除文件
|
||||
*/
|
||||
public String deleteFile(String fileUrl) {
|
||||
if (StringUtils.isEmpty(fileUrl)) {
|
||||
log.info("fileUrl == >>文件路径为空...");
|
||||
return "文件路径不能为空";
|
||||
}
|
||||
try {
|
||||
StorePath storePath = StorePath.parseFromUrl(fileUrl);
|
||||
storageClient.deleteFile(storePath.getGroup(), storePath.getPath());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return "删除成功";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package com.bwie.common.utils;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @description: 生成验证码工具类
|
||||
* @Date 2023-5-11 上午 10:09
|
||||
*/
|
||||
public class GenCodeUtils {
|
||||
|
||||
/**
|
||||
* 数字类型
|
||||
*/
|
||||
private static final String NUMBER_STR = "0123456789";
|
||||
/**
|
||||
* 字母类型
|
||||
*/
|
||||
private static final String LETTERS_STR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
/**
|
||||
* 短信验证码长度
|
||||
*/
|
||||
private static final Integer SMS_CODE_LENGTH = 4;
|
||||
|
||||
/**
|
||||
* 生成短信四位验证码
|
||||
* @return 验证码
|
||||
*/
|
||||
public static String genLetterStrSms(){
|
||||
return genCode(LETTERS_STR, SMS_CODE_LENGTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成短信四位验证码
|
||||
* @return 验证码
|
||||
*/
|
||||
public static String genNumberCodeSms(){
|
||||
return genCode(NUMBER_STR, SMS_CODE_LENGTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成验证码
|
||||
* @param codeLength 验证码长度
|
||||
* @return 验证码
|
||||
*/
|
||||
public static String genLetterStr(int codeLength){
|
||||
return genCode(LETTERS_STR, codeLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成验证码
|
||||
* @param codeLength 验证码长度
|
||||
* @return 验证码
|
||||
*/
|
||||
public static String genNumberCode( int codeLength){
|
||||
return genCode(NUMBER_STR, codeLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成验证码
|
||||
* @param str 验证码字符串
|
||||
* @param codeLength 验证码长度
|
||||
* @return 验证码
|
||||
*/
|
||||
public static String genCode (String str, int codeLength){
|
||||
//将字符串转换为一个新的字符数组。
|
||||
char[] verificationCodeArray = str.toCharArray();
|
||||
Random random = new Random();
|
||||
//计数器
|
||||
int count = 0;
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
do {
|
||||
//随机生成一个随机数
|
||||
int index = random.nextInt(verificationCodeArray.length);
|
||||
char c = verificationCodeArray[index];
|
||||
//限制四位不重复数字
|
||||
if (stringBuilder.indexOf(String.valueOf(c)) == -1) {
|
||||
stringBuilder.append(c);
|
||||
//计数器加1
|
||||
count++;
|
||||
}
|
||||
//当count等于4时结束,随机生成四位数的验证码
|
||||
} while (count != codeLength);
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
package com.bwie.common.utils;
|
||||
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.model.GetObjectRequest;
|
||||
import com.aliyun.oss.model.PutObjectRequest;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Oss服务调用
|
||||
*/
|
||||
@Log4j2
|
||||
public class OssUtil {
|
||||
|
||||
/**
|
||||
* Endpoint 存储对象概述 阿里云主账号AccessKey,accessKeySecret拥有所有API的访问权限 访问路径前缀 存储对象概述
|
||||
*/
|
||||
private static String endPoint = "oss-cn-shanghai.aliyuncs.com";
|
||||
private static String accessKeyId = "LTAI5tD2tppzLQ4Rb6yKYyph";
|
||||
private static String accessKeySecret = "KEKNKwVvDq7PZLjE63NPBouqHXox4Q";
|
||||
private static String accessPre = "https://dzlmuyu.oss-cn-shanghai.aliyuncs.com/";
|
||||
|
||||
/**
|
||||
* bucket名称
|
||||
* @return
|
||||
*/
|
||||
private static String bucketName = "dzlmuyu";
|
||||
|
||||
private static OSS ossClient ;
|
||||
|
||||
static {
|
||||
ossClient = new OSSClientBuilder().build(
|
||||
endPoint,
|
||||
accessKeyId,
|
||||
accessKeySecret);
|
||||
log.info("oss服务连接成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认路径上传本地文件
|
||||
* @param filePath
|
||||
*/
|
||||
public static String uploadFile(String filePath){
|
||||
return uploadFileForBucket(bucketName,getOssFilePath(filePath) ,filePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认路径上传multipartFile文件
|
||||
* @param multipartFile
|
||||
*/
|
||||
public static String uploadMultipartFile(MultipartFile multipartFile) {
|
||||
return uploadMultipartFile(bucketName,getOssFilePath(multipartFile.getOriginalFilename()),multipartFile);
|
||||
}
|
||||
/**
|
||||
* 上传 multipartFile 类型文件
|
||||
* @param bucketName
|
||||
* @param ossPath
|
||||
* @param multipartFile
|
||||
*/
|
||||
public static String uploadMultipartFile(String bucketName , String ossPath , MultipartFile multipartFile){
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = multipartFile.getInputStream();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
uploadFileInputStreamForBucket(bucketName, ossPath, inputStream);
|
||||
return accessPre+ossPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用File上传PutObject上传文件 ** 程序默认使用次方法上传
|
||||
* @param bucketName 实例名称
|
||||
* @param ossPath oss存储路径
|
||||
* @param filePath 本地文件路径
|
||||
*/
|
||||
public static String uploadFileForBucket(String bucketName , String ossPath , String filePath) {
|
||||
// 创建PutObjectRequest对象。
|
||||
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, ossPath, new File(filePath));
|
||||
|
||||
// 上传
|
||||
ossClient.putObject(putObjectRequest);
|
||||
return accessPre+ossPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用文件流上传到指定的bucket实例
|
||||
* @param bucketName 实例名称
|
||||
* @param ossPath oss存储路径
|
||||
* @param filePath 本地文件路径
|
||||
*/
|
||||
public static String uploadFileInputStreamForBucket(String bucketName , String ossPath , String filePath){
|
||||
|
||||
// 填写本地文件的完整路径。如果未指定本地路径,则默认从示例程序所属项目对应本地路径中上传文件流。
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = new FileInputStream(filePath);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 填写Bucket名称和Object完整路径。Object完整路径中不能包含Bucket名称。
|
||||
uploadFileInputStreamForBucket(bucketName, ossPath, inputStream);
|
||||
return accessPre+ossPath;
|
||||
}
|
||||
|
||||
public static void uploadFileInputStreamForBucket(String bucketName , String ossPath , InputStream inputStream ){
|
||||
ossClient.putObject(bucketName, ossPath, inputStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载
|
||||
* @param ossFilePath
|
||||
* @param filePath
|
||||
*/
|
||||
public static void downloadFile(String ossFilePath , String filePath ){
|
||||
downloadFileForBucket(bucketName , ossFilePath , filePath);
|
||||
}
|
||||
/**
|
||||
* 下载
|
||||
* @param bucketName 实例名称
|
||||
* @param ossFilePath oss存储路径
|
||||
* @param filePath 本地文件路径
|
||||
*/
|
||||
public static void downloadFileForBucket(String bucketName , String ossFilePath , String filePath ){
|
||||
ossClient.getObject(new GetObjectRequest(bucketName, ossFilePath), new File(filePath));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getOssDefaultPath(){
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
String url =
|
||||
now.getYear()+"/"+
|
||||
now.getMonth()+"/"+
|
||||
now.getDayOfMonth()+"/"+
|
||||
now.getHour()+"/"+
|
||||
now.getMinute()+"/";
|
||||
return url;
|
||||
}
|
||||
|
||||
public static String getOssFilePath(String filePath){
|
||||
String fileSuf = filePath.substring(filePath.indexOf(".") + 1);
|
||||
return getOssDefaultPath() + UUID.randomUUID().toString() + "." + fileSuf;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>bwie-models</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bwie-shopList</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- 系统公共 依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>bwie-common</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringBoot Web-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!-- Druid -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.2.8</version>
|
||||
</dependency>
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<!-- Mybatis 依赖配置 -->
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.2.2</version>
|
||||
</dependency>
|
||||
<!-- Pagehelper -->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.4.1</version>
|
||||
</dependency>
|
||||
<!-- test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
</project>
|
|
@ -0,0 +1,11 @@
|
|||
package com.bwie;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class ListApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ListApplication.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.bwie.list.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bwie.common.pojo.VO.VOGoods;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.list.service.GoodsService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@RestController
|
||||
@Log4j2
|
||||
public class GoodsController {
|
||||
@Autowired
|
||||
private GoodsService goodsService;
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@PostMapping("/goodsList")
|
||||
public Result goodsList(@RequestBody VOGoods voGoods){
|
||||
log.info("功能名称:[查询商品设备表],请求URI:{},请求方式:{},请求参数:{}",
|
||||
request.getRequestURI(),request.getMethod(),voGoods);
|
||||
|
||||
Result result = goodsService.goodsList(voGoods);
|
||||
|
||||
log.info("功能名称:[查询商品设备表],请求URI:{},请求方式:{},响应结果:{}",
|
||||
request.getRequestURI(),request.getMethod(), JSONObject.toJSONString(result));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@PostMapping("/topShop")
|
||||
public Result topShop(@RequestBody VOGoods voGoods){
|
||||
log.info("功能名称:[上架],请求URI:{},请求方式:{},请求参数:{}",
|
||||
request.getRequestURI(),request.getMethod(),voGoods);
|
||||
Result result = goodsService.topShop(voGoods);
|
||||
log.info("功能名称:[上架],请求URI:{},请求方式:{},响应结果:{}",
|
||||
request.getRequestURI(),request.getMethod(), JSONObject.toJSONString(result));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@PostMapping("/bottomShop")
|
||||
public Result bottomShop(@RequestBody VOGoods voGoods){
|
||||
log.info("功能名称:[下架],请求URI:{},请求方式:{},请求参数:{}",
|
||||
request.getRequestURI(),request.getMethod(),voGoods);
|
||||
Result result = goodsService.bottomShop(voGoods);
|
||||
log.info("功能名称:[下架],请求URI:{},请求方式:{},响应结果:{}",
|
||||
request.getRequestURI(),request.getMethod(), JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
@PostMapping("/addGoodsNum")
|
||||
public Result addGoodsNum(@RequestBody VOGoods voGoods){
|
||||
return goodsService.addGoodsNum(voGoods);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.bwie.list.controller;
|
||||
|
||||
import com.bwie.common.pojo.VO.VOShop;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.list.service.ShopService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@Log4j2
|
||||
public class ShopController {
|
||||
@Autowired
|
||||
private ShopService shopService;
|
||||
|
||||
//展示商品列表
|
||||
@PostMapping("/shopList")
|
||||
public Result shopList(@RequestBody VOShop voShop){
|
||||
return shopService.shopList(voShop);
|
||||
}
|
||||
|
||||
//上传图片
|
||||
@PostMapping("/upImg")
|
||||
public Result upImg(@RequestParam("file")MultipartFile myFile){
|
||||
return shopService.upImg(myFile);
|
||||
}
|
||||
//添加商品
|
||||
@PostMapping("/addShop")
|
||||
public Result addShop(@RequestBody VOShop shop){
|
||||
return shopService.addShop(shop);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.bwie.list.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.list.service.TypeService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@RestController
|
||||
@Log4j2
|
||||
public class TypeController {
|
||||
@Autowired
|
||||
private TypeService typeService;
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
// 根据商品类型查询商品的商品类型菜单栏
|
||||
@GetMapping("/findType")
|
||||
public Result findType(){
|
||||
|
||||
log.info("功能名称:[类型菜单栏],请求URI:{},请求方式:{},请求参数:{}",
|
||||
request.getRequestURI(),request.getMethod(),"");
|
||||
|
||||
Result result = typeService.findType();
|
||||
|
||||
log.info("功能名称:[类型菜单栏],请求URI:{},请求方式:{},响应结果:{}",
|
||||
request.getRequestURI(),request.getMethod(), JSONObject.toJSONString(result));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.bwie.list.mapper;
|
||||
|
||||
import com.bwie.common.pojo.DTO.DTOGoods;
|
||||
import com.bwie.common.pojo.Goods;
|
||||
import com.bwie.common.pojo.VO.VOGoods;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface GoodsMapper {
|
||||
List<DTOGoods> goodsList(VOGoods voGoods);
|
||||
|
||||
Goods findShopId(Integer shopId, Integer facilityId);
|
||||
|
||||
Integer addGoods(VOGoods voGoods);
|
||||
|
||||
Integer changeGoodsState(@Param("goodsId") Integer goodsId);
|
||||
|
||||
Integer updateGoodsState(@Param("goodsId") Integer goodsId);
|
||||
|
||||
|
||||
Integer changeGoodsNum(VOGoods voGoods);
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.bwie.list.mapper;
|
||||
|
||||
import com.bwie.common.pojo.DTO.DTOShop;
|
||||
import com.bwie.common.pojo.VO.VOShop;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ShopMapper {
|
||||
List<DTOShop> shopList(VOShop voShop);
|
||||
|
||||
Integer addShop(VOShop shop);
|
||||
|
||||
void addImg(VOShop shop);
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.bwie.list.mapper;
|
||||
|
||||
import com.bwie.common.pojo.Type;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface TypeMapper {
|
||||
|
||||
List<Type> findType();
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.bwie.list.service;
|
||||
|
||||
import com.bwie.common.pojo.VO.VOGoods;
|
||||
import com.bwie.common.result.Result;
|
||||
|
||||
public interface GoodsService {
|
||||
Result goodsList(VOGoods voGoods);
|
||||
|
||||
Result topShop(VOGoods voGoods);
|
||||
|
||||
Result bottomShop(VOGoods voGoods);
|
||||
|
||||
Result addGoodsNum(VOGoods voGoods);
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.bwie.list.service;
|
||||
|
||||
import com.bwie.common.pojo.VO.VOShop;
|
||||
import com.bwie.common.result.Result;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
public interface ShopService {
|
||||
Result shopList(VOShop voShop);
|
||||
|
||||
Result addShop(VOShop shop);
|
||||
|
||||
Result upImg(MultipartFile myFile);
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.bwie.list.service;
|
||||
|
||||
import com.bwie.common.result.Result;
|
||||
|
||||
public interface TypeService {
|
||||
Result findType();
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package com.bwie.list.service.impl;
|
||||
|
||||
import com.bwie.common.pojo.DTO.DTOGoods;
|
||||
import com.bwie.common.pojo.Goods;
|
||||
import com.bwie.common.pojo.VO.VOGoods;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.list.mapper.GoodsMapper;
|
||||
import com.bwie.list.service.GoodsService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class GoodsServiceImpl implements GoodsService {
|
||||
@Autowired
|
||||
private GoodsMapper goodsMapper;
|
||||
|
||||
@Override
|
||||
public Result goodsList(VOGoods voGoods) {
|
||||
|
||||
PageHelper.startPage(voGoods.getPageNum(), voGoods.getPageSize());
|
||||
|
||||
List<DTOGoods> dtoGoodsList = goodsMapper.goodsList(voGoods);
|
||||
|
||||
PageInfo<DTOGoods> info = new PageInfo<>(dtoGoodsList);
|
||||
|
||||
return Result.success(info,"商品设备中间表");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result topShop(VOGoods voGoods) {
|
||||
|
||||
Goods goods = goodsMapper.findShopId(voGoods.getShopId(),voGoods.getFacilityId());
|
||||
if (goods==null){
|
||||
Integer i = goodsMapper.addGoods(voGoods);
|
||||
if (i>0){
|
||||
return Result.success(voGoods,"上架成功");
|
||||
}
|
||||
} else {
|
||||
if (goods.getGoodsIsDelete() == 0){
|
||||
Integer i = goodsMapper.changeGoodsState(goods.getGoodsId());
|
||||
if (i>0){
|
||||
return Result.success(voGoods,"上架成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Result.error("商品已上架不能重复上架哦~~");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result bottomShop(VOGoods voGoods) {
|
||||
Goods goods = goodsMapper.findShopId(voGoods.getShopId(),voGoods.getFacilityId());
|
||||
if (goods==null){
|
||||
|
||||
return Result.error("商品还未上架");
|
||||
|
||||
}else {
|
||||
|
||||
if (goods.getGoodsIsDelete()==1){
|
||||
Integer i = goodsMapper.updateGoodsState(goods.getGoodsId());
|
||||
if (i>0){
|
||||
return Result.success(voGoods,"下架成功");
|
||||
}else {
|
||||
return Result.error("下架失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Result.error("商品已经下架");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result addGoodsNum(VOGoods voGoods) {
|
||||
Integer i = goodsMapper.changeGoodsNum(voGoods);
|
||||
if (i>0){
|
||||
return Result.success(voGoods,"进货成功");
|
||||
}
|
||||
return Result.error("进货失败");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package com.bwie.list.service.impl;
|
||||
|
||||
import com.bwie.common.pojo.DTO.DTOShop;
|
||||
import com.bwie.common.pojo.VO.VOShop;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.common.utils.FastUtil;
|
||||
import com.bwie.list.mapper.ShopMapper;
|
||||
import com.bwie.list.service.ShopService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ShopServiceImpl implements ShopService {
|
||||
@Autowired
|
||||
private ShopMapper shopMapper;
|
||||
@Autowired
|
||||
private FastUtil fastUtil;
|
||||
|
||||
@Override
|
||||
public Result shopList(VOShop voShop) {
|
||||
|
||||
PageHelper.startPage(voShop.getPageNum(),voShop.getPageSize());
|
||||
|
||||
List<DTOShop> dtoShops = shopMapper.shopList(voShop);
|
||||
|
||||
PageInfo<DTOShop> info = new PageInfo<>(dtoShops);
|
||||
|
||||
return Result.success(info,"商品列表展示");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result addShop(VOShop shop) {
|
||||
|
||||
Integer i = shopMapper.addShop(shop);
|
||||
if (i>0){
|
||||
shopMapper.addImg(shop);
|
||||
return Result.success(shop,"成功");
|
||||
}
|
||||
return Result.error("失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result upImg(MultipartFile myFile) {
|
||||
|
||||
String url = null;
|
||||
|
||||
try {
|
||||
url = fastUtil.upload(myFile);
|
||||
|
||||
if (url==null || url.equals("")){
|
||||
return Result.error("图片上传失败");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
return Result.success("http://82.157.236.130:8888/"+url,"上传成功");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.bwie.list.service.impl;
|
||||
|
||||
import com.bwie.common.pojo.Type;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.list.mapper.TypeMapper;
|
||||
import com.bwie.list.service.TypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class TypeServiceImpl implements TypeService {
|
||||
@Autowired
|
||||
private TypeMapper typeMapper;
|
||||
|
||||
@Override
|
||||
public Result findType() {
|
||||
List<Type> typeList = typeMapper.findType();
|
||||
return Result.success(typeList,"类型展示");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9002
|
||||
# Spring
|
||||
spring:
|
||||
main:
|
||||
allow-circular-references: true
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
# 应用名称
|
||||
name: bwie-list
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 82.157.236.130:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 82.157.236.130:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
fdfs:
|
||||
so-timeout: 1500 # socket 连接时长
|
||||
connect-timeout: 600 # 连接 tracker 服务器超时时长
|
||||
# 这两个是你服务器的 IP 地址,注意 23000 端口也要打开,阿里云服务器记得配置安全组。tracker 要和 stroage 服务进行交流
|
||||
tracker-list: 82.157.236.130:22122
|
||||
web-server-url: 82.157.236.130:8888
|
||||
pool:
|
||||
jmx-enabled: false
|
||||
# 生成缩略图
|
||||
thumb-image:
|
||||
height: 500
|
||||
width: 500
|
|
@ -0,0 +1,64 @@
|
|||
<?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">
|
||||
<!--
|
||||
1.在mybats的开发中namespace有特殊的意思,一定要是对应接口的全限定名
|
||||
通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
|
||||
-->
|
||||
<mapper namespace="com.bwie.list.mapper.GoodsMapper">
|
||||
|
||||
<resultMap id="map" type="com.bwie.common.pojo.DTO.DTOGoods">
|
||||
<id property="goodsId" column="goods_id"></id>
|
||||
<result property="goodsNum" column="goods_num"></result>
|
||||
<result property="goodsIsDelete" column="goods_isdelete"></result>
|
||||
<result property="shopId" column="shop_id"></result>
|
||||
<result property="shopPrice" column="shop_price"></result>
|
||||
<result property="shopName" column="shop_name"></result>
|
||||
<result property="typeId" column="type_id"></result>
|
||||
<result property="typeName" column="type_name"></result>
|
||||
<result property="facilityId" column="facility_id"></result>
|
||||
<result property="facilityType" column="facility_type"></result>
|
||||
<result property="facilitySite" column="facility_site"></result>
|
||||
<collection property="pictureUrl" ofType="java.lang.String">
|
||||
<result column="picture_url"></result>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<!-- 添加中间表 -->
|
||||
<insert id="addGoods">
|
||||
INSERT INTO `shop_manage`.`t_goods` (`shop_id`, `facility_id`, `goods_num`, `goods_isdelete`)
|
||||
VALUES (#{shopId}, #{facilityId}, NULL, 1)
|
||||
</insert>
|
||||
<!-- 上架修改状态 -->
|
||||
<update id="changeGoodsState">
|
||||
UPDATE `shop_manage`.`t_goods` SET `goods_isdelete` = 1 WHERE `goods_id` = #{goodsId}
|
||||
</update>
|
||||
<!-- 下架修改状态 -->
|
||||
<update id="updateGoodsState">
|
||||
UPDATE `shop_manage`.`t_goods` SET `goods_isdelete` = 0 WHERE `goods_id` = #{goodsId}
|
||||
</update>
|
||||
<!-- 修改库存数 -->
|
||||
<update id="changeGoodsNum">
|
||||
UPDATE `shop_manage`.`t_goods` SET `goods_num` = (`goods_num` + #{goodsNum}) WHERE `goods_id` = #{goodsId}
|
||||
</update>
|
||||
|
||||
<select id="goodsList" resultMap="map">
|
||||
SELECT g.goods_id,g.shop_id,s.shop_name,s.shop_price,s.type_id,t.type_name,p.picture_url,
|
||||
g.facility_id,f.facility_type,f.facility_site,g.goods_num,g.goods_isdelete
|
||||
FROM t_goods g
|
||||
LEFT JOIN t_shop s on g.shop_id = s.shop_id
|
||||
LEFT JOIN t_type t on s.type_id=t.type_id
|
||||
LEFT JOIN t_picture p on s.shop_id = p.shop_id
|
||||
LEFT JOIN t_facility f on g.facility_id = f.facility_id
|
||||
<where>
|
||||
and g.goods_isdelete = 1
|
||||
<if test="facilityId != null">
|
||||
and g.facility_id = #{facilityId}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY g.goods_id
|
||||
</select>
|
||||
<select id="findShopId" resultType="com.bwie.common.pojo.Goods">
|
||||
SELECT * FROM t_goods WHERE shop_id=#{shopId} and facility_id=#{facilityId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,42 @@
|
|||
<?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.bwie.list.mapper.ShopMapper">
|
||||
|
||||
<resultMap id="map" type="com.bwie.common.pojo.DTO.DTOShop">
|
||||
<id property="shopId" column="shop_id"></id>
|
||||
<result property="shopName" column="shop_name"></result>
|
||||
<result property="shopPrice" column="shop_price"></result>
|
||||
<result property="typeId" column="type_id"></result>
|
||||
<result property="typeName" column="type_name"></result>
|
||||
<collection property="pictureUrl" ofType="java.lang.String">
|
||||
<result column="picture_url"></result>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<insert id="addShop" keyProperty="shopId" useGeneratedKeys="true">
|
||||
INSERT INTO `shop_manage`.`t_shop` (`shop_name`, `shop_price`, `type_id`)
|
||||
VALUES ( #{shopName}, #{shopPrice}, #{typeId});
|
||||
</insert>
|
||||
<insert id="addImg">
|
||||
INSERT INTO `shop_manage`.`t_picture`(`picture_url`,`shop_id`)
|
||||
VALUES
|
||||
<foreach collection="pictureUrl" separator="," item="url">
|
||||
(#{url},#{shopId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
<select id="shopList" resultMap="map">
|
||||
select s.shop_id,s.shop_name,s.shop_price,s.type_id,t.type_name,p.picture_id,p.picture_url
|
||||
from t_shop s
|
||||
left join t_type t on s.type_id=t.type_id
|
||||
left join t_picture p on s.shop_id = p.shop_id
|
||||
<where>
|
||||
<if test="typeId != null">
|
||||
and s.type_id = #{typeId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,8 @@
|
|||
<?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.bwie.list.mapper.TypeMapper">
|
||||
|
||||
<select id="findType" resultType="com.bwie.common.pojo.Type">
|
||||
select type_id,type_name from t_type
|
||||
</select>
|
||||
</mapper>
|
|
@ -10,10 +10,6 @@
|
|||
</parent>
|
||||
|
||||
<artifactId>bwie-models</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>bwie-buy</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
|
|
Loading…
Reference in New Issue