Compare commits

...

No commits in common. "yaoyao" and "master" have entirely different histories.

51 changed files with 1851 additions and 0 deletions

8
.idea/.gitignore vendored 100644
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<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/bwie-sell/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-models/bwie-shopList/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-models/bwie-user/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" />
</component>
</project>

View File

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

16
.idea/misc.xml 100644
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
<option value="$PROJECT_DIR$/bwie-models/bwie-buy/pom.xml" />
<option value="$PROJECT_DIR$/bwie-models/bwie-shopList/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

6
.idea/vcs.xml 100644
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -105,6 +105,20 @@
</dependency>
<!--fastDfs文件上传-->
<dependency>
<groupId>com.github.tobato</groupId>
<artifactId>fastdfs-client</artifactId>
<version>1.26.5</version>
</dependency>
<!-- oss 图片上传 -->
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.12.0</version>
</dependency>
<!--短信依赖 5条依赖-->
<dependency>
<groupId>com.alibaba</groupId>

View File

@ -0,0 +1,48 @@
package com.bwie.common.pojo.DTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* @author FangShiBa
* @date 2023/12/17
* @apiNote
*/
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class DTOGoods {
private Integer goodsId; //商品设备中间id
private Integer shopId; //商品id
private Integer facilityId; //设备id
private Integer goodsNum; //库存
private Integer goodsIsDelete; //上下架(逻辑字段: 0上架, 1下架)
private String shopName; //商品名称
private Double shopPrice; //商品价格
private Integer typeId; //商品类型id
private String facilityType; //设备类型
private String facilitySite; //设备地址
private Integer replenishmentUserId; //补货员工
private Integer maintainUserId; //维修员工
private String facilityStatic; //设备状态
private Integer delId; //删除状态
//商品类型名称
private String typeName;
//图片
private List<String> pictureUrl;
}

View File

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

View File

@ -24,6 +24,7 @@ public class DTOUser {
*/
private String expiredTime;
private Integer userId;
}

View File

@ -0,0 +1,28 @@
package com.bwie.common.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* @author FangShiBa
* @date 2023/12/17
* @apiNote
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Facility {
private Integer facilityId; //设备编号
private String facilityType; //设备类型
private String facilitySite; //设备地址
private Integer replenishmentUserId; //补货员工
private Integer maintainUserId; //维修员工
private String facilityStatic; //设备状态
private Integer delId; //删除状态
}

View File

@ -0,0 +1,26 @@
package com.bwie.common.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* @author FangShiBa
* @date 2023/12/17
* @apiNote
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Goods {
private Integer goodsId; //商品设备中间id
private Integer shopId; //商品id
private Integer facilityId; //设备id
private Integer goodsNum; //库存
private Integer goodsIsDelete; //上下架(逻辑字段: 0上架, 1下架)
}

View File

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

View File

@ -0,0 +1,25 @@
package com.bwie.common.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* @author FangShiBa
* @date 2023/12/17
* @apiNote
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Shop {
private Integer shopId; //商品id
private String shopName; //商品名称
private Double shopPrice; //商品价格
private Integer typeId; //商品类型id
}

View File

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

View File

@ -0,0 +1,30 @@
package com.bwie.common.pojo.VO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* @author FangShiBa
* @date 2023/12/17
* @apiNote
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class VOGoods {
private Integer goodsId; //商品设备中间id
private Integer shopId; //商品id
private Integer facilityId; //设备id
private Integer goodsNum; //库存
private Integer goodsIsDelete; //上下架(逻辑字段: 0上架, 1下架)
private Double payForMoney; //支付金额
private Integer pageNum=1;
private Integer pageSize=3;
}

View File

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

View File

@ -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 "删除成功";
}
}

View File

@ -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();
}
}

View File

@ -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 AccessKeyaccessKeySecretAPI访 访
*/
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;
}
/**
* 使FilePutObject ** 使
* @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;
}
}

View File

@ -0,0 +1,16 @@
package com.bwie.gateway;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author FangShiBa
* @date 2023/12/17
* @apiNote
*/
@SpringBootApplication
public class GateWayApplication {
public static void main(String[] args) {
SpringApplication.run(GateWayApplication.class,args);
}
}

38
bwie-models/bwie-buy/.gitignore vendored 100644
View File

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -0,0 +1,20 @@
<?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-buy</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>
</project>

View File

@ -0,0 +1,18 @@
package com.bwie.buy;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author FangShiBa
* @date 2023/12/17
* @apiNote
*/
@SpringBootApplication
@MapperScan("com.bwie.buy.dao")
public class BuyApplication {
public static void main(String[] args) {
SpringApplication.run(BuyApplication.class,args);
}
}

View File

@ -0,0 +1,60 @@
package com.bwie.buy.controller;
import com.alibaba.fastjson.JSONObject;
import com.bwie.buy.service.BuyService;
import com.bwie.common.pojo.VO.VOGoods;
import com.bwie.common.result.Result;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
* @author FangShiBa
* @date 2023/12/17
* @apiNote
*/
@Log4j2
@RestController
@RequestMapping("/buy")
public class BuyController {
@Autowired
private BuyService service;
@Autowired
private HttpServletRequest request;
/*
,
*/
@PostMapping("/showGoodsList")
public Result showGoodsList(@RequestBody VOGoods voGoods){
log.info("功能:{商品列表展示}请求URI{},请求方法:{},请求参数:{}",
request.getRequestURI(), request.getMethod(),voGoods );
Result result=service.showGoodsList(voGoods);
log.info("功能:{商品列表展示}请求URI{},请求方法:{},响应参数:{}",
request.getRequestURI(), request.getMethod(), JSONObject.toJSONString(result));
return result;
}
/*
*/
@PostMapping("/buyGood")
public Result buyGood(@RequestBody VOGoods voGoods){
log.info("功能:{购买商品}请求URI{},请求方法:{},请求参数:{}",
request.getRequestURI(), request.getMethod(),voGoods );
Result result=service.buyGood(voGoods);
log.info("功能:{购买商品}请求URI{},请求方法:{},响应参数:{}",
request.getRequestURI(), request.getMethod(), JSONObject.toJSONString(result));
return result;
}
}

View File

@ -0,0 +1,29 @@
package com.bwie.buy.dao;
import com.bwie.common.pojo.DTO.DTOGoods;
import com.bwie.common.pojo.Sell;
import com.bwie.common.pojo.Shop;
import com.bwie.common.pojo.VO.VOGoods;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author FangShiBa
* @date 2023/12/17
* @apiNote
*/
@Component
public interface BuyDao {
List<DTOGoods> showGoodsList(VOGoods voGoods);
Shop findById(@Param("shopId") Integer shopId);
void buyGood(VOGoods voGoods);
void addSell(Sell sell);
}

View File

@ -0,0 +1,15 @@
package com.bwie.buy.service;
import com.bwie.common.pojo.VO.VOGoods;
import com.bwie.common.result.Result;
/**
* @author FangShiBa
* @date 2023/12/17
* @apiNote
*/
public interface BuyService {
Result buyGood(VOGoods voGoods);
Result showGoodsList(VOGoods voGoods);
}

View File

