Compare commits
11 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
3c7c255eed | 2 years ago |
|
|
b4217be985 | 2 years ago |
|
|
6f2f8bd12d | 2 years ago |
|
|
efc5cc18df | 2 years ago |
|
|
b6181060c2 | 2 years ago |
|
|
fe47995c0c | 2 years ago |
|
|
ebe07f9587 | 2 years ago |
|
|
808cf96a8c | 2 years ago |
|
|
ed354c6237 | 2 years ago |
|
|
70f38ef0c1 | 2 years ago |
|
|
918321fa17 | 2 years ago |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
@ -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
|
||||
@ -0,0 +1,3 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/itmk-base-commom/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/itmk-base-commom/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/itmk-base-web/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/itmk-base-web/src/main/resources" 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>
|
||||
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MarkdownSettingsMigration">
|
||||
<option name="stateVersion" value="1" />
|
||||
</component>
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="corretto-1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
@ -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>
|
||||
@ -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
|
||||
@ -0,0 +1,48 @@
|
||||
<?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>
|
||||
<packaging>jar</packaging>
|
||||
<parent>
|
||||
<groupId>com.itmk</groupId>
|
||||
<artifactId>shopAPI</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>itmk-base-commom</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<!-- jwt-->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>0.9.0</version>
|
||||
</dependency>
|
||||
<!-- 工具类依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.commit451</groupId>
|
||||
<artifactId>bitmapji</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.commit451</groupId>
|
||||
<artifactId>bitmapji</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.commit451</groupId>
|
||||
<artifactId>bitmapji</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,14 @@
|
||||
package com.itmk.status;
|
||||
|
||||
/**
|
||||
* 返回状态码
|
||||
*/
|
||||
public class StatusCode {
|
||||
//返回成功
|
||||
public static final int SUCCESS_CODE = 200;
|
||||
//错误状态码
|
||||
public static final int ERROR_CODE = 500;
|
||||
//无权限
|
||||
public static final int NO_LOGIN = 600;
|
||||
public static final int NO_AUTH = 700;
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
package com.itmk.utils;
|
||||
|
||||
import com.itmk.status.StatusCode;
|
||||
|
||||
/**
|
||||
* 数据返回工具类
|
||||
*/
|
||||
public class ResultUtils {
|
||||
/**
|
||||
* 无参数返回
|
||||
* @return
|
||||
*/
|
||||
public static ResultVo succcess(String s) {
|
||||
return Vo(null, StatusCode.SUCCESS_CODE, null);
|
||||
}
|
||||
public static ResultVo success(String msg){
|
||||
return Vo(msg,StatusCode.SUCCESS_CODE,null);
|
||||
}
|
||||
/**
|
||||
* 返回带参数
|
||||
* @param msg
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public static ResultVo success(String msg,Object data){
|
||||
return Vo(msg,StatusCode.SUCCESS_CODE,data);
|
||||
}
|
||||
public static ResultVo success(String msg,int code,Object data){
|
||||
return Vo(msg,code,data);
|
||||
}
|
||||
public static ResultVo Vo(String msg, int code, Object data) {
|
||||
return new ResultVo(msg, code, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 错误返回
|
||||
* @return
|
||||
*/
|
||||
public static ResultVo error(){
|
||||
return Vo(null,StatusCode.ERROR_CODE,null);
|
||||
}
|
||||
public static ResultVo error(String msg){
|
||||
return Vo(msg,StatusCode.ERROR_CODE,null);
|
||||
}
|
||||
public static ResultVo error(String msg,int code,Object data){
|
||||
return Vo(msg,code,data);
|
||||
}
|
||||
public static ResultVo error(String msg,int code){
|
||||
return Vo(msg,code,null);
|
||||
}
|
||||
public static ResultVo error(String msg,Object data){
|
||||
return Vo(msg, StatusCode.ERROR_CODE,data);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.itmk.utils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class ResultVo<T> {
|
||||
private String msg;
|
||||
private int code;
|
||||
private T data;
|
||||
}
|
||||
@ -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
|
||||
@ -0,0 +1,115 @@
|
||||
<?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.itmk</groupId>
|
||||
<artifactId>shopAPI</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>itmk-base-web</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.itmk</groupId>
|
||||
<artifactId>itmk-base-commom</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!--web启动器,对springmvc,serlvet等支持-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
<!--图片验证码-->
|
||||
<dependency>
|
||||
<groupId>com.github.penggle</groupId>
|
||||
<artifactId>kaptcha</artifactId>
|
||||
</dependency>
|
||||
<!--数据库依赖-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<!--mybatis-plus启动器-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!--druid连接池-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- swagger api文档 -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
<version>1.18</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.commit451</groupId>
|
||||
<artifactId>bitmapji</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.commit451</groupId>
|
||||
<artifactId>bitmapji</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.commit451</groupId>
|
||||
<artifactId>bitmapji</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.1.4.RELEASE</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.19.1</version>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests> <!--打包过程默认关掉单元测试 -->
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,12 @@
|
||||
package com.itmk;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
|
||||
@SpringBootApplication
|
||||
public class ShopApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ShopApplication.class,args);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package com.itmk.config.imagecode;
|
||||
|
||||
import com.google.code.kaptcha.Constants;
|
||||
import com.google.code.kaptcha.impl.DefaultKaptcha;
|
||||
import com.google.code.kaptcha.util.Config;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* 验证码配置类
|
||||
*/
|
||||
@Configuration
|
||||
public class ImageConfig {
|
||||
@Bean
|
||||
public DefaultKaptcha getDefaultKaptcha(){
|
||||
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
|
||||
Properties properties = new Properties();
|
||||
//验证码是否有边框
|
||||
properties.setProperty(Constants.KAPTCHA_BORDER, "yes");
|
||||
//边框颜色
|
||||
properties.setProperty(Constants.KAPTCHA_BORDER_COLOR, "105,179,90");
|
||||
//字体颜色
|
||||
properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_FONT_COLOR, "blue");
|
||||
//验证码图片宽度
|
||||
properties.setProperty(Constants.KAPTCHA_IMAGE_WIDTH, "200");
|
||||
//验证码图片高度
|
||||
properties.setProperty(Constants.KAPTCHA_IMAGE_HEIGHT, "36");
|
||||
//生成验证码的字符
|
||||
properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_CHAR_STRING, "0123456789");
|
||||
//去掉干扰线
|
||||
properties.setProperty(Constants.KAPTCHA_NOISE_IMPL,"com.google.code.kaptcha.impl.NoNoise");
|
||||
//字体大小
|
||||
properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_FONT_SIZE, "34");
|
||||
//字体样式
|
||||
properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_FONT_NAMES, "楷体");
|
||||
//验证码位数
|
||||
properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, "4");
|
||||
// 图片效果
|
||||
properties.setProperty(Constants.KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy");
|
||||
Config config = new Config(properties);
|
||||
defaultKaptcha.setConfig(config);
|
||||
return defaultKaptcha;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package com.itmk.config.mvc;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class MvcConfiguration implements WebMvcConfigurer {
|
||||
|
||||
/**
|
||||
* 跨域配置
|
||||
* @param registry
|
||||
*/
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOriginPatterns("*")
|
||||
.allowedMethods("*")
|
||||
.allowedHeaders("*")
|
||||
.maxAge(3600)
|
||||
.allowCredentials(true);
|
||||
}
|
||||
|
||||
@Value("${web.load-path}")
|
||||
private String loadPath;
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/images/**")
|
||||
.addResourceLocations(loadPath);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.itmk.config.mybatis;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@MapperScan("com.itmk.*.*.mapper")
|
||||
public class MyBatisPlusConfig {
|
||||
// 最新版
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||
return interceptor;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package com.itmk.upload.image;
|
||||
|
||||
import com.itmk.utils.ResultUtils;
|
||||
import com.itmk.utils.ResultVo;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/upload")
|
||||
public class ImageUploadController {
|
||||
//图片上传的路径
|
||||
@Value("${web.uploadpath}")
|
||||
private String webUploadpath;
|
||||
|
||||
@RequestMapping("/uploadImage")
|
||||
public ResultVo uploadImage(@RequestParam("file") MultipartFile file){
|
||||
String Url = "";
|
||||
String fileName = file.getOriginalFilename();
|
||||
//获取文件扩展名
|
||||
String fileExtenionName = fileName.substring(fileName.indexOf("."));
|
||||
//新的文件名
|
||||
String newName = UUID.randomUUID().toString()+fileExtenionName;
|
||||
String path = webUploadpath;
|
||||
File fileDir = new File(path);
|
||||
if(!fileDir.exists()){
|
||||
fileDir.mkdirs();
|
||||
//设置权限
|
||||
fileDir.setWritable(true);
|
||||
}
|
||||
File targetFile = new File(path,newName);
|
||||
try{
|
||||
file.transferTo(targetFile);
|
||||
Url = "/" + targetFile.getName();
|
||||
}catch (Exception e){
|
||||
return null;
|
||||
}
|
||||
return ResultUtils.success("成功", "/images" + Url);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,158 @@
|
||||
package com.itmk.web.goods.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.itmk.utils.ResultUtils;
|
||||
import com.itmk.utils.ResultVo;
|
||||
import com.itmk.web.goods.entity.*;
|
||||
import com.itmk.web.goods.service.GoodsService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/goods")
|
||||
public class GoodsController {
|
||||
@Autowired
|
||||
private GoodsService goodsService;
|
||||
|
||||
//发布
|
||||
@PostMapping("/release")
|
||||
public ResultVo release(@RequestBody Goods goods){
|
||||
//设置时间
|
||||
goods.setCreateTime(new Date());
|
||||
if(goodsService.save(goods)){
|
||||
return ResultUtils.success("发布成功!");
|
||||
}
|
||||
return ResultUtils.error("发布失败!");
|
||||
}
|
||||
|
||||
//列表
|
||||
@GetMapping("/list")
|
||||
public ResultVo getList(GoodsListParm parm){
|
||||
//构造分页对象
|
||||
IPage<Goods> page = new Page<>(parm.getCurrentPage(),parm.getPageSize());
|
||||
//构造查询条件
|
||||
QueryWrapper<Goods> query = new QueryWrapper<>();
|
||||
query.lambda().like(StringUtils.isNotEmpty(parm.getGoodsName()),Goods::getGoodsName,parm.getGoodsName())
|
||||
.eq(Goods::getDeleteStatus,"0")
|
||||
.orderByDesc(Goods::getCreateTime);
|
||||
IPage<Goods> list = goodsService.page(page, query);
|
||||
return ResultUtils.success("查询成功",list);
|
||||
}
|
||||
|
||||
//上架下架
|
||||
@PostMapping("/upanddown")
|
||||
public ResultVo upanddown(@RequestBody UpandDownParm parm){
|
||||
UpdateWrapper<Goods> query = new UpdateWrapper<>();
|
||||
query.lambda().set(Goods::getStatus,parm.getStatus())
|
||||
.eq(Goods::getGoodsId,parm.getGoodsId());
|
||||
if(goodsService.update(query)){
|
||||
return ResultUtils.success("设置成功!");
|
||||
}
|
||||
return ResultUtils.error("设置失败!");
|
||||
}
|
||||
|
||||
//推荐首页
|
||||
@PostMapping("/setIndex")
|
||||
public ResultVo setIndex(@RequestBody UpandDownParm parm){
|
||||
UpdateWrapper<Goods> query = new UpdateWrapper<>();
|
||||
query.lambda().set(Goods::getSetIndex,parm.getSetIndex())
|
||||
.eq(Goods::getGoodsId,parm.getGoodsId());
|
||||
if(goodsService.update(query)){
|
||||
return ResultUtils.success("设置成功!");
|
||||
}
|
||||
return ResultUtils.error("设置失败!");
|
||||
}
|
||||
|
||||
//删除
|
||||
@PostMapping("/delete")
|
||||
public ResultVo delete(@RequestBody UpandDownParm parm){
|
||||
UpdateWrapper<Goods> query = new UpdateWrapper<>();
|
||||
query.lambda().set(Goods::getDeleteStatus,"1")
|
||||
.eq(Goods::getGoodsId,parm.getGoodsId());
|
||||
if(goodsService.update(query)){
|
||||
return ResultUtils.success("删除成功!");
|
||||
}
|
||||
return ResultUtils.error("删除失败!");
|
||||
}
|
||||
|
||||
//小程序闲置列表查询
|
||||
@GetMapping("/getUsedList")
|
||||
public ResultVo getUsedList(WxIndexParm parm){
|
||||
//构造查询条件
|
||||
QueryWrapper<Goods> query = new QueryWrapper<>();
|
||||
query.lambda().like(StringUtils.isNotEmpty(parm.getKeywords()),Goods::getGoodsName,parm.getKeywords())
|
||||
.eq(Goods::getStatus,"0")
|
||||
.eq(Goods::getDeleteStatus,"0")
|
||||
.eq(Goods::getType,"0")
|
||||
.eq(Goods::getSellStatus,"0")
|
||||
.eq(Goods::getCategoryId,parm.getCategoryId())
|
||||
.orderByDesc(Goods::getCreateTime);
|
||||
//构造分页对象
|
||||
IPage<Goods> page = new Page<>(parm.getCurrentPage(),parm.getPageSize());
|
||||
IPage<Goods> list = goodsService.page(page, query);
|
||||
return ResultUtils.success("查询成功",list);
|
||||
}
|
||||
|
||||
//小程序求购列表查询
|
||||
@GetMapping("/getBuyList")
|
||||
public ResultVo getBuyList(WxIndexParm parm){
|
||||
//构造查询条件
|
||||
QueryWrapper<Goods> query = new QueryWrapper<>();
|
||||
query.lambda().like(StringUtils.isNotEmpty(parm.getKeywords()),Goods::getGoodsName,parm.getKeywords())
|
||||
.eq(Goods::getStatus,"0")
|
||||
.eq(Goods::getDeleteStatus,"0")
|
||||
.eq(Goods::getType,"1")
|
||||
.eq(Goods::getSellStatus,"0")
|
||||
.eq(Goods::getCategoryId,parm.getCategoryId())
|
||||
.orderByDesc(Goods::getCreateTime);
|
||||
//构造分页对象
|
||||
IPage<Goods> page = new Page<>(parm.getCurrentPage(),parm.getPageSize());
|
||||
IPage<Goods> list = goodsService.page(page, query);
|
||||
return ResultUtils.success("查询成功",list);
|
||||
}
|
||||
|
||||
//小程序首页推荐列表
|
||||
@GetMapping("/getIndexList")
|
||||
public ResultVo getIndexList(WxIndexParm parm){
|
||||
QueryWrapper<Goods> query = new QueryWrapper<>();
|
||||
query.lambda().like(StringUtils.isNotEmpty(parm.getKeywords()),Goods::getGoodsName,parm.getKeywords())
|
||||
.eq(Goods::getSetIndex,"1")
|
||||
.eq(Goods::getStatus,"0")
|
||||
.eq(Goods::getDeleteStatus,"0")
|
||||
.orderByDesc(Goods::getCreateTime);
|
||||
IPage<Goods> page = new Page<>(parm.getCurrentPage(),parm.getPageSize());
|
||||
IPage<Goods> list = goodsService.page(page,query);
|
||||
return ResultUtils.success("查询成功",list);
|
||||
}
|
||||
|
||||
//小程序我发布的闲置
|
||||
@GetMapping("/getMyUnusedList")
|
||||
public ResultVo getMyUnusedList(MyGoodsParm parm){
|
||||
//构造查询条件
|
||||
QueryWrapper<Goods> query = new QueryWrapper<>();
|
||||
query.lambda().eq(Goods::getUserId,parm.getUserId())
|
||||
.eq(Goods::getType,parm.getType())
|
||||
.eq(Goods::getDeleteStatus,"0");
|
||||
//构造分页对象
|
||||
IPage<Goods> page = new Page<>(parm.getCurrentPage(),parm.getPageSize());
|
||||
IPage<Goods> list = goodsService.page(page, query);
|
||||
return ResultUtils.success("查询成",list);
|
||||
}
|
||||
|
||||
//编辑
|
||||
@PostMapping("/edit")
|
||||
public ResultVo edit(@RequestBody Goods goods){
|
||||
if(goodsService.updateById(goods)){
|
||||
return ResultUtils.success("编辑成功!");
|
||||
}
|
||||
return ResultUtils.error("编辑失败!");
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package com.itmk.web.goods.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GoodsListParm {
|
||||
private Long currentPage;
|
||||
private Long pageSize;
|
||||
private String goodsName;
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package com.itmk.web.goods.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpandDownParm {
|
||||
private Long goodsId;
|
||||
private String status;
|
||||
private String setIndex;
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.itmk.web.goods.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WxIndexParm {
|
||||
private Long currentPage;
|
||||
private Long pageSize;
|
||||
private Long categoryId;
|
||||
private String keywords;
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package com.itmk.web.goods.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.itmk.web.goods.entity.Goods;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface GoodsMapper extends BaseMapper<Goods> {
|
||||
//查询我的订单
|
||||
IPage<Goods> getMyOrder(IPage<Goods> page, @Param("userId") Long userId);
|
||||
//查询出售订单
|
||||
IPage<Goods> getSellOrder(IPage<Goods> page, @Param("userId") Long userId);
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.itmk.web.goods.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.itmk.web.goods.entity.Goods;
|
||||
import com.itmk.web.goods.entity.MyGoodsParm;
|
||||
|
||||
|
||||
public interface GoodsService extends IService<Goods> {
|
||||
//查询我的订单
|
||||
IPage<Goods> getMyOrder(MyGoodsParm parm);
|
||||
//查询出售订单
|
||||
IPage<Goods> getSellOrder(MyGoodsParm parm);
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package com.itmk.web.goods.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.itmk.web.goods.entity.Goods;
|
||||
import com.itmk.web.goods.entity.MyGoodsParm;
|
||||
import com.itmk.web.goods.mapper.GoodsMapper;
|
||||
import com.itmk.web.goods.service.GoodsService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@Service
|
||||
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {
|
||||
@Override
|
||||
public IPage<Goods> getMyOrder(MyGoodsParm parm) {
|
||||
//构造分页对象
|
||||
IPage<Goods> page = new Page<>(parm.getCurrentPage(),parm.getPageSize());
|
||||
return this.baseMapper.getMyOrder(page,parm.getUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<Goods> getSellOrder(MyGoodsParm parm) {
|
||||
//构造分页对象
|
||||
IPage<Goods> page = new Page<>(parm.getCurrentPage(),parm.getPageSize());
|
||||
return this.baseMapper.getSellOrder(page,parm.getUserId());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
package com.itmk.web.goods_category.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.itmk.utils.ResultUtils;
|
||||
import com.itmk.utils.ResultVo;
|
||||
import com.itmk.web.goods_category.entity.GoodsCategory;
|
||||
import com.itmk.web.goods_category.entity.ListParm;
|
||||
import com.itmk.web.goods_category.entity.SelectType;
|
||||
import com.itmk.web.goods_category.service.GoodsCategoryService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/category")
|
||||
public class GoodsCategoryController {
|
||||
@Autowired
|
||||
private GoodsCategoryService goodsCategoryService;
|
||||
|
||||
//新增
|
||||
@PostMapping
|
||||
public ResultVo add(@RequestBody GoodsCategory goodsCategory){
|
||||
if(goodsCategoryService.save(goodsCategory)){
|
||||
return ResultUtils.success("新增成功");
|
||||
}
|
||||
return ResultUtils.error("新增失败!");
|
||||
}
|
||||
|
||||
//编辑
|
||||
@PutMapping
|
||||
public ResultVo edit(@RequestBody GoodsCategory goodsCategory) {
|
||||
if (goodsCategoryService.updateById(goodsCategory)) {
|
||||
return ResultUtils.success("编辑成功!");
|
||||
}
|
||||
return ResultUtils.error("编辑失败!");
|
||||
}
|
||||
|
||||
//删除
|
||||
@DeleteMapping("/{categoryId}")
|
||||
public ResultVo delete(@PathVariable("categoryId") Long categoryId) {
|
||||
if (goodsCategoryService.removeById(categoryId)) {
|
||||
return ResultUtils.success("删除成功!");
|
||||
}
|
||||
return ResultUtils.error("删除失败!");
|
||||
}
|
||||
|
||||
//列表
|
||||
@GetMapping("/list")
|
||||
public ResultVo list(ListParm parm) {
|
||||
//构造分页对象
|
||||
IPage<GoodsCategory> page = new Page<>(parm.getCurrentPage(), parm.getPageSize());
|
||||
//构造查询条件
|
||||
QueryWrapper<GoodsCategory> query = new QueryWrapper<>();
|
||||
query.lambda().like(StringUtils.isNotEmpty(parm.getCategoryName()), GoodsCategory::getCategoryName, parm.getCategoryName())
|
||||
.orderByDesc(GoodsCategory::getOrderNum);
|
||||
//查询数据
|
||||
IPage<GoodsCategory> list = goodsCategoryService.page(page, query);
|
||||
return ResultUtils.success("查询成功", list);
|
||||
}
|
||||
|
||||
//小程序分类
|
||||
@GetMapping("/getSelectList")
|
||||
public ResultVo getSelectList() {
|
||||
//查询分类列表
|
||||
QueryWrapper<GoodsCategory> query = new QueryWrapper<>();
|
||||
query.lambda().orderByAsc(GoodsCategory::getOrderNum);
|
||||
List<GoodsCategory> list = goodsCategoryService.list(query);
|
||||
//存储小程序需要的类型
|
||||
List<SelectType> selectList = new ArrayList<>();
|
||||
//构造小程序需要的类型
|
||||
Optional.ofNullable(list).orElse(new ArrayList<>())
|
||||
.stream()
|
||||
.forEach(item -> {
|
||||
SelectType type = new SelectType();
|
||||
type.setLabel(item.getCategoryName());
|
||||
type.setValue(item.getCategoryId());
|
||||
selectList.add(type);
|
||||
});
|
||||
return ResultUtils.success("查询成功", selectList);
|
||||
}
|
||||
|
||||
|
||||
//小程序分类接口
|
||||
@GetMapping("/getCateList")
|
||||
public ResultVo getCateList(){
|
||||
List<GoodsCategory> list = goodsCategoryService.list();
|
||||
return ResultUtils.success("查询成功",list);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.itmk.web.goods_category.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("goods_category")
|
||||
public class GoodsCategory {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long categoryId;
|
||||
private String categoryName;
|
||||
private Integer orderNum;
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.itmk.web.goods_category.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class ListParm {
|
||||
private Integer currentPage; //当前页
|
||||
private Integer pageSize;//每页查询的条数
|
||||
private String categoryName;
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package com.itmk.web.goods_category.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class SelectType {
|
||||
private Long value;
|
||||
private String label;
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package com.itmk.web.goods_category.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.itmk.web.goods_category.entity.GoodsCategory;
|
||||
|
||||
public interface GoodsCategoryMapper extends BaseMapper<GoodsCategory> {
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package com.itmk.web.goods_category.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.itmk.web.goods_category.entity.GoodsCategory;
|
||||
|
||||
public interface GoodsCategoryService extends IService<GoodsCategory> {
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.itmk.web.goods_category.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.itmk.web.goods_category.entity.GoodsCategory;
|
||||
import com.itmk.web.goods_category.mapper.GoodsCategoryMapper;
|
||||
import com.itmk.web.goods_category.service.GoodsCategoryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class GoodsCategoryServiceImpl extends ServiceImpl<GoodsCategoryMapper, GoodsCategory> implements GoodsCategoryService {
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package com.itmk.web.goods_collect.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.itmk.utils.ResultUtils;
|
||||
import com.itmk.utils.ResultVo;
|
||||
import com.itmk.web.goods.entity.Goods;
|
||||
import com.itmk.web.goods_collect.entity.CollectParm;
|
||||
import com.itmk.web.goods_collect.entity.GoodsCollect;
|
||||
import com.itmk.web.goods_collect.service.GoodsCollectService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@RequestMapping("/api/collect")
|
||||
@RestController
|
||||
public class GoodsCollectController {
|
||||
@Autowired
|
||||
private GoodsCollectService goodsCollectService;
|
||||
|
||||
//收藏
|
||||
@PostMapping("/collect")
|
||||
public ResultVo collect(@RequestBody GoodsCollect goodsCollect){
|
||||
//判断是否已经收藏
|
||||
QueryWrapper<GoodsCollect> query = new QueryWrapper<>();
|
||||
query.lambda().eq(GoodsCollect::getGoodsId,goodsCollect.getGoodsId())
|
||||
.eq(GoodsCollect::getUserId,goodsCollect.getUserId());
|
||||
GoodsCollect one = goodsCollectService.getOne(query);
|
||||
if(one == null){ //未收藏
|
||||
goodsCollect.setCollectTime(new Date());
|
||||
if(goodsCollectService.save(goodsCollect)){
|
||||
return ResultUtils.success("收藏成功!");
|
||||
}
|
||||
return ResultUtils.error("收藏失败!");
|
||||
}else{ //已收藏,取消收藏
|
||||
if(goodsCollectService.remove(query)){
|
||||
return ResultUtils.success("收藏成功!");
|
||||
}
|
||||
return ResultUtils.error("收藏失败!");
|
||||
}
|
||||
}
|
||||
|
||||
//判断是否已经收藏
|
||||
@GetMapping("/hasCollect")
|
||||
public ResultVo hasCollect(GoodsCollect goodsCollect){
|
||||
//判断是否已经收藏
|
||||
QueryWrapper<GoodsCollect> query = new QueryWrapper<>();
|
||||
query.lambda().eq(GoodsCollect::getGoodsId,goodsCollect.getGoodsId())
|
||||
.eq(GoodsCollect::getUserId,goodsCollect.getUserId());
|
||||
GoodsCollect one = goodsCollectService.getOne(query);
|
||||
if(one != null){ //已经收藏
|
||||
return ResultUtils.success("查询成功","1");
|
||||
}else{ //未收藏
|
||||
return ResultUtils.success("查询成功","0");
|
||||
}
|
||||
}
|
||||
|
||||
//小程序我的收藏列表
|
||||
@GetMapping("/getMyCollect")
|
||||
public ResultVo getMyCollect(CollectParm parm){
|
||||
IPage<Goods> list = goodsCollectService.getMyCollect(parm);
|
||||
return ResultUtils.success("查询成功",list);
|
||||
}
|
||||
|
||||
//取消收藏
|
||||
@PostMapping("/cancel")
|
||||
public ResultVo cancel(@RequestBody GoodsCollect collect){
|
||||
if(goodsCollectService.removeById(collect.getCollectId())){
|
||||
return ResultUtils.success("取消成功!");
|
||||
}
|
||||
return ResultUtils.error("取消失败!");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package com.itmk.web.goods_collect.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CollectParm {
|
||||
private Long userId;
|
||||
private Long currentPage;
|
||||
private Long pageSize;
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.itmk.web.goods_collect.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("goods_collect")
|
||||
public class GoodsCollect {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long collectId;
|
||||
private Long userId;
|
||||
private Long goodsId;
|
||||
private Date collectTime;
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package com.itmk.web.goods_collect.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.itmk.web.goods.entity.Goods;
|
||||
import com.itmk.web.goods_collect.entity.GoodsCollect;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface GoodsCollectMapper extends BaseMapper<GoodsCollect> {
|
||||
//小程序我的收藏列表
|
||||
IPage<Goods> getMyCollect(IPage<Goods> page, @Param("userId") Long userId);
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package com.itmk.web.goods_collect.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.itmk.web.goods.entity.Goods;
|
||||
import com.itmk.web.goods_collect.entity.CollectParm;
|
||||
import com.itmk.web.goods_collect.entity.GoodsCollect;
|
||||
|
||||
|
||||
public interface GoodsCollectService extends IService<GoodsCollect> {
|
||||
IPage<Goods> getMyCollect(CollectParm parm);
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.itmk.web.goods_collect.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.itmk.web.goods.entity.Goods;
|
||||
import com.itmk.web.goods_collect.entity.CollectParm;
|
||||
import com.itmk.web.goods_collect.entity.GoodsCollect;
|
||||
import com.itmk.web.goods_collect.mapper.GoodsCollectMapper;
|
||||
import com.itmk.web.goods_collect.service.GoodsCollectService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@Service
|
||||
public class GoodsCollectServiceImpl extends ServiceImpl<GoodsCollectMapper, GoodsCollect> implements GoodsCollectService {
|
||||
@Override
|
||||
public IPage<Goods> getMyCollect(CollectParm parm) {
|
||||
//构造分页对象
|
||||
IPage<Goods> page = new Page<>(parm.getCurrentPage(),parm.getPageSize());
|
||||
return this.baseMapper.getMyCollect(page,parm.getUserId());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
package com.itmk.web.goods_order.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.itmk.utils.ResultUtils;
|
||||
import com.itmk.utils.ResultVo;
|
||||
import com.itmk.web.goods.entity.Goods;
|
||||
import com.itmk.web.goods.entity.MyGoodsParm;
|
||||
import com.itmk.web.goods.service.GoodsService;
|
||||
import com.itmk.web.goods_order.entity.GoodsOrder;
|
||||
import com.itmk.web.goods_order.entity.OrderParm;
|
||||
import com.itmk.web.goods_order.entity.OrderVo;
|
||||
import com.itmk.web.goods_order.service.GoodsOrderService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/goodsOrder")
|
||||
public class GoodsOrderController {
|
||||
@Autowired
|
||||
private GoodsOrderService goodsOrderService;
|
||||
@Autowired
|
||||
private GoodsService goodsService;
|
||||
//交易订单
|
||||
@PostMapping("/replaceOrder")
|
||||
public ResultVo replaceOrder(@RequestBody GoodsOrder order){
|
||||
goodsOrderService.replaceOrder(order);
|
||||
return ResultUtils.success("交易成功!");
|
||||
}
|
||||
//小程序我的订单
|
||||
@GetMapping("/getMyOrder")
|
||||
public ResultVo getMyOrder(MyGoodsParm parm){
|
||||
IPage<Goods> list = goodsService.getMyOrder(parm);
|
||||
return ResultUtils.success("查询成功!",list);
|
||||
}
|
||||
|
||||
//我的出售订单
|
||||
@GetMapping("/getSellOrder")
|
||||
public ResultVo getSellOrder(MyGoodsParm parm){
|
||||
IPage<Goods> list = goodsService.getSellOrder(parm);
|
||||
return ResultUtils.success("查询成功!",list);
|
||||
}
|
||||
|
||||
//订单列表
|
||||
@GetMapping("/getList")
|
||||
public ResultVo getList(OrderParm parm){
|
||||
IPage<OrderVo> list = goodsOrderService.getList(parm);
|
||||
return ResultUtils.success("查询成功",list);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.itmk.web.goods_order.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("goods_order")
|
||||
public class GoodsOrder {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long orderId;
|
||||
private Long goodsId;
|
||||
private Long orderUser;
|
||||
private BigDecimal price;
|
||||
private Date createTime;
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.itmk.web.goods_order.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class OrderParm {
|
||||
private Long currentPage;
|
||||
private Long pageSize;
|
||||
private String goodsName;
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.itmk.web.goods_order.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class OrderVo {
|
||||
private Long orderId;
|
||||
private int goodsId;
|
||||
private int orderUser;
|
||||
private String goodsName;
|
||||
private String image;
|
||||
private String nickName;
|
||||
private BigDecimal goodsPrice;
|
||||
private BigDecimal price;
|
||||
//创建时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date createTime;
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package com.itmk.web.goods_order.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.itmk.web.goods_order.entity.GoodsOrder;
|
||||
import com.itmk.web.goods_order.entity.OrderVo;
|
||||
|
||||
public interface GoodsOrderMapper extends BaseMapper<GoodsOrder> {
|
||||
IPage<OrderVo> getList(IPage<OrderVo> page);
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package com.itmk.web.goods_order.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.itmk.web.goods_order.entity.GoodsOrder;
|
||||
import com.itmk.web.goods_order.entity.OrderParm;
|
||||
import com.itmk.web.goods_order.entity.OrderVo;
|
||||
|
||||
public interface GoodsOrderService extends IService<GoodsOrder> {
|
||||
void replaceOrder(GoodsOrder goodsOrder);
|
||||
//闲置订单列表
|
||||
IPage<OrderVo> getList(OrderParm parm);
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package com.itmk.web.goods_order.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.itmk.web.goods.entity.Goods;
|
||||
import com.itmk.web.goods.service.GoodsService;
|
||||
import com.itmk.web.goods_order.entity.GoodsOrder;
|
||||
import com.itmk.web.goods_order.entity.OrderParm;
|
||||
import com.itmk.web.goods_order.entity.OrderVo;
|
||||
import com.itmk.web.goods_order.mapper.GoodsOrderMapper;
|
||||
import com.itmk.web.goods_order.service.GoodsOrderService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
public class GoodsOrderServiceImpl extends ServiceImpl<GoodsOrderMapper, GoodsOrder> implements GoodsOrderService {
|
||||
|
||||
@Autowired
|
||||
private GoodsService goodsService;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void replaceOrder(GoodsOrder goodsOrder) {
|
||||
//1、插入订单数据
|
||||
goodsOrder.setCreateTime(new Date());
|
||||
int insert = this.baseMapper.insert(goodsOrder);
|
||||
//2、更新商品状态
|
||||
if(insert > 0){
|
||||
UpdateWrapper<Goods> query = new UpdateWrapper<>();
|
||||
query.lambda().set(Goods::getSellStatus,"1")
|
||||
.set(Goods::getStatus,"1")
|
||||
.eq(Goods::getGoodsId,goodsOrder.getGoodsId());
|
||||
goodsService.update(query);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<OrderVo> getList(OrderParm parm) {
|
||||
//构造分页对象
|
||||
IPage<OrderVo> page = new Page<>(parm.getCurrentPage(),parm.getPageSize());
|
||||
return this.baseMapper.getList(page);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.itmk.web.login.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class UpadateParm {
|
||||
private Long userId;
|
||||
private String password;
|
||||
private String oldPassword;
|
||||
}
|
||||
@ -0,0 +1,118 @@
|
||||
package com.itmk.web.sys_banner.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.itmk.utils.ResultUtils;
|
||||
import com.itmk.utils.ResultVo;
|
||||
import com.itmk.web.goods.entity.Goods;
|
||||
import com.itmk.web.goods.service.GoodsService;
|
||||
import com.itmk.web.goods_category.entity.SelectType;
|
||||
import com.itmk.web.sys_banner.entity.BannerParm;
|
||||
import com.itmk.web.sys_banner.entity.SysBanner;
|
||||
import com.itmk.web.sys_banner.service.SysBannerService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RequestMapping("/api/banner")
|
||||
@RestController
|
||||
public class SysBannerController {
|
||||
@Autowired
|
||||
private SysBannerService sysBannerService;
|
||||
@Autowired
|
||||
private GoodsService goodsService;
|
||||
|
||||
//新增
|
||||
@PostMapping
|
||||
public ResultVo add(@RequestBody SysBanner sysBanner){
|
||||
if(sysBannerService.save(sysBanner)){
|
||||
return ResultUtils.success("新增成功!");
|
||||
}
|
||||
return ResultUtils.error("新增失败!");
|
||||
}
|
||||
|
||||
//编辑
|
||||
@PutMapping
|
||||
public ResultVo edit(@RequestBody SysBanner sysBanner){
|
||||
if(sysBannerService.updateById(sysBanner)){
|
||||
return ResultUtils.success("编辑成功!");
|
||||
}
|
||||
return ResultUtils.error("编辑失败!");
|
||||
}
|
||||
|
||||
//删除
|
||||
@DeleteMapping("/{banId}")
|
||||
public ResultVo delete(@PathVariable("banId") Long banId){
|
||||
if(sysBannerService.removeById(banId)){
|
||||
return ResultUtils.success("删除成功!");
|
||||
}
|
||||
return ResultUtils.error("删除失败!");
|
||||
}
|
||||
|
||||
//列表
|
||||
@GetMapping("/list")
|
||||
public ResultVo list(BannerParm parm){
|
||||
//构造分页对象
|
||||
IPage<SysBanner> page = new Page<>(parm.getCurrentPage(),parm.getPageSize());
|
||||
//构造查询条件
|
||||
QueryWrapper<SysBanner> query = new QueryWrapper<>();
|
||||
query.lambda().like(StringUtils.isNotEmpty(parm.getTitle()),SysBanner::getTitle,parm.getTitle())
|
||||
.orderByDesc(SysBanner::getOrderNum);
|
||||
IPage<SysBanner> list = sysBannerService.page(page, query);
|
||||
return ResultUtils.success("查询成功!",list);
|
||||
}
|
||||
|
||||
//商品列表
|
||||
@GetMapping("/getGoods")
|
||||
public ResultVo getGoods(){
|
||||
//查询商品
|
||||
QueryWrapper<Goods> query = new QueryWrapper<>();
|
||||
query.lambda().eq(Goods::getStatus,"0").eq(Goods::getSellStatus,"0");
|
||||
List<Goods> list = goodsService.list(query);
|
||||
//组装select需要的数据格式
|
||||
List<SelectType> selectList = new ArrayList<>();
|
||||
for(int i=0;i<list.size();i++){
|
||||
SelectType type = new SelectType();
|
||||
type.setValue(list.get(i).getGoodsId());
|
||||
type.setLabel(list.get(i).getGoodsName());
|
||||
selectList.add(type);
|
||||
}
|
||||
return ResultUtils.success("查询成功",selectList);
|
||||
}
|
||||
|
||||
//上架下架
|
||||
@PostMapping("/upandown")
|
||||
public ResultVo upandown(@RequestBody SysBanner sysBanner){
|
||||
UpdateWrapper<SysBanner> query = new UpdateWrapper<>();
|
||||
query.lambda().set(SysBanner::getStatus,sysBanner.getStatus())
|
||||
.eq(SysBanner::getBanId,sysBanner.getBanId());
|
||||
if(sysBannerService.update(query)){
|
||||
return ResultUtils.success("设置成功!");
|
||||
}
|
||||
return ResultUtils.error("设置失败!");
|
||||
}
|
||||
|
||||
//查询小程序首页轮播图数据
|
||||
@GetMapping("/getIndexBanner")
|
||||
public ResultVo getIndexBanner(){
|
||||
QueryWrapper<SysBanner> query = new QueryWrapper<>();
|
||||
query.lambda().eq(SysBanner::getStatus,"0")
|
||||
.orderByAsc(SysBanner::getOrderNum);
|
||||
List<SysBanner> list = sysBannerService.list(query);
|
||||
if(list.size() > 0){
|
||||
for (int i=0;i<list.size();i++){
|
||||
Long goodsId = list.get(i).getGoodsId();
|
||||
Goods goods = goodsService.getById(goodsId);
|
||||
list.get(i).setGoods(goods);
|
||||
}
|
||||
}
|
||||
return ResultUtils.success("查询成功",list);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package com.itmk.web.sys_banner.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BannerParm {
|
||||
private Long currentPage;
|
||||
private Long pageSize;
|
||||
private String title;
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.itmk.web.sys_banner.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.itmk.web.goods.entity.Goods;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
@TableName("sys_banner")
|
||||
public class SysBanner {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long banId;
|
||||
private Long goodsId;
|
||||
private String title;
|
||||
private String images;
|
||||
private String status;
|
||||
private Integer orderNum;
|
||||
@TableField(exist = false)
|
||||
private Goods goods;
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
package com.itmk.web.sys_banner.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.itmk.web.sys_banner.entity.SysBanner;
|
||||
|
||||
|
||||
public interface SysBannerMapper extends BaseMapper<SysBanner> {
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.itmk.web.sys_banner.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.itmk.web.sys_banner.entity.SysBanner;
|
||||
|
||||
/**
|
||||
* @Author java实战基地
|
||||
* @Version 2383404558
|
||||
*/
|
||||
public interface SysBannerService extends IService<SysBanner> {
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.itmk.web.sys_banner.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.itmk.web.sys_banner.entity.SysBanner;
|
||||
import com.itmk.web.sys_banner.mapper.SysBannerMapper;
|
||||
import com.itmk.web.sys_banner.service.SysBannerService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author java实战基地
|
||||
* @Version 2383404558
|
||||
*/
|
||||
@Service
|
||||
public class SysBannerServiceImpl extends ServiceImpl<SysBannerMapper, SysBanner> implements SysBannerService {
|
||||
}
|
||||
@ -0,0 +1,108 @@
|
||||
package com.itmk.web.sys_menu.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.itmk.utils.ResultUtils;
|
||||
import com.itmk.utils.ResultVo;
|
||||
import com.itmk.web.sys_menu.entity.MakeMenuTree;
|
||||
import com.itmk.web.sys_menu.entity.SysMenu;
|
||||
import com.itmk.web.sys_menu.service.SysMenuService;
|
||||
import com.itmk.web.sys_user.entity.PermissonVo;
|
||||
import com.itmk.web.sys_user.entity.SysUser;
|
||||
import com.itmk.web.sys_user.service.SysUserService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/menu")
|
||||
public class SysMenuController {
|
||||
@Autowired
|
||||
private SysMenuService sysMenuService;
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
|
||||
//新增
|
||||
@PostMapping
|
||||
public ResultVo add(@RequestBody SysMenu sysMenu){
|
||||
sysMenu.setCreateTime(new Date());
|
||||
if(sysMenuService.save(sysMenu)){
|
||||
return ResultUtils.success("新增成功!");
|
||||
}
|
||||
return ResultUtils.error("新增失败!");
|
||||
}
|
||||
|
||||
//编辑
|
||||
@PutMapping
|
||||
public ResultVo edit(@RequestBody SysMenu sysMenu){
|
||||
if(sysMenuService.updateById(sysMenu)){
|
||||
return ResultUtils.success("编辑成功!");
|
||||
}
|
||||
return ResultUtils.error("编辑失败!");
|
||||
}
|
||||
|
||||
//删除
|
||||
@DeleteMapping("/{menuId}")
|
||||
public ResultVo delete(@PathVariable("menuId") Long menuId){
|
||||
if(sysMenuService.removeById(menuId)){
|
||||
return ResultUtils.success("删除成功!");
|
||||
}
|
||||
return ResultUtils.error("删除失败!");
|
||||
}
|
||||
|
||||
//列表
|
||||
@GetMapping("/list")
|
||||
public ResultVo list(){
|
||||
QueryWrapper<SysMenu> query = new QueryWrapper<>();
|
||||
query.lambda().orderByAsc(SysMenu::getOrderNum);
|
||||
List<SysMenu> menuList = sysMenuService.list(query);
|
||||
//组装树形数据
|
||||
List<SysMenu> list = MakeMenuTree.makeTree(menuList, 0L);
|
||||
return ResultUtils.success("查询成功",list);
|
||||
}
|
||||
|
||||
//上级菜单
|
||||
@GetMapping("/getParent")
|
||||
public ResultVo getParent(){
|
||||
List<SysMenu> parent = sysMenuService.getParent();
|
||||
return ResultUtils.success("查询成功",parent);
|
||||
}
|
||||
|
||||
//分配菜单树数据查询和回显
|
||||
@GetMapping("/getAssignTree")
|
||||
public ResultVo getAssignTree(Long userId,Long assId){
|
||||
//查询当前用户的信息
|
||||
SysUser user = sysUserService.getById(userId);
|
||||
//查询菜单信息
|
||||
List<SysMenu> menuList = null;
|
||||
//判断用户是否是超级管理员,超级管理员拥有所有的权限
|
||||
if(StringUtils.isNotEmpty(user.getIsAdmin()) && "1".equals(user.getIsAdmin())){
|
||||
menuList = sysMenuService.list();
|
||||
}else{
|
||||
//根据用户id查询
|
||||
menuList = sysMenuService.getMenuByUserId(userId);
|
||||
}
|
||||
//组装树数据
|
||||
List<SysMenu> menus = MakeMenuTree.makeTree(menuList, 0L);
|
||||
//设置菜单数据
|
||||
PermissonVo vo = new PermissonVo();
|
||||
//!!!!!!!!!
|
||||
vo.setMenuList(menus);
|
||||
//查询回显的数据
|
||||
List<SysMenu> menuByUserId = sysMenuService.getMenuByUserId(assId);
|
||||
List<Long> ids = new ArrayList<>();
|
||||
Optional.ofNullable(menuByUserId).orElse(new ArrayList<>())
|
||||
.stream()
|
||||
.filter(item -> item != null)
|
||||
.forEach(item ->{
|
||||
ids.add(item.getMenuId());
|
||||
});
|
||||
vo.setCheckList(ids.toArray());
|
||||
return ResultUtils.success("查询成功!",vo);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
package com.itmk.web.sys_menu.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CodeVo {
|
||||
private String code;
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.itmk.web.sys_menu.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MenuVo {
|
||||
private Long menuId;
|
||||
private String title;
|
||||
private String path;
|
||||
private String icon;
|
||||
|
||||
public MenuVo(Long menuId, String title, String path, String icon) {
|
||||
this.menuId=menuId;
|
||||
this.title=title;
|
||||
this.path=path;
|
||||
this.icon=icon;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package com.itmk.web.sys_menu.entity;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
@TableName("sys_menu")
|
||||
public class SysMenu {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long menuId;
|
||||
private Long parentId;
|
||||
private String title;
|
||||
private String code;
|
||||
@TableField(exist = false)
|
||||
private Long value;
|
||||
@TableField(exist = false)
|
||||
private String label;
|
||||
private String type;
|
||||
private String icon;
|
||||
private String path;
|
||||
private String parentName;
|
||||
private Integer orderNum;
|
||||
private Date createTime;
|
||||
@TableField(exist = false)
|
||||
private List<SysMenu> children = new ArrayList<>();
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package com.itmk.web.sys_menu.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.itmk.web.sys_menu.entity.SysMenu;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
||||
//根据用户id查询菜单
|
||||
List<SysMenu> getMenuByUserId(@Param("userId") Long userId);
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package com.itmk.web.sys_menu.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.itmk.web.sys_menu.entity.SysMenu;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface SysMenuService extends IService<SysMenu> {
|
||||
List<SysMenu> getParent();
|
||||
//根据用户id查询菜单
|
||||
List<SysMenu> getMenuByUserId(Long userId);
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
package com.itmk.web.sys_menu.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.itmk.web.sys_menu.entity.MakeMenuTree;
|
||||
import com.itmk.web.sys_menu.entity.SysMenu;
|
||||
import com.itmk.web.sys_menu.mapper.SysMenuMapper;
|
||||
import com.itmk.web.sys_menu.service.SysMenuService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService {
|
||||
@Override
|
||||
public List<SysMenu> getParent() {
|
||||
//查询出所有的菜单
|
||||
QueryWrapper<SysMenu> query = new QueryWrapper<>();
|
||||
query.lambda().eq(SysMenu::getType,"1")
|
||||
.orderByAsc(SysMenu::getOrderNum);
|
||||
List<SysMenu> menuList = this.baseMapper.selectList(query);
|
||||
//构造顶级菜单
|
||||
SysMenu menu = new SysMenu();
|
||||
menu.setMenuId(0L);
|
||||
menu.setParentId(-1L);
|
||||
menu.setTitle("顶级菜单");
|
||||
menu.setLabel("顶级菜单");
|
||||
menu.setValue(0L);
|
||||
//添加到菜单数据
|
||||
menuList.add(menu);
|
||||
//组装树形数据
|
||||
return MakeMenuTree.makeTree(menuList,-1L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenu> getMenuByUserId(Long userId) {
|
||||
return this.baseMapper.getMenuByUserId(userId);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,172 @@
|
||||
package com.itmk.web.sys_user.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.code.kaptcha.impl.DefaultKaptcha;
|
||||
import com.itmk.utils.ResultUtils;
|
||||
import com.itmk.utils.ResultVo;
|
||||
import com.itmk.web.sys_menu.entity.MenuVo;
|
||||
import com.itmk.web.sys_menu.entity.SysMenu;
|
||||
import com.itmk.web.sys_menu.service.SysMenuService;
|
||||
import com.itmk.web.sys_user.entity.LoginParm;
|
||||
import com.itmk.web.sys_user.entity.LoginVo;
|
||||
import com.itmk.web.sys_user.entity.PageParm;
|
||||
import com.itmk.web.sys_user.entity.SysUser;
|
||||
import com.itmk.web.sys_user.service.SysUserService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.DigestUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import sun.misc.BASE64Encoder;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController//处理客户端的 HTTP 请求
|
||||
@RequestMapping("/api/sysUser")//处理以 /api/sysUser 开头的所有请求
|
||||
public class SysUserController {
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
@Autowired
|
||||
private SysMenuService sysMenuService;
|
||||
|
||||
// 新增
|
||||
@PostMapping
|
||||
public ResultVo add(@RequestBody SysUser sysUser) {
|
||||
sysUser.setPassword( DigestUtils.md5DigestAsHex(sysUser.getPassword().getBytes()));
|
||||
if (sysUserService.save(sysUser)) {
|
||||
return ResultUtils.success("新增成功!");
|
||||
}
|
||||
return ResultUtils.error("新增失败!!");
|
||||
}
|
||||
|
||||
// 编辑
|
||||
@PutMapping
|
||||
public ResultVo edit(@RequestBody SysUser sysUser) {
|
||||
if (sysUserService.updateById(sysUser)) {
|
||||
return ResultUtils.success("编辑成功!");
|
||||
}
|
||||
return ResultUtils.error("编辑失败!!");
|
||||
}
|
||||
|
||||
// 删除
|
||||
@DeleteMapping("/{userId}")
|
||||
public ResultVo delete(@PathVariable("userId") Long userId) {
|
||||
if (sysUserService.removeById(userId)) {
|
||||
return ResultUtils.success("删除成功!");
|
||||
}
|
||||
return ResultUtils.error("删除失败!!");
|
||||
}
|
||||
|
||||
//列表
|
||||
@GetMapping("/getList")
|
||||
public ResultVo getList(PageParm parm) {
|
||||
//构造查询条件:
|
||||
QueryWrapper<SysUser> query = new QueryWrapper<>();
|
||||
query.lambda()
|
||||
// 使用 StringUtils.isNotEmpty(parm.getNickName()) 条件来判断是否需要添加模糊查询条件
|
||||
.like(StringUtils.isNotEmpty(parm.getNickName()), // 如果 parm.getNickName() 不为空才执行下面的条件
|
||||
SysUser::getNickName, // 要查询的字段名
|
||||
parm.getNickName() // 查询的关键词,即需要模糊匹配的值
|
||||
);
|
||||
//构造分页对象
|
||||
IPage<SysUser> page = new Page<>(parm.getCurrentPage(), parm.getPageSize());
|
||||
IPage<SysUser> list = sysUserService.page(page, query);
|
||||
return ResultUtils.success("查询成功", list);
|
||||
}
|
||||
@Autowired
|
||||
private DefaultKaptcha defaultKaptcha;
|
||||
//生成验证码
|
||||
@PostMapping("/image")
|
||||
public ResultVo imageCode(HttpServletRequest request) {
|
||||
//生成验证码 4562
|
||||
String text = defaultKaptcha.createText();
|
||||
//验证码存到session
|
||||
HttpSession session = request.getSession();
|
||||
session.setAttribute("code", text);
|
||||
//生成图片,转换为base64
|
||||
BufferedImage bufferedImage = defaultKaptcha.createImage(text);
|
||||
ByteArrayOutputStream outputStream = null;
|
||||
try {
|
||||
outputStream = new ByteArrayOutputStream();
|
||||
ImageIO.write(bufferedImage, "jpg", outputStream);
|
||||
BASE64Encoder encoder = new BASE64Encoder();
|
||||
String base64 = encoder.encode(outputStream.toByteArray());
|
||||
String captchaBase64 = "data:image/jpeg;base64," + base64.replaceAll("\r\n", "");
|
||||
ResultVo result = new ResultVo("生成成功", 200, captchaBase64);
|
||||
return result;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (outputStream != null) {
|
||||
outputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//登录
|
||||
@PostMapping("/login")
|
||||
public ResultVo login(@RequestBody LoginParm parm, HttpServletRequest request) {
|
||||
//获取sesson里面的code验证码
|
||||
HttpSession session = request.getSession();
|
||||
String code = (String) session.getAttribute("code");
|
||||
//获取前端传递过来的验证码
|
||||
String codeParm = parm.getCode();
|
||||
if (StringUtils.isEmpty(code)) {
|
||||
return ResultUtils.error("验证码过期!");
|
||||
}
|
||||
//对比验证码
|
||||
if (!codeParm.equals(code)) {
|
||||
return ResultUtils.error("验证码错误!");
|
||||
}
|
||||
//验证用户信息
|
||||
QueryWrapper<SysUser> query = new QueryWrapper<>();
|
||||
query.lambda().eq(SysUser::getUsername, parm.getUsername())
|
||||
.eq(SysUser::getPassword, DigestUtils.md5DigestAsHex(parm.getPassword().getBytes()));
|
||||
SysUser user = sysUserService.getOne(query);
|
||||
if (user == null) {
|
||||
return ResultUtils.error("用户名或者密码错误!");
|
||||
}
|
||||
if (user.getStatus().equals("1")) {
|
||||
return ResultUtils.error("账户被停用,请联系管理员!");
|
||||
}
|
||||
//返回登录信息
|
||||
LoginVo vo = new LoginVo();
|
||||
vo.setUserId(user.getUserId());
|
||||
vo.setNickName(user.getNickName());
|
||||
//返回用户的菜单和按钮
|
||||
List<SysMenu> menuList = null;
|
||||
//是超级管理员
|
||||
if (StringUtils.isNotEmpty(user.getIsAdmin()) && "1".equals(user.getIsAdmin())) {
|
||||
menuList = sysMenuService.list();
|
||||
} else {
|
||||
menuList = sysMenuService.getMenuByUserId(user.getUserId());
|
||||
}
|
||||
//获取权限字段
|
||||
List<String> codeList = Optional.ofNullable(menuList).orElse(new ArrayList<>())
|
||||
.stream()
|
||||
.map(item -> item.getCode()).collect(Collectors.toList());
|
||||
vo.setCodeList(codeList);
|
||||
//获取菜单
|
||||
List<MenuVo> menuVoList = Optional.ofNullable(menuList).orElse(new ArrayList<>())
|
||||
.stream()
|
||||
.filter(item -> item.getType().equals("1"))
|
||||
.map(item -> new MenuVo(item.getMenuId(), item.getTitle(), item.getPath(), item.getIcon())).collect(Collectors.toList());
|
||||
vo.setMenuList(menuVoList);
|
||||
return ResultUtils.success("登录成功", vo);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package com.itmk.web.sys_user.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class AssignParm {
|
||||
private Long assId;
|
||||
private List<Long> list;
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.itmk.web.sys_user.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class LoginParm {
|
||||
private String username;
|
||||
private String password;
|
||||
private String code;
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.itmk.web.sys_user.entity;
|
||||
|
||||
import com.itmk.web.sys_menu.entity.MenuVo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class LoginVo {
|
||||
private Long userId;
|
||||
private String nickName;
|
||||
private List<MenuVo> menuList = new ArrayList<>();
|
||||
private List<String> codeList = new ArrayList<>();
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.itmk.web.sys_user.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class PageParm {
|
||||
private Long currentPage;
|
||||
private Long pageSize;
|
||||
private String nickName;
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.itmk.web.sys_user.entity;
|
||||
|
||||
import com.itmk.web.sys_menu.entity.SysMenu;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class PermissonVo {
|
||||
//当前用户的菜单
|
||||
List<SysMenu> menuList = new ArrayList<>();
|
||||
//回显的数据:被分配的用户的菜单
|
||||
private Object[] checkList;
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.itmk.web.sys_user.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data//get和set自动生成
|
||||
@TableName("sys_user")
|
||||
public class SysUser {
|
||||
// userId是主键
|
||||
@TableId(type = IdType.AUTO)
|
||||
private long userId;
|
||||
private String username;
|
||||
private String password;
|
||||
private String nickName;
|
||||
private String phone;
|
||||
private String sex;
|
||||
private String status;
|
||||
private String isAdmin;
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.itmk.web.sys_user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.itmk.web.sys_menu.entity.SysMenu;
|
||||
import com.itmk.web.sys_user.entity.SysUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
//通用的增删改查
|
||||
public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
//根据用户id查询菜单
|
||||
List<SysMenu> getMenuByUserId(@Param("userId") Long userId);
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package com.itmk.web.sys_user.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.itmk.web.sys_user.entity.SysUser;
|
||||
|
||||
public interface SysUserService extends IService<SysUser> {
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.itmk.web.sys_user.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.itmk.web.sys_user.entity.SysUser;
|
||||
import com.itmk.web.sys_user.mapper.SysUserMapper;
|
||||
import com.itmk.web.sys_user.service.SysUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package com.itmk.web.user_menu.controller;
|
||||
|
||||
import com.itmk.utils.ResultUtils;
|
||||
import com.itmk.utils.ResultVo;
|
||||
import com.itmk.web.sys_user.entity.AssignParm;
|
||||
import com.itmk.web.sys_user.entity.SysUser;
|
||||
import com.itmk.web.sys_user.service.SysUserService;
|
||||
import com.itmk.web.user_menu.service.UserMenuService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
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;
|
||||
|
||||
@RestController//处理客户端的 HTTP 请求
|
||||
@RequestMapping("/api/userMenu")//处理以 /api/userMenu 开头的所有请求
|
||||
public class MenuUserController {
|
||||
|
||||
@Autowired
|
||||
private UserMenuService userMenuService;
|
||||
private SysUserService sysUserService;
|
||||
|
||||
//分配菜单保存
|
||||
@PostMapping("/assignSave")
|
||||
public ResultVo assignSave(@RequestBody AssignParm parm) {
|
||||
//判断是否是超级管理员
|
||||
SysUser user = sysUserService.getById(parm.getAssId());
|
||||
if (user != null && StringUtils.isNotEmpty(user.getIsAdmin()) && user.getIsAdmin().equals("1")) {
|
||||
return ResultUtils.error("当前用户是超级管理员,无需分配菜单!");
|
||||
}
|
||||
userMenuService.saveMenu(parm);
|
||||
return ResultUtils.success("分配菜单成功!");
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.itmk.web.user_menu.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("user_menu")
|
||||
public class UserMenu {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long userMenuId;
|
||||
private Long userId;
|
||||
private Long menuId;
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.itmk.web.user_menu.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.itmk.web.user_menu.entity.UserMenu;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserMenuMapper extends BaseMapper<UserMenu> {
|
||||
boolean saveMenu(@Param("useId") Long userId, @Param("menuIds")List<Long> menuIds);
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package com.itmk.web.user_menu.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.itmk.web.sys_user.entity.AssignParm;
|
||||
import com.itmk.web.user_menu.entity.UserMenu;
|
||||
|
||||
public interface UserMenuService extends IService<UserMenu> {
|
||||
void saveMenu(AssignParm parm);
|
||||
|
||||
}
|
||||
@ -0,0 +1,150 @@
|
||||
package com.itmk.web.wx_user.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.itmk.utils.ResultUtils;
|
||||
import com.itmk.utils.ResultVo;
|
||||
import com.itmk.web.login.entity.UpadateParm;
|
||||
import com.itmk.web.wx_user.entity.LoginVo;
|
||||
import com.itmk.web.wx_user.entity.WxUser;
|
||||
import com.itmk.web.wx_user.entity.WxUserParm;
|
||||
import com.itmk.web.wx_user.service.WxUserService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.DigestUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/wxUser")
|
||||
public class WxUserController {
|
||||
@Autowired
|
||||
private WxUserService wxUserService;
|
||||
|
||||
//注册
|
||||
@PostMapping("/register")
|
||||
public ResultVo register(@RequestBody WxUser user){
|
||||
//判断账户是否被占用
|
||||
QueryWrapper<WxUser> query = new QueryWrapper<>();
|
||||
query.lambda().eq(WxUser::getUsername,user.getUsername());
|
||||
//查询用户
|
||||
WxUser one = wxUserService.getOne(query);
|
||||
if(one != null){
|
||||
return ResultUtils.error("用户名被占用!");
|
||||
}
|
||||
//密码加密
|
||||
user.setPassword(DigestUtils.md5DigestAsHex(user.getPassword().getBytes()));
|
||||
//存到数据库
|
||||
if(wxUserService.saveOrUpdate(user)){
|
||||
return ResultUtils.success("注册成功!");
|
||||
}
|
||||
return ResultUtils.error("注册失败!");
|
||||
}
|
||||
|
||||
//登录
|
||||
@PostMapping("/login")
|
||||
public ResultVo login(@RequestBody WxUser user){
|
||||
//构造查询条件
|
||||
QueryWrapper<WxUser> query = new QueryWrapper<>();
|
||||
query.lambda().eq(WxUser::getUsername,user.getUsername()).eq(WxUser::getPassword,
|
||||
DigestUtils.md5DigestAsHex(user.getPassword().getBytes()));
|
||||
WxUser wxUser = wxUserService.getOne(query);
|
||||
if(wxUser != null){
|
||||
if(wxUser.getStatus().equals("1")){
|
||||
return ResultUtils.error("您的账户被停用,请联系管理员!");
|
||||
}
|
||||
//返回成功的数据
|
||||
LoginVo vo = new LoginVo();
|
||||
vo.setNickName(wxUser.getNickName());
|
||||
vo.setPhone(wxUser.getPhone());
|
||||
vo.setUserId(wxUser.getUserId());
|
||||
return ResultUtils.success("登录成功",vo);
|
||||
}
|
||||
return ResultUtils.error("用户密码或密码错误!");
|
||||
}
|
||||
|
||||
//列表
|
||||
@GetMapping("/list")
|
||||
public ResultVo getList(WxUserParm parm){
|
||||
//构造分页对象
|
||||
IPage<WxUser> page = new Page<>(parm.getCurrentPage(),parm.getPageSize());
|
||||
//构造查询条件
|
||||
QueryWrapper<WxUser> query = new QueryWrapper<>();
|
||||
query.lambda().like(StringUtils.isNotEmpty(parm.getPhone()),WxUser::getPhone,parm.getPhone())
|
||||
.orderByDesc(WxUser::getUsername);
|
||||
IPage<WxUser> list = wxUserService.page(page, query);
|
||||
return ResultUtils.success("查询成功",list);
|
||||
}
|
||||
|
||||
//账户停用
|
||||
@PostMapping("/stopUser")
|
||||
public ResultVo stopUser(@RequestBody WxUser user){
|
||||
UpdateWrapper<WxUser> query = new UpdateWrapper<>();
|
||||
query.lambda().set(WxUser::getStatus,user.getStatus())
|
||||
.eq(WxUser::getUserId,user.getUserId());
|
||||
if(wxUserService.update(query)){
|
||||
return ResultUtils.success("设置成功!");
|
||||
}
|
||||
return ResultUtils.error("设置失败!");
|
||||
}
|
||||
|
||||
//重置密码
|
||||
@PostMapping("/updatePassword")
|
||||
public ResultVo updatePassword(@RequestBody WxUser user){
|
||||
//默认重置密码为12345q
|
||||
String pas = "12345q";
|
||||
UpdateWrapper<WxUser> query = new UpdateWrapper<>();
|
||||
query.lambda().set(WxUser::getPassword,DigestUtils.md5DigestAsHex(pas.getBytes()))
|
||||
.eq(WxUser::getUserId,user.getUserId());
|
||||
if(wxUserService.update(query)){
|
||||
return ResultUtils.success("重置成功!");
|
||||
}
|
||||
return ResultUtils.error("重置失败!");
|
||||
}
|
||||
|
||||
//删除用户
|
||||
@DeleteMapping("/{userId}")
|
||||
public ResultVo delete(@PathVariable("userId") Long userId){
|
||||
if(wxUserService.removeById(userId)){
|
||||
return ResultUtils.success("删除成功!");
|
||||
}
|
||||
return ResultUtils.error("删除失败!");
|
||||
}
|
||||
|
||||
//小程序更新密码
|
||||
@PostMapping("/wxupdatePassword")
|
||||
public ResultVo wxupdatePassword(@RequestBody UpadateParm parm){
|
||||
//判断原密码是否正确
|
||||
QueryWrapper<WxUser> query = new QueryWrapper<>();
|
||||
query.lambda().eq(WxUser::getUserId,parm.getUserId())
|
||||
.eq(WxUser::getPassword,DigestUtils.md5DigestAsHex(parm.getOldPassword().getBytes()));
|
||||
WxUser one = wxUserService.getOne(query);
|
||||
if(one == null){
|
||||
return ResultUtils.error("原密码不正确!");
|
||||
}
|
||||
UpdateWrapper<WxUser> update = new UpdateWrapper<>();
|
||||
update.lambda().set(WxUser::getPassword,DigestUtils.md5DigestAsHex(parm.getPassword().getBytes()))
|
||||
.eq(WxUser::getUserId,parm.getUserId());
|
||||
if(wxUserService.update(update)){
|
||||
return ResultUtils.success("密码修改成功!");
|
||||
}
|
||||
return ResultUtils.error("密码修改失败!");
|
||||
}
|
||||
|
||||
//小程序修改信息
|
||||
@PostMapping("/editInfo")
|
||||
public ResultVo editInfo(@RequestBody WxUser wxUser){
|
||||
if(wxUserService.updateById(wxUser)){
|
||||
return ResultUtils.success("修改成功!");
|
||||
}
|
||||
return ResultUtils.error("修改失败!");
|
||||
}
|
||||
|
||||
//小程序查询个人信息
|
||||
@GetMapping("/getInfo")
|
||||
public ResultVo getInfo(Long userId){
|
||||
WxUser user = wxUserService.getById(userId);
|
||||
return ResultUtils.success("查询成功!",user);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package com.itmk.web.wx_user.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class LoginVo {
|
||||
private Long userId;
|
||||
private String phone;
|
||||
private String nickName;
|
||||
private String token;
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package com.itmk.web.wx_user.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WxUserParm {
|
||||
private Long currentPage;
|
||||
private Long pageSize;
|
||||
private String phone;
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package com.itmk.web.wx_user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.itmk.web.wx_user.entity.WxUser;
|
||||
|
||||
public interface WxUserMapper extends BaseMapper<WxUser> {
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package com.itmk.web.wx_user.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.itmk.web.wx_user.entity.WxUser;
|
||||
|
||||
public interface WxUserService extends IService<WxUser> {
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.itmk.web.wx_user.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.itmk.web.wx_user.entity.WxUser;
|
||||
import com.itmk.web.wx_user.mapper.WxUserMapper;
|
||||
import com.itmk.web.wx_user.service.WxUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class WxUserServiceImpl extends ServiceImpl<WxUserMapper, WxUser> implements WxUserService {
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue