提交 c3256a3d 编写于 作者: Q qinxiaodong@pannk.com

项目代码

上级 d566de48
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>springboot-demo</artifactId>
<groupId>com.pannk</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>mms</artifactId>
<description>SpringBoot2实战教程项目</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<mysql.version>5.1.49</mysql.version>
<druid.version>1.1.13</druid.version>
<shiro.version>1.4.0</shiro.version>
<fastjson.version>1.2.60</fastjson.version>
<swagger.version>2.7.0</swagger.version>
<commons.lang.version>2.6</commons.lang.version>
<commons.codec.version>1.10</commons.codec.version>
<commons.io.version>2.5</commons.io.version>
<commons.configuration.version>1.10</commons.configuration.version>
<lombok.version>1.18.4</lombok.version>
<poi.version>3.17</poi.version>
<mybatisplus.version>3.2.0</mybatisplus.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-test</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatisplus.version}</version>
<exclusions>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${poi.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-codec</artifactId>
<groupId>commons-codec</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
<version>${shiro.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring</artifactId>
<version>${shiro.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>public</id>
<name>aliyun nexus</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</repository>
</repositories>
</project>
\ No newline at end of file
package com.pannk.mms;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* MMS系统
* Created by wolf on 20-11-2.
*/
@SpringBootApplication
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
package com.pannk.mms.common.base;
import com.pannk.mms.modules.sys.entity.SysUserEntity;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import java.util.Date;
/**
* Created by wolf on 20-11-2.
*/
@Slf4j
public class BaseController {
/**
* 获取当前登录用户
*
* @return sysUserEntity
*/
protected SysUserEntity getUser() {
return (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
}
/**
* 获取登录用户id
*
* @return long
*/
protected Long getUserId() {
// return getUser().getId();
return 1L;
}
/**
* 处理新建用户数据
*
* @param baseEntity 实体
*/
protected void createData(BaseEntity baseEntity) {
baseEntity.setCreateDate(new Date());
baseEntity.setCreateUser(getUserId());
}
/**
* 处理更新用户数据
*
* @param baseEntity 实体
*/
protected void updateDate(BaseEntity baseEntity) {
baseEntity.setUpdateDate(new Date());
baseEntity.setUpdateUser(getUserId());
}
}
package com.pannk.mms.common.base;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* Created by wolf on 20-11-2.
*/
@Data
public class BaseEntity implements Serializable {
/**
* 创建人
*/
private Long createUser;
/**
* 创建日期
*/
private Date createDate;
/**
* 更新人
*/
private Long updateUser;
/**
* 更新日期
*/
private Date updateDate;
}
\ No newline at end of file
package com.pannk.mms.common.base;
/**
* Created by wolf on 20-11-2.
*/
public class Constant {
public static final String CODE = "code";
public static final String MESSAGE = "msg";
public static final String SUCCESS = "success";
public static final String ERROR = "error";
public static final String DATA="data";
}
package com.pannk.mms.common.base;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import java.util.HashMap;
import static com.pannk.mms.common.base.Constant.*;
/**
* Created by wolf on 20-11-2.
*/
@Slf4j
@Data
public class Result extends HashMap<String, Object> {
public Result() {
put(CODE, 0);
put(MESSAGE, Constant.SUCCESS);
}
public static Result success() {
return new Result();
}
public static Result success(String msg) {
Result result = new Result();
result.put(MESSAGE, msg);
return result;
}
public static Result error(int code, String msg) {
Result result = new Result();
result.put(CODE, code);
result.put(MESSAGE, msg);
return result;
}
public static Result error(String msg) {
return error(1, msg);
}
public static Result success(Object data) {
Result result = new Result();
result.put(DATA, data);
return result;
}
}
package com.pannk.mms.modules.sys.controller;
import com.pannk.mms.common.base.BaseController;
import com.pannk.mms.common.base.Result;
import com.pannk.mms.modules.sys.entity.SysUserEntity;
import com.pannk.mms.modules.sys.service.SysUserService;
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;
/**
* Created by wolf on 20-11-2.
*/
@RequestMapping("/sys/user")
@RestController
public class SysUserController extends BaseController {
@Autowired
private SysUserService sysUserService;
@GetMapping("/list")
public Result list() {
return Result.success(sysUserService.list());
}
@GetMapping("/detail/{id}")
public Result detail(@PathVariable Long id) {
return Result.success(sysUserService.getById(id));
}
@GetMapping("/save")
public Result save() {
SysUserEntity sysUserEntity = new SysUserEntity();
sysUserEntity.setCode("P00001");
sysUserEntity.setEmail("qxd@126.com");
sysUserEntity.setFullName("秦晓东");
sysUserEntity.setGender(0);
sysUserEntity.setStatus(0);
sysUserEntity.setUserName("qxd");
sysUserEntity.setPassword("123456");
createData(sysUserEntity);
sysUserService.save(sysUserEntity);
return Result.success(sysUserEntity);
}
}
package com.pannk.mms.modules.sys.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pannk.mms.modules.sys.entity.SysUserEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 系统用户
* Created by wolf on 20-11-2.
*/
@Mapper
public interface SysUserMapper extends BaseMapper<SysUserEntity> {
}
package com.pannk.mms.modules.sys.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.pannk.mms.common.base.BaseEntity;
import lombok.Data;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
/**
* Created by wolf on 20-11-2.
*/
@Data
@TableName("sys_user")
public class SysUserEntity extends BaseEntity {
private static final long serialVersionUID = 1152008973624969800L;
@TableId
private Long id;
/**
* 用户名
*/
@NotBlank(message = "用户名不能为空")
private String userName;
/**
* 密码
*/
@NotBlank(message = "密码不能为空")
private String password;
/**
* 编号
*/
@NotBlank(message = "编号不能为空")
private String code;
/**
* 性别
*/
private Integer gender;
/**
* 邮箱
*/
@NotBlank(message = "邮箱不能为空")
@Email(message = "邮箱格式不正确")
private String email;
/**
* 姓名
*/
private String fullName;
/**
* 状态 0:启用,1:禁用
*/
private Integer status;
}
package com.pannk.mms.modules.sys.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.pannk.mms.modules.sys.entity.SysUserEntity;
/**
* Created by wolf on 20-11-2.
*/
public interface SysUserService extends IService<SysUserEntity> {
}
package com.pannk.mms.modules.sys.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pannk.mms.modules.sys.dao.SysUserMapper;
import com.pannk.mms.modules.sys.entity.SysUserEntity;
import com.pannk.mms.modules.sys.service.SysUserService;
import org.springframework.stereotype.Service;
/**
* Created by wolf on 20-11-2.
*/
@Service("sysUserService")
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUserEntity> implements SysUserService {
}
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/mms?userUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: 123456
initial-size: 10
max-active: 100
min-idle: 10
max-wait: 60000
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
test-while-idle: true
test-on-borrow: false
test-on-return: false
stat-view-servlet:
enabled: true
url-pattern: /druid/*
filter:
stat:
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
\ No newline at end of file
server:
port: 8080
servlet:
context-path: /
spring:
application:
name: MMS
profiles:
active: dev
mybatis-plus:
mapper-locations: classpath*:/mapper/**/*.xml
type-aliases-package: com.pannk.mms.modules.*.entity
global-config:
db-config:
id-type: AUTO
banner: false
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
call-setters-on-nulls: true
jdbc-type-for-null: 'null'
\ No newline at end of file
MMMMMMMM MMMMMMMMMMMMMMMM MMMMMMMM SSSSSSSSSSSSSSS
M:::::::M M:::::::MM:::::::M M:::::::M SS:::::::::::::::S
M::::::::M M::::::::MM::::::::M M::::::::MS:::::SSSSSS::::::S
M:::::::::M M:::::::::MM:::::::::M M:::::::::MS:::::S SSSSSSS
M::::::::::M M::::::::::MM::::::::::M M::::::::::MS:::::S
M:::::::::::M M:::::::::::MM:::::::::::M M:::::::::::MS:::::S
M:::::::M::::M M::::M:::::::MM:::::::M::::M M::::M:::::::M S::::SSSS
M::::::M M::::M M::::M M::::::MM::::::M M::::M M::::M M::::::M SS::::::SSSSS
M::::::M M::::M::::M M::::::MM::::::M M::::M::::M M::::::M SSS::::::::SS
M::::::M M:::::::M M::::::MM::::::M M:::::::M M::::::M SSSSSS::::S
M::::::M M:::::M M::::::MM::::::M M:::::M M::::::M S:::::S
M::::::M MMMMM M::::::MM::::::M MMMMM M::::::M S:::::S
M::::::M M::::::MM::::::M M::::::MSSSSSSS S:::::S
M::::::M M::::::MM::::::M M::::::MS::::::SSSSSS:::::S
M::::::M M::::::MM::::::M M::::::MS:::::::::::::::SS
MMMMMMMM MMMMMMMMMMMMMMMM MMMMMMMM SSSSSSSSSSSSSSS
==========================Material Management System============================
SpringBoot version: ${spring-boot.version}
\ No newline at end of file
-- 系统用户表
CREATE TABLE `sys_user` (
`id` BIGINT NOT NULL AUTO_INCREMENT
COMMENT '主键',
`user_name` VARCHAR(100) NOT NULL
COMMENT '用户名',
`password` VARCHAR(100) NOT NULL
COMMENT '密码',
`code` VARCHAR(100) NOT NULL
COMMENT '编号',
`gender` SMALLINT DEFAULT 0
COMMENT '性别,0:男,1:女',
`email` VARCHAR(100) DEFAULT NULL
COMMENT '邮箱',
`full_name` VARCHAR(100) DEFAULT NULL
COMMENT '姓名',
`status` VARCHAR(100) NOT NULL
COMMENT '状态,0:启用,1:禁用',
`create_date` DATE DEFAULT NULL
COMMENT '新增日期',
`create_user` VARCHAR(100) DEFAULT NULL
COMMENT '新增人',
`update_date` DATE DEFAULT NULL
COMMENT '更新日期',
`update_user` VARCHAR(100) DEFAULT NULL
COMMENT '更新人',
PRIMARY KEY (`id`),
UNIQUE KEY `user_name_unique` (`user_name`),
UNIQUE KEY `code_unique` (`code`)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;
-- 用户角色表
CREATE TABLE `sys_user_role` (
`id` BIGINT NOT NULL AUTO_INCREMENT
COMMENT '主键',
`user_id` BIGINT NOT NULL
COMMENT '用户id',
`role_id` BIGINT NOT NULL
COMMENT '角色ID',
PRIMARY KEY (`id`)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;
-- 系统角色表
CREATE TABLE `sys_role` (
`id` BIGINT NOT NULL AUTO_INCREMENT
COMMENT '主键',
`name` VARCHAR(100) NOT NULL
COMMENT '角色名称',
`code` VARCHAR(100) NOT NULL
COMMENT '角色编码',
`remark` BIGINT DEFAULT NULL
COMMENT '备注',
`status` SMALLINT NOT NULL
COMMENT '状态,0:启用,1:禁用',
`create_user` BIGINT DEFAULT NULL
COMMENT '新增人',
`create_date` DATETIME DEFAULT NULL
COMMENT '新增日期',
`update_date` DATETIME DEFAULT NULL
COMMENT '更新日期',
`update_user` BIGINT DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `code_unique` (`code`)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;
-- 系统菜单表
CREATE TABLE `sys_menu` (
`id` BIGINT NOT NULL AUTO_INCREMENT
COMMENT '主键',
`parent_id` BIGINT DEFAULT NULL
COMMENT '父级id',
`name` VARCHAR(100) NOT NULL
COMMENT '名称',
`type` SMALLINT NOT NULL
COMMENT '类型,0:目录,1:菜单,2:按钮',
`url` TEXT COMMENT 'url',
`perms` TEXT COMMENT '权限',
`icon` VARCHAR(100) DEFAULT NULL
COMMENT '图标',
`seq` INT DEFAULT NULL
COMMENT '排序',
`create_user` BIGINT DEFAULT NULL
COMMENT '新增人',
`create_date` DATETIME DEFAULT NULL
COMMENT '新增日期',
`update_user` BIGINT DEFAULT NULL
COMMENT '更新人',
`update_date` DATETIME DEFAULT NULL
COMMENT '更新日期',
PRIMARY KEY (`id`),
UNIQUE KEY `name_unique` (`name`)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;
-- 角色菜单表
CREATE TABLE `sys_role_menu` (
`id` BIGINT NOT NULL AUTO_INCREMENT
COMMENT '主键',
`role_id` BIGINT NOT NULL
COMMENT '角色ID',
`menu_id` BIGINT NOT NULL
COMMENT '菜单ID',
PRIMARY KEY (`id`)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;
-- 系统日志表
CREATE TABLE `sys_log` (
`id` BIGINT NOT NULL AUTO_INCREMENT
COMMENT '主键',
`user_name` VARCHAR(100) NOT NULL
COMMENT '用户名',
`user_code` VARCHAR(100) NOT NULL
COMMENT '用户编码',
`operation` VARCHAR(100) NOT NULL
COMMENT '操作',
`content` TEXT COMMENT '操作内容',
`ip` VARCHAR(100) DEFAULT NULL
COMMENT 'ip地址',
`operate_date` DATETIME NOT NULL
COMMENT '操作日期',
`elapsed_time` BIGINT DEFAULT NULL
COMMENT '耗时',
PRIMARY KEY (`id`)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;
-- 系统字典类型表
CREATE TABLE `sys_dict_type` (
`id` BIGINT NOT NULL AUTO_INCREMENT
COMMENT '主键',
`name` VARCHAR(100) NOT NULL
COMMENT '名称',
`code` VARCHAR(100) NOT NULL
COMMENT '编码',
`create_user` BIGINT DEFAULT NULL
COMMENT '新增人',
`create_date` DATE DEFAULT NULL
COMMENT '新增日期',
`update_user` BIGINT DEFAULT NULL
COMMENT '更新人',
`update_date` DATETIME DEFAULT NULL
COMMENT '更新日期',
PRIMARY KEY (`id`),
UNIQUE KEY `code_unique` (`code`)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;
-- 系统字典表
CREATE TABLE `sys_dict_item` (
`id` BIGINT NOT NULL AUTO_INCREMENT
COMMENT '主键',
`type_id` BIGINT NOT NULL
COMMENT '类型ID',
`type_name` VARCHAR(100) NOT NULL
COMMENT '类型名称',
`type_code` VARCHAR(100) NOT NULL
COMMENT '类型编码',
`name` VARCHAR(100) NOT NULL
COMMENT '名称',
`key` VARCHAR(100) NOT NULL
COMMENT '键',
`value` VARCHAR(100) NOT NULL
COMMENT '值',
`remark` VARCHAR(100) DEFAULT NULL
COMMENT '备注',
`create_user` BIGINT DEFAULT NULL
COMMENT '新增人',
`create_date` DATETIME DEFAULT NULL
COMMENT '新增日期',
`update_id` BIGINT DEFAULT NULL
COMMENT '更新人',
`update_date` DATETIME DEFAULT NULL
COMMENT '更新日期',
PRIMARY KEY (`id`),
UNIQUE KEY `typeid_union_key_unique` (`type_id`, `key`)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;
-- 流程定义表
CREATE TABLE `biz_workflow` (
`id` BIGINT NOT NULL AUTO_INCREMENT
COMMENT '主键',
`code` VARCHAR(100) NOT NULL
COMMENT '编码',
`name` VARCHAR(100) NOT NULL
COMMENT '名称',
`xml` TEXT NOT NULL
COMMENT 'xml',
`svg` TEXT NOT NULL
COMMENT 'svg',
`status` SMALLINT DEFAULT NULL
COMMENT '发布,0:已发布,1:未发布',
`create_user` BIGINT DEFAULT NULL
COMMENT '新增人',
`create_date` DATETIME DEFAULT NULL
COMMENT '创建日期',
`update_date` DATETIME DEFAULT NULL
COMMENT '更新日期',
`更新人` BIGINT DEFAULT NULL
COMMENT '更新人',
PRIMARY KEY (`id`),
UNIQUE KEY `biz_workflow_unique` (`code`)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci
\ No newline at end of file
<?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.pannk.mms.modules.sys.dao.SysUserMapper">
</mapper>
\ No newline at end of file
......@@ -11,6 +11,7 @@
<modules>
<module>first-application</module>
<module>common-config</module>
<module>mms</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册