【22届软件创新实验室暑假集训】后端赛道大作业

1. 设计思路

1.1 技术栈选择

后端:shiro + springboot + springMVC + mybatis + druid + mysql
前端:thymeleaf + bootstrap

1.2 数据建模

用户信息

字段数据类型字段描述字段长度是否主键是否为空
idintID-
namevarchar用户名20
rbactinyint是否为管理员1
pwdvarchar密码20

物料信息

字段数据类型字段描述字段长度是否主键是否为空
art_noint货号-
namevarchar货物名称20
avg_pricedecimal总仓均价10, 5
amountint数量-

台账

字段数据类型字段描述字段长度是否主键是否为空
time_stamptimestamp记录时间6
depo_novarchar所属仓库10
art_noint货号-
statetinyint出库/入库1
amountint数量()标准单位-
unit_pricedecimal单价10, 5
totaldecimal总金额10, 5
targetvarchar来源/去向20

货物信息

字段数据类型字段描述字段长度是否主键是否为空
art_noint货号-
depo_novarchar所属仓库10
amountint数量-
unit_pricedecimal单价10, 5

1.3 框架搭建

直接改的上学期的仓库管理系统,因为正好用thymeleaf重构了前端,所以就不实现接口了(其实是纯纯的不会
项目整体目录结构如图
在这里插入图片描述
pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.hoppi</groupId>
    <artifactId>SpringBootDemo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>SpringBootDemo</name>
    <description>SpringBootDemo</description>
    <properties>
        <java.version>18</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.2.9</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.webjars/jquery -->
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery</artifactId>
            <version>3.6.0</version>
        </dependency>
        <!-- thymeleaf -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter -->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.2.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>5.2.2</version>
        </dependency>
        <!-- shiro -->
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-spring</artifactId>
            <version>1.9.1</version>
        </dependency>
        <dependency>
            <groupId>com.github.theborakompanioni</groupId>
            <artifactId>thymeleaf-extras-shiro</artifactId>
            <version>2.1.0</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

application.yaml

spring:
  browser:
    open: true
    url: http://localhost:8080
  datasource:
    username: root
    password: ******
    url: jdbc:mysql://localhost:3306/depo_db?userSSL=true&useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
    driver-class-name: com.mysql.cj.jdbc.Driver
    type: com.alibaba.druid.pool.DruidDataSource
    initialSize: 5
    minIdle: 5
    maxActive: 20
    maxWait: 60000
    timeBetweenEvictionRunsMillis: 60000
    minEvictableIdleTimeMillis: 300000
    validationQuery: SELECT 1 FROM DUAL
    testWhileIdle: true
    testOnBorrow: false
    testOnReturn: false
    poolPreparedStatements: true
    filters: stat, wall, logback
    maxPoolPreparedStatementPerConnectionSize: 20
    useGlobalDataSourceStat: true
    connectionProperties: druid.stat.mergeSql=true; druid.stat.slowSqlMillis=500
  thymeleaf:
    cache: false
mybatis:
  type-aliases-package: com.hoppi.pojo
  mapper-locations: classpath:mybatis/mapper/*.xml

数据库脚本(不含数据,并且因为我没有写注册功能,只能自己在数据库里创建第一个管理员以登录和创建更多用户)

CREATE DATABASE `depo_db`CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `depo_db`;
CREATE TABLE `depository` (
  `art_no` int NOT NULL,
  `amount` int NOT NULL,
  `unit_price` decimal(10,5) NOT NULL COMMENT '单价',
  `depo_no` varchar(10) NOT NULL COMMENT '所属仓库',
  PRIMARY KEY (`art_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `log` (
  `time_stamp` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
  `depo_no` varchar(10) NOT NULL,
  `art_no` int NOT NULL,
  `state` tinyint(1) NOT NULL COMMENT '入库为1,出库为0',
  `amount` int NOT NULL,
  `unit_price` decimal(10,5) NOT NULL COMMENT '单价',
  `total` decimal(10,5) NOT NULL COMMENT '总金额',
  `target` varchar(20) NOT NULL COMMENT '去向/来源',
  PRIMARY KEY (`time_stamp`,`depo_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `stuff` (
  `art_no` int NOT NULL,
  `name` varchar(20) NOT NULL,
  `avg_price` decimal(10,5) NOT NULL,
  PRIMARY KEY (`art_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `user` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `rbac` tinyint(1) NOT NULL DEFAULT '0' COMMENT '权限控制',
  `pwd` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

2. 图文展示

2.1 架构图

在这里插入图片描述

2.2 数据建模ER图

在这里插入图片描述

2.3 基本数据流图

在这里插入图片描述

3. 遇到的问题以及解决办法

遇到的问题都是前端的( ╯□╰ )


问题1:
原先的Spring项目中使用的模板引擎是JSP
重构成SpringBoot项目时转换成Thymeleaf,导致大量JSP语法片段失效
解决方法: 重写


问题2:
JS似乎无法清除Thymeleaf的session(反正我没找到方法),导致关闭弹窗后刷新页面仍然出现弹窗的离谱情况
解决方法: 本来想用Thymeleaf的语法调用Java方法清除session,但没找到相关文章,所以选择了转发+JS延时自动跳转的方式,缺陷是弹窗要加一句“三秒后自动关闭”

4. 我的收获

学会了使用SpringBoot(入门级)
第一次画架构图(
水了一篇博客(bushi)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值