@ -0,0 +1,67 @@
package com.bwie.buy.service.impl;
import com.alibaba.fastjson.JSON;
import com.bwie.buy.dao.BuyDao;
import com.bwie.buy.service.BuyService;
import com.bwie.common.constants.JwtConstants;
import com.bwie.common.pojo.DTO.DTOGoods;
import com.bwie.common.pojo.DTO.DTOUser;
import com.bwie.common.pojo.Sell;
import com.bwie.common.pojo.Shop;
import com.bwie.common.pojo.VO.VOGoods;
import com.bwie.common.result.Result;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @author FangShiBa
* @date 2023/12/17
* @apiNote
*/
@Service
public class BuyServiceImp implements BuyService {
@Autowired
private BuyDao dao;
@Autowired
private RedisTemplate<String,String> redisTemplate;
@Autowired
private HttpServletRequest request;
@Override
public Result buyGood(VOGoods voGoods) {
if(null==voGoods.getFacilityId()||null==voGoods.getPayForMoney()){
return Result.error("输入的值有误或未输入");
}
Shop shop=dao.findById(voGoods.getShopId());
if(shop.getShopPrice()>voGoods.getPayForMoney()){
return Result.error("小老弟,钱不够");
}
//voGoods 参数有商品编号和售货机编号
dao.buyGood(voGoods);
String token = request.getHeader("token");
String s = redisTemplate.opsForValue().get(JwtConstants.LOGIN_TOKEN + token);
DTOUser dtoUser = JSON.parseObject(s, DTOUser.class);
Sell sell = new Sell();
sell.setFacilityId(voGoods.getFacilityId());
sell.setShopId(voGoods.getShopId());
sell.setUserId(dtoUser.getUserId());
dao.addSell(sell);
return Result.success("购买成功");
}
@Override
public Result showGoodsList(VOGoods voGoods) {
PageHelper.startPage(voGoods.getPageNum(),voGoods.getPageSize());
List<DTOGoods> list=dao.showGoodsList(voGoods);
PageInfo<DTOGoods> info = new PageInfo<>(list);
return Result.success(info);
}
}

View File

@ -0,0 +1,55 @@
package com.bwie.buy.util;
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 "删除成功";
}
}

View File

@ -0,0 +1,41 @@
# Tomcat
server:
port: 9004
# Spring
spring:
main:
allow-circular-references: true
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
application:
# 应用名称
name: bwie-buy
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 110.42.214.8:8848
config:
# 配置中心地址
server-addr: 110.42.214.8: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: 110.42.214.8:22122
web-server-url: 110.42.214.8:8888
pool:
jmx-enabled: false
# 生成缩略图
thumb-image:
height: 500
width: 500

View File

@ -0,0 +1,29 @@
<?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.buy.dao.BuyDao">
<insert id="addSell">
INSERT INTO `shop_manage`.`t_sell`
(`shop_id`, `sell_time`, `user_id`, `facility_id`) VALUES
(#{shopId}, now(), #{userId}, #{facilityId});
</insert>
<update id="buyGood">
UPDATE `shop_manage`.`t_goods` SET
`goods_num` = (`goods_num`-1)
WHERE
`shop_id` = #{shopId} and
`facility_id` = #{facilityId}
</update>
<select id="showGoodsList" resultType="com.bwie.common.pojo.DTO.DTOGoods">
select * from t_goods g
left join t_shop s on g.shop_id=s.shop_id
left join t_facility f on g.facility_id=f.facility_id
WHERE f.facility_id=#{facilityId}
</select>
<select id="findById" resultType="com.bwie.common.pojo.Shop">
select * from t_shop
where shop_id=${shopId}
</select>
</mapper>

View File

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

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

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

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -0,0 +1,8 @@
package com.bwie.list.service;
import com.bwie.common.result.Result;
public interface TypeService {
Result findType();
}

View File

@ -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("进货失败");
}
}

View File

@ -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,"上传成功");
}
}

View File

@ -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,"类型展示");
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -14,6 +14,8 @@
<modules>
<module>bwie-user</module>
<module>bwie-sell</module>
<module>bwie-buy</module>
<module>bwie-shopList</module>
</modules>
<properties>
@ -22,4 +24,53 @@
<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>

View File

@ -0,0 +1,17 @@
package com.bwie.mq;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* @author FangShiBa
* @date 2023/12/17
* @apiNote
*/
@SpringBootApplication
public class MqApplication {
public static void main(String[] args) {
SpringApplication.run(MqApplication.class,args);
}
}