SSM -> 毕设项目《仓库管理系统》

需求分析

暂未更新

使用技术

vue2.0
element-ui
ajax
java1.8
mysql5.7
mybatis-plus5.7

技术架构

后台页面

vue2.0
element-ui
ajax

后端架构

SpringBoot2.3.12.RELEASE
MybatisPlus3.4.1
Java jdk1.8
MySQL5.7

代码实现

页面代码

暂未更新

后端代码

代码贴图

后端代码架构图

pom依赖

<?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>
    <groupId>com.example</groupId>
    <artifactId>wms</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>wms</name>
    <description>wms</description>
    <properties>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <spring-boot.version>2.3.12.RELEASE</spring-boot.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.4.1</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</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>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot.version}</version>
                <configuration>
                    <mainClass>com.example.WmsApplication</mainClass>
                    <skip>true</skip>
                </configuration>
                <executions>
                    <execution>
                        <id>repackage</id>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

yml配置文件

server:
  port: 8001
spring:
  application:
    name: wms
  datasource:
    url: jdbc:mysql://localhost:3306/db2023?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
    username: root
    driverClassName: com.mysql.cj.jdbc.Driver

mybatis-plus:
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

user实体类

package com.example.entities;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {
    @TableId(type= IdType.AUTO)
    private Integer id;
    private String no;
    private String name;
    private String password;
    private Integer age;
    private Integer sex;
    private String phone;
    private Integer roleId;
    @TableField("isvalid")
    private String isValid;
}

Dao层

package com.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entities.User;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface UserMapper extends BaseMapper<User> {
}

service层

package com.example.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.example.entities.User;

public interface UserService extends IService<User> {
}

实现类

package com.example.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.entities.User;
import com.example.mapper.UserMapper;
import com.example.service.UserService;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
}

controller层

package com.example.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.common.QueryPageParam;
import com.example.common.Result;
import com.example.entities.User;
import com.example.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@RestController
public class UserController {
    @Autowired
    private UserService userService;

    //新增用户
    @PostMapping("save")
    public Result saveUser(@RequestBody User user) {
        boolean b = userService.save(user);
        if (b) {
            return new Result(200, "保存成功", user);
        }
        return new Result(400, "保存失败");

    }

    //删除用户
    @DeleteMapping("delete/{id}")
    public Result deleteUser(@PathVariable Integer id) {
        boolean b = userService.removeById(id);

        if (b) {
            return new Result(200, "删除成功");
        }
        return new Result(400, "删除失败");
    }

    //更新用户
    @PutMapping("update")
    public Result updateUser(@RequestBody User user) {
        boolean b = userService.updateById(user);
        if (b) {
            return new Result(200, " 更新成功", user);
        }
        return new Result(400, "更新失败", user);
    }

    //查询用户
    @GetMapping("get/{id}")
    public Result getUserById(@PathVariable Integer id) {
        User user = userService.getById(id);
        if (user != null) {
            return new Result(200, " 查询成功", user);
        }
        return new Result(200, " 查询失败");

    }

    //模糊查询
    @GetMapping("like")
    public Result getUserByName(@RequestBody User user) {
        LambdaQueryWrapper<User> lambdaQueryWrapper = new LambdaQueryWrapper();
        LambdaQueryWrapper<User> userLambdaQueryWrapper = lambdaQueryWrapper.like(User::getName, user.getName());
        HashMap hashMap = new HashMap();

        hashMap.put("size", userService.list(userLambdaQueryWrapper).size());
        hashMap.put("data", userService.list(userLambdaQueryWrapper));
        if (userService.list(userLambdaQueryWrapper) != null) {
            return new Result(200, "查询成功", hashMap);
        }
        return new Result(200, "查询失败");

    }

    //分页查询
    @GetMapping("listPage")
    public Result listPage(@RequestBody QueryPageParam queryPageParam) {

        //定义一个page,当前第几页,一页多少条
        Page<User> page = new Page(queryPageParam.getPageNum(), queryPageParam.getPageSize());


        if (userService.page(page).getRecords() != null) {
            return new Result(200, "查询成功", userService.page(page));
        }
        return new Result(200, "查询失败");
    }

}

common

QueryPageParam

package com.example.common;

import lombok.Data;

import java.util.HashMap;

@Data
public class QueryPageParam {
    private static int PAGE_SIZE=20;
    public static int PAGE_NUM = 1;
    private int pageSize=PAGE_SIZE;
    private int pageNum=PAGE_NUM;

    public HashMap param;
}

Result

package com.example.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {
    private Integer code;
    private String msg;
    private T data;

    public Result(Integer code,String msg){
        this.code = code;
        this.msg = msg;
    }
}

config

package com.example.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Config {
    /**
     * mybatis-plus分页插件
     * @return
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return mybatisPlusInterceptor;
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值