Merge pull request 'dev' (#1) from dev into master
Reviewed-on: #1 整合MQ、ES完成 网关配置完成 feignClient,service-product-client模块完成 - service模块搭建有以下几个是完成的 - acl完成 - product完成 - search完成 - sys完成
This commit is contained in:
commit
4ad2935724
|
@ -35,4 +35,6 @@ build/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
### Mac OS ###
|
### Mac OS ###
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
logs
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||||
|
<data-source source="LOCAL" name="shequ-acl@106.15.251.123" uuid="f86335eb-64b5-4b7d-b1cc-3bd8653c089f">
|
||||||
|
<driver-ref>mysql.8</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<imported>true</imported>
|
||||||
|
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:mysql://106.15.251.123:3305/shequ-acl?serverTimezone=GMT</jdbc-url>
|
||||||
|
<jdbc-additional-properties>
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.resource.type" value="Deployment" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||||
|
</jdbc-additional-properties>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
<data-source source="LOCAL" name="shequ-sys@106.15.251.123" uuid="78d73e25-2234-4332-8e1f-cfdd278718d2">
|
||||||
|
<driver-ref>mysql.8</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<imported>true</imported>
|
||||||
|
<remarks>$PROJECT_DIR$/service/service-sys/src/main/resources/application.yml</remarks>
|
||||||
|
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:mysql://106.15.251.123:3305/shequ-sys?serverTimezone=GMT</jdbc-url>
|
||||||
|
<jdbc-additional-properties>
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.resource.type" value="Deployment" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||||
|
</jdbc-additional-properties>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
<data-source source="LOCAL" name="shequ-product@106.15.251.123" uuid="d3e0a640-b7a0-4ff1-8fba-50e8d871e2ae">
|
||||||
|
<driver-ref>mysql.8</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<imported>true</imported>
|
||||||
|
<remarks>$PROJECT_DIR$/service/service-product/src/main/resources/application.yml</remarks>
|
||||||
|
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:mysql://106.15.251.123:3305/shequ-product?serverTimezone=GMT</jdbc-url>
|
||||||
|
<jdbc-additional-properties>
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||||
|
</jdbc-additional-properties>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
<data-source source="LOCAL" name="0@47.120.65.66" uuid="80c74a8a-8467-45dc-ad24-8422085124e9">
|
||||||
|
<driver-ref>redis</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<imported>true</imported>
|
||||||
|
<jdbc-driver>jdbc.RedisDriver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:redis://47.120.65.66:6379/0</jdbc-url>
|
||||||
|
<jdbc-additional-properties>
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||||
|
</jdbc-additional-properties>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="PublishConfigData" autoUpload="Always" remoteFilesAllowedToDisappearOnAutoupload="false" autoUploadExternalChanges="true">
|
|
||||||
<option name="myAutoUpload" value="ALWAYS" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -4,6 +4,7 @@
|
||||||
<file url="file://$PROJECT_DIR$/common/common-util/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/common/common-util/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/common/common-util/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/common/common-util/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/common/common-util/src/main/resources-filtered" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/common/common-util/src/main/resources-filtered" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/common/rabbit-util/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/common/service-util/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/common/service-util/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/common/service-util/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/common/service-util/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/common/service-util/src/main/resources-filtered" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/common/service-util/src/main/resources-filtered" charset="UTF-8" />
|
||||||
|
@ -13,7 +14,15 @@
|
||||||
<file url="file://$PROJECT_DIR$/model/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/model/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/model/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/model/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/model/src/main/resources-filtered" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/model/src/main/resources-filtered" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/service-client/service-product-client/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/service-client/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/service-client/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/service-gateway/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/service/service-acl/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/service/service-acl/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/service/service-activity/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/service/service-product/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/service/service-search/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/service/service-sys/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/service/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/service/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/service/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/service/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/service/src/main/resources-filtered" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/service/src/main/resources-filtered" charset="UTF-8" />
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="MavenProjectsManager">
|
<component name="MavenProjectsManager">
|
||||||
<option name="originalFiles">
|
<option name="originalFiles">
|
||||||
<list>
|
<list>
|
||||||
<option value="$PROJECT_DIR$/pom.xml" />
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
|
<option value="$PROJECT_DIR$/service-gateway/pom.xml" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|
|
@ -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,30 @@
|
||||||
|
package com.atguigu.common.utils;
|
||||||
|
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
|
|
||||||
|
public final class MD5 {
|
||||||
|
public static String encrypt(String strSrc) {
|
||||||
|
try {
|
||||||
|
char[] hexChars = {'0', '1', '2', '3', '4', '5', '6', '7', '8',
|
||||||
|
'9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||||
|
byte[] bytes = strSrc.getBytes();
|
||||||
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||||
|
md.update(bytes);
|
||||||
|
bytes = md.digest();
|
||||||
|
int j = bytes.length;
|
||||||
|
char[] chars = new char[j * 2];
|
||||||
|
int k = 0;
|
||||||
|
for (int i = 0; i < bytes.length; i++) {
|
||||||
|
byte b = bytes[i];
|
||||||
|
chars[k++] = hexChars[b >>> 4 & 0xf];
|
||||||
|
chars[k++] = hexChars[b & 0xf];
|
||||||
|
}
|
||||||
|
return new String(chars);
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new RuntimeException("MD5加密出错!!+" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.atguigu.common.utils;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.model.acl.Permission;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PermissionHelper {
|
||||||
|
public static List<Permission> buildPermissions(List<Permission> permissionList) {
|
||||||
|
ArrayList<Permission> trees = new ArrayList<>();
|
||||||
|
|
||||||
|
permissionList.forEach(permission -> {
|
||||||
|
if (permission.getPid() == 0) {
|
||||||
|
permission.setLevel(1);
|
||||||
|
trees.add(findChildren(permission, permissionList));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return trees;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Permission findChildren(Permission permission, List<Permission> allList) {
|
||||||
|
permission.setChildren(new ArrayList<>());
|
||||||
|
|
||||||
|
allList.forEach(p -> {
|
||||||
|
if (p.getId().equals(permission.getPid())) {
|
||||||
|
int level = permission.getLevel() + 1;
|
||||||
|
p.setLevel(level);
|
||||||
|
|
||||||
|
if (permission.getChildren() == null) {
|
||||||
|
permission.setChildren(new ArrayList<>());
|
||||||
|
}
|
||||||
|
// 封装下层数据
|
||||||
|
permission.getChildren().add(findChildren(p, allList));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return permission;
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,6 +15,7 @@
|
||||||
<modules>
|
<modules>
|
||||||
<module>common-util</module>
|
<module>common-util</module>
|
||||||
<module>service-util</module>
|
<module>service-util</module>
|
||||||
|
<module>rabbit-util</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -50,5 +51,11 @@
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- minio -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.minio</groupId>
|
||||||
|
<artifactId>minio</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.atguigu</groupId>
|
||||||
|
<artifactId>common</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<artifactId>rabbit-util</artifactId>
|
||||||
|
<name>Archetype - rabbit-util</name>
|
||||||
|
<url>https://maven.apache.org</url>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!--rabbitmq消息队列-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- 消息转换器 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||||
|
<artifactId>jackson-dataformat-xml</artifactId>
|
||||||
|
<version>2.16.0-rc1</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.atguigu.ssyx.mq.config;
|
||||||
|
|
||||||
|
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||||
|
import org.springframework.amqp.support.converter.MessageConverter;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class RabbitMQConfiguration {
|
||||||
|
/**
|
||||||
|
* * 重写,并引入消息转换器
|
||||||
|
* <dependency>
|
||||||
|
* <groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||||
|
* <artifactId>jackson-dataformat-xml</artifactId>
|
||||||
|
* <version>2.16.0-rc1</version>
|
||||||
|
* </dependency>
|
||||||
|
*
|
||||||
|
* @return MessageConverter
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public MessageConverter jsonMessageConverter() {
|
||||||
|
// 1.定义消息转换器
|
||||||
|
Jackson2JsonMessageConverter converter = new Jackson2JsonMessageConverter();
|
||||||
|
// 2.配置自动创建消息id,用于识别不同消息,也可以在业务中基于ID判断是否是重复消息
|
||||||
|
converter.setCreateMessageIds(true);
|
||||||
|
return converter;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.atguigu.ssyx.mq.constant;
|
||||||
|
|
||||||
|
public class MqConst {
|
||||||
|
// 消息补偿
|
||||||
|
public static final String MQ_KEY_PREFIX = "ssyx.mq:list";
|
||||||
|
public static final int RETRY_COUNT = 3;
|
||||||
|
|
||||||
|
// 商品上下架
|
||||||
|
public static final String EXCHANGE_GOODS_DIRECT = "ssyx.goods.direct";
|
||||||
|
public static final String ROUTING_GOODS_UPPER = "ssyx.goods.upper";
|
||||||
|
public static final String ROUTING_GOODS_LOWER = "ssyx.goods.lower";
|
||||||
|
// 队列
|
||||||
|
public static final String QUEUE_GOODS_UPPER = "ssyx.goods.upper";
|
||||||
|
public static final String QUEUE_GOODS_LOWER = "ssyx.goods.lower";
|
||||||
|
|
||||||
|
// 团长上下线
|
||||||
|
public static final String EXCHANGE_LEADER_DIRECT = "ssyx.leader.direct";
|
||||||
|
public static final String ROUTING_LEADER_UPPER = "ssyx.leader.upper";
|
||||||
|
public static final String ROUTING_LEADER_LOWER = "ssyx.leader.lower";
|
||||||
|
// 队列
|
||||||
|
public static final String QUEUE_LEADER_UPPER = "ssyx.leader.upper";
|
||||||
|
public static final String QUEUE_LEADER_LOWER = "ssyx.leader.lower";
|
||||||
|
|
||||||
|
// 订单
|
||||||
|
public static final String EXCHANGE_ORDER_DIRECT = "ssyx.order.direct";
|
||||||
|
public static final String ROUTING_ROLLBACK_STOCK = "ssyx.rollback.stock";
|
||||||
|
public static final String ROUTING_MINUS_STOCK = "ssyx.minus.stock";
|
||||||
|
|
||||||
|
public static final String ROUTING_DELETE_CART = "ssyx.delete.cart";
|
||||||
|
// 解锁普通商品库存
|
||||||
|
public static final String QUEUE_ROLLBACK_STOCK = "ssyx.rollback.stock";
|
||||||
|
public static final String QUEUE_SECKILL_ROLLBACK_STOCK = "ssyx.seckill.rollback.stock";
|
||||||
|
public static final String QUEUE_MINUS_STOCK = "ssyx.minus.stock";
|
||||||
|
public static final String QUEUE_DELETE_CART = "ssyx.delete.cart";
|
||||||
|
|
||||||
|
// 支付
|
||||||
|
public static final String EXCHANGE_PAY_DIRECT = "ssyx.pay.direct";
|
||||||
|
public static final String ROUTING_PAY_SUCCESS = "ssyx.pay.success";
|
||||||
|
public static final String QUEUE_ORDER_PAY = "ssyx.order.pay";
|
||||||
|
public static final String QUEUE_LEADER_BILL = "ssyx.leader.bill";
|
||||||
|
|
||||||
|
// 取消订单
|
||||||
|
public static final String EXCHANGE_CANCEL_ORDER_DIRECT = "ssyx.cancel.order.direct";
|
||||||
|
public static final String ROUTING_CANCEL_ORDER = "ssyx.cancel.order";
|
||||||
|
// 延迟取消订单队列
|
||||||
|
public static final String QUEUE_CANCEL_ORDER = "ssyx.cancel.order";
|
||||||
|
|
||||||
|
// 定时任务
|
||||||
|
public static final String EXCHANGE_DIRECT_TASK = "ssyx.exchange.direct.task";
|
||||||
|
public static final String ROUTING_TASK_23 = "ssyx.task.23";
|
||||||
|
// 队列
|
||||||
|
public static final String QUEUE_TASK_23 = "ssyx.queue.task.23";
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.atguigu.ssyx.mq.service;
|
||||||
|
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class RabbitService {
|
||||||
|
@Autowired
|
||||||
|
private RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送消息
|
||||||
|
*
|
||||||
|
* @param exchange 交换机
|
||||||
|
* @param routerKey 路由
|
||||||
|
* @param message 消息
|
||||||
|
*/
|
||||||
|
public void sendMessage(String exchange, String routerKey, Object message) {
|
||||||
|
rabbitTemplate.convertAndSend(exchange, routerKey, message);
|
||||||
|
}
|
||||||
|
}
|
|
@ -55,5 +55,23 @@
|
||||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-generator</artifactId>
|
||||||
|
<version>3.4.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.velocity</groupId>
|
||||||
|
<artifactId>velocity-engine-core</artifactId>
|
||||||
|
<version>2.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--mysql-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.atguigu.ssyx.common;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.DbType;
|
||||||
|
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||||
|
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
|
||||||
|
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
|
||||||
|
import com.baomidou.mybatisplus.generator.config.PackageConfig;
|
||||||
|
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
|
||||||
|
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class CodeGet {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// 1、创建代码生成器
|
||||||
|
AutoGenerator mpg = new AutoGenerator();
|
||||||
|
|
||||||
|
// 2、全局配置
|
||||||
|
// 全局配置
|
||||||
|
GlobalConfig gc = new GlobalConfig();
|
||||||
|
// TODO 需要修改路径名称
|
||||||
|
gc.setOutputDir("G:\\File\\Java\\ssyx\\ssyx-parent\\service\\service-activity" + "/src/main/java");
|
||||||
|
|
||||||
|
gc.setServiceName("%sService"); // 去掉Service接口的首字母I
|
||||||
|
gc.setAuthor("bunny");
|
||||||
|
gc.setOpen(false);
|
||||||
|
mpg.setGlobalConfig(gc);
|
||||||
|
|
||||||
|
// 3、数据源配置
|
||||||
|
DataSourceConfig dsc = new DataSourceConfig();
|
||||||
|
// TODO 需要修改数据库
|
||||||
|
dsc.setUrl("jdbc:mysql://106.15.251.123:3305/shequ-activity?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true");
|
||||||
|
dsc.setDriverName("com.mysql.cj.jdbc.Driver");
|
||||||
|
dsc.setUsername("root");
|
||||||
|
dsc.setPassword("02120212");
|
||||||
|
dsc.setDbType(DbType.MYSQL);
|
||||||
|
mpg.setDataSource(dsc);
|
||||||
|
|
||||||
|
// 4、包配置
|
||||||
|
PackageConfig pc = new PackageConfig();
|
||||||
|
pc.setParent("com.atguigu.ssyx");
|
||||||
|
// TODO 需要修改模块名
|
||||||
|
pc.setModuleName("activity");
|
||||||
|
pc.setController("controller");
|
||||||
|
pc.setService("service");
|
||||||
|
pc.setMapper("mapper");
|
||||||
|
mpg.setPackageInfo(pc);
|
||||||
|
|
||||||
|
// 5、策略配置
|
||||||
|
StrategyConfig strategy = getStrategyConfig();
|
||||||
|
|
||||||
|
mpg.setStrategy(strategy);
|
||||||
|
|
||||||
|
// 6、执行
|
||||||
|
mpg.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static StrategyConfig getStrategyConfig() {
|
||||||
|
StrategyConfig strategy = new StrategyConfig();
|
||||||
|
|
||||||
|
strategy.setInclude("activity_info", "activity_rule", "activity_sku", "coupon_info", "coupon_range", "coupon_use");
|
||||||
|
strategy.setNaming(NamingStrategy.underline_to_camel);// 数据库表映射到实体的命名策略
|
||||||
|
strategy.setColumnNaming(NamingStrategy.underline_to_camel);// 数据库表字段映射到实体的命名策略
|
||||||
|
strategy.setEntityLombokModel(true); // lombok 模型 @Accessors(chain = true) setter链式操作
|
||||||
|
strategy.setRestControllerStyle(true); // restful api风格控制器
|
||||||
|
strategy.setControllerMappingHyphenStyle(true); // url中驼峰转连字符
|
||||||
|
return strategy;
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerIntercep
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
@ -14,6 +15,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
* MybatisPlus配置类
|
* MybatisPlus配置类
|
||||||
*/
|
*/
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
|
@MapperScan("com.atguigu.ssyx.*.mapper")
|
||||||
@Configuration
|
@Configuration
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class MybatisPlusConfig {
|
public class MybatisPlusConfig {
|
||||||
|
@ -24,7 +26,7 @@ public class MybatisPlusConfig {
|
||||||
@Bean
|
@Bean
|
||||||
public MybatisPlusInterceptor optimisticLockerInnerInterceptor() {
|
public MybatisPlusInterceptor optimisticLockerInnerInterceptor() {
|
||||||
log.info("注入MybatisPlus配置类...");
|
log.info("注入MybatisPlus配置类...");
|
||||||
|
|
||||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||||
// 向Mybatis过滤器链中添加分页拦截器
|
// 向Mybatis过滤器链中添加分页拦截器
|
||||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
package com.atguigu.ssyx.common.config;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||||
|
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
|
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.cache.CacheManager;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||||
|
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||||
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||||
|
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||||
|
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||||
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@Slf4j
|
||||||
|
public class RedisConfiguration {
|
||||||
|
/**
|
||||||
|
* 使用StringRedisSerializer序列化为字符串
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public RedisTemplate<String, Object> redisTemplate(LettuceConnectionFactory connectionFactory) {
|
||||||
|
log.info("RedisConfiguration===>使用StringRedisSerializer序列化为字符串");
|
||||||
|
|
||||||
|
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||||
|
redisTemplate.setConnectionFactory(connectionFactory);
|
||||||
|
// 设置key序列化为string
|
||||||
|
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||||
|
// 设置value序列化为JSON,使用GenericJackson2JsonRedisSerializer替换默认序列化
|
||||||
|
redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer());
|
||||||
|
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
|
||||||
|
redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
|
||||||
|
|
||||||
|
return redisTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解决cache(@Cacheable)把数据缓存到redis中的value是乱码问题
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
public CacheManager cacheManager(RedisConnectionFactory factory) {
|
||||||
|
log.info("RedisConfiguration===>解决cache(@Cacheable)把数据缓存到redis中的value是乱码问题");
|
||||||
|
|
||||||
|
StringRedisSerializer redisSerializer = new StringRedisSerializer();
|
||||||
|
// 配置序列化
|
||||||
|
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig();
|
||||||
|
RedisCacheConfiguration redisCacheConfiguration = config
|
||||||
|
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(redisSerializer))
|
||||||
|
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jsonRedisSerializer()));
|
||||||
|
|
||||||
|
RedisCacheManager cacheManager = RedisCacheManager.builder(factory)
|
||||||
|
.cacheDefaults(redisCacheConfiguration).build();
|
||||||
|
return cacheManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指定的日期模式
|
||||||
|
*/
|
||||||
|
public Jackson2JsonRedisSerializer<Object> jsonRedisSerializer() {
|
||||||
|
log.info("RedisConfiguration===>指定的日期模式");
|
||||||
|
|
||||||
|
Jackson2JsonRedisSerializer<Object> serializer = new Jackson2JsonRedisSerializer<>(Object.class);
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
// 设置ObjectMapper访问权限
|
||||||
|
mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||||
|
// 记录序列化之后的数据类型,方便反序列化
|
||||||
|
mapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
|
||||||
|
// LocalDatetime序列化,默认不兼容jdk8日期序列化
|
||||||
|
JavaTimeModule timeModule = new JavaTimeModule();
|
||||||
|
timeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
||||||
|
timeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
||||||
|
|
||||||
|
timeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||||
|
timeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||||
|
// 关闭默认的日期格式化方式,默认UTC日期格式 yyyy-MM-dd’T’HH:mm:ss.SSS
|
||||||
|
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||||
|
mapper.registerModule(timeModule);
|
||||||
|
|
||||||
|
serializer.setObjectMapper(mapper);
|
||||||
|
return serializer;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,24 +2,10 @@ package com.atguigu.ssyx.common.config;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class WebMvcConfiguration implements WebMvcConfigurer {
|
public class WebMvcConfiguration implements WebMvcConfigurer {
|
||||||
/**
|
|
||||||
* * 解决跨域
|
|
||||||
*
|
|
||||||
* @param registry 跨域注册表
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void addCorsMappings(CorsRegistry registry) {
|
|
||||||
log.info("WebMvcConfiguration===>开始跨域注册表...");
|
|
||||||
|
|
||||||
registry.addMapping("/admin/**")// 添加路径规则
|
|
||||||
.allowCredentials(true)// 是否允许在跨域的情况下传递Cookie
|
|
||||||
.allowedOrigins("*")// 允许请求来源的域规则
|
|
||||||
.allowedMethods("*").allowedHeaders("*");// 允许所有的请求头
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.atguigu.ssyx.common.properties;
|
||||||
|
|
||||||
|
import io.minio.MinioClient;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "bunny.minio")
|
||||||
|
@ConditionalOnProperty(name = "bunny.minio.bucket-name")// 当属性有值时这个配置才生效
|
||||||
|
@Data
|
||||||
|
@Slf4j
|
||||||
|
public class MinioProperties {
|
||||||
|
private String endpointUrl;
|
||||||
|
private String accessKey;
|
||||||
|
private String secretKey;
|
||||||
|
private String bucketName;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public MinioClient minioClient() {
|
||||||
|
log.info("注册MinioClient...");
|
||||||
|
return MinioClient.builder().endpoint(endpointUrl).credentials(accessKey, secretKey).build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,7 @@ import lombok.Getter;
|
||||||
@Getter
|
@Getter
|
||||||
public enum ResultCodeEnum {
|
public enum ResultCodeEnum {
|
||||||
|
|
||||||
SUCCESS(200, "成功"),
|
SUCCESS(200, "操作成功"),
|
||||||
FAIL(201, "失败"),
|
FAIL(201, "失败"),
|
||||||
SERVICE_ERROR(2012, "服务异常"),
|
SERVICE_ERROR(2012, "服务异常"),
|
||||||
DATA_ERROR(204, "数据异常"),
|
DATA_ERROR(204, "数据异常"),
|
||||||
|
|
|
@ -33,8 +33,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.xiaoymin</groupId>
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||||
<!--在引用时请在maven中央仓库搜索2.X最新版本号-->
|
<version>3.0.3</version>
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -19,16 +19,14 @@ import lombok.Data;
|
||||||
@ApiModel(description = "用户角色")
|
@ApiModel(description = "用户角色")
|
||||||
@TableName("admin_role")
|
@TableName("admin_role")
|
||||||
public class AdminRole extends BaseEntity {
|
public class AdminRole extends BaseEntity {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "角色id")
|
|
||||||
@TableField("role_id")
|
|
||||||
private Long roleId;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "用户id")
|
@ApiModelProperty(value = "角色id")
|
||||||
@TableField("admin_id")
|
@TableField("role_id")
|
||||||
private Long adminId;
|
private Long roleId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "用户id")
|
||||||
|
@TableField("admin_id")
|
||||||
|
private Long adminId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,78 +13,77 @@ import java.math.BigDecimal;
|
||||||
@ApiModel(description = "SkuInfo")
|
@ApiModel(description = "SkuInfo")
|
||||||
@TableName("sku_info")
|
@TableName("sku_info")
|
||||||
public class SkuInfo extends BaseEntity {
|
public class SkuInfo extends BaseEntity {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
@ApiModelProperty(value = "分类id")
|
||||||
|
@TableField("category_id")
|
||||||
|
private Long categoryId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "分类id")
|
@ApiModelProperty(value = "平台属性分组id")
|
||||||
@TableField("category_id")
|
@TableField("attr_group_id")
|
||||||
private Long categoryId;
|
private Long attrGroupId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "平台属性分组id")
|
@ApiModelProperty(value = "商品类型:0->普通商品 1->秒杀商品")
|
||||||
@TableField("attr_group_id")
|
@TableField("sku_type")
|
||||||
private Long attrGroupId;
|
private Integer skuType;
|
||||||
|
|
||||||
@ApiModelProperty(value = "商品类型:0->普通商品 1->秒杀商品")
|
@ApiModelProperty(value = "spu名称")
|
||||||
@TableField("sku_type")
|
@TableField("sku_name")
|
||||||
private Integer skuType;
|
private String skuName;
|
||||||
|
|
||||||
@ApiModelProperty(value = "spu名称")
|
@ApiModelProperty(value = "展示图片")
|
||||||
@TableField("sku_name")
|
@TableField("img_url")
|
||||||
private String skuName;
|
private String imgUrl;
|
||||||
|
|
||||||
@ApiModelProperty(value = "展示图片")
|
@ApiModelProperty(value = "限购个数/每天(0:不限购)")
|
||||||
@TableField("img_url")
|
@TableField("per_limit")
|
||||||
private String imgUrl;
|
private Integer perLimit;
|
||||||
|
|
||||||
@ApiModelProperty(value = "限购个数/每天(0:不限购)")
|
@ApiModelProperty(value = "上架状态:0->下架;1->上架")
|
||||||
@TableField("per_limit")
|
@TableField("publish_status")
|
||||||
private Integer perLimit;
|
private Integer publishStatus;
|
||||||
|
|
||||||
@ApiModelProperty(value = "上架状态:0->下架;1->上架")
|
@ApiModelProperty(value = "审核状态:0->未审核;1->审核通过")
|
||||||
@TableField("publish_status")
|
@TableField("check_status")
|
||||||
private Integer publishStatus;
|
private Integer checkStatus;
|
||||||
|
|
||||||
@ApiModelProperty(value = "审核状态:0->未审核;1->审核通过")
|
@ApiModelProperty(value = "是否新人专享:0->否;1->是")
|
||||||
@TableField("check_status")
|
@TableField("is_new_person")
|
||||||
private Integer checkStatus;
|
private Integer isNewPerson;
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否新人专享:0->否;1->是")
|
@ApiModelProperty(value = "排序")
|
||||||
@TableField("is_new_person")
|
@TableField("sort")
|
||||||
private Integer isNewPerson;
|
private Integer sort;
|
||||||
|
|
||||||
@ApiModelProperty(value = "排序")
|
@ApiModelProperty(value = "sku编码")
|
||||||
@TableField("sort")
|
@TableField("sku_code")
|
||||||
private Integer sort;
|
private String skuCode;
|
||||||
|
|
||||||
@ApiModelProperty(value = "sku编码")
|
@ApiModelProperty(value = "价格")
|
||||||
@TableField("sku_code")
|
@TableField("price")
|
||||||
private String skuCode;
|
private BigDecimal price;
|
||||||
|
|
||||||
@ApiModelProperty(value = "价格")
|
@ApiModelProperty(value = "市场价")
|
||||||
@TableField("price")
|
@TableField("market_price")
|
||||||
private BigDecimal price;
|
private BigDecimal marketPrice;
|
||||||
|
|
||||||
@ApiModelProperty(value = "市场价")
|
@ApiModelProperty(value = "库存")
|
||||||
@TableField("market_price")
|
@TableField("stock")
|
||||||
private BigDecimal marketPrice;
|
private Integer stock;
|
||||||
|
|
||||||
@ApiModelProperty(value = "库存")
|
@ApiModelProperty(value = "锁定库存")
|
||||||
@TableField("stock")
|
@TableField("lock_stock")
|
||||||
private Integer stock;
|
private Integer lockStock;
|
||||||
|
|
||||||
@ApiModelProperty(value = "锁定库存")
|
@ApiModelProperty(value = "预警库存")
|
||||||
@TableField("lock_stock")
|
@TableField("low_stock")
|
||||||
private Integer lockStock;
|
private Integer lowStock;
|
||||||
|
|
||||||
@ApiModelProperty(value = "预警库存")
|
@ApiModelProperty(value = "销量")
|
||||||
@TableField("low_stock")
|
@TableField("sale")
|
||||||
private Integer lowStock;
|
private Integer sale;
|
||||||
|
|
||||||
@ApiModelProperty(value = "销量")
|
@ApiModelProperty(value = "仓库")
|
||||||
@TableField("sale")
|
@TableField("ware_id")
|
||||||
private Integer sale;
|
private Long wareId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "仓库")
|
|
||||||
@TableField("ware_id")
|
|
||||||
private Long wareId;
|
|
||||||
}
|
}
|
|
@ -1,22 +1,16 @@
|
||||||
package com.atguigu.ssyx.model.search;
|
package com.atguigu.ssyx.model.search;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.elasticsearch.annotations.DateFormat;
|
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
||||||
import org.springframework.data.elasticsearch.annotations.FieldType;
|
import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Document(indexName = "skues" ,shards = 3,replicas = 1)
|
@Document(indexName = "skues", shards = 3, replicas = 1)
|
||||||
public class SkuEs {
|
public class SkuEs {
|
||||||
|
|
||||||
// 商品Id= skuId
|
// 商品Id= skuId
|
||||||
@Id
|
@Id
|
||||||
private Long id;
|
private Long id;
|
||||||
|
@ -64,5 +58,4 @@ public class SkuEs {
|
||||||
|
|
||||||
@Field(type = FieldType.Object, index = false)
|
@Field(type = FieldType.Object, index = false)
|
||||||
private List<String> ruleList;
|
private List<String> ruleList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.atguigu.ssyx.vo.acl;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.model.acl.Role;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@ApiModel(description = "所有角色数据")
|
||||||
|
public class AssignAdminRoleVo {
|
||||||
|
@ApiModelProperty(value = "角色列表数据")
|
||||||
|
private List<Role> assignRoles;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "所有角色数据")
|
||||||
|
private List<Role> allRolesList;
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.atguigu.ssyx.vo.acl;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@ApiModel(description = "返回用户信息")
|
||||||
|
public class LoginInfoVo {
|
||||||
|
@ApiModelProperty(value = "用户名")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "头像")
|
||||||
|
private String avatar;
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.atguigu.ssyx.vo.acl;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@ApiModel(description = "登录成功后返回")
|
||||||
|
public class LoginVo {
|
||||||
|
@ApiModelProperty(value = "token")
|
||||||
|
private String token;
|
||||||
|
}
|
|
@ -19,11 +19,9 @@ import java.io.Serializable;
|
||||||
@Data
|
@Data
|
||||||
@ApiModel(description = "角色查询实体")
|
@ApiModel(description = "角色查询实体")
|
||||||
public class RoleQueryVo implements Serializable {
|
public class RoleQueryVo implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "角色名称")
|
|
||||||
private String roleName;
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "角色名称")
|
||||||
|
private String roleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,25 @@
|
||||||
package com.atguigu.ssyx.vo.product;
|
package com.atguigu.ssyx.vo.product;
|
||||||
|
|
||||||
import com.atguigu.ssyx.model.product.*;
|
|
||||||
import com.atguigu.ssyx.model.product.SkuAttrValue;
|
import com.atguigu.ssyx.model.product.SkuAttrValue;
|
||||||
import com.atguigu.ssyx.model.product.SkuImage;
|
import com.atguigu.ssyx.model.product.SkuImage;
|
||||||
import com.atguigu.ssyx.model.product.SkuInfo;
|
import com.atguigu.ssyx.model.product.SkuInfo;
|
||||||
import com.atguigu.ssyx.model.product.SkuPoster;
|
import com.atguigu.ssyx.model.product.SkuPoster;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class SkuInfoVo extends SkuInfo {
|
public class SkuInfoVo extends SkuInfo {
|
||||||
|
@ApiModelProperty(value = "海报列表")
|
||||||
|
private List<SkuPoster> skuPosterList;
|
||||||
|
|
||||||
@ApiModelProperty(value = "海报列表")
|
@ApiModelProperty(value = "属性值")
|
||||||
private List<SkuPoster> skuPosterList;
|
private List<SkuAttrValue> skuAttrValueList;
|
||||||
|
|
||||||
@ApiModelProperty(value = "属性值")
|
|
||||||
private List<SkuAttrValue> skuAttrValueList;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "图片")
|
|
||||||
private List<SkuImage> skuImagesList;
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "图片")
|
||||||
|
private List<SkuImage> skuImagesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
69
pom.xml
69
pom.xml
|
@ -18,6 +18,7 @@
|
||||||
<module>common</module>
|
<module>common</module>
|
||||||
<module>model</module>
|
<module>model</module>
|
||||||
<module>service</module>
|
<module>service</module>
|
||||||
|
<module>service-client</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -37,6 +38,7 @@
|
||||||
<knife4j.version>2.0.8</knife4j.version>
|
<knife4j.version>2.0.8</knife4j.version>
|
||||||
<jodatime.version>2.10.1</jodatime.version>
|
<jodatime.version>2.10.1</jodatime.version>
|
||||||
<xxl-job.version>2.3.0</xxl-job.version>
|
<xxl-job.version>2.3.0</xxl-job.version>
|
||||||
|
<minio.version>8.4.3</minio.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!--配置dependencyManagement锁定依赖的版本-->
|
<!--配置dependencyManagement锁定依赖的版本-->
|
||||||
|
@ -108,30 +110,49 @@
|
||||||
<artifactId>xxl-job-core</artifactId>
|
<artifactId>xxl-job-core</artifactId>
|
||||||
<version>${xxl-job.version}</version>
|
<version>${xxl-job.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- minio -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.minio</groupId>
|
||||||
|
<artifactId>minio</artifactId>
|
||||||
|
<version>${minio.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
|
<artifactId>okhttp</artifactId>
|
||||||
|
<version>4.9.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- hutool -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
<version>5.8.25</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
<repositories>
|
<!-- <repositories> -->
|
||||||
<repository>
|
<!-- <repository> -->
|
||||||
<id>nexus-aliyun</id>
|
<!-- <id>nexus-aliyun</id> -->
|
||||||
<name>Nexus aliyun</name>
|
<!-- <name>Nexus aliyun</name> -->
|
||||||
<layout>default</layout>
|
<!-- <layout>default</layout> -->
|
||||||
<url>https://maven.aliyun.com/repository/public</url>
|
<!-- <url>https://maven.aliyun.com/repository/public</url> -->
|
||||||
<snapshots>
|
<!-- <snapshots> -->
|
||||||
<enabled>false</enabled>
|
<!-- <enabled>false</enabled> -->
|
||||||
</snapshots>
|
<!-- </snapshots> -->
|
||||||
<releases>
|
<!-- <releases> -->
|
||||||
<enabled>true</enabled>
|
<!-- <enabled>true</enabled> -->
|
||||||
</releases>
|
<!-- </releases> -->
|
||||||
</repository>
|
<!-- </repository> -->
|
||||||
<repository>
|
<!-- <repository> -->
|
||||||
<id>spring</id>
|
<!-- <id>spring</id> -->
|
||||||
<url>https://maven.aliyun.com/repository/spring</url>
|
<!-- <url>https://maven.aliyun.com/repository/spring</url> -->
|
||||||
<releases>
|
<!-- <releases> -->
|
||||||
<enabled>true</enabled>
|
<!-- <enabled>true</enabled> -->
|
||||||
</releases>
|
<!-- </releases> -->
|
||||||
<snapshots>
|
<!-- <snapshots> -->
|
||||||
<enabled>true</enabled>
|
<!-- <enabled>true</enabled> -->
|
||||||
</snapshots>
|
<!-- </snapshots> -->
|
||||||
</repository>
|
<!-- </repository> -->
|
||||||
</repositories>
|
<!-- </repositories> -->
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.atguigu</groupId>
|
||||||
|
<artifactId>guigu-ssyx-parent</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>service-client</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<name>service-client</name>
|
||||||
|
<url>https://maven.apache.org</url>
|
||||||
|
<modules>
|
||||||
|
<module>service-product-client</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.atguigu</groupId>
|
||||||
|
<artifactId>service-util</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.atguigu</groupId>
|
||||||
|
<artifactId>model</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 服务调用feign -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- loadbalancer依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-loadbalancer</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,23 @@
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.atguigu</groupId>
|
||||||
|
<artifactId>service-client</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>service-product-client</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>service-product-client</name>
|
||||||
|
<url>https://maven.apache.org</url>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.atguigu.ssyx.client.product;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.common.result.Result;
|
||||||
|
import com.atguigu.ssyx.model.product.Category;
|
||||||
|
import com.atguigu.ssyx.model.product.SkuInfo;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
|
||||||
|
@FeignClient(value = "service-product", path = "/api/product")
|
||||||
|
public interface ProductFeignClient {
|
||||||
|
@GetMapping("inner/getCategory/{categoryId}")
|
||||||
|
Result<Category> getCategory(@PathVariable Long categoryId);
|
||||||
|
|
||||||
|
@GetMapping("inner/getSkuInfo/{skuId}")
|
||||||
|
Result<SkuInfo> getSkuInfo(@PathVariable Long skuId);
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
FROM openjdk:17
|
||||||
|
MAINTAINER bunny
|
||||||
|
|
||||||
|
#系统编码
|
||||||
|
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
|
||||||
|
|
||||||
|
# 设置时区,构建镜像时执行的命令
|
||||||
|
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||||
|
RUN echo "Asia/Shanghai" > /etc/timezone
|
||||||
|
|
||||||
|
# 设定工作目录
|
||||||
|
WORKDIR /home/bunny
|
||||||
|
|
||||||
|
# 复制jar包
|
||||||
|
COPY target/*.jar /home/bunny/app.jar
|
||||||
|
|
||||||
|
#启动容器时的进程
|
||||||
|
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
|
||||||
|
|
||||||
|
#暴露 8080 端口
|
||||||
|
EXPOSE 8080
|
|
@ -0,0 +1,47 @@
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.atguigu</groupId>
|
||||||
|
<artifactId>guigu-ssyx-parent</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>service-gateway</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>service-gateway</name>
|
||||||
|
<url>https://maven.apache.org</url>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.atguigu</groupId>
|
||||||
|
<artifactId>service-util</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- 服务保护组件 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- loadbalancer依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-loadbalancer</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- gateway -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-gateway</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- 服务注册 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.atguigu.ssyx.geteway;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class ServiceGatewayApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(ServiceGatewayApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.atguigu.ssyx.geteway.config;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.cors.CorsConfiguration;
|
||||||
|
import org.springframework.web.cors.reactive.CorsWebFilter;
|
||||||
|
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@Slf4j
|
||||||
|
public class GateWayCorsConfig {
|
||||||
|
@Bean
|
||||||
|
protected CorsWebFilter addCorsMappings() {
|
||||||
|
log.info("CorsConfig===>开始跨域注册表...");
|
||||||
|
|
||||||
|
CorsConfiguration config = new CorsConfiguration();
|
||||||
|
// 设置跨域请求地址
|
||||||
|
config.addAllowedMethod("*");
|
||||||
|
config.addAllowedHeader("*");
|
||||||
|
config.addAllowedOrigin("*");
|
||||||
|
config.setAllowCredentials(true);
|
||||||
|
|
||||||
|
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||||
|
source.registerCorsConfiguration("/**", config);
|
||||||
|
|
||||||
|
return new CorsWebFilter(source);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.atguigu.ssyx.geteway.controller;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.common.result.Result;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RequestMapping("/")
|
||||||
|
@RestController
|
||||||
|
@Slf4j
|
||||||
|
public class IndexController {
|
||||||
|
@GetMapping()
|
||||||
|
public Result<String> index() {
|
||||||
|
return Result.success("欢迎访问。。。");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
server:
|
||||||
|
port: 8200
|
||||||
|
|
||||||
|
bunny:
|
||||||
|
nacos:
|
||||||
|
server-addr: z-bunny.cn:8848
|
||||||
|
discovery:
|
||||||
|
namespace: ssyx
|
|
@ -0,0 +1,82 @@
|
||||||
|
server:
|
||||||
|
port: 8200
|
||||||
|
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: server-gateway
|
||||||
|
main:
|
||||||
|
web-application-type: reactive
|
||||||
|
profiles:
|
||||||
|
active: dev
|
||||||
|
cloud:
|
||||||
|
sentinel:
|
||||||
|
log:
|
||||||
|
dir: logs/${spring.application.name}/sentinel
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
namespace: ${bunny.nacos.discovery.namespace}
|
||||||
|
server-addr: ${bunny.nacos.server-addr}
|
||||||
|
log-name: logs/${spring.application.name}
|
||||||
|
gateway:
|
||||||
|
discovery:
|
||||||
|
locator:
|
||||||
|
enabled: true
|
||||||
|
routes:
|
||||||
|
- id: service-acl
|
||||||
|
uri: lb://service-acl
|
||||||
|
predicates:
|
||||||
|
- Path=/*/acl/**
|
||||||
|
|
||||||
|
- id: service-sys
|
||||||
|
uri: lb://service-sys
|
||||||
|
predicates:
|
||||||
|
- Path=/*/sys/**
|
||||||
|
|
||||||
|
- id: service-product
|
||||||
|
uri: lb://service-product
|
||||||
|
predicates:
|
||||||
|
- Path=/*/product/**
|
||||||
|
|
||||||
|
- id: service-activity
|
||||||
|
uri: lb://service-activity
|
||||||
|
predicates:
|
||||||
|
- Path=/*/activity/**
|
||||||
|
|
||||||
|
- id: service-order
|
||||||
|
uri: lb://service-order
|
||||||
|
predicates:
|
||||||
|
- Path=/*/order/**
|
||||||
|
|
||||||
|
- id: service-payment
|
||||||
|
uri: lb://service-payment
|
||||||
|
predicates:
|
||||||
|
- Path=/*/payment/**
|
||||||
|
|
||||||
|
- id: service-user
|
||||||
|
uri: lb://service-user
|
||||||
|
predicates:
|
||||||
|
- Path=/*/user/**
|
||||||
|
|
||||||
|
- id: service-search
|
||||||
|
uri: lb://service-search
|
||||||
|
predicates:
|
||||||
|
- Path=/*/search/**
|
||||||
|
|
||||||
|
- id: service-home
|
||||||
|
uri: lb://service-home
|
||||||
|
predicates:
|
||||||
|
- Path=/*/home/**
|
||||||
|
|
||||||
|
- id: service-cart
|
||||||
|
uri: lb://service-cart
|
||||||
|
predicates:
|
||||||
|
- Path=/*/cart/**
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.atguigu.ssyx.acl.mapper: debug
|
||||||
|
com.atguigu.ssyx.acl.controller: info
|
||||||
|
com.atguigu.ssyx.acl.service: info
|
||||||
|
pattern:
|
||||||
|
dateformat: HH:mm:ss:SSS
|
||||||
|
file:
|
||||||
|
path: "logs/${spring.application.name}"
|
|
@ -0,0 +1,16 @@
|
||||||
|
-----------------▄██-█▄---------
|
||||||
|
-----------------███▄██▄--------
|
||||||
|
-----------------███████--------
|
||||||
|
-----------------▀███████-------
|
||||||
|
-------------------██████▄▄-----
|
||||||
|
-------------------█████████▄---
|
||||||
|
-------------------██████▄████--
|
||||||
|
-------▄███████████████████████-
|
||||||
|
-----▄███████████████████████▀--
|
||||||
|
---▄██████████████████████------
|
||||||
|
---███████████████████████------
|
||||||
|
---███████████████████████------
|
||||||
|
-▄▄██████████████████████▀------
|
||||||
|
-█████████████████▀█████--------
|
||||||
|
-▀██████████████▀▀-▀█████▄------
|
||||||
|
-------▀▀▀▀▀▀▀▀▀------▀▀▀▀------
|
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
|
@ -14,6 +14,10 @@
|
||||||
<url>https://maven.apache.org</url>
|
<url>https://maven.apache.org</url>
|
||||||
<modules>
|
<modules>
|
||||||
<module>service-acl</module>
|
<module>service-acl</module>
|
||||||
|
<module>service-sys</module>
|
||||||
|
<module>service-product</module>
|
||||||
|
<module>service-search</module>
|
||||||
|
<module>service-activity</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -69,12 +73,5 @@
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--开发者工具-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-devtools</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -14,10 +14,62 @@
|
||||||
<url>https://maven.apache.org</url>
|
<url>https://maven.apache.org</url>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
<docker.repostory>192.168.1.4:1100</docker.repostory>
|
||||||
|
<docker.registry.name>ssyx</docker.registry.name>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.spotify</groupId>
|
||||||
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
|
<version>1.2.2</version>
|
||||||
|
<!--将插件绑定在某个phase执行-->
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>build-image</id>
|
||||||
|
<!--将插件绑定在package这个phase(阶段)上。也就是说,用户只需执行mvn package,就会自动执行mvn docker:build-->
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>build</goal>
|
||||||
|
<goal>push</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<serverId>harbor</serverId>
|
||||||
|
<registryUrl>http://${docker.repostory}</registryUrl>
|
||||||
|
<!-- 配置docker主机地址 -->
|
||||||
|
<dockerHost>http://192.168.1.4:2375</dockerHost>
|
||||||
|
<!--指定生成的镜像名-->
|
||||||
|
<imageName>
|
||||||
|
${docker.repostory}/${docker.registry.name}/${project.artifactId}:${project.version}
|
||||||
|
</imageName>
|
||||||
|
<!-- 指定 dockerfile 路径-->
|
||||||
|
<dockerDirectory>${project.basedir}</dockerDirectory>
|
||||||
|
<!-- 是否跳过docker构建 -->
|
||||||
|
<skipDockerBuild>false</skipDockerBuild>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package com.atguigu.ssyx.acl;
|
package com.atguigu.ssyx.acl;
|
||||||
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@ComponentScan("com.atguigu.ssyx.common")
|
@ComponentScan(basePackages = {"com.atguigu.ssyx.common", "com.atguigu.ssyx.acl"})
|
||||||
@MapperScan("com.atguigu.ssyx.*.mapper")
|
@EnableTransactionManagement
|
||||||
public class ServiceAclApplication {
|
public class ServiceAclApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(ServiceAclApplication.class, args);
|
SpringApplication.run(ServiceAclApplication.class, args);
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
package com.atguigu.ssyx.acl.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
|
import springfox.documentation.builders.ParameterBuilder;
|
||||||
|
import springfox.documentation.builders.PathSelectors;
|
||||||
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
import springfox.documentation.schema.ModelRef;
|
||||||
|
import springfox.documentation.service.ApiInfo;
|
||||||
|
import springfox.documentation.service.Contact;
|
||||||
|
import springfox.documentation.service.Parameter;
|
||||||
|
import springfox.documentation.spi.DocumentationType;
|
||||||
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableSwagger2WebMvc
|
||||||
|
public class Knife4jConfig {
|
||||||
|
@Bean
|
||||||
|
public Docket adminApiConfig() {
|
||||||
|
List<Parameter> pars = new ArrayList<>();
|
||||||
|
ParameterBuilder tokenPar = new ParameterBuilder();
|
||||||
|
tokenPar.name("adminId")
|
||||||
|
.description("用户token")
|
||||||
|
.defaultValue("1")
|
||||||
|
.modelRef(new ModelRef("string"))
|
||||||
|
.parameterType("header")
|
||||||
|
.required(false)
|
||||||
|
.build();
|
||||||
|
pars.add(tokenPar.build());
|
||||||
|
|
||||||
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.groupName("adminApi")
|
||||||
|
.apiInfo(adminApiInfo())
|
||||||
|
.select()
|
||||||
|
.apis(RequestHandlerSelectors.basePackage("com.atguigu.ssyx.acl.controller"))
|
||||||
|
.paths(PathSelectors.regex("/admin/.*"))
|
||||||
|
.build()
|
||||||
|
.globalOperationParameters(pars);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApiInfo adminApiInfo() {
|
||||||
|
return new ApiInfoBuilder()
|
||||||
|
.title("后台管理系统-API文档")
|
||||||
|
.description("本文档描述了尚上优选后台系统服务接口定义")
|
||||||
|
.version("1.0")
|
||||||
|
.contact(new Contact("atguigu", "http://atguigu.com", "atguigu"))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,73 @@
|
||||||
package com.atguigu.ssyx.acl.controller;
|
package com.atguigu.ssyx.acl.controller;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.acl.service.AdminService;
|
||||||
|
import com.atguigu.ssyx.common.result.Result;
|
||||||
|
import com.atguigu.ssyx.model.acl.Admin;
|
||||||
|
import com.atguigu.ssyx.vo.acl.AdminQueryVo;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/admin/acl/user")
|
@RequestMapping("/admin/acl/user")
|
||||||
@Api(tags = "用户管理")
|
@Api(tags = "用户管理")
|
||||||
public class AdminController {
|
public class AdminController {
|
||||||
|
@Autowired
|
||||||
|
private AdminService adminService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取管理用户分页列表")
|
||||||
|
@GetMapping("{page}/{limit}")
|
||||||
|
public Result<IPage<Admin>> index(
|
||||||
|
@ApiParam(name = "page", value = "当前页码", required = true)
|
||||||
|
@PathVariable Long page,
|
||||||
|
|
||||||
|
@ApiParam(name = "limit", value = "每页记录数", required = true)
|
||||||
|
@PathVariable Long limit,
|
||||||
|
|
||||||
|
@ApiParam(name = "userQueryVo", value = "查询对象")
|
||||||
|
AdminQueryVo userQueryVo
|
||||||
|
) {
|
||||||
|
IPage<Admin> pageModel = adminService.selectPage(page, limit, userQueryVo);
|
||||||
|
return Result.success(pageModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取管理用户")
|
||||||
|
@GetMapping("get/{id}")
|
||||||
|
public Result<Admin> get(@PathVariable Long id) {
|
||||||
|
Admin admin = adminService.getById(id);
|
||||||
|
return Result.success(admin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "新增管理用户")
|
||||||
|
@PostMapping("save")
|
||||||
|
public Result<Admin> save(@RequestBody Admin admin) {
|
||||||
|
boolean isSuccess = adminService.saveByAdmin(admin);
|
||||||
|
return isSuccess ? Result.success() : Result.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改管理用户")
|
||||||
|
@PutMapping("update")
|
||||||
|
public Result<Admin> updateById(@RequestBody Admin admin) {
|
||||||
|
adminService.updateById(admin);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "删除管理用户")
|
||||||
|
@DeleteMapping("remove/{id}")
|
||||||
|
public Result<Admin> remove(@PathVariable Long id) {
|
||||||
|
adminService.removeById(id);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "根据id列表删除管理用户")
|
||||||
|
@DeleteMapping("batchRemove")
|
||||||
|
public Result<List<Long>> batchRemove(@RequestBody List<Long> ids) {
|
||||||
|
adminService.removeByIds(ids);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.atguigu.ssyx.acl.controller;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.acl.service.AdminRoleService;
|
||||||
|
import com.atguigu.ssyx.common.result.Result;
|
||||||
|
import com.atguigu.ssyx.vo.acl.AssignAdminRoleVo;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/acl/user")
|
||||||
|
@Api(tags = "用户和角色管理")
|
||||||
|
public class AdminRoleController {
|
||||||
|
@Autowired
|
||||||
|
private AdminRoleService adminRoleService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "根据用户获取角色数据")
|
||||||
|
@GetMapping("/toAssign/{adminId}")
|
||||||
|
public Result<AssignAdminRoleVo> toAssign(@PathVariable Long adminId) {
|
||||||
|
AssignAdminRoleVo vo = adminRoleService.findRoleByUserId(adminId);
|
||||||
|
return Result.success(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "根据用户分配角色")
|
||||||
|
@PostMapping("/doAssign")
|
||||||
|
public Result<String> doAssign(@RequestParam Long adminId, @RequestParam Long[] roleId) {
|
||||||
|
adminRoleService.saveUserRoleShip(adminId, roleId);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,22 +1,36 @@
|
||||||
package com.atguigu.ssyx.acl.controller;
|
package com.atguigu.ssyx.acl.controller;
|
||||||
|
|
||||||
import com.atguigu.ssyx.common.result.Result;
|
import com.atguigu.ssyx.common.result.Result;
|
||||||
|
import com.atguigu.ssyx.vo.acl.LoginInfoVo;
|
||||||
|
import com.atguigu.ssyx.vo.acl.LoginVo;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Api(tags = "登录相关管理")
|
@Api(tags = "登录相关管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/admin/acl/index")
|
@RequestMapping("/admin/acl/index")
|
||||||
public class IndexController {
|
public class IndexController {
|
||||||
|
@ApiOperation(value = "请求登陆的login")
|
||||||
@PostMapping("login")
|
@PostMapping("login")
|
||||||
public Result<Map<String, Object>> login() {
|
public Result<LoginVo> login() {
|
||||||
Map<String, Object> map = new HashMap<>();
|
LoginVo vo = LoginVo.builder().token("admin-token").build();
|
||||||
map.put("token", "admin-token");
|
return Result.success(vo);
|
||||||
return Result.success(map);
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取用户信息")
|
||||||
|
@GetMapping("info")
|
||||||
|
public Result<LoginInfoVo> info() {
|
||||||
|
LoginInfoVo vo = LoginInfoVo.builder().name("admin").avatar("").build();
|
||||||
|
return Result.success(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "退出登录")
|
||||||
|
@PostMapping("logout")
|
||||||
|
public Result<String> logout() {
|
||||||
|
return Result.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.atguigu.ssyx.acl.controller;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.acl.service.PermissionService;
|
||||||
|
import com.atguigu.ssyx.common.result.Result;
|
||||||
|
import com.atguigu.ssyx.model.acl.Permission;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/acl/permission")
|
||||||
|
@Api(tags = "菜单管理")
|
||||||
|
@Slf4j
|
||||||
|
public class PermissionController {
|
||||||
|
@Autowired
|
||||||
|
private PermissionService permissionService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取菜单")
|
||||||
|
@GetMapping
|
||||||
|
public Result<List<Permission>> index() {
|
||||||
|
List<Permission> list = permissionService.queryAllMenu();
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "新增菜单")
|
||||||
|
@PostMapping("save")
|
||||||
|
public Result<Permission> save(@RequestBody Permission permission) {
|
||||||
|
permissionService.save(permission);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改菜单")
|
||||||
|
@PutMapping("update")
|
||||||
|
public Result<Permission> updateById(@RequestBody Permission permission) {
|
||||||
|
permissionService.updateById(permission);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "递归删除菜单")
|
||||||
|
@DeleteMapping("remove/{id}")
|
||||||
|
public Result<Permission> remove(@PathVariable Long id) {
|
||||||
|
permissionService.removeChildById(id);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.atguigu.ssyx.acl.controller;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.acl.service.RoleService;
|
||||||
|
import com.atguigu.ssyx.common.result.Result;
|
||||||
|
import com.atguigu.ssyx.model.acl.Role;
|
||||||
|
import com.atguigu.ssyx.vo.acl.RoleQueryVo;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/acl/role")
|
||||||
|
@Api(tags = "角色管理")
|
||||||
|
@Slf4j
|
||||||
|
public class RoleController {
|
||||||
|
@Autowired
|
||||||
|
private RoleService roleService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取角色分页列表")
|
||||||
|
@GetMapping("{page}/{limit}")
|
||||||
|
public Result<IPage<Role>> index(@ApiParam(name = "page", value = "当前页码", required = true)
|
||||||
|
@PathVariable Long page,
|
||||||
|
|
||||||
|
@ApiParam(name = "limit", value = "每页记录数", required = true)
|
||||||
|
@PathVariable Long limit,
|
||||||
|
|
||||||
|
@ApiParam(name = "roleQueryVo", value = "查询对象")
|
||||||
|
RoleQueryVo vo) {
|
||||||
|
IPage<Role> roleIPage = roleService.selectPage(page, limit, vo);
|
||||||
|
return Result.success(roleIPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取角色")
|
||||||
|
@GetMapping("get/{id}")
|
||||||
|
public Result<Role> getRole(@PathVariable Long id) {
|
||||||
|
Role role = roleService.getById(id);
|
||||||
|
return Result.success(role);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "新增角色")
|
||||||
|
@PostMapping("save")
|
||||||
|
public Result<Role> saveRole(@RequestBody Role role) {
|
||||||
|
roleService.save(role);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "更新角色")
|
||||||
|
@PutMapping("update")
|
||||||
|
public Result<Role> updateRole(@RequestBody Role role) {
|
||||||
|
boolean isSuccess = roleService.updateById(role);
|
||||||
|
return isSuccess ? Result.success() : Result.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "删除角色")
|
||||||
|
@DeleteMapping("remove/{id}")
|
||||||
|
public Result<Role> removeRole(@PathVariable Long id) {
|
||||||
|
roleService.removeById(id);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "根据id列表删除角色")
|
||||||
|
@DeleteMapping("batchRemove")
|
||||||
|
public Result<List<Long>> batchRemove(@RequestBody List<Long> ids) {
|
||||||
|
roleService.removeByIds(ids);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.atguigu.ssyx.acl.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.model.acl.AdminRole;
|
||||||
|
import com.atguigu.ssyx.model.acl.Role;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface AdminRoleMapper extends BaseMapper<AdminRole> {
|
||||||
|
/**
|
||||||
|
* * 根据用户ID查找角色
|
||||||
|
*
|
||||||
|
* @param adminId 用户ID
|
||||||
|
* @return 角色列表
|
||||||
|
*/
|
||||||
|
List<Role> findRoleByUserId(Long adminId);
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.atguigu.ssyx.acl.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.model.acl.Permission;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface PermissionMapper extends BaseMapper<Permission> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.atguigu.ssyx.acl.service;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.model.acl.AdminRole;
|
||||||
|
import com.atguigu.ssyx.vo.acl.AssignAdminRoleVo;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
public interface AdminRoleService extends IService<AdminRole> {
|
||||||
|
/**
|
||||||
|
* * 根据用户获取角色数据
|
||||||
|
*
|
||||||
|
* @param adminId 用户ID
|
||||||
|
* @return 分配集合
|
||||||
|
*/
|
||||||
|
AssignAdminRoleVo findRoleByUserId(Long adminId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 根据用户分配角色
|
||||||
|
*
|
||||||
|
* @param adminId 用户ID
|
||||||
|
* @param roleId 角色ID
|
||||||
|
*/
|
||||||
|
void saveUserRoleShip(Long adminId, Long[] roleId);
|
||||||
|
}
|
|
@ -1,8 +1,26 @@
|
||||||
package com.atguigu.ssyx.acl.service;
|
package com.atguigu.ssyx.acl.service;
|
||||||
|
|
||||||
import com.atguigu.ssyx.model.acl.Admin;
|
import com.atguigu.ssyx.model.acl.Admin;
|
||||||
|
import com.atguigu.ssyx.vo.acl.AdminQueryVo;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
public interface AdminService extends IService<Admin> {
|
public interface AdminService extends IService<Admin> {
|
||||||
|
/**
|
||||||
|
* * 条件分页查询
|
||||||
|
*
|
||||||
|
* @param page 当前页码
|
||||||
|
* @param limit 每页记录数
|
||||||
|
* @param userQueryVo 查询对象
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
|
||||||
|
IPage<Admin> selectPage(Long page, Long limit, AdminQueryVo userQueryVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增管理用户
|
||||||
|
*
|
||||||
|
* @param admin 用户管理员
|
||||||
|
*/
|
||||||
|
Boolean saveByAdmin(Admin admin);
|
||||||
}
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.atguigu.ssyx.acl.service;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.model.acl.Permission;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface PermissionService extends IService<Permission> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有菜单列表
|
||||||
|
*
|
||||||
|
* @return 权限列表
|
||||||
|
*/
|
||||||
|
List<Permission> queryAllMenu();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归删除
|
||||||
|
*
|
||||||
|
* @param id 删除ID
|
||||||
|
*/
|
||||||
|
void removeChildById(Long id);
|
||||||
|
}
|
|
@ -1,7 +1,18 @@
|
||||||
package com.atguigu.ssyx.acl.service;
|
package com.atguigu.ssyx.acl.service;
|
||||||
|
|
||||||
import com.atguigu.ssyx.model.acl.Role;
|
import com.atguigu.ssyx.model.acl.Role;
|
||||||
|
import com.atguigu.ssyx.vo.acl.RoleQueryVo;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
public interface RoleService extends IService<Role> {
|
public interface RoleService extends IService<Role> {
|
||||||
|
/**
|
||||||
|
* * 获取角色分页列表
|
||||||
|
*
|
||||||
|
* @param page 当前页码
|
||||||
|
* @param limit 每页记录数
|
||||||
|
* @param vo 角色查询实体
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
IPage<Role> selectPage(Long page, Long limit, RoleQueryVo vo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.atguigu.ssyx.acl.service.impl;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.acl.mapper.AdminRoleMapper;
|
||||||
|
import com.atguigu.ssyx.acl.service.AdminRoleService;
|
||||||
|
import com.atguigu.ssyx.acl.service.RoleService;
|
||||||
|
import com.atguigu.ssyx.model.acl.AdminRole;
|
||||||
|
import com.atguigu.ssyx.model.acl.Role;
|
||||||
|
import com.atguigu.ssyx.vo.acl.AssignAdminRoleVo;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class AdminRoleServiceImpl extends ServiceImpl<AdminRoleMapper, AdminRole> implements AdminRoleService {
|
||||||
|
@Autowired
|
||||||
|
private RoleService roleService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户获取角色数据
|
||||||
|
*
|
||||||
|
* @param adminId 用户ID
|
||||||
|
* @return 分配集合
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AssignAdminRoleVo findRoleByUserId(Long adminId) {
|
||||||
|
// 查询所有的角色
|
||||||
|
List<Role> allRolesList = roleService.list(null);
|
||||||
|
// 根据用户id查询角色
|
||||||
|
List<Role> roleList = baseMapper.findRoleByUserId(adminId);
|
||||||
|
|
||||||
|
// 返回全部角色和当前用户查询的角色
|
||||||
|
return AssignAdminRoleVo.builder()
|
||||||
|
.assignRoles(roleList)
|
||||||
|
.allRolesList(allRolesList).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 根据用户分配角色
|
||||||
|
*
|
||||||
|
* @param adminId 用户ID
|
||||||
|
* @param roleIds 角色ID
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void saveUserRoleShip(Long adminId, Long[] roleIds) {
|
||||||
|
// 先删除这个用户id下所有的角色信息
|
||||||
|
remove(Wrappers.<AdminRole>lambdaQuery().eq(AdminRole::getAdminId, adminId));
|
||||||
|
// 创建集合,遍历完成后一次性插入
|
||||||
|
ArrayList<AdminRole> adminRoles = new ArrayList<>();
|
||||||
|
|
||||||
|
// 循环遍历并插入
|
||||||
|
for (Long roleId : roleIds) {
|
||||||
|
// 为用户设置角色id
|
||||||
|
AdminRole adminRole = new AdminRole();
|
||||||
|
adminRole.setAdminId(adminId);
|
||||||
|
adminRole.setRoleId(roleId);
|
||||||
|
adminRoles.add(adminRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 插入整体数据
|
||||||
|
saveBatch(adminRoles);
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,15 +3,53 @@ package com.atguigu.ssyx.acl.service.impl;
|
||||||
import com.atguigu.ssyx.acl.mapper.AdminMapper;
|
import com.atguigu.ssyx.acl.mapper.AdminMapper;
|
||||||
import com.atguigu.ssyx.acl.service.AdminService;
|
import com.atguigu.ssyx.acl.service.AdminService;
|
||||||
import com.atguigu.ssyx.model.acl.Admin;
|
import com.atguigu.ssyx.model.acl.Admin;
|
||||||
|
import com.atguigu.ssyx.vo.acl.AdminQueryVo;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.DigestUtils;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {
|
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {
|
||||||
|
/**
|
||||||
|
* * 条件分页查询
|
||||||
|
*
|
||||||
|
* @param page 当前页码
|
||||||
|
* @param limit 每页记录数
|
||||||
|
* @param vo 查询对象
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean save(Admin entity) {
|
public IPage<Admin> selectPage(Long page, Long limit, AdminQueryVo vo) {
|
||||||
return super.save(entity);
|
Page<Admin> pageParam = new Page<Admin>(page, limit);
|
||||||
|
String name = vo.getName();
|
||||||
|
String username = vo.getUsername();
|
||||||
|
|
||||||
|
// 封装条件进行返回
|
||||||
|
LambdaQueryWrapper<Admin> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(!StringUtils.isEmpty(username), Admin::getUsername, username);
|
||||||
|
wrapper.like(!StringUtils.isEmpty(name), Admin::getName, name);
|
||||||
|
|
||||||
|
return baseMapper.selectPage(pageParam, wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增管理用户
|
||||||
|
*
|
||||||
|
* @param admin 用户管理员
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean saveByAdmin(Admin admin) {
|
||||||
|
// 获取密码并加密
|
||||||
|
String password = admin.getPassword();
|
||||||
|
String encryptPassword = DigestUtils.md5DigestAsHex(password.getBytes());
|
||||||
|
// 设置密码
|
||||||
|
admin.setPassword(encryptPassword);
|
||||||
|
return save(admin);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.atguigu.ssyx.acl.service.impl;
|
||||||
|
|
||||||
|
import com.atguigu.common.utils.PermissionHelper;
|
||||||
|
import com.atguigu.ssyx.acl.mapper.PermissionMapper;
|
||||||
|
import com.atguigu.ssyx.acl.service.PermissionService;
|
||||||
|
import com.atguigu.ssyx.acl.service.module.PermissionServiceModule;
|
||||||
|
import com.atguigu.ssyx.model.acl.Permission;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements PermissionService {
|
||||||
|
@Autowired
|
||||||
|
private PermissionServiceModule permissionServiceModule;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有菜单列表
|
||||||
|
*
|
||||||
|
* @return 权限列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Permission> queryAllMenu() {
|
||||||
|
// 转换要求数据格式
|
||||||
|
return PermissionHelper.buildPermissions(list());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归删除
|
||||||
|
*
|
||||||
|
* @param id 删除ID
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void removeChildById(Long id) {
|
||||||
|
ArrayList<Long> idList = new ArrayList<>();
|
||||||
|
|
||||||
|
// 获取菜单下子菜单
|
||||||
|
permissionServiceModule.getAllPermissionId(id, idList);
|
||||||
|
|
||||||
|
// 调用方法根据多个菜单ID删除
|
||||||
|
baseMapper.deleteBatchIds(idList);
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,11 +3,38 @@ package com.atguigu.ssyx.acl.service.impl;
|
||||||
import com.atguigu.ssyx.acl.mapper.RoleMapper;
|
import com.atguigu.ssyx.acl.mapper.RoleMapper;
|
||||||
import com.atguigu.ssyx.acl.service.RoleService;
|
import com.atguigu.ssyx.acl.service.RoleService;
|
||||||
import com.atguigu.ssyx.model.acl.Role;
|
import com.atguigu.ssyx.model.acl.Role;
|
||||||
|
import com.atguigu.ssyx.vo.acl.RoleQueryVo;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
|
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
|
||||||
|
/**
|
||||||
|
* 获取角色分页列表
|
||||||
|
*
|
||||||
|
* @param page 当前页码
|
||||||
|
* @param limit 每页记录数
|
||||||
|
* @param vo 角色查询实体
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public IPage<Role> selectPage(Long page, Long limit, RoleQueryVo vo) {
|
||||||
|
Page<Role> roleParam = new Page<>(page, limit);
|
||||||
|
// 获取条件值
|
||||||
|
String roleName = vo.getRoleName();
|
||||||
|
// 创建mp对象
|
||||||
|
LambdaQueryWrapper<Role> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
// 判断条件值是否为空
|
||||||
|
if (!StringUtils.isEmpty(roleName)) {
|
||||||
|
wrapper.like(Role::getRoleName, roleParam);
|
||||||
|
}
|
||||||
|
// 调用犯法实现分页查询
|
||||||
|
return baseMapper.selectPage(roleParam, wrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.atguigu.ssyx.acl.service.module;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.acl.mapper.PermissionMapper;
|
||||||
|
import com.atguigu.ssyx.model.acl.Permission;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class PermissionServiceModule {
|
||||||
|
@Autowired
|
||||||
|
private PermissionMapper permissionMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取菜单下子菜单
|
||||||
|
*
|
||||||
|
* @param id 菜单ID
|
||||||
|
* @param idList IDList
|
||||||
|
*/
|
||||||
|
public void getAllPermissionId(Long id, ArrayList<Long> idList) {
|
||||||
|
List<Permission> permissions = permissionMapper.selectList(Wrappers.<Permission>lambdaQuery().eq(Permission::getId, id));
|
||||||
|
|
||||||
|
permissions.forEach(item -> {
|
||||||
|
idList.add(item.getId());
|
||||||
|
getAllPermissionId(item.getId(), idList);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,18 +14,8 @@ bunny:
|
||||||
discovery:
|
discovery:
|
||||||
namespace: ssyx
|
namespace: ssyx
|
||||||
|
|
||||||
redis:
|
minio:
|
||||||
host: 47.120.65.66
|
endpointUrl: "http://129.211.31.58:9000"
|
||||||
port: 6379
|
bucket-name: ssyx
|
||||||
database: 2
|
accessKey: bunny
|
||||||
password: "02120212"
|
secretKey: "02120212"
|
||||||
|
|
||||||
logging:
|
|
||||||
level:
|
|
||||||
com.atguigu.ssyx.acl.mapper: debug
|
|
||||||
com.atguigu.ssyx.acl.controller: info
|
|
||||||
com.atguigu.ssyx.acl.service: info
|
|
||||||
pattern:
|
|
||||||
dateformat: HH:mm:ss:SSS
|
|
||||||
file:
|
|
||||||
path: "logs/${spring.application.name}"
|
|
|
@ -1,5 +1,5 @@
|
||||||
server:
|
server:
|
||||||
port: 8291
|
port: 8201
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: service-acl
|
name: service-acl
|
||||||
|
@ -11,7 +11,7 @@ spring:
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://${bunny.datasource.host}:${bunny.datasource.port}/${bunny.datasource.sqlData}?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true
|
url: jdbc:mysql://${bunny.datasource.host}:${bunny.datasource.port}/${bunny.datasource.sqlData}?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true
|
||||||
username: ${bunny.datasource.username}
|
username: ${bunny.datasource.username}
|
||||||
password: "${bunny.datasource.password}"
|
password: ${bunny.datasource.password}
|
||||||
|
|
||||||
cloud:
|
cloud:
|
||||||
sentinel:
|
sentinel:
|
||||||
|
@ -34,14 +34,29 @@ mybatis-plus:
|
||||||
map-underscore-to-camel-case: true
|
map-underscore-to-camel-case: true
|
||||||
auto-mapping-behavior: full
|
auto-mapping-behavior: full
|
||||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 查看日志
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 查看日志
|
||||||
# global-config:
|
global-config:
|
||||||
# db-config:
|
db-config:
|
||||||
# 设置表名前缀,不用在每个tableName添加前缀
|
# 设置表名前缀,不用在每个tableName添加前缀
|
||||||
# table-prefix: t_
|
# table-prefix: t_
|
||||||
# 全局配置主键值方式
|
# 全局配置主键值方式
|
||||||
# id-type: assign_id
|
id-type: assign_id
|
||||||
# 指定逻辑删除-未删除
|
logic-not-delete-value: 0 # 未删除默认为0
|
||||||
# logic-not-delete-value: 0 # 未删除默认为0
|
logic-delete-value: 1 # 删除
|
||||||
# 指定逻辑删除-删除
|
logic-delete-field: deleted # 全局配置逻辑删除
|
||||||
# logic-delete-value: 1 # 删除
|
|
||||||
# logic-delete-field: deleted # 全局配置逻辑删除
|
logging:
|
||||||
|
level:
|
||||||
|
com.atguigu.ssyx.acl.mapper: debug
|
||||||
|
com.atguigu.ssyx.acl.controller: info
|
||||||
|
com.atguigu.ssyx.acl.service: info
|
||||||
|
pattern:
|
||||||
|
dateformat: HH:mm:ss:SSS
|
||||||
|
file:
|
||||||
|
path: "logs/${spring.application.name}"
|
||||||
|
|
||||||
|
bunny:
|
||||||
|
minio:
|
||||||
|
endpointUrl: ${bunny.minio.endpointUrl}
|
||||||
|
accessKey: ${bunny.minio.accessKey}
|
||||||
|
secretKey: ${bunny.minio.secretKey}
|
||||||
|
bucket-name: ${bunny.minio.bucket-name}
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?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.atguigu.ssyx.acl.mapper.AdminRoleMapper">
|
||||||
|
<!-- 根据用户ID查找角色 -->
|
||||||
|
<select id="findRoleByUserId" resultType="com.atguigu.ssyx.model.acl.Role">
|
||||||
|
SELECT r.*
|
||||||
|
FROM admin_role ar
|
||||||
|
LEFT JOIN role r ON ar.role_id = r.id AND ar.admin_id = #{adminId}
|
||||||
|
WHERE ar.is_deleted = 0
|
||||||
|
AND r.is_deleted = 0
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,21 @@
|
||||||
|
FROM openjdk:17
|
||||||
|
MAINTAINER bunny
|
||||||
|
|
||||||
|
#系统编码
|
||||||
|
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
|
||||||
|
|
||||||
|
# 设置时区,构建镜像时执行的命令
|
||||||
|
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||||
|
RUN echo "Asia/Shanghai" > /etc/timezone
|
||||||
|
|
||||||
|
# 设定工作目录
|
||||||
|
WORKDIR /home/bunny
|
||||||
|
|
||||||
|
# 复制jar包
|
||||||
|
COPY target/*.jar /home/bunny/app.jar
|
||||||
|
|
||||||
|
#启动容器时的进程
|
||||||
|
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
|
||||||
|
|
||||||
|
#暴露 8080 端口
|
||||||
|
EXPOSE 8080
|
|
@ -0,0 +1,23 @@
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.atguigu</groupId>
|
||||||
|
<artifactId>service</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>service-activity</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>service-activity</name>
|
||||||
|
<url>https://maven.apache.org</url>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.atguigu.ssyx.activity;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@ComponentScan(basePackages = {
|
||||||
|
"com.atguigu.ssyx.common",
|
||||||
|
"com.atguigu.ssyx.activity"})
|
||||||
|
@EnableTransactionManagement
|
||||||
|
public class ServiceActivityApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(ServiceActivityApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.atguigu.ssyx.activity.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.activity.service.ActivityInfoService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 活动表 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-04
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/activity/activityInfo")
|
||||||
|
public class ActivityInfoController {
|
||||||
|
@Autowired
|
||||||
|
private ActivityInfoService activityInfoService;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.atguigu.ssyx.activity.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 优惠券信息 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-04
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/activity/coupon-info")
|
||||||
|
public class CouponInfoController {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.atguigu.ssyx.activity.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.model.activity.ActivityInfo;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 活动表 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-04
|
||||||
|
*/
|
||||||
|
public interface ActivityInfoMapper extends BaseMapper<ActivityInfo> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.atguigu.ssyx.activity.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.model.activity.CouponInfo;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 优惠券信息 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-04
|
||||||
|
*/
|
||||||
|
public interface CouponInfoMapper extends BaseMapper<CouponInfo> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.atguigu.ssyx.activity.service;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.model.activity.ActivityInfo;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 活动表 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-04
|
||||||
|
*/
|
||||||
|
public interface ActivityInfoService extends IService<ActivityInfo> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.atguigu.ssyx.activity.service;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.model.activity.CouponInfo;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 优惠券信息 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-04
|
||||||
|
*/
|
||||||
|
public interface CouponInfoService extends IService<CouponInfo> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.atguigu.ssyx.activity.service.impl;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.activity.mapper.ActivityInfoMapper;
|
||||||
|
import com.atguigu.ssyx.activity.service.ActivityInfoService;
|
||||||
|
import com.atguigu.ssyx.model.activity.ActivityInfo;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 活动表 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-04
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ActivityInfoServiceImpl extends ServiceImpl<ActivityInfoMapper, ActivityInfo> implements ActivityInfoService {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.atguigu.ssyx.activity.service.impl;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.activity.mapper.CouponInfoMapper;
|
||||||
|
import com.atguigu.ssyx.activity.service.CouponInfoService;
|
||||||
|
import com.atguigu.ssyx.model.activity.CouponInfo;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 优惠券信息 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-04
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CouponInfoServiceImpl extends ServiceImpl<CouponInfoMapper, CouponInfo> implements CouponInfoService {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
server:
|
||||||
|
port: 8204
|
||||||
|
|
||||||
|
bunny:
|
||||||
|
datasource:
|
||||||
|
host: 106.15.251.123
|
||||||
|
port: 3305
|
||||||
|
sqlData: shequ-activity
|
||||||
|
username: root
|
||||||
|
password: "02120212"
|
||||||
|
|
||||||
|
nacos:
|
||||||
|
server-addr: z-bunny.cn:8848
|
||||||
|
discovery:
|
||||||
|
namespace: ssyx
|
|
@ -0,0 +1,54 @@
|
||||||
|
server:
|
||||||
|
port: 8204
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: service-activity
|
||||||
|
profiles:
|
||||||
|
active: dev
|
||||||
|
|
||||||
|
datasource:
|
||||||
|
type: com.zaxxer.hikari.HikariDataSource
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
url: jdbc:mysql://${bunny.datasource.host}:${bunny.datasource.port}/${bunny.datasource.sqlData}?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true
|
||||||
|
username: ${bunny.datasource.username}
|
||||||
|
password: ${bunny.datasource.password}
|
||||||
|
|
||||||
|
cloud:
|
||||||
|
sentinel:
|
||||||
|
log:
|
||||||
|
dir: logs/${spring.application.name}/sentinel
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
namespace: ${bunny.nacos.discovery.namespace}
|
||||||
|
server-addr: ${bunny.nacos.server-addr}
|
||||||
|
|
||||||
|
jackson:
|
||||||
|
date-format: yyyy-MM-dd HH:mm:ss
|
||||||
|
time-zone: GMT+8
|
||||||
|
|
||||||
|
mybatis-plus:
|
||||||
|
type-aliases-package: com.atguigu.model # 配置每个包前缀
|
||||||
|
mapper-locations: classpath:mapper/*.xml
|
||||||
|
configuration:
|
||||||
|
map-underscore-to-camel-case: true
|
||||||
|
auto-mapping-behavior: full
|
||||||
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 查看日志
|
||||||
|
global-config:
|
||||||
|
db-config:
|
||||||
|
# 设置表名前缀,不用在每个tableName添加前缀
|
||||||
|
# table-prefix: t_
|
||||||
|
# 全局配置主键值方式
|
||||||
|
id-type: assign_id
|
||||||
|
logic-not-delete-value: 0 # 未删除默认为0
|
||||||
|
logic-delete-value: 1 # 删除
|
||||||
|
logic-delete-field: deleted # 全局配置逻辑删除
|
||||||
|
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.atguigu.ssyx.activity.mapper: debug
|
||||||
|
com.atguigu.ssyx.activity.controller: info
|
||||||
|
com.atguigu.ssyx.activity.service: info
|
||||||
|
pattern:
|
||||||
|
dateformat: HH:mm:ss:SSS
|
||||||
|
file:
|
||||||
|
path: "logs/${spring.application.name}"
|
|
@ -0,0 +1,16 @@
|
||||||
|
-----------------▄██-█▄---------
|
||||||
|
-----------------███▄██▄--------
|
||||||
|
-----------------███████--------
|
||||||
|
-----------------▀███████-------
|
||||||
|
-------------------██████▄▄-----
|
||||||
|
-------------------█████████▄---
|
||||||
|
-------------------██████▄████--
|
||||||
|
-------▄███████████████████████-
|
||||||
|
-----▄███████████████████████▀--
|
||||||
|
---▄██████████████████████------
|
||||||
|
---███████████████████████------
|
||||||
|
---███████████████████████------
|
||||||
|
-▄▄██████████████████████▀------
|
||||||
|
-█████████████████▀█████--------
|
||||||
|
-▀██████████████▀▀-▀█████▄------
|
||||||
|
-------▀▀▀▀▀▀▀▀▀------▀▀▀▀------
|
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
|
@ -0,0 +1,5 @@
|
||||||
|
<?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.atguigu.ssyx.activity.mapper.ActivityInfoMapper">
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?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.atguigu.ssyx.activity.mapper.CouponInfoMapper">
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -0,0 +1,21 @@
|
||||||
|
FROM openjdk:17
|
||||||
|
MAINTAINER bunny
|
||||||
|
|
||||||
|
#系统编码
|
||||||
|
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
|
||||||
|
|
||||||
|
# 设置时区,构建镜像时执行的命令
|
||||||
|
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||||
|
RUN echo "Asia/Shanghai" > /etc/timezone
|
||||||
|
|
||||||
|
# 设定工作目录
|
||||||
|
WORKDIR /home/bunny
|
||||||
|
|
||||||
|
# 复制jar包
|
||||||
|
COPY target/*.jar /home/bunny/app.jar
|
||||||
|
|
||||||
|
#启动容器时的进程
|
||||||
|
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
|
||||||
|
|
||||||
|
#暴露 8080 端口
|
||||||
|
EXPOSE 8080
|
|
@ -0,0 +1,32 @@
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.atguigu</groupId>
|
||||||
|
<artifactId>service</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>service-product</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>service-product</name>
|
||||||
|
<url>https://maven.apache.org</url>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.atguigu</groupId>
|
||||||
|
<artifactId>rabbit-util</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.atguigu.ssyx.product;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@ComponentScan(basePackages = {
|
||||||
|
"com.atguigu.ssyx.common",
|
||||||
|
"com.atguigu.ssyx.mq",
|
||||||
|
"com.atguigu.ssyx.product"})
|
||||||
|
@EnableTransactionManagement
|
||||||
|
public class ServiceProductApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(ServiceProductApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.atguigu.ssyx.product.api;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.common.result.Result;
|
||||||
|
import com.atguigu.ssyx.model.product.Category;
|
||||||
|
import com.atguigu.ssyx.model.product.SkuInfo;
|
||||||
|
import com.atguigu.ssyx.product.service.CategoryService;
|
||||||
|
import com.atguigu.ssyx.product.service.SkuInfoService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@Api(value = "远程调用接口", tags = "远程调用接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/product")
|
||||||
|
public class ProductInnerController {
|
||||||
|
@Autowired
|
||||||
|
private CategoryService categoryService;
|
||||||
|
@Autowired
|
||||||
|
private SkuInfoService skuInfoService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "根据分类id获取分类信息")
|
||||||
|
@GetMapping("inner/getCategory/{categoryId}")
|
||||||
|
public Result<Category> getCategory(@PathVariable Long categoryId) {
|
||||||
|
Category category = categoryService.getById(categoryId);
|
||||||
|
return Result.success(category);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "根据skuId获取sku信息")
|
||||||
|
@GetMapping("inner/getSkuInfo/{skuId}")
|
||||||
|
public Result<SkuInfo> getSkuInfo(@PathVariable Long skuId) {
|
||||||
|
SkuInfo skuInfo = skuInfoService.getById(skuId);
|
||||||
|
return Result.success(skuInfo);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
package com.atguigu.ssyx.product.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
|
import springfox.documentation.builders.ParameterBuilder;
|
||||||
|
import springfox.documentation.builders.PathSelectors;
|
||||||
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
import springfox.documentation.schema.ModelRef;
|
||||||
|
import springfox.documentation.service.ApiInfo;
|
||||||
|
import springfox.documentation.service.Contact;
|
||||||
|
import springfox.documentation.service.Parameter;
|
||||||
|
import springfox.documentation.spi.DocumentationType;
|
||||||
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableSwagger2WebMvc
|
||||||
|
public class Knife4jConfig {
|
||||||
|
@Bean
|
||||||
|
public Docket adminApiConfig() {
|
||||||
|
List<Parameter> pars = new ArrayList<>();
|
||||||
|
ParameterBuilder tokenPar = new ParameterBuilder();
|
||||||
|
tokenPar.name("adminId")
|
||||||
|
.description("用户token")
|
||||||
|
.defaultValue("1")
|
||||||
|
.modelRef(new ModelRef("string"))
|
||||||
|
.parameterType("header")
|
||||||
|
.required(false)
|
||||||
|
.build();
|
||||||
|
pars.add(tokenPar.build());
|
||||||
|
|
||||||
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.groupName("商品相关API")
|
||||||
|
.apiInfo(adminApiInfo())
|
||||||
|
.select()
|
||||||
|
.apis(RequestHandlerSelectors.basePackage("com.atguigu.ssyx.product.controller"))
|
||||||
|
.paths(PathSelectors.regex("/admin/.*"))
|
||||||
|
.build()
|
||||||
|
.globalOperationParameters(pars);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApiInfo adminApiInfo() {
|
||||||
|
return new ApiInfoBuilder()
|
||||||
|
.title("后台管理系统-API文档")
|
||||||
|
.description("本文档描述了尚上优选后台系统服务接口定义")
|
||||||
|
.version("1.0")
|
||||||
|
.contact(new Contact("atguigu", "http://atguigu.com", "atguigu"))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
package com.atguigu.ssyx.product.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.common.result.Result;
|
||||||
|
import com.atguigu.ssyx.model.product.Attr;
|
||||||
|
import com.atguigu.ssyx.product.service.AttrService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 商品属性 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-03
|
||||||
|
*/
|
||||||
|
@Api(value = "Attr管理", tags = "平台属性管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/admin/product/attr")
|
||||||
|
public class AttrController {
|
||||||
|
@Autowired
|
||||||
|
private AttrService attrService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取列表")
|
||||||
|
@GetMapping("{attrGroupId}")
|
||||||
|
public Result<List<Attr>> index(
|
||||||
|
@ApiParam(name = "attrGroupId", value = "分组id", required = true)
|
||||||
|
@PathVariable Long attrGroupId) {
|
||||||
|
List<Attr> attrList = attrService.findByAttrGroupId(attrGroupId);
|
||||||
|
return Result.success(attrList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取")
|
||||||
|
@GetMapping("get/{id}")
|
||||||
|
public Result<Attr> get(@PathVariable Long id) {
|
||||||
|
Attr attr = attrService.getById(id);
|
||||||
|
return Result.success(attr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "新增")
|
||||||
|
@PostMapping("save")
|
||||||
|
public Result<Attr> save(@RequestBody Attr attr) {
|
||||||
|
attrService.save(attr);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改")
|
||||||
|
@PutMapping("update")
|
||||||
|
public Result<Attr> updateById(@RequestBody Attr attr) {
|
||||||
|
attrService.updateById(attr);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "删除")
|
||||||
|
@DeleteMapping("remove/{id}")
|
||||||
|
public Result<Attr> remove(@PathVariable Long id) {
|
||||||
|
attrService.removeById(id);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "根据id列表删除")
|
||||||
|
@DeleteMapping("batchRemove")
|
||||||
|
public Result<Attr> batchRemove(@RequestBody List<Long> ids) {
|
||||||
|
attrService.removeByIds(ids);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
package com.atguigu.ssyx.product.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.common.result.Result;
|
||||||
|
import com.atguigu.ssyx.model.product.AttrGroup;
|
||||||
|
import com.atguigu.ssyx.product.service.AttrGroupService;
|
||||||
|
import com.atguigu.ssyx.vo.product.AttrGroupQueryVo;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 属性分组 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-03
|
||||||
|
*/
|
||||||
|
@Api(value = "AttrGroup管理", tags = "平台属性分组管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/admin/product/attrGroup")
|
||||||
|
public class AttrGroupController {
|
||||||
|
@Autowired
|
||||||
|
private AttrGroupService attrGroupService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取分页列表")
|
||||||
|
@GetMapping("{page}/{limit}")
|
||||||
|
public Result<IPage<AttrGroup>> index(
|
||||||
|
@ApiParam(name = "page", value = "当前页码", required = true)
|
||||||
|
@PathVariable Long page,
|
||||||
|
|
||||||
|
@ApiParam(name = "limit", value = "每页记录数", required = true)
|
||||||
|
@PathVariable Long limit,
|
||||||
|
|
||||||
|
@ApiParam(name = "attrGroupQueryVo", value = "查询对象", required = false)
|
||||||
|
AttrGroupQueryVo attrGroupQueryVo) {
|
||||||
|
Page<AttrGroup> pageParam = new Page<>(page, limit);
|
||||||
|
IPage<AttrGroup> pageModel = attrGroupService.selectPage(pageParam, attrGroupQueryVo);
|
||||||
|
return Result.success(pageModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取")
|
||||||
|
@GetMapping("get/{id}")
|
||||||
|
public Result<AttrGroup> get(@PathVariable Long id) {
|
||||||
|
AttrGroup attrGroup = attrGroupService.getById(id);
|
||||||
|
return Result.success(attrGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "新增")
|
||||||
|
@PostMapping("save")
|
||||||
|
public Result<AttrGroup> save(@RequestBody AttrGroup group) {
|
||||||
|
attrGroupService.save(group);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改")
|
||||||
|
@PutMapping("update")
|
||||||
|
public Result<AttrGroup> updateById(@RequestBody AttrGroup attrGroup) {
|
||||||
|
attrGroupService.updateById(attrGroup);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "删除")
|
||||||
|
@DeleteMapping("remove/{id}")
|
||||||
|
public Result<Long> remove(@PathVariable Long id) {
|
||||||
|
attrGroupService.removeById(id);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "根据id列表删除")
|
||||||
|
@DeleteMapping("batchRemove")
|
||||||
|
public Result<AttrGroup> batchRemove(@RequestBody List<Long> ids) {
|
||||||
|
attrGroupService.removeByIds(ids);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取全部属性分组")
|
||||||
|
@GetMapping("findAllList")
|
||||||
|
public Result<List<AttrGroup>> findAllList() {
|
||||||
|
return Result.success(attrGroupService.list());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
package com.atguigu.ssyx.product.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.common.result.Result;
|
||||||
|
import com.atguigu.ssyx.model.product.Category;
|
||||||
|
import com.atguigu.ssyx.product.service.CategoryService;
|
||||||
|
import com.atguigu.ssyx.vo.product.CategoryQueryVo;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Api(value = "Category管理", tags = "商品分类管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/admin/product/category")
|
||||||
|
public class CategoryController {
|
||||||
|
@Autowired
|
||||||
|
private CategoryService categoryService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取商品分类分页列表")
|
||||||
|
@GetMapping("{page}/{limit}")
|
||||||
|
public Result<IPage<Category>> index(
|
||||||
|
@ApiParam(name = "page", value = "当前页码", required = true)
|
||||||
|
@PathVariable Long page,
|
||||||
|
@ApiParam(name = "limit", value = "每页记录数", required = true)
|
||||||
|
@PathVariable Long limit,
|
||||||
|
@ApiParam(name = "categoryQueryVo", value = "查询对象", required = false)
|
||||||
|
CategoryQueryVo categoryQueryVo) {
|
||||||
|
Page<Category> pageParam = new Page<>(page, limit);
|
||||||
|
IPage<Category> pageModel = categoryService.selectPage(pageParam, categoryQueryVo);
|
||||||
|
|
||||||
|
return Result.success(pageModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取商品分类信息")
|
||||||
|
@GetMapping("get/{id}")
|
||||||
|
public Result<Category> get(@PathVariable Long id) {
|
||||||
|
Category category = categoryService.getById(id);
|
||||||
|
return Result.success(category);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "新增商品分类")
|
||||||
|
@PostMapping("save")
|
||||||
|
public Result<Category> save(@RequestBody Category category) {
|
||||||
|
categoryService.save(category);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改商品分类")
|
||||||
|
@PutMapping("update")
|
||||||
|
public Result<Category> updateById(@RequestBody Category category) {
|
||||||
|
categoryService.updateById(category);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "删除商品分类")
|
||||||
|
@DeleteMapping("remove/{id}")
|
||||||
|
public Result<Category> remove(@PathVariable Long id) {
|
||||||
|
categoryService.removeById(id);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "根据id列表删除商品分类")
|
||||||
|
@DeleteMapping("batchRemove")
|
||||||
|
public Result<Category> batchRemove(@RequestBody List<Long> ids) {
|
||||||
|
categoryService.removeByIds(ids);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取全部商品分类")
|
||||||
|
@GetMapping("findAllList")
|
||||||
|
public Result<List<Category>> findAllList() {
|
||||||
|
List<Category> categoryList = categoryService.findAllList();
|
||||||
|
return Result.success(categoryList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.atguigu.ssyx.product.controller;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.common.result.Result;
|
||||||
|
import com.atguigu.ssyx.product.service.FileUploadService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
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 org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
@Api(tags = "文件上传接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/product")
|
||||||
|
public class FileUploadController {
|
||||||
|
@Autowired
|
||||||
|
private FileUploadService fileUploadService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "文件上传")
|
||||||
|
@PostMapping("fileUpload")
|
||||||
|
public Result<String> fileUpload(@RequestBody MultipartFile file) {
|
||||||
|
String filename = fileUploadService.uploadFile(file);
|
||||||
|
return Result.success(filename);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.atguigu.ssyx.product.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* spu属性值 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-03
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/product/sku-attr-value")
|
||||||
|
public class SkuAttrValueController {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.atguigu.ssyx.product.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 商品图片 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-03
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/product/sku-image")
|
||||||
|
public class SkuImageController {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,107 @@
|
||||||
|
package com.atguigu.ssyx.product.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.common.result.Result;
|
||||||
|
import com.atguigu.ssyx.model.product.SkuInfo;
|
||||||
|
import com.atguigu.ssyx.product.service.SkuInfoService;
|
||||||
|
import com.atguigu.ssyx.vo.product.SkuInfoQueryVo;
|
||||||
|
import com.atguigu.ssyx.vo.product.SkuInfoVo;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* sku信息 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-03
|
||||||
|
*/
|
||||||
|
@Api(value = "SkuInfo管理", tags = "商品Sku管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/admin/product/skuInfo")
|
||||||
|
public class SkuInfoController {
|
||||||
|
@Autowired
|
||||||
|
private SkuInfoService skuInfoService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取sku分页列表")
|
||||||
|
@GetMapping("{page}/{limit}")
|
||||||
|
public Result<IPage<SkuInfo>> index(
|
||||||
|
@ApiParam(name = "page", value = "当前页码", required = true)
|
||||||
|
@PathVariable Long page,
|
||||||
|
|
||||||
|
@ApiParam(name = "limit", value = "每页记录数", required = true)
|
||||||
|
@PathVariable Long limit,
|
||||||
|
|
||||||
|
@ApiParam(name = "skuInfoQueryVo", value = "查询对象", required = false)
|
||||||
|
SkuInfoQueryVo skuInfoQueryVo) {
|
||||||
|
Page<SkuInfo> pageParam = new Page<>(page, limit);
|
||||||
|
IPage<SkuInfo> pageModel = skuInfoService.selectPage(pageParam, skuInfoQueryVo);
|
||||||
|
return Result.success(pageModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "商品添加方法")
|
||||||
|
@PostMapping("save")
|
||||||
|
public Result<SkuInfo> save(@RequestBody SkuInfoVo skuInfoVo) {
|
||||||
|
skuInfoService.saveSkuInfo(skuInfoVo);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取商品SKU信息")
|
||||||
|
@GetMapping("get/{id}")
|
||||||
|
public Result<SkuInfoVo> get(@PathVariable Long id) {
|
||||||
|
SkuInfoVo skuInfoVo = skuInfoService.getSkuInfoVo(id);
|
||||||
|
return Result.success(skuInfoVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改商品sku信息")
|
||||||
|
@PutMapping("update")
|
||||||
|
public Result<SkuInfoVo> updateById(@RequestBody SkuInfoVo skuInfoVo) {
|
||||||
|
skuInfoService.updateSkuInfo(skuInfoVo);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "商品SKU删除")
|
||||||
|
@DeleteMapping("remove/{id}")
|
||||||
|
public Result<SkuInfoVo> remove(@PathVariable Long id) {
|
||||||
|
skuInfoService.removeById(id);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "根据id列表删除")
|
||||||
|
@DeleteMapping("batchRemove")
|
||||||
|
public Result<SkuInfoVo> batchRemove(@RequestBody List<Long> ids) {
|
||||||
|
skuInfoService.removeByIds(ids);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "商品审核")
|
||||||
|
@GetMapping("check/{skuId}/{status}")
|
||||||
|
public Result<SkuInfo> check(@PathVariable Long skuId, @PathVariable Integer status) {
|
||||||
|
skuInfoService.check(skuId, status);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "商品上架")
|
||||||
|
@GetMapping("publish/{skuId}/{status}")
|
||||||
|
public Result<SkuInfo> publish(@PathVariable("skuId") Long skuId,
|
||||||
|
@PathVariable("status") Integer status) {
|
||||||
|
skuInfoService.publish(skuId, status);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "新人专享")
|
||||||
|
@GetMapping("isNewPerson/{skuId}/{status}")
|
||||||
|
public Result<SkuInfo> isNewPerson(@PathVariable Long skuId, @PathVariable Integer status) {
|
||||||
|
skuInfoService.isNewPerson(skuId, status);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.atguigu.ssyx.product.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 商品海报表 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-03
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/product/sku-poster")
|
||||||
|
public class SkuPosterController {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.atguigu.ssyx.product.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.model.product.AttrGroup;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 属性分组 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-03
|
||||||
|
*/
|
||||||
|
public interface AttrGroupMapper extends BaseMapper<AttrGroup> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.atguigu.ssyx.product.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.model.product.Attr;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 商品属性 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-03
|
||||||
|
*/
|
||||||
|
public interface AttrMapper extends BaseMapper<Attr> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.atguigu.ssyx.product.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.model.product.Category;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 商品三级分类 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-03
|
||||||
|
*/
|
||||||
|
public interface CategoryMapper extends BaseMapper<Category> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.atguigu.ssyx.product.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.model.product.SkuAttrValue;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* spu属性值 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-03
|
||||||
|
*/
|
||||||
|
public interface SkuAttrValueMapper extends BaseMapper<SkuAttrValue> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.atguigu.ssyx.product.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.ssyx.model.product.SkuImage;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 商品图片 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-03
|
||||||
|
*/
|
||||||
|
public interface SkuImageMapper extends BaseMapper<SkuImage> {
|
||||||
|
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue