@ -0,0 +1,8 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="springboot" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
<module name="springboot" options="-parameters" />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="psi_manager@localhost" uuid="991872a3-250e-496f-8ecd-ca9d10e010a9">
|
||||
<driver-ref>mysql.8</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<imported>true</imported>
|
||||
<remarks>$PROJECT_DIR$/springboot/src/main/resources/application.yml</remarks>
|
||||
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:mysql://localhost:3306/psi_manager?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false&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>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/springboot/src/main/java" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="public" />
|
||||
<option name="name" value="aliyun nexus" />
|
||||
<option name="url" value="https://maven.aliyun.com/repository/public" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="public" />
|
||||
<option name="name" value="aliyun nexus" />
|
||||
<option name="url" value="http://maven.aliyun.com/nexus/content/groups/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://maven.aliyun.com/repository/public" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/springboot/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_22" default="true" project-jdk-name="openjdk-22" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/psi_manager.iml" filepath="$PROJECT_DIR$/.idea/psi_manager.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="web" name="Web">
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/vue/src/web.xml" />
|
||||
</descriptors>
|
||||
<webroots>
|
||||
<root url="file://$MODULE_DIR$/vue/src" relative="/WEB-INF" />
|
||||
</webroots>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="springboot" />
|
||||
<orderEntry type="module" module-name="springboot" />
|
||||
</component>
|
||||
</module>
|
After Width: | Height: | Size: 674 KiB |
After Width: | Height: | Size: 142 KiB |
After Width: | Height: | Size: 104 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 88 KiB |
After Width: | Height: | Size: 66 KiB |
After Width: | Height: | Size: 354 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 511 KiB |
After Width: | Height: | Size: 511 KiB |
After Width: | Height: | Size: 167 KiB |
After Width: | Height: | Size: 82 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 8.2 KiB |
After Width: | Height: | Size: 245 KiB |
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 8.5 KiB |
@ -0,0 +1,115 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>springboot</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.5.9</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--mysql-->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20210307</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.4.6</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.18</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
<version>4.3.0</version>
|
||||
</dependency>
|
||||
<!-- 引入验证码依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.github.whvcse</groupId>
|
||||
<artifactId>easy-captcha</artifactId>
|
||||
<version>1.6.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- poi依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>5.2.3</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<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-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>public</id>
|
||||
<name>aliyun nexus</name>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
@ -0,0 +1,17 @@
|
||||
package com.example;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.example.mapper")
|
||||
@EnableScheduling
|
||||
public class SpringbootApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringbootApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.example.common;
|
||||
|
||||
public interface Constants {
|
||||
|
||||
String TOKEN = "token";
|
||||
|
||||
String USER_DEFAULT_PASSWORD = "123";
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package com.example.common;
|
||||
|
||||
import com.example.common.enums.ResultCodeEnum;
|
||||
|
||||
public class Result {
|
||||
private String code;
|
||||
private String msg;
|
||||
private Object data;
|
||||
|
||||
private Result(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public Result() {
|
||||
}
|
||||
|
||||
public static Result success() {
|
||||
Result tResult = new Result();
|
||||
tResult.setCode(ResultCodeEnum.SUCCESS.code);
|
||||
tResult.setMsg(ResultCodeEnum.SUCCESS.msg);
|
||||
return tResult;
|
||||
}
|
||||
|
||||
public static Result success(Object data) {
|
||||
Result tResult = new Result (data);
|
||||
tResult.setCode(ResultCodeEnum.SUCCESS.code);
|
||||
tResult.setMsg(ResultCodeEnum.SUCCESS.msg);
|
||||
return tResult;
|
||||
}
|
||||
|
||||
public static Result error() {
|
||||
Result tResult = new Result();
|
||||
tResult.setCode(ResultCodeEnum.SYSTEM_ERROR.code);
|
||||
tResult.setMsg(ResultCodeEnum.SYSTEM_ERROR.msg);
|
||||
return tResult;
|
||||
}
|
||||
|
||||
public static Result error(String code, String msg) {
|
||||
Result tResult = new Result();
|
||||
tResult.setCode(code);
|
||||
tResult.setMsg(msg);
|
||||
return tResult;
|
||||
}
|
||||
|
||||
public static Result error(ResultCodeEnum resultCodeEnum) {
|
||||
Result tResult = new Result();
|
||||
tResult.setCode(resultCodeEnum.code);
|
||||
tResult.setMsg(resultCodeEnum.msg);
|
||||
return tResult;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.example.common.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
|
||||
/**
|
||||
* 跨域配置
|
||||
*/
|
||||
@Configuration
|
||||
public class CorsConfig {
|
||||
|
||||
@Bean
|
||||
public CorsFilter corsFilter() {
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
CorsConfiguration corsConfiguration = new CorsConfiguration();
|
||||
corsConfiguration.addAllowedOrigin("*"); // 1 设置访问源地址
|
||||
corsConfiguration.addAllowedHeader("*"); // 2 设置访问源请求头
|
||||
corsConfiguration.addAllowedMethod("*"); // 3 设置访问源请求方法
|
||||
source.registerCorsConfiguration("/**", corsConfiguration); // 4 对接口配置跨域设置
|
||||
return new CorsFilter(source);
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.example.common.config;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.JWTVerifier;
|
||||
import com.auth0.jwt.algorithms.Algorithm;
|
||||
import com.auth0.jwt.exceptions.JWTVerificationException;
|
||||
import com.example.common.Constants;
|
||||
import com.example.common.enums.ResultCodeEnum;
|
||||
import com.example.common.enums.RoleEnum;
|
||||
import com.example.entity.Account;
|
||||
import com.example.exception.CustomException;
|
||||
import com.example.service.AdminService;
|
||||
import com.example.service.StaffService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* jwt拦截器
|
||||
*/
|
||||
@Component
|
||||
public class JwtInterceptor implements HandlerInterceptor {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(JwtInterceptor.class);
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@Resource
|
||||
private StaffService staffService;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||
// 1. 从http请求的header中获取token
|
||||
String token = request.getHeader(Constants.TOKEN);
|
||||
if (ObjectUtil.isEmpty(token)) {
|
||||
// 如果没拿到,从参数里再拿一次
|
||||
token = request.getParameter(Constants.TOKEN);
|
||||
}
|
||||
// 2. 开始执行认证
|
||||
if (ObjectUtil.isEmpty(token)) {
|
||||
throw new CustomException(ResultCodeEnum.TOKEN_INVALID_ERROR);
|
||||
}
|
||||
Account account = null;
|
||||
try {
|
||||
// 解析token获取存储的数据
|
||||
String userRole = JWT.decode(token).getAudience().get(0);
|
||||
String userId = userRole.split("-")[0];
|
||||
String role = userRole.split("-")[1];
|
||||
// 根据userId查询数据库
|
||||
if (RoleEnum.ADMIN.name().equals(role)) {
|
||||
account = adminService.selectById(Integer.valueOf(userId));
|
||||
} else if (RoleEnum.STAFF.name().equals(role)) {
|
||||
account = staffService.selectById(Integer.valueOf(userId));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new CustomException(ResultCodeEnum.TOKEN_CHECK_ERROR);
|
||||
}
|
||||
if (ObjectUtil.isNull(account)) {
|
||||
throw new CustomException(ResultCodeEnum.USER_NOT_EXIST_ERROR);
|
||||
}
|
||||
try {
|
||||
// 用户密码加签验证 token
|
||||
JWTVerifier jwtVerifier = JWT.require(Algorithm.HMAC256(account.getPassword())).build();
|
||||
jwtVerifier.verify(token); // 验证token
|
||||
} catch (JWTVerificationException e) {
|
||||
throw new CustomException(ResultCodeEnum.TOKEN_CHECK_ERROR);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.example.common.enums;
|
||||
|
||||
public enum RoleEnum {
|
||||
// 管理员
|
||||
ADMIN,
|
||||
// 员工
|
||||
STAFF,
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package com.example.controller;
|
||||
|
||||
import com.example.common.Result;
|
||||
import com.example.entity.Admin;
|
||||
import com.example.service.AdminService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 管理员前端操作接口
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/admin")
|
||||
public class AdminController {
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody Admin admin) {
|
||||
adminService.add(admin);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public Result deleteById(@PathVariable Integer id) {
|
||||
adminService.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
@DeleteMapping("/delete/batch")
|
||||
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
||||
adminService.deleteBatch(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public Result updateById(@RequestBody Admin admin) {
|
||||
adminService.updateById(admin);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@GetMapping("/selectById/{id}")
|
||||
public Result selectById(@PathVariable Integer id) {
|
||||
Admin admin = adminService.selectById(id);
|
||||
return Result.success(admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
@GetMapping("/selectAll")
|
||||
public Result selectAll(Admin admin ) {
|
||||
List<Admin> list = adminService.selectAll(admin);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/selectPage")
|
||||
public Result selectPage(Admin admin,
|
||||
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
PageInfo<Admin> page = adminService.selectPage(admin, pageNum, pageSize);
|
||||
return Result.success(page);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package com.example.controller;
|
||||
|
||||
import com.example.common.Result;
|
||||
import com.example.entity.Back;
|
||||
import com.example.service.BackService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品退货前端操作接口
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/back")
|
||||
public class BackController {
|
||||
|
||||
@Resource
|
||||
private BackService backService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody Back back) {
|
||||
backService.add(back);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public Result deleteById(@PathVariable Integer id) {
|
||||
backService.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
@DeleteMapping("/delete/batch")
|
||||
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
||||
backService.deleteBatch(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public Result updateById(@RequestBody Back back) {
|
||||
backService.updateById(back);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@GetMapping("/selectById/{id}")
|
||||
public Result selectById(@PathVariable Integer id) {
|
||||
Back back = backService.selectById(id);
|
||||
return Result.success(back);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
@GetMapping("/selectAll")
|
||||
public Result selectAll(Back back) {
|
||||
List<Back> list = backService.selectAll(back);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/selectPage")
|
||||
public Result selectPage(Back back,
|
||||
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
PageInfo<Back> page = backService.selectPage(back, pageNum, pageSize);
|
||||
return Result.success(page);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
//package com.example.controller;
|
||||
//
|
||||
//import org.json.JSONObject;
|
||||
//import org.springframework.beans.factory.annotation.Value;
|
||||
//import org.springframework.http.*;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//import org.springframework.web.client.RestTemplate;
|
||||
//
|
||||
//import javax.annotation.PostConstruct;
|
||||
//import javax.servlet.http.HttpSession;
|
||||
//import java.util.logging.Level;
|
||||
//import java.util.logging.Logger;
|
||||
//
|
||||
//@RestController
|
||||
//@RequestMapping("/api/chat")
|
||||
//@CrossOrigin
|
||||
//public class ChatController {
|
||||
// private static final Logger LOGGER = Logger.getLogger(ChatController.class.getName());
|
||||
//
|
||||
// private String apiKey = "sk-2afc18092ea24c938020a4d5f1f9f91a";
|
||||
//
|
||||
// private String appId = "1d2b00751a914efd84ea4b354fffd962";
|
||||
//
|
||||
// private final RestTemplate restTemplate;
|
||||
// private String apiUrl;
|
||||
//
|
||||
// public ChatController() {
|
||||
// this.restTemplate = new RestTemplate();
|
||||
// }
|
||||
//
|
||||
// @PostConstruct
|
||||
// private void init() {
|
||||
// // 使用appId构建完整的API URL
|
||||
// this.apiUrl = "https://dashscope.aliyuncs.com/api/v1/apps/" + appId + "/completion";
|
||||
// }
|
||||
//
|
||||
// @PostMapping
|
||||
// public ResponseEntity<?> chat(@RequestParam String prompt, HttpSession session) {
|
||||
// try {
|
||||
// String sessionId = (String) session.getAttribute("chatSessionId");
|
||||
//
|
||||
// JSONObject requestBody = new JSONObject();
|
||||
// JSONObject input = new JSONObject();
|
||||
// input.put("prompt", prompt);
|
||||
// if (sessionId != null) {
|
||||
// input.put("session_id", sessionId);
|
||||
// }
|
||||
// requestBody.put("input", input);
|
||||
// requestBody.put("parameters", new JSONObject());
|
||||
//
|
||||
// HttpHeaders headers = new HttpHeaders();
|
||||
// headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
// headers.set("Authorization", "Bearer " + apiKey);
|
||||
//
|
||||
// HttpEntity<String> entity = new HttpEntity<>(requestBody.toString(), headers);
|
||||
//
|
||||
// ResponseEntity<String> response = restTemplate.exchange(
|
||||
// apiUrl,
|
||||
// HttpMethod.POST,
|
||||
// entity,
|
||||
// String.class
|
||||
// );
|
||||
//
|
||||
// return ResponseEntity.ok(response.getBody());
|
||||
// } catch (Exception e) {
|
||||
// LOGGER.log(Level.SEVERE, "聊天请求处理失败", e);
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
// .body("{\"error\":\"服务器错误: " + e.getMessage() + "\"}");
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -0,0 +1,137 @@
|
||||
package com.example.controller;
|
||||
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import cn.hutool.poi.excel.ExcelWriter;
|
||||
import com.example.common.Result;
|
||||
import com.example.common.enums.ResultCodeEnum;
|
||||
import com.example.entity.Customer;
|
||||
import com.example.service.CustomerService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 客户表前端操作接口
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/customer")
|
||||
public class CustomerController {
|
||||
|
||||
@Resource
|
||||
private CustomerService customerService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody Customer customer) {
|
||||
customerService.add(customer);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public Result deleteById(@PathVariable Integer id) {
|
||||
customerService.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
@DeleteMapping("/delete/batch")
|
||||
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
||||
customerService.deleteBatch(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public Result updateById(@RequestBody Customer customer) {
|
||||
customerService.updateById(customer);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@GetMapping("/selectById/{id}")
|
||||
public Result selectById(@PathVariable Integer id) {
|
||||
Customer customer = customerService.selectById(id);
|
||||
return Result.success(customer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
@GetMapping("/selectAll")
|
||||
public Result selectAll(Customer customer) {
|
||||
List<Customer> list = customerService.selectAll(customer);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/selectPage")
|
||||
public Result selectPage(Customer customer,
|
||||
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
PageInfo<Customer> page = customerService.selectPage(customer, pageNum, pageSize);
|
||||
return Result.success(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量导出数据
|
||||
*/
|
||||
@GetMapping("/export")
|
||||
public void exportData(HttpServletResponse response) throws IOException {
|
||||
ExcelWriter writer = ExcelUtil.getWriter(true);
|
||||
|
||||
List<Customer> list = customerService.selectAll(null);
|
||||
writer.write(list, true);
|
||||
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("客户信息表", "UTF-8") + ".xlsx");
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
writer.flush(outputStream, true);
|
||||
outputStream.flush();
|
||||
writer.close();
|
||||
outputStream.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量导入
|
||||
*
|
||||
* @param file 传入的excel文件对象
|
||||
* @return 导入结果
|
||||
*/
|
||||
@PostMapping("/import")
|
||||
public Result importData(MultipartFile file) throws IOException {
|
||||
ExcelReader reader = ExcelUtil.getReader(file.getInputStream());
|
||||
List<Customer> list = reader.readAll(Customer.class);
|
||||
// 写入数据到数据库
|
||||
try {
|
||||
for (Customer customer : list) {
|
||||
customerService.add(customer);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
return Result.error(ResultCodeEnum.DATA_IMPORT_ERROR);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package com.example.controller;
|
||||
|
||||
import com.example.common.Result;
|
||||
import com.example.entity.Department;
|
||||
import com.example.service.DepartmentService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部门信息接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/department")
|
||||
public class DepartmentController {
|
||||
@Resource
|
||||
private DepartmentService departmentService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody Department department) {
|
||||
departmentService.add(department);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public Result deleteById(@PathVariable Integer id) {
|
||||
departmentService.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
@DeleteMapping("/delete/batch")
|
||||
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
||||
departmentService.deleteBatch(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public Result updateById(@RequestBody Department department) {
|
||||
departmentService.updateById(department);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@GetMapping("/selectById/{id}")
|
||||
public Result selectById(@PathVariable Integer id) {
|
||||
Department department = departmentService.selectById(id);
|
||||
return Result.success(department);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
@GetMapping("/selectAll")
|
||||
public Result selectAll(Department department ) {
|
||||
List<Department> list = departmentService.selectAll(department);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询树形结构数据
|
||||
*/
|
||||
@GetMapping("/selectTree")
|
||||
public Result selectTree() {
|
||||
List<Department> list = departmentService.selectTree();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/selectPage")
|
||||
public Result selectPage(Department department,
|
||||
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
PageInfo<Department> page = departmentService.selectPage(department, pageNum, pageSize);
|
||||
return Result.success(page);
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package com.example.controller;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.example.common.Result;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/files")
|
||||
public class FileController {
|
||||
|
||||
// 文件上传存储路径
|
||||
private static final String filePath = System.getProperty("user.dir") + "/files/";
|
||||
|
||||
@Value("${server.port:9090}")
|
||||
private String port;
|
||||
|
||||
@Value("${ip:localhost}")
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
*/
|
||||
@PostMapping("/upload")
|
||||
public Result upload(MultipartFile file) {
|
||||
String flag;
|
||||
synchronized (FileController.class) {
|
||||
flag = System.currentTimeMillis() + "";
|
||||
ThreadUtil.sleep(1L);
|
||||
}
|
||||
String fileName = file.getOriginalFilename();
|
||||
try {
|
||||
if (!FileUtil.isDirectory(filePath)) {
|
||||
FileUtil.mkdir(filePath);
|
||||
}
|
||||
// 文件存储形式:时间戳-文件名
|
||||
FileUtil.writeBytes(file.getBytes(), filePath + flag + "-" + fileName); // ***/manager/files/1697438073596-avatar.png
|
||||
System.out.println(fileName + "--上传成功");
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println(fileName + "--文件上传失败");
|
||||
}
|
||||
String http = "http://" + ip + ":" + port + "/files/";
|
||||
return Result.success(http + flag + "-" + fileName); // http://localhost:9090/files/1697438073596-avatar.png
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取文件
|
||||
*
|
||||
* @param flag
|
||||
* @param response
|
||||
*/
|
||||
@GetMapping("/{flag}") // 1697438073596-avatar.png
|
||||
public void avatarPath(@PathVariable String flag, HttpServletResponse response) {
|
||||
OutputStream os;
|
||||
try {
|
||||
if (StrUtil.isNotEmpty(flag)) {
|
||||
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(flag, "UTF-8"));
|
||||
response.setContentType("application/octet-stream");
|
||||
byte[] bytes = FileUtil.readBytes(filePath + flag);
|
||||
os = response.getOutputStream();
|
||||
os.write(bytes);
|
||||
os.flush();
|
||||
os.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("文件下载失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*
|
||||
* @param flag
|
||||
*/
|
||||
@DeleteMapping("/{flag}")
|
||||
public void delFile(@PathVariable String flag) {
|
||||
FileUtil.del(filePath + flag);
|
||||
System.out.println("删除文件" + flag + "成功");
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,137 @@
|
||||
package com.example.controller;
|
||||
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import cn.hutool.poi.excel.ExcelWriter;
|
||||
import com.example.common.Result;
|
||||
import com.example.common.enums.ResultCodeEnum;
|
||||
import com.example.entity.Goods;
|
||||
import com.example.service.GoodsService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品表前端操作接口
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/goods")
|
||||
public class GoodsController {
|
||||
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody Goods goods) {
|
||||
goodsService.add(goods);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public Result deleteById(@PathVariable Integer id) {
|
||||
goodsService.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
@DeleteMapping("/delete/batch")
|
||||
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
||||
goodsService.deleteBatch(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public Result updateById(@RequestBody Goods goods) {
|
||||
goodsService.updateById(goods);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@GetMapping("/selectById/{id}")
|
||||
public Result selectById(@PathVariable Integer id) {
|
||||
Goods goods = goodsService.selectById(id);
|
||||
return Result.success(goods);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
@GetMapping("/selectAll")
|
||||
public Result selectAll(Goods goods) {
|
||||
List<Goods> list = goodsService.selectAll(goods);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/selectPage")
|
||||
public Result selectPage(Goods goods,
|
||||
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
PageInfo<Goods> page = goodsService.selectPage(goods, pageNum, pageSize);
|
||||
return Result.success(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量导出数据
|
||||
*/
|
||||
@GetMapping("/export")
|
||||
public void exportData(HttpServletResponse response) throws IOException {
|
||||
ExcelWriter writer = ExcelUtil.getWriter(true);
|
||||
|
||||
List<Goods> list = goodsService.selectAll(null);// 查询出当前User表的所有数据
|
||||
writer.write(list, true);
|
||||
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("商品信息表", "UTF-8") + ".xlsx");
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
writer.flush(outputStream, true);
|
||||
outputStream.flush();
|
||||
writer.close();
|
||||
outputStream.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量导入
|
||||
*
|
||||
* @param file 传入的excel文件对象
|
||||
* @return 导入结果
|
||||
*/
|
||||
@PostMapping("/import")
|
||||
public Result importData(MultipartFile file) throws IOException {
|
||||
ExcelReader reader = ExcelUtil.getReader(file.getInputStream());
|
||||
List<Goods> list = reader.readAll(Goods.class);
|
||||
// 写入数据到数据库
|
||||
try {
|
||||
for (Goods goods : list) {
|
||||
goodsService.add(goods);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
return Result.error(ResultCodeEnum.DATA_IMPORT_ERROR);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package com.example.controller;
|
||||
|
||||
import com.example.common.Result;
|
||||
import com.example.entity.Logs;
|
||||
import com.example.service.LogsService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 前端操作接口
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/logs")
|
||||
public class LogsController {
|
||||
|
||||
@Resource
|
||||
private LogsService logsService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody Logs logs) {
|
||||
logsService.add(logs);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public Result deleteById(@PathVariable Integer id) {
|
||||
logsService.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
@DeleteMapping("/delete/batch")
|
||||
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
||||
logsService.deleteBatch(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public Result updateById(@RequestBody Logs logs) {
|
||||
logsService.updateById(logs);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@GetMapping("/selectById/{id}")
|
||||
public Result selectById(@PathVariable Integer id) {
|
||||
Logs logs = logsService.selectById(id);
|
||||
return Result.success(logs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
@GetMapping("/selectAll")
|
||||
public Result selectAll(Logs logs) {
|
||||
List<Logs> list = logsService.selectAll(logs);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/selectPage")
|
||||
public Result selectPage(Logs logs,
|
||||
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
PageInfo<Logs> page = logsService.selectPage(logs, pageNum, pageSize);
|
||||
return Result.success(page);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package com.example.controller;
|
||||
|
||||
import com.example.common.Result;
|
||||
import com.example.entity.Notice;
|
||||
import com.example.service.NoticeService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 公告信息表前端操作接口
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/notice")
|
||||
public class NoticeController {
|
||||
|
||||
@Resource
|
||||
private NoticeService noticeService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody Notice notice) {
|
||||
noticeService.add(notice);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public Result deleteById(@PathVariable Integer id) {
|
||||
noticeService.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
@DeleteMapping("/delete/batch")
|
||||
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
||||
noticeService.deleteBatch(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public Result updateById(@RequestBody Notice notice) {
|
||||
noticeService.updateById(notice);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@GetMapping("/selectById/{id}")
|
||||
public Result selectById(@PathVariable Integer id) {
|
||||
Notice notice = noticeService.selectById(id);
|
||||
return Result.success(notice);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
@GetMapping("/selectAll")
|
||||
public Result selectAll(Notice notice ) {
|
||||
List<Notice> list = noticeService.selectAll(notice);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/selectPage")
|
||||
public Result selectPage(Notice notice,
|
||||
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
PageInfo<Notice> page = noticeService.selectPage(notice, pageNum, pageSize);
|
||||
return Result.success(page);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package com.example.controller;
|
||||
|
||||
import com.example.common.Result;
|
||||
import com.example.entity.SaleBack;
|
||||
import com.example.service.SaleBackService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品销售前端操作接口
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/saleBack")
|
||||
public class SaleBackController {
|
||||
|
||||
@Resource
|
||||
private SaleBackService saleBackService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody SaleBack saleBack) {
|
||||
saleBackService.add(saleBack);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public Result deleteById(@PathVariable Integer id) {
|
||||
saleBackService.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
@DeleteMapping("/delete/batch")
|
||||
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
||||
saleBackService.deleteBatch(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public Result updateById(@RequestBody SaleBack saleBack) {
|
||||
saleBackService.updateById(saleBack);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@GetMapping("/selectById/{id}")
|
||||
public Result selectById(@PathVariable Integer id) {
|
||||
SaleBack saleBack = saleBackService.selectById(id);
|
||||
return Result.success(saleBack);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
@GetMapping("/selectAll")
|
||||
public Result selectAll(SaleBack saleBack) {
|
||||
List<SaleBack> list = saleBackService.selectAll(saleBack);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/selectPage")
|
||||
public Result selectPage(SaleBack saleBack,
|
||||
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
PageInfo<SaleBack> page = saleBackService.selectPage(saleBack, pageNum, pageSize);
|
||||
return Result.success(page);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package com.example.controller;
|
||||
|
||||
import com.example.common.Result;
|
||||
import com.example.entity.Sale;
|
||||
import com.example.service.SaleService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品销售前端操作接口
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/sale")
|
||||
public class SaleController {
|
||||
|
||||
@Resource
|
||||
private SaleService saleService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody Sale sale) {
|
||||
saleService.add(sale);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public Result deleteById(@PathVariable Integer id) {
|
||||
saleService.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
@DeleteMapping("/delete/batch")
|
||||
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
||||
saleService.deleteBatch(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public Result updateById(@RequestBody Sale sale) {
|
||||
saleService.updateById(sale);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@GetMapping("/selectById/{id}")
|
||||
public Result selectById(@PathVariable Integer id) {
|
||||
Sale sale = saleService.selectById(id);
|
||||
return Result.success(sale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
@GetMapping("/selectAll")
|
||||
public Result selectAll(Sale sale) {
|
||||
List<Sale> list = saleService.selectAll(sale);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/selectPage")
|
||||
public Result selectPage(Sale sale,
|
||||
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
PageInfo<Sale> page = saleService.selectPage(sale, pageNum, pageSize);
|
||||
return Result.success(page);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package com.example.controller;
|
||||
|
||||
import com.example.common.Result;
|
||||
import com.example.entity.Account;
|
||||
import com.example.entity.Staff;
|
||||
import com.example.service.LogsService;
|
||||
import com.example.service.StaffService;
|
||||
import com.example.utils.TokenUtils;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/staff")
|
||||
public class StaffController {
|
||||
|
||||
@Resource
|
||||
private StaffService staffService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody Staff staff) {
|
||||
staffService.add(staff);
|
||||
|
||||
Account currentUser = TokenUtils.getCurrentUser();
|
||||
LogsService.recordLog("新增员工" + staff.getUsername(), "新增", currentUser.getUsername());
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public Result deleteById(@PathVariable Integer id) {
|
||||
Account currentUser = TokenUtils.getCurrentUser();
|
||||
Staff staff = staffService.selectById(id);
|
||||
LogsService.recordLog("删除员工" + staff.getUsername(), "删除", currentUser.getUsername());
|
||||
|
||||
staffService.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
@DeleteMapping("/delete/batch")
|
||||
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
||||
staffService.deleteBatch(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public Result updateById(@RequestBody Staff staff) {
|
||||
staffService.updateById(staff);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@GetMapping("/selectById/{id}")
|
||||
public Result selectById(@PathVariable Integer id) {
|
||||
Staff staff = staffService.selectById(id);
|
||||
return Result.success(staff);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
@GetMapping("/selectAll")
|
||||
public Result selectAll(Staff staff) {
|
||||
List<Staff> list = staffService.selectAll(staff);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/selectPage")
|
||||
public Result selectPage(Staff staff,
|
||||
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
PageInfo<Staff> page = staffService.selectPage(staff, pageNum, pageSize);
|
||||
return Result.success(page);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package com.example.controller;
|
||||
|
||||
import com.example.common.Result;
|
||||
import com.example.entity.Stock;
|
||||
import com.example.service.StockService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品进货前端操作接口
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/stock")
|
||||
public class StockController {
|
||||
|
||||
@Resource
|
||||
private StockService stockService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody Stock stock) {
|
||||
stockService.add(stock);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public Result deleteById(@PathVariable Integer id) {
|
||||
stockService.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
@DeleteMapping("/delete/batch")
|
||||
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
||||
stockService.deleteBatch(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public Result updateById(@RequestBody Stock stock) {
|
||||
stockService.updateById(stock);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@GetMapping("/selectById/{id}")
|
||||
public Result selectById(@PathVariable Integer id) {
|
||||
Stock stock = stockService.selectById(id);
|
||||
return Result.success(stock);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
@GetMapping("/selectAll")
|
||||
public Result selectAll(Stock stock) {
|
||||
List<Stock> list = stockService.selectAll(stock);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/selectPage")
|
||||
public Result selectPage(Stock stock,
|
||||
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
PageInfo<Stock> page = stockService.selectPage(stock, pageNum, pageSize);
|
||||
return Result.success(page);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
package com.example.controller;
|
||||
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import cn.hutool.poi.excel.ExcelWriter;
|
||||
import com.example.common.Result;
|
||||
import com.example.common.enums.ResultCodeEnum;
|
||||
import com.example.entity.Supplier;
|
||||
import com.example.service.SupplierService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 供应商表前端操作接口
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/supplier")
|
||||
public class SupplierController {
|
||||
|
||||
@Resource
|
||||
private SupplierService supplierService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody Supplier supplier) {
|
||||
supplierService.add(supplier);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public Result deleteById(@PathVariable Integer id) {
|
||||
supplierService.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
@DeleteMapping("/delete/batch")
|
||||
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
||||
supplierService.deleteBatch(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public Result updateById(@RequestBody Supplier supplier) {
|
||||
supplierService.updateById(supplier);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@GetMapping("/selectById/{id}")
|
||||
public Result selectById(@PathVariable Integer id) {
|
||||
Supplier supplier = supplierService.selectById(id);
|
||||
return Result.success(supplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
@GetMapping("/selectAll")
|
||||
public Result selectAll(Supplier supplier) {
|
||||
List<Supplier> list = supplierService.selectAll(supplier);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/selectPage")
|
||||
public Result selectPage(Supplier supplier,
|
||||
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
PageInfo<Supplier> page = supplierService.selectPage(supplier, pageNum, pageSize);
|
||||
return Result.success(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量导出数据
|
||||
*/
|
||||
@GetMapping("/export")
|
||||
public void exportData(HttpServletResponse response) throws IOException {
|
||||
ExcelWriter writer = ExcelUtil.getWriter(true);
|
||||
|
||||
List<Supplier> list = supplierService.selectAll(null);
|
||||
writer.write(list, true);
|
||||
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("供应商信息表", "UTF-8") + ".xlsx");
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
writer.flush(outputStream, true);
|
||||
outputStream.flush();
|
||||
writer.close();
|
||||
outputStream.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量导入
|
||||
*/
|
||||
@PostMapping("/import")
|
||||
public Result importData(MultipartFile file) throws IOException {
|
||||
ExcelReader reader = ExcelUtil.getReader(file.getInputStream());
|
||||
List<Supplier> list = reader.readAll(Supplier.class);
|
||||
// 写入数据到数据库
|
||||
try {
|
||||
for (Supplier supplier : list) {
|
||||
supplierService.add(supplier);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return Result.error(ResultCodeEnum.DATA_IMPORT_ERROR);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,241 @@
|
||||
package com.example.controller;
|
||||
|
||||
import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.example.common.Result;
|
||||
import com.example.common.enums.ResultCodeEnum;
|
||||
import com.example.common.enums.RoleEnum;
|
||||
import com.example.entity.Account;
|
||||
import com.example.entity.Goods;
|
||||
import com.example.entity.Sale;
|
||||
import com.example.entity.Stock;
|
||||
import com.example.exception.CustomException;
|
||||
import com.example.service.*;
|
||||
import com.example.utils.TokenUtils;
|
||||
import com.example.utils.ValidateCodeCache;
|
||||
import com.example.utils.ValidateCodeProperties;
|
||||
import com.wf.captcha.GifCaptcha;
|
||||
import com.wf.captcha.SpecCaptcha;
|
||||
import com.wf.captcha.base.Captcha;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 基础前端接口
|
||||
*/
|
||||
@RestController
|
||||
public class WebController {
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@Resource
|
||||
private StaffService staffService;
|
||||
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
|
||||
@Resource
|
||||
StockService stockService;
|
||||
|
||||
@Resource
|
||||
SaleService saleService;
|
||||
@Autowired
|
||||
WarnService warnService;
|
||||
|
||||
@GetMapping("/")
|
||||
public Result hello() {
|
||||
return Result.success("访问成功");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/getValidateCode")
|
||||
public void getValidateCode(HttpServletRequest request, HttpServletResponse response) {
|
||||
// 生成验证码
|
||||
ValidateCodeProperties code = new ValidateCodeProperties();
|
||||
setHeader(response, code.getType());
|
||||
Captcha captcha = createCaptcha(code);
|
||||
// 存储验证码到缓存
|
||||
ValidateCodeCache.setCache(request.getParameter("key"), captcha.text().toLowerCase());
|
||||
try {
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
captcha.out(outputStream);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new CustomException(ResultCodeEnum.VALIDATE_CODE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建验证码
|
||||
*/
|
||||
private Captcha createCaptcha(ValidateCodeProperties code) {
|
||||
Captcha captcha = null;
|
||||
if ("gif".equalsIgnoreCase(code.getType())) {
|
||||
captcha = new GifCaptcha(code.getWidth(), code.getHeight(), code.getLength());
|
||||
} else {
|
||||
captcha = new SpecCaptcha(code.getWidth(), code.getHeight(), code.getLength());
|
||||
}
|
||||
captcha.setCharType(code.getCharType());
|
||||
return captcha;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置验证码返回头
|
||||
*/
|
||||
private void setHeader(HttpServletResponse response, String type) {
|
||||
if ("gif".equalsIgnoreCase(type)) {
|
||||
response.setContentType(MediaType.IMAGE_GIF_VALUE);
|
||||
} else {
|
||||
response.setContentType(MediaType.IMAGE_PNG_VALUE);
|
||||
}
|
||||
response.setHeader(HttpHeaders.PRAGMA, "No-cache");
|
||||
response.setHeader(HttpHeaders.CACHE_CONTROL, "no-cache");
|
||||
response.setDateHeader(HttpHeaders.EXPIRES, 0L);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
public Result login(@RequestBody Account account) {
|
||||
if (ObjectUtil.isEmpty(account.getUsername()) || ObjectUtil.isEmpty(account.getPassword())
|
||||
|| ObjectUtil.isEmpty(account.getRole()) || ObjectUtil.isEmpty(account.getKey())
|
||||
|| ObjectUtil.isEmpty(account.getCode())) {
|
||||
return Result.error(ResultCodeEnum.PARAM_LOST_ERROR);
|
||||
}
|
||||
// 对验证码进行校验
|
||||
boolean result = ValidateCodeCache.validateCode(account.getKey(), account.getCode());
|
||||
if (!result) { // code不存在
|
||||
return Result.error(ResultCodeEnum.VALIDATE_CODE_ERROR);
|
||||
}
|
||||
if (RoleEnum.ADMIN.name().equals(account.getRole())) {
|
||||
account = adminService.login(account);
|
||||
} else if (RoleEnum.STAFF.name().equals(account.getRole())) {
|
||||
account = staffService.login(account);
|
||||
}
|
||||
// 记录登录的日志
|
||||
LogsService.recordLog("用户登录", "登录", account.getUsername());
|
||||
return Result.success(account);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
@PostMapping("/register")
|
||||
public Result register(@RequestBody Account account) {
|
||||
if (StrUtil.isBlank(account.getUsername()) || StrUtil.isBlank(account.getPassword())
|
||||
|| ObjectUtil.isEmpty(account.getRole())) {
|
||||
return Result.error(ResultCodeEnum.PARAM_LOST_ERROR);
|
||||
}
|
||||
if (RoleEnum.STAFF.name().equals(account.getRole())) {
|
||||
staffService.register(account);
|
||||
// 记录登录的日志
|
||||
LogsService.recordLog("用户注册", "注册", account.getUsername());
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*/
|
||||
@PutMapping("/updatePassword")
|
||||
public Result updatePassword(@RequestBody Account account) {
|
||||
if (StrUtil.isBlank(account.getUsername()) || StrUtil.isBlank(account.getPassword())
|
||||
|| ObjectUtil.isEmpty(account.getNewPassword())) {
|
||||
return Result.error(ResultCodeEnum.PARAM_LOST_ERROR);
|
||||
}
|
||||
if (RoleEnum.ADMIN.name().equals(account.getRole())) {
|
||||
adminService.updatePassword(account);
|
||||
} else if (RoleEnum.STAFF.name().equals(account.getRole())) {
|
||||
staffService.updatePassword(account);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计数据
|
||||
*/
|
||||
@GetMapping("/dataCount")
|
||||
public Result dataCount() {
|
||||
List<Goods> goodsList = goodsService.selectAll(null);
|
||||
List<Stock> stockList = stockService.selectAll(null);
|
||||
List<Sale> saleList = saleService.selectAll(null);
|
||||
// 查询商品总库存
|
||||
Integer store = goodsList.stream().map(Goods::getNum).reduce(Integer::sum).orElse(0);
|
||||
// 查询商品的总金额
|
||||
Double money = goodsList.stream().map(goods -> goods.getPrice() * goods.getNum()).reduce(Double::sum).orElse(0D);
|
||||
// 查询进货数量
|
||||
Integer stock = stockList.stream().map(Stock::getNum).reduce(Integer::sum).orElse(0);
|
||||
// 查询销售数量
|
||||
Integer sale = saleList.stream().map(Sale::getNum).reduce(Integer::sum).orElse(0);
|
||||
Dict dict = Dict.create().set("store", store).set("money", money).set("stock", stock).set("sale", sale);
|
||||
return Result.success(dict);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计过去一周的商品销售额
|
||||
*/
|
||||
@GetMapping("/goodsCount")
|
||||
public Result goodsCount() {
|
||||
List<Sale> saleList = saleService.selectAll(null);
|
||||
// 获取最新的一周的数据
|
||||
Date today = new Date();
|
||||
// 从8天前到昨天 一周的时间集合
|
||||
List<DateTime> dateRange = DateUtil.rangeToList(DateUtil.offsetDay(today, -8), DateUtil.offsetDay(today, -1), DateField.DAY_OF_YEAR);
|
||||
// 排序
|
||||
dateRange = dateRange.stream().sorted((a, b) -> (int) (a.getTime() - b.getTime())).collect(Collectors.toList());
|
||||
List<Dict> list = new ArrayList<>();
|
||||
for (DateTime dateTime : dateRange) {
|
||||
String dateStr = DateUtil.formatDate(dateTime);// 把 datetime类型的数据转换成字符串
|
||||
Double sum = saleList.stream().filter(sale -> sale.getTime().contains(dateStr)).map(Sale::getTotal).reduce(Double::sum).orElse(0D);
|
||||
Dict dict = Dict.create();
|
||||
dict.set("name", dateStr).set("value", sum);
|
||||
list.add(dict);
|
||||
}
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计过去一周的商品销售额
|
||||
*/
|
||||
@GetMapping("/storeCount")
|
||||
public Result storeCount() {
|
||||
List<Goods> goodsList = goodsService.selectAll(null);
|
||||
List<Dict> list = new ArrayList<>();
|
||||
List<String> nameList = goodsList.stream().map(Goods::getName).collect(Collectors.toList());
|
||||
for (String name : nameList) {
|
||||
Dict dict = Dict.create();
|
||||
Integer sum = goodsList.stream().filter(goods -> goods.getName().equals(name)).map(Goods::getNum).reduce(Integer::sum).orElse(0);
|
||||
dict.set("name", name).set("value", sum);
|
||||
list.add(dict);
|
||||
}
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/warning")
|
||||
public Result warning(){
|
||||
return warnService.warning();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
package com.example.entity;
|
||||
|
||||
/**
|
||||
* 角色用户父类
|
||||
*/
|
||||
public class Account {
|
||||
private Integer id;
|
||||
/** 用户名 */
|
||||
private String username;
|
||||
/** 名称 */
|
||||
private String name;
|
||||
/** 密码 */
|
||||
private String password;
|
||||
/** 角色标识 */
|
||||
private String role;
|
||||
/** 新密码 */
|
||||
private String newPassword;
|
||||
/** 头像 */
|
||||
private String avatar;
|
||||
|
||||
private String token;
|
||||
private String key;
|
||||
private String code;
|
||||
private Boolean status;
|
||||
private String departmentName;
|
||||
|
||||
public String getDepartmentName() {
|
||||
return departmentName;
|
||||
}
|
||||
|
||||
public void setDepartmentName(String departmentName) {
|
||||
this.departmentName = departmentName;
|
||||
}
|
||||
|
||||
public Boolean getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Boolean status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public String getNewPassword() {
|
||||
return newPassword;
|
||||
}
|
||||
|
||||
public void setNewPassword(String newPassword) {
|
||||
this.newPassword = newPassword;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
package com.example.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 管理员
|
||||
*/
|
||||
public class Admin extends Account implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
private Integer id;
|
||||
/** 用户名 */
|
||||
private String username;
|
||||
/** 密码 */
|
||||
private String password;
|
||||
/** 姓名 */
|
||||
private String name;
|
||||
/** 电话 */
|
||||
private String phone;
|
||||
/** 邮箱 */
|
||||
private String email;
|
||||
/** 头像 */
|
||||
private String avatar;
|
||||
/** 角色标识 */
|
||||
private String role;
|
||||
|
||||
@Override
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
}
|
@ -0,0 +1,139 @@
|
||||
package com.example.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 商品退货
|
||||
*/
|
||||
public class Back implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
private Integer id;
|
||||
/** 供应商ID */
|
||||
private Integer supplierId;
|
||||
/** 商品ID */
|
||||
private Integer goodsId;
|
||||
/** 支付类型 */
|
||||
private String payType;
|
||||
/** 退货时间 */
|
||||
private String time;
|
||||
/** 操作人ID */
|
||||
private String user;
|
||||
/** 退货数量 */
|
||||
private Integer num;
|
||||
/** 商品规格 */
|
||||
private String unit;
|
||||
/** 退货价格 */
|
||||
private Double price;
|
||||
/** 退货总价格 */
|
||||
private Double total;
|
||||
/** 备注 */
|
||||
private String comment;
|
||||
private String goodsName;
|
||||
private String supplierName;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getSupplierId() {
|
||||
return supplierId;
|
||||
}
|
||||
|
||||
public void setSupplierId(Integer supplierId) {
|
||||
this.supplierId = supplierId;
|
||||
}
|
||||
|
||||
public Integer getGoodsId() {
|
||||
return goodsId;
|
||||
}
|
||||
|
||||
public void setGoodsId(Integer goodsId) {
|
||||
this.goodsId = goodsId;
|
||||
}
|
||||
|
||||
public String getPayType() {
|
||||
return payType;
|
||||
}
|
||||
|
||||
public void setPayType(String payType) {
|
||||
this.payType = payType;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public Integer getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public void setNum(Integer num) {
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
public String getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
public void setUnit(String unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
public Double getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(Double price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public Double getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(Double total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public String getGoodsName() {
|
||||
return goodsName;
|
||||
}
|
||||
|
||||
public void setGoodsName(String goodsName) {
|
||||
this.goodsName = goodsName;
|
||||
}
|
||||
|
||||
public String getSupplierName() {
|
||||
return supplierName;
|
||||
}
|
||||
|
||||
public void setSupplierName(String supplierName) {
|
||||
this.supplierName = supplierName;
|
||||
}
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
package com.example.entity;
|
||||
|
||||
import cn.hutool.core.annotation.Alias;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 客户表
|
||||
*/
|
||||
public class Customer implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
@Alias("ID")
|
||||
private Integer id;
|
||||
/** 客户名称 */
|
||||
@Alias("客户名称")
|
||||
private String name;
|
||||
/** 客户地址 */
|
||||
@Alias("客户地址")
|
||||
private String address;
|
||||
/** 客户电话 */
|
||||
@Alias("客户电话")
|
||||
private String tel;
|
||||
/** 客户邮箱 */
|
||||
@Alias("客户邮箱")
|
||||
private String email;
|
||||
/** 客户邮编 */
|
||||
@Alias("客户邮编")
|
||||
private String zipCode;
|
||||
/** 联系人 */
|
||||
@Alias("联系人")
|
||||
private String user;
|
||||
/** 联系人电话 */
|
||||
@Alias("联系人电话")
|
||||
private String phone;
|
||||
/** 开户银行 */
|
||||
@Alias("开户银行")
|
||||
private String bank;
|
||||
/** 开户行账号 */
|
||||
@Alias("开户行账号")
|
||||
private String bankCard;
|
||||
/** 状态 */
|
||||
@Alias("状态")
|
||||
private String status;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getTel() {
|
||||
return tel;
|
||||
}
|
||||
|
||||
public void setTel(String tel) {
|
||||
this.tel = tel;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getZipCode() {
|
||||
return zipCode;
|
||||
}
|
||||
|
||||
public void setZipCode(String zipCode) {
|
||||
this.zipCode = zipCode;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getBank() {
|
||||
return bank;
|
||||
}
|
||||
|
||||
public void setBank(String bank) {
|
||||
this.bank = bank;
|
||||
}
|
||||
|
||||
public String getBankCard() {
|
||||
return bankCard;
|
||||
}
|
||||
|
||||
public void setBankCard(String bankCard) {
|
||||
this.bankCard = bankCard;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package com.example.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部门的实体类
|
||||
*/
|
||||
public class Department {
|
||||
|
||||
private Integer id;
|
||||
private String name;
|
||||
private String address;
|
||||
private Integer pid;
|
||||
private Integer level;
|
||||
|
||||
private List<Department> children;
|
||||
|
||||
public List<Department> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<Department> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public Integer getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(Integer pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public Integer getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(Integer level) {
|
||||
this.level = level;
|
||||
}
|
||||
}
|
@ -0,0 +1,190 @@
|
||||
package com.example.entity;
|
||||
|
||||
import cn.hutool.core.annotation.Alias;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 商品表
|
||||
*/
|
||||
public class Goods implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@Alias("ID")
|
||||
private Integer id;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@Alias("商品名称")
|
||||
private String name;
|
||||
/**
|
||||
* 供应商ID
|
||||
*/
|
||||
@Alias("供应商ID")
|
||||
private Integer supplierId;
|
||||
/**
|
||||
* 商品产地
|
||||
*/
|
||||
@Alias("商品产地")
|
||||
private String producer;
|
||||
/**
|
||||
* 商品描述
|
||||
*/
|
||||
@Alias("商品描述")
|
||||
private String descr;
|
||||
/**
|
||||
* 销售价格
|
||||
*/
|
||||
@Alias("销售价格")
|
||||
private Double price;
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
@Alias("数量")
|
||||
private Integer num;
|
||||
/**
|
||||
* 商品图片
|
||||
*/
|
||||
@Alias("商品图片")
|
||||
private String img;
|
||||
/**
|
||||
* 商品规格
|
||||
*/
|
||||
@Alias("商品规格")
|
||||
private String unit;
|
||||
/**
|
||||
* 包装单位
|
||||
*/
|
||||
@Alias("包装单位")
|
||||
private String pack;
|
||||
/**
|
||||
* 生产批号
|
||||
*/
|
||||
@Alias("生产批号")
|
||||
private String productNo;
|
||||
/**
|
||||
* 批准文号
|
||||
*/
|
||||
@Alias("批准文号")
|
||||
private String approveNo;
|
||||
@Alias("状态")
|
||||
private String status;
|
||||
|
||||
@Alias("供应商名称")
|
||||
private String supplierName;
|
||||
|
||||
public String getSupplierName() {
|
||||
return supplierName;
|
||||
}
|
||||
|
||||
public void setSupplierName(String supplierName) {
|
||||
this.supplierName = supplierName;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getSupplierId() {
|
||||
return supplierId;
|
||||
}
|
||||
|
||||
public void setSupplierId(Integer supplierId) {
|
||||
this.supplierId = supplierId;
|
||||
}
|
||||
|
||||
public String getProducer() {
|
||||
return producer;
|
||||
}
|
||||
|
||||
public void setProducer(String producer) {
|
||||
this.producer = producer;
|
||||
}
|
||||
|
||||
public String getDescr() {
|
||||
return descr;
|
||||
}
|
||||
|
||||
public void setDescr(String descr) {
|
||||
this.descr = descr;
|
||||
}
|
||||
|
||||
public Double getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(Double price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getImg() {
|
||||
return img;
|
||||
}
|
||||
|
||||
public void setImg(String img) {
|
||||
this.img = img;
|
||||
}
|
||||
|
||||
public String getPack() {
|
||||
return pack;
|
||||
}
|
||||
|
||||
public void setPack(String pack) {
|
||||
this.pack = pack;
|
||||
}
|
||||
|
||||
public String getProductNo() {
|
||||
return productNo;
|
||||
}
|
||||
|
||||
public void setProductNo(String productNo) {
|
||||
this.productNo = productNo;
|
||||
}
|
||||
|
||||
public String getApproveNo() {
|
||||
return approveNo;
|
||||
}
|
||||
|
||||
public void setApproveNo(String approveNo) {
|
||||
this.approveNo = approveNo;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Integer getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public void setNum(Integer num) {
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
public String getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
public void setUnit(String unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package com.example.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 日志
|
||||
*/
|
||||
public class Logs implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 操作
|
||||
*/
|
||||
private String operation;
|
||||
/**
|
||||
* 操作人
|
||||
*/
|
||||
private String username;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* IP地址
|
||||
*/
|
||||
private String ip;
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
private String time;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(String operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.example.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 公告信息表
|
||||
*/
|
||||
public class Notice implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
private Integer id;
|
||||
/** 标题 */
|
||||
private String title;
|
||||
/** 内容 */
|
||||
private String content;
|
||||
/** 创建时间 */
|
||||
private String time;
|
||||
/** 创建人 */
|
||||
private String user;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,150 @@
|
||||
package com.example.entity;
|
||||
|
||||
import cn.hutool.core.annotation.Alias;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 商品销售
|
||||
*/
|
||||
public class Sale implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
@Alias("序号")
|
||||
private Integer id;
|
||||
/** 客户ID */
|
||||
@Alias("客户ID")
|
||||
private Integer customerId;
|
||||
/** 商品ID */
|
||||
@Alias("商品ID")
|
||||
private Integer goodsId;
|
||||
/** 支付类型 */
|
||||
@Alias("支付类型")
|
||||
private String payType;
|
||||
/** 销售时间 */
|
||||
@Alias("销售时间")
|
||||
private String time;
|
||||
/** 操作人 */
|
||||
@Alias("操作人")
|
||||
private String user;
|
||||
/** 销售价格 */
|
||||
@Alias("销售价格")
|
||||
private Double price;
|
||||
/** 销售数量 */
|
||||
@Alias("销售数量")
|
||||
private Integer num;
|
||||
/** 商品规格 */
|
||||
@Alias("商品规格")
|
||||
private String unit;
|
||||
/** 备注 */
|
||||
@Alias("备注")
|
||||
private String comment;
|
||||
private String customerName;
|
||||
private String goodsName;
|
||||
private Double total;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getCustomerId() {
|
||||
return customerId;
|
||||
}
|
||||
|
||||
public void setCustomerId(Integer customerId) {
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
public Integer getGoodsId() {
|
||||
return goodsId;
|
||||
}
|
||||
|
||||
public void setGoodsId(Integer goodsId) {
|
||||
this.goodsId = goodsId;
|
||||
}
|
||||
|
||||
public String getGoodsName() {
|
||||
return goodsName;
|
||||
}
|
||||
|
||||
public void setGoodsName(String goodsName) {
|
||||
this.goodsName = goodsName;
|
||||
}
|
||||
|
||||
public String getPayType() {
|
||||
return payType;
|
||||
}
|
||||
|
||||
public void setPayType(String payType) {
|
||||
this.payType = payType;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public Double getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(Double price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public Integer getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public void setNum(Integer num) {
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
public String getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
public void setUnit(String unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public String getCustomerName() {
|
||||
return customerName;
|
||||
}
|
||||
|
||||
public void setCustomerName(String customerName) {
|
||||
this.customerName = customerName;
|
||||
}
|
||||
|
||||
public Double getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(Double total) {
|
||||
this.total = total;
|
||||
}
|
||||
}
|
@ -0,0 +1,139 @@
|
||||
package com.example.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 商品销售
|
||||
*/
|
||||
public class SaleBack implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
private Integer id;
|
||||
/** 客户ID */
|
||||
private Integer customerId;
|
||||
/** 商品ID */
|
||||
private Integer goodsId;
|
||||
/** 支付类型 */
|
||||
private String payType;
|
||||
/** 退货时间 */
|
||||
private String time;
|
||||
/** 操作人 */
|
||||
private String user;
|
||||
/** 退货单价 */
|
||||
private Double price;
|
||||
/** 退货数量 */
|
||||
private Integer num;
|
||||
/** 商品规格 */
|
||||
private String unit;
|
||||
/** 退货总价 */
|
||||
private Double total;
|
||||
/** 备注 */
|
||||
private String comment;
|
||||
private String customerName;
|
||||
private String goodsName;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getCustomerId() {
|
||||
return customerId;
|
||||
}
|
||||
|
||||
public void setCustomerId(Integer customerId) {
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
public Integer getGoodsId() {
|
||||
return goodsId;
|
||||
}
|
||||
|
||||
public void setGoodsId(Integer goodsId) {
|
||||
this.goodsId = goodsId;
|
||||
}
|
||||
|
||||
public String getPayType() {
|
||||
return payType;
|
||||
}
|
||||
|
||||
public void setPayType(String payType) {
|
||||
this.payType = payType;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public Double getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(Double price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public Integer getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public void setNum(Integer num) {
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
public String getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
public void setUnit(String unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
public Double getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(Double total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public String getCustomerName() {
|
||||
return customerName;
|
||||
}
|
||||
|
||||
public void setCustomerName(String customerName) {
|
||||
this.customerName = customerName;
|
||||
}
|
||||
|
||||
public String getGoodsName() {
|
||||
return goodsName;
|
||||
}
|
||||
|
||||
public void setGoodsName(String goodsName) {
|
||||
this.goodsName = goodsName;
|
||||
}
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
package com.example.entity;
|
||||
|
||||
/**
|
||||
* 员工实体类
|
||||
*/
|
||||
public class Staff extends Account {
|
||||
|
||||
private Integer id;
|
||||
private String username;
|
||||
private String password;
|
||||
private String name;
|
||||
private String avatar;
|
||||
private String role;
|
||||
private String sex;
|
||||
private String phone;
|
||||
private String email;
|
||||
private String birth;
|
||||
private Integer departmentId;
|
||||
private Boolean status;
|
||||
|
||||
private String departmentName;
|
||||
|
||||
public String getDepartmentName() {
|
||||
return departmentName;
|
||||
}
|
||||
|
||||
public void setDepartmentName(String departmentName) {
|
||||
this.departmentName = departmentName;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getBirth() {
|
||||
return birth;
|
||||
}
|
||||
|
||||
public void setBirth(String birth) {
|
||||
this.birth = birth;
|
||||
}
|
||||
|
||||
public Integer getDepartmentId() {
|
||||
return departmentId;
|
||||
}
|
||||
|
||||
public void setDepartmentId(Integer departmentId) {
|
||||
this.departmentId = departmentId;
|
||||
}
|
||||
|
||||
public Boolean getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Boolean status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
@ -0,0 +1,142 @@
|
||||
package com.example.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 商品进货
|
||||
*/
|
||||
public class Stock implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
private Integer id;
|
||||
/** 供应商ID */
|
||||
private Integer supplierId;
|
||||
/** 商品ID */
|
||||
private Integer goodsId;
|
||||
/** 支付类型 */
|
||||
private String payType;
|
||||
/** 进货时间 */
|
||||
private String time;
|
||||
/** 操作人ID */
|
||||
private String user;
|
||||
/** 进货数量 */
|
||||
private Integer num;
|
||||
/** 商品规格 */
|
||||
private String unit;
|
||||
/** 进货价格 */
|
||||
private Double price;
|
||||
/** 进货总价格 */
|
||||
private Double total;
|
||||
/** 备注 */
|
||||
private String comment;
|
||||
|
||||
private String supplierName;
|
||||
|
||||
private String goodsName;
|
||||
|
||||
public String getSupplierName() {
|
||||
return supplierName;
|
||||
}
|
||||
|
||||
public void setSupplierName(String supplierName) {
|
||||
this.supplierName = supplierName;
|
||||
}
|
||||
|
||||
public String getGoodsName() {
|
||||
return goodsName;
|
||||
}
|
||||
|
||||
public void setGoodsName(String goodsName) {
|
||||
this.goodsName = goodsName;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getSupplierId() {
|
||||
return supplierId;
|
||||
}
|
||||
|
||||
public void setSupplierId(Integer supplierId) {
|
||||
this.supplierId = supplierId;
|
||||
}
|
||||
|
||||
public Integer getGoodsId() {
|
||||
return goodsId;
|
||||
}
|
||||
|
||||
public void setGoodsId(Integer goodsId) {
|
||||
this.goodsId = goodsId;
|
||||
}
|
||||
|
||||
public String getPayType() {
|
||||
return payType;
|
||||
}
|
||||
|
||||
public void setPayType(String payType) {
|
||||
this.payType = payType;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public Integer getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public void setNum(Integer num) {
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
public String getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
public void setUnit(String unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
public Double getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(Double price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public Double getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(Double total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
package com.example.entity;
|
||||
|
||||
import cn.hutool.core.annotation.Alias;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 供应商表
|
||||
*/
|
||||
public class Supplier implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
@Alias("ID")
|
||||
private Integer id;
|
||||
/** 供应商名称 */
|
||||
@Alias("供应商名称")
|
||||
private String name;
|
||||
/** 供应商地址 */
|
||||
@Alias("供应商地址")
|
||||
private String address;
|
||||
/** 供应商电话 */
|
||||
@Alias("供应商电话")
|
||||
private String tel;
|
||||
/** 供应商邮箱 */
|
||||
@Alias("供应商邮箱")
|
||||
private String email;
|
||||
/** 邮编 */
|
||||
@Alias("邮编")
|
||||
private String zipCode;
|
||||
/** 联系人 */
|
||||
@Alias("联系人")
|
||||
private String user;
|
||||
/** 联系人电话 */
|
||||
@Alias("联系人电话")
|
||||
private String phone;
|
||||
/** 开户银行 */
|
||||
@Alias("开户银行")
|
||||
private String bank;
|
||||
/** 开户行账号 */
|
||||
@Alias("开户行账号")
|
||||
private String bankCard;
|
||||
/** 状态 */
|
||||
@Alias("状态")
|
||||
private String status;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getTel() {
|
||||
return tel;
|
||||
}
|
||||
|
||||
public void setTel(String tel) {
|
||||
this.tel = tel;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getZipCode() {
|
||||
return zipCode;
|
||||
}
|
||||
|
||||
public void setZipCode(String zipCode) {
|
||||
this.zipCode = zipCode;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getBank() {
|
||||
return bank;
|
||||
}
|
||||
|
||||
public void setBank(String bank) {
|
||||
this.bank = bank;
|
||||
}
|
||||
|
||||
public String getBankCard() {
|
||||
return bankCard;
|
||||
}
|
||||
|
||||
public void setBankCard(String bankCard) {
|
||||
this.bankCard = bankCard;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.example.exception;
|
||||
|
||||
import com.example.common.enums.ResultCodeEnum;
|
||||
|
||||
public class CustomException extends RuntimeException {
|
||||
private String code;
|
||||
private String msg;
|
||||
|
||||
public CustomException(ResultCodeEnum resultCodeEnum) {
|
||||
this.code = resultCodeEnum.code;
|
||||
this.msg = resultCodeEnum.msg;
|
||||
}
|
||||
|
||||
public CustomException(String code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.example.exception;
|
||||
|
||||
import cn.hutool.log.Log;
|
||||
import cn.hutool.log.LogFactory;
|
||||
import com.example.common.Result;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@ControllerAdvice(basePackages="com.example.controller")
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
private static final Log log = LogFactory.get();
|
||||
|
||||
|
||||
//统一异常处理@ExceptionHandler,主要用于Exception
|
||||
@ExceptionHandler(Exception.class)
|
||||
@ResponseBody//返回json串
|
||||
public Result error(HttpServletRequest request, Exception e){
|
||||
log.error("异常信息:",e);
|
||||
return Result.error();
|
||||
}
|
||||
|
||||
@ExceptionHandler(CustomException.class)
|
||||
@ResponseBody//返回json串
|
||||
public Result customError(HttpServletRequest request, CustomException e){
|
||||
return Result.error(e.getCode(), e.getMsg());
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.example.mapper;
|
||||
|
||||
import com.example.entity.Admin;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作admin相关数据接口
|
||||
*/
|
||||
public interface AdminMapper {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
int insert(Admin admin);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
int updateById(Admin admin);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
Admin selectById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
List<Admin> selectAll(Admin admin);
|
||||
|
||||
@Select("select * from admin where username = #{username}")
|
||||
Admin selectByUsername(String username);
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.example.mapper;
|
||||
|
||||
import com.example.entity.Back;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作back相关数据接口
|
||||
*/
|
||||
public interface BackMapper {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
int insert(Back back);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
int updateById(Back back);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
Back selectById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
List<Back> selectAll(Back back);
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.example.mapper;
|
||||
|
||||
import com.example.entity.Customer;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作customer相关数据接口
|
||||
*/
|
||||
public interface CustomerMapper {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
int insert(Customer customer);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
int updateById(Customer customer);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
Customer selectById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
List<Customer> selectAll(Customer customer);
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.example.mapper;
|
||||
|
||||
import com.example.entity.Department;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DepartmentMapper {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
int insert(Department department);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
int updateById(Department department);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
Department selectById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
List<Department> selectAll(Department department);
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.example.mapper;
|
||||
|
||||
import com.example.entity.Goods;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作goods相关数据接口
|
||||
*/
|
||||
public interface GoodsMapper {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
int insert(Goods goods);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
int updateById(Goods goods);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
Goods selectById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
List<Goods> selectAll(Goods goods);
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.example.mapper;
|
||||
|
||||
import com.example.entity.Logs;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作logs相关数据接口
|
||||
*/
|
||||
public interface LogsMapper {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
int insert(Logs logs);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
int updateById(Logs logs);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
Logs selectById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
List<Logs> selectAll(Logs logs);
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.example.mapper;
|
||||
|
||||
import com.example.entity.Notice;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作notice相关数据接口
|
||||
*/
|
||||
public interface NoticeMapper {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
int insert(Notice notice);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
int updateById(Notice notice);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
Notice selectById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
List<Notice> selectAll(Notice notice);
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.example.mapper;
|
||||
|
||||
import com.example.entity.SaleBack;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作sale_back相关数据接口
|
||||
*/
|
||||
public interface SaleBackMapper {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
int insert(SaleBack saleBack);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
int updateById(SaleBack saleBack);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
SaleBack selectById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
List<SaleBack> selectAll(SaleBack saleBack);
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.example.mapper;
|
||||
|
||||
import com.example.entity.Sale;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作sale相关数据接口
|
||||
*/
|
||||
public interface SaleMapper {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
int insert(Sale sale);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
int updateById(Sale sale);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
Sale selectById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
List<Sale> selectAll(Sale sale);
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.example.mapper;
|
||||
|
||||
import com.example.entity.Staff;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface StaffMapper {
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
int insert(Staff staff);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
int updateById(Staff staff);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
Staff selectById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
List<Staff> selectAll(Staff staff);
|
||||
|
||||
Staff selectByUsername(String username);
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.example.mapper;
|
||||
|
||||
import com.example.entity.Stock;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作stock相关数据接口
|
||||
*/
|
||||
public interface StockMapper {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
int insert(Stock stock);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
int updateById(Stock stock);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
Stock selectById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
List<Stock> selectAll(Stock stock);
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.example.mapper;
|
||||
|
||||
import com.example.entity.Supplier;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作supplier相关数据接口
|
||||
*/
|
||||
public interface SupplierMapper {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
int insert(Supplier supplier);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
int updateById(Supplier supplier);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
Supplier selectById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
List<Supplier> selectAll(Supplier supplier);
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.example.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface WarnMapper {
|
||||
|
||||
@Select("SELECT name, num FROM goods WHERE num >= 100")
|
||||
public List<Map<String, Object>> much();
|
||||
|
||||
@Select("SELECT name, num FROM goods WHERE num < 10")
|
||||
public List<Map<String, Object>> little();
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
package com.example.service;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.example.common.Constants;
|
||||
import com.example.common.enums.ResultCodeEnum;
|
||||
import com.example.common.enums.RoleEnum;
|
||||
import com.example.entity.Account;
|
||||
import com.example.entity.Admin;
|
||||
import com.example.exception.CustomException;
|
||||
import com.example.mapper.AdminMapper;
|
||||
import com.example.utils.TokenUtils;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 管理员业务处理
|
||||
**/
|
||||
@Service
|
||||
public class AdminService {
|
||||
|
||||
@Resource
|
||||
private AdminMapper adminMapper;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
public void add(Admin admin) {
|
||||
Admin dbAdmin = adminMapper.selectByUsername(admin.getUsername());
|
||||
if (ObjectUtil.isNotNull(dbAdmin)) {
|
||||
throw new CustomException(ResultCodeEnum.USER_EXIST_ERROR);
|
||||
}
|
||||
if (ObjectUtil.isEmpty(admin.getPassword())) {
|
||||
admin.setPassword(Constants.USER_DEFAULT_PASSWORD);
|
||||
}
|
||||
if (ObjectUtil.isEmpty(admin.getName())) {
|
||||
admin.setName(admin.getUsername());
|
||||
}
|
||||
admin.setRole(RoleEnum.ADMIN.name());
|
||||
adminMapper.insert(admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void deleteById(Integer id) {
|
||||
adminMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
public void deleteBatch(List<Integer> ids) {
|
||||
for (Integer id : ids) {
|
||||
adminMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void updateById(Admin admin) {
|
||||
adminMapper.updateById(admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
public Admin selectById(Integer id) {
|
||||
return adminMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
public List<Admin> selectAll(Admin admin) {
|
||||
return adminMapper.selectAll(admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
public PageInfo<Admin> selectPage(Admin admin, Integer pageNum, Integer pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Admin> list = adminMapper.selectAll(admin);
|
||||
return PageInfo.of(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
public Account login(Account account) {
|
||||
Account dbAdmin = adminMapper.selectByUsername(account.getUsername());
|
||||
if (ObjectUtil.isNull(dbAdmin)) {
|
||||
throw new CustomException(ResultCodeEnum.USER_NOT_EXIST_ERROR);
|
||||
}
|
||||
if (!account.getPassword().equals(dbAdmin.getPassword())) {
|
||||
throw new CustomException(ResultCodeEnum.USER_ACCOUNT_ERROR);
|
||||
}
|
||||
// 生成token
|
||||
String tokenData = dbAdmin.getId() + "-" + RoleEnum.ADMIN.name();
|
||||
String token = TokenUtils.createToken(tokenData, dbAdmin.getPassword());
|
||||
dbAdmin.setToken(token);
|
||||
return dbAdmin;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
public void register(Account account) {
|
||||
Admin admin = new Admin();
|
||||
BeanUtils.copyProperties(account, admin);
|
||||
add(admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*/
|
||||
public void updatePassword(Account account) {
|
||||
Admin dbAdmin = adminMapper.selectByUsername(account.getUsername());
|
||||
if (ObjectUtil.isNull(dbAdmin)) {
|
||||
throw new CustomException(ResultCodeEnum.USER_NOT_EXIST_ERROR);
|
||||
}
|
||||
if (!account.getPassword().equals(dbAdmin.getPassword())) {
|
||||
throw new CustomException(ResultCodeEnum.PARAM_PASSWORD_ERROR);
|
||||
}
|
||||
dbAdmin.setPassword(account.getNewPassword());
|
||||
adminMapper.updateById(dbAdmin);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package com.example.service;
|
||||
|
||||
import com.example.entity.Account;
|
||||
import com.example.entity.Back;
|
||||
import com.example.entity.Goods;
|
||||
import com.example.mapper.BackMapper;
|
||||
import com.example.utils.TokenUtils;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品退货业务处理
|
||||
**/
|
||||
@Service
|
||||
public class BackService {
|
||||
|
||||
@Resource
|
||||
private BackMapper backMapper;
|
||||
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@Transactional
|
||||
public void add(Back back) {
|
||||
Goods goods = goodsService.selectById(back.getGoodsId());
|
||||
goods.setNum(goods.getNum() - back.getNum());
|
||||
goodsService.updateById(goods);
|
||||
backMapper.insert(back);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void deleteById(Integer id) {
|
||||
backMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
public void deleteBatch(List<Integer> ids) {
|
||||
for (Integer id : ids) {
|
||||
backMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void updateById(Back back) {
|
||||
backMapper.updateById(back);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
public Back selectById(Integer id) {
|
||||
return backMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
public List<Back> selectAll(Back back) {
|
||||
return backMapper.selectAll(back);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
public PageInfo<Back> selectPage(Back back, Integer pageNum, Integer pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Back> list = backMapper.selectAll(back);
|
||||
return PageInfo.of(list);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.example.service;
|
||||
|
||||
import com.example.entity.Customer;
|
||||
import com.example.mapper.CustomerMapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 客户表业务处理
|
||||
**/
|
||||
@Service
|
||||
public class CustomerService {
|
||||
|
||||
@Resource
|
||||
private CustomerMapper customerMapper;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
public void add(Customer customer) {
|
||||
customerMapper.insert(customer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void deleteById(Integer id) {
|
||||
customerMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
public void deleteBatch(List<Integer> ids) {
|
||||
for (Integer id : ids) {
|
||||
customerMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void updateById(Customer customer) {
|
||||
customerMapper.updateById(customer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
public Customer selectById(Integer id) {
|
||||
return customerMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
public List<Customer> selectAll(Customer customer) {
|
||||
return customerMapper.selectAll(customer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
public PageInfo<Customer> selectPage(Customer customer, Integer pageNum, Integer pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Customer> list = customerMapper.selectAll(customer);
|
||||
return PageInfo.of(list);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package com.example.service;
|
||||
|
||||
import com.example.entity.Department;
|
||||
import com.example.mapper.DepartmentMapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class DepartmentService {
|
||||
|
||||
@Resource
|
||||
private DepartmentMapper departmentMapper;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
public void add(Department department) {
|
||||
departmentMapper.insert(department);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void deleteById(Integer id) {
|
||||
departmentMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
public void deleteBatch(List<Integer> ids) {
|
||||
for (Integer id : ids) {
|
||||
departmentMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void updateById(Department department) {
|
||||
departmentMapper.updateById(department);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
public Department selectById(Integer id) {
|
||||
return departmentMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
public List<Department> selectAll(Department department) {
|
||||
return departmentMapper.selectAll(department);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
public PageInfo<Department> selectPage(Department department, Integer pageNum, Integer pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Department> list = departmentMapper.selectAll(department);
|
||||
return PageInfo.of(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询树形结构
|
||||
*/
|
||||
public List<Department> selectTree() {
|
||||
Department params = new Department();
|
||||
params.setLevel(1); // 先查询出一级节点
|
||||
List<Department> level1DepartmentList = this.selectAll(params);
|
||||
for (Department level1 : level1DepartmentList) {
|
||||
Integer level1Id = level1.getId();
|
||||
Department params1 = new Department();
|
||||
params1.setPid(level1Id); // 再查询2级节点
|
||||
List<Department> leve2DepartmentList = this.selectAll(params1);
|
||||
level1.setChildren(leve2DepartmentList); // 设置一级节点的子节点
|
||||
for (Department level2 : leve2DepartmentList) {
|
||||
Integer level2Id = level2.getId();
|
||||
Department params2 = new Department();
|
||||
params2.setPid(level2Id); // 查询三级节点
|
||||
List<Department> leve3DepartmentList = this.selectAll(params2);
|
||||
level2.setChildren(leve3DepartmentList); // 设置儿级节点的子节点
|
||||
}
|
||||
}
|
||||
return level1DepartmentList;
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.example.service;
|
||||
|
||||
import com.example.entity.Goods;
|
||||
import com.example.mapper.GoodsMapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品表业务处理
|
||||
**/
|
||||
@Service
|
||||
public class GoodsService {
|
||||
|
||||
@Resource
|
||||
private GoodsMapper goodsMapper;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
public void add(Goods goods) {
|
||||
goodsMapper.insert(goods);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void deleteById(Integer id) {
|
||||
goodsMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
public void deleteBatch(List<Integer> ids) {
|
||||
for (Integer id : ids) {
|
||||
goodsMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void updateById(Goods goods) {
|
||||
goodsMapper.updateById(goods);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
public Goods selectById(Integer id) {
|
||||
return goodsMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
public List<Goods> selectAll(Goods goods) {
|
||||
return goodsMapper.selectAll(goods);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
public PageInfo<Goods> selectPage(Goods goods, Integer pageNum, Integer pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Goods> list = goodsMapper.selectAll(goods);
|
||||
return PageInfo.of(list);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package com.example.service;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.example.entity.Logs;
|
||||
import com.example.mapper.LogsMapper;
|
||||
import com.example.utils.IpUtils;
|
||||
import com.example.utils.TokenUtils;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 业务处理
|
||||
**/
|
||||
@Service
|
||||
public class LogsService implements InitializingBean {
|
||||
|
||||
@Resource
|
||||
private LogsMapper logsMapper;
|
||||
@Resource
|
||||
HttpServletRequest request;
|
||||
|
||||
private static LogsMapper staticLogsMapper;
|
||||
|
||||
private static HttpServletRequest staticHttpServletRequest;
|
||||
|
||||
|
||||
/**
|
||||
* 记录日志
|
||||
*/
|
||||
public static void recordLog(String operation, String type, String username) {
|
||||
Logs logs = new Logs();
|
||||
logs.setOperation(operation);
|
||||
logs.setType(type);
|
||||
logs.setTime(DateUtil.now());
|
||||
logs.setIp(IpUtils.getIpAddr(staticHttpServletRequest));
|
||||
logs.setUsername(username);
|
||||
staticLogsMapper.insert(logs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
public void add(Logs logs) {
|
||||
logsMapper.insert(logs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void deleteById(Integer id) {
|
||||
logsMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
public void deleteBatch(List<Integer> ids) {
|
||||
for (Integer id : ids) {
|
||||
logsMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void updateById(Logs logs) {
|
||||
logsMapper.updateById(logs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
public Logs selectById(Integer id) {
|
||||
return logsMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
public List<Logs> selectAll(Logs logs) {
|
||||
return logsMapper.selectAll(logs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
public PageInfo<Logs> selectPage(Logs logs, Integer pageNum, Integer pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Logs> list = logsMapper.selectAll(logs);
|
||||
return PageInfo.of(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
staticLogsMapper = this.logsMapper;
|
||||
staticHttpServletRequest = this.request;
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package com.example.service;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.example.entity.Account;
|
||||
import com.example.entity.Notice;
|
||||
import com.example.mapper.NoticeMapper;
|
||||
import com.example.utils.TokenUtils;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 公告信息表业务处理
|
||||
**/
|
||||
@Service
|
||||
public class NoticeService {
|
||||
|
||||
@Resource
|
||||
private NoticeMapper noticeMapper;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
public void add(Notice notice) {
|
||||
notice.setTime(DateUtil.today());
|
||||
Account currentUser = TokenUtils.getCurrentUser();
|
||||
notice.setUser(currentUser.getUsername());
|
||||
noticeMapper.insert(notice);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void deleteById(Integer id) {
|
||||
noticeMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
public void deleteBatch(List<Integer> ids) {
|
||||
for (Integer id : ids) {
|
||||
noticeMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void updateById(Notice notice) {
|
||||
noticeMapper.updateById(notice);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
public Notice selectById(Integer id) {
|
||||
return noticeMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
public List<Notice> selectAll(Notice notice) {
|
||||
return noticeMapper.selectAll(notice);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
public PageInfo<Notice> selectPage(Notice notice, Integer pageNum, Integer pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Notice> list = noticeMapper.selectAll(notice);
|
||||
return PageInfo.of(list);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package com.example.service;
|
||||
|
||||
import com.example.entity.Goods;
|
||||
import com.example.entity.SaleBack;
|
||||
import com.example.mapper.SaleBackMapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品销售业务处理
|
||||
**/
|
||||
@Service
|
||||
public class SaleBackService {
|
||||
|
||||
@Resource
|
||||
private SaleBackMapper saleBackMapper;
|
||||
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@Transactional
|
||||
public void add(SaleBack saleBack) {
|
||||
Goods goods = goodsService.selectById(saleBack.getGoodsId());
|
||||
goods.setNum(goods.getNum() + saleBack.getNum()); // 销售退货 增加库存
|
||||
goodsService.updateById(goods);
|
||||
|
||||
saleBackMapper.insert(saleBack);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void deleteById(Integer id) {
|
||||
saleBackMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
public void deleteBatch(List<Integer> ids) {
|
||||
for (Integer id : ids) {
|
||||
saleBackMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void updateById(SaleBack saleBack) {
|
||||
saleBackMapper.updateById(saleBack);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
public SaleBack selectById(Integer id) {
|
||||
return saleBackMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
public List<SaleBack> selectAll(SaleBack saleBack) {
|
||||
return saleBackMapper.selectAll(saleBack);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
public PageInfo<SaleBack> selectPage(SaleBack saleBack, Integer pageNum, Integer pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<SaleBack> list = saleBackMapper.selectAll(saleBack);
|
||||
return PageInfo.of(list);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
package com.example.service;
|
||||
|
||||
import com.example.common.enums.ResultCodeEnum;
|
||||
import com.example.entity.Account;
|
||||
import com.example.entity.Goods;
|
||||
import com.example.entity.Sale;
|
||||
import com.example.exception.CustomException;
|
||||
import com.example.mapper.SaleMapper;
|
||||
import com.example.utils.TokenUtils;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品销售业务处理
|
||||
**/
|
||||
@Service
|
||||
public class SaleService {
|
||||
|
||||
@Resource
|
||||
private SaleMapper saleMapper;
|
||||
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@Transactional
|
||||
public void add(Sale sale) {
|
||||
Account currentUser = TokenUtils.getCurrentUser();
|
||||
sale.setUser(currentUser.getName());
|
||||
sale.setTotal(sale.getPrice() * sale.getNum());
|
||||
saleMapper.insert(sale);
|
||||
|
||||
// 商品减库存
|
||||
Goods goods = goodsService.selectById(sale.getGoodsId());
|
||||
int num = goods.getNum() - sale.getNum();
|
||||
if (num < 0) {
|
||||
throw new CustomException(ResultCodeEnum.GOODS_NUM_LIMIT);
|
||||
}
|
||||
goods.setNum(num);
|
||||
goodsService.updateById(goods);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void deleteById(Integer id) {
|
||||
saleMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
public void deleteBatch(List<Integer> ids) {
|
||||
for (Integer id : ids) {
|
||||
saleMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void updateById(Sale sale) {
|
||||
sale.setTotal(sale.getPrice() * sale.getNum());
|
||||
saleMapper.updateById(sale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
public Sale selectById(Integer id) {
|
||||
return saleMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
public List<Sale> selectAll(Sale sale) {
|
||||
return saleMapper.selectAll(sale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
public PageInfo<Sale> selectPage(Sale sale, Integer pageNum, Integer pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Sale> list = saleMapper.selectAll(sale);
|
||||
return PageInfo.of(list);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
package com.example.service;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.example.common.Constants;
|
||||
import com.example.common.enums.ResultCodeEnum;
|
||||
import com.example.common.enums.RoleEnum;
|
||||
import com.example.entity.Account;
|
||||
import com.example.entity.Admin;
|
||||
import com.example.entity.Staff;
|
||||
import com.example.exception.CustomException;
|
||||
import com.example.mapper.StaffMapper;
|
||||
import com.example.utils.TokenUtils;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class StaffService {
|
||||
|
||||
@Resource
|
||||
private StaffMapper staffMapper;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
public void add(Staff staff) {
|
||||
Staff dbStaff = staffMapper.selectByUsername(staff.getUsername());
|
||||
if (ObjectUtil.isNotNull(dbStaff)) {
|
||||
throw new CustomException(ResultCodeEnum.USER_EXIST_ERROR);
|
||||
}
|
||||
if (ObjectUtil.isEmpty(staff.getPassword())) {
|
||||
staff.setPassword(Constants.USER_DEFAULT_PASSWORD);
|
||||
}
|
||||
if (ObjectUtil.isEmpty(staff.getName())) {
|
||||
staff.setName(staff.getUsername());
|
||||
}
|
||||
staff.setRole(RoleEnum.STAFF.name());
|
||||
staffMapper.insert(staff);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void deleteById(Integer id) {
|
||||
staffMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
public void deleteBatch(List<Integer> ids) {
|
||||
for (Integer id : ids) {
|
||||
staffMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void updateById(Staff staff) {
|
||||
staffMapper.updateById(staff);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
public Staff selectById(Integer id) {
|
||||
return staffMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
public List<Staff> selectAll(Staff staff) {
|
||||
return staffMapper.selectAll(staff);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
public PageInfo<Staff> selectPage(Staff staff, Integer pageNum, Integer pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Staff> list = staffMapper.selectAll(staff);
|
||||
return PageInfo.of(list);
|
||||
}
|
||||
|
||||
public Account login(Account account) {
|
||||
Account dbStaff = staffMapper.selectByUsername(account.getUsername());
|
||||
if (ObjectUtil.isNull(dbStaff)) {
|
||||
throw new CustomException(ResultCodeEnum.USER_NOT_EXIST_ERROR);
|
||||
}
|
||||
if (dbStaff.getStatus()) { // 如果是禁用的员工,不允许登录
|
||||
throw new CustomException(ResultCodeEnum.NO_AUTH);
|
||||
}
|
||||
if (!account.getPassword().equals(dbStaff.getPassword())) {
|
||||
throw new CustomException(ResultCodeEnum.USER_ACCOUNT_ERROR);
|
||||
}
|
||||
// 生成token
|
||||
String tokenData = dbStaff.getId() + "-" + RoleEnum.STAFF.name();
|
||||
String token = TokenUtils.createToken(tokenData, dbStaff.getPassword());
|
||||
dbStaff.setToken(token);
|
||||
return dbStaff;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
public void register(Account account) {
|
||||
Staff staff = new Staff();
|
||||
BeanUtils.copyProperties(account, staff);
|
||||
this.add(staff);
|
||||
}
|
||||
|
||||
public void updatePassword(Account account) {
|
||||
Staff staff = staffMapper.selectByUsername(account.getUsername());
|
||||
if (ObjectUtil.isNull(staff)) {
|
||||
throw new CustomException(ResultCodeEnum.USER_NOT_EXIST_ERROR);
|
||||
}
|
||||
if (!account.getPassword().equals(staff.getPassword())) {
|
||||
throw new CustomException(ResultCodeEnum.PARAM_PASSWORD_ERROR);
|
||||
}
|
||||
staff.setPassword(account.getNewPassword());
|
||||
staffMapper.updateById(staff);
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package com.example.service;
|
||||
|
||||
import com.example.entity.Account;
|
||||
import com.example.entity.Goods;
|
||||
import com.example.entity.Stock;
|
||||
import com.example.mapper.StockMapper;
|
||||
import com.example.utils.TokenUtils;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品进货业务处理
|
||||
**/
|
||||
@Service
|
||||
public class StockService {
|
||||
|
||||
@Resource
|
||||
private StockMapper stockMapper;
|
||||
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@Transactional
|
||||
public void add(Stock stock) {
|
||||
Account currentUser = TokenUtils.getCurrentUser();
|
||||
stock.setUser(currentUser.getName());
|
||||
stock.setTotal(stock.getPrice() * stock.getNum());
|
||||
|
||||
// 查询进货的商品信息
|
||||
Goods goods = goodsService.selectById(stock.getGoodsId());
|
||||
goods.setNum(goods.getNum() + stock.getNum());
|
||||
goodsService.updateById(goods);
|
||||
|
||||
stockMapper.insert(stock);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void deleteById(Integer id) {
|
||||
stockMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
public void deleteBatch(List<Integer> ids) {
|
||||
for (Integer id : ids) {
|
||||
stockMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void updateById(Stock stock) {
|
||||
stock.setTotal(stock.getPrice() * stock.getNum());
|
||||
stockMapper.updateById(stock);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
public Stock selectById(Integer id) {
|
||||
return stockMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
public List<Stock> selectAll(Stock stock) {
|
||||
return stockMapper.selectAll(stock);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
public PageInfo<Stock> selectPage(Stock stock, Integer pageNum, Integer pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Stock> list = stockMapper.selectAll(stock);
|
||||
return PageInfo.of(list);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.example.service;
|
||||
|
||||
import com.example.entity.Supplier;
|
||||
import com.example.mapper.SupplierMapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 供应商表业务处理
|
||||
**/
|
||||
@Service
|
||||
public class SupplierService {
|
||||
|
||||
@Resource
|
||||
private SupplierMapper supplierMapper;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
public void add(Supplier supplier) {
|
||||
supplierMapper.insert(supplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void deleteById(Integer id) {
|
||||
supplierMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
public void deleteBatch(List<Integer> ids) {
|
||||
for (Integer id : ids) {
|
||||
supplierMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void updateById(Supplier supplier) {
|
||||
supplierMapper.updateById(supplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
public Supplier selectById(Integer id) {
|
||||
return supplierMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
public List<Supplier> selectAll(Supplier supplier) {
|
||||
return supplierMapper.selectAll(supplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
public PageInfo<Supplier> selectPage(Supplier supplier, Integer pageNum, Integer pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Supplier> list = supplierMapper.selectAll(supplier);
|
||||
return PageInfo.of(list);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.example.service;
|
||||
|
||||
import com.example.common.Result;
|
||||
import com.example.mapper.WarnMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class WarnService {
|
||||
@Autowired
|
||||
private WarnMapper warnMapper;
|
||||
public Result warning() {
|
||||
List<Map<String, Object>> much = warnMapper.much();
|
||||
List<Map<String, Object>> little = warnMapper.little();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("下列货物滞销:\n");
|
||||
int i = 1;
|
||||
for (Map<String, Object> map : much) {
|
||||
sb.append(i + "、" + map.get("name") + "(" + map.get("num") + ")\n");
|
||||
i++;
|
||||
}
|
||||
sb.append("\n");
|
||||
sb.append("下列货物缺货:\n");
|
||||
int j = 1;
|
||||
for (Map<String, Object> map : little) {
|
||||
sb.append(j + "、" + map.get("name") + "(" + map.get("num") + ")\n");
|
||||
j++;
|
||||
}
|
||||
return Result.success(sb.toString());
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.example.utils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public class IpUtils {
|
||||
|
||||
/**
|
||||
* 获取IP地址
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static String getIpAddr(HttpServletRequest request) {
|
||||
String ip = request.getHeader("x-forwarded-for");
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("X-Forwarded-For");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("X-Real-IP");
|
||||
}
|
||||
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : ip;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package com.example.utils;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.algorithms.Algorithm;
|
||||
import com.example.common.Constants;
|
||||
import com.example.common.enums.RoleEnum;
|
||||
import com.example.entity.Account;
|
||||
import com.example.service.AdminService;
|
||||
import com.example.service.StaffService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Token工具类
|
||||
*/
|
||||
@Component
|
||||
public class TokenUtils {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(TokenUtils.class);
|
||||
|
||||
private static AdminService staticAdminService;
|
||||
private static StaffService staticStaffService;
|
||||
|
||||
@Resource
|
||||
AdminService adminService;
|
||||
|
||||
@Resource
|
||||
StaffService staffService;
|
||||
|
||||
@PostConstruct
|
||||
public void setUserService() {
|
||||
staticAdminService = adminService;
|
||||
staticStaffService = staffService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成token
|
||||
*/
|
||||
public static String createToken(String data, String sign) {
|
||||
return JWT.create().withAudience(data) // 将 userId-role 保存到 token 里面,作为载荷
|
||||
.withExpiresAt(DateUtil.offsetHour(new Date(), 2)) // 2小时后token过期
|
||||
.sign(Algorithm.HMAC256(sign)); // 以 password 作为 token 的密钥
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录的用户信息
|
||||
*/
|
||||
public static Account getCurrentUser() {
|
||||
try {
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
String token = request.getHeader(Constants.TOKEN);
|
||||
if (ObjectUtil.isNotEmpty(token)) {
|
||||
String userRole = JWT.decode(token).getAudience().get(0);
|
||||
String userId = userRole.split("-")[0]; // 获取用户id
|
||||
String role = userRole.split("-")[1]; // 获取角色
|
||||
if (RoleEnum.ADMIN.name().equals(role)) {
|
||||
return staticAdminService.selectById(Integer.valueOf(userId));
|
||||
} else if (RoleEnum.STAFF.name().equals(role)) {
|
||||
return staticStaffService.selectById(Integer.valueOf(userId));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取当前用户信息出错", e);
|
||||
}
|
||||
return new Account(); // 返回空的账号对象
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,53 @@
|
||||
package com.example.utils;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class ValidateCodeCache {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ValidateCodeCache.class);
|
||||
|
||||
private static List<CodeCache> codeCache = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 设置验证码到缓存
|
||||
*/
|
||||
public static void setCache(String key, String code) {
|
||||
CodeCache cache = new CodeCache();
|
||||
cache.setKey(key);
|
||||
cache.setCode(code);
|
||||
cache.setTimestamp(System.currentTimeMillis());
|
||||
codeCache.add(cache);
|
||||
log.info("当前的验证码缓存: {}", codeCache);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证
|
||||
*/
|
||||
public static boolean validateCode(String key, String code) {
|
||||
return codeCache.stream().anyMatch(cache -> cache.getKey().equals(key) && cache.getCode().equalsIgnoreCase(code));
|
||||
}
|
||||
|
||||
@Scheduled(fixedRate = 60000) // 1分钟清理一次
|
||||
public void task() {
|
||||
log.info("=======================开始清理验证码缓存,验证码集合缓存长度: " + codeCache.size() + "=======================");
|
||||
List<CodeCache> codeList = codeCache.stream().filter(cache -> {
|
||||
long timestamp = cache.getTimestamp();
|
||||
long duration = System.currentTimeMillis() - timestamp;
|
||||
return duration > 120000; // 2分钟过期
|
||||
}).collect(Collectors.toList());
|
||||
codeCache.removeAll(codeList); // 清除过期的缓存
|
||||
if (codeCache.size() > 1024) { // 当缓存的长度太长 到达阈值的时候 清空所有缓存
|
||||
codeCache.clear();
|
||||
}
|
||||
log.info("=======================清理验证码缓存结束,验证码集合缓存长度: " + codeCache.size() + "=======================");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
server:
|
||||
port: 9090
|
||||
|
||||
# 数据库配置
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: root #你本地的数据库用户名
|
||||
password: 123456 #你本地的数据库密码
|
||||
url: jdbc:mysql://localhost:3306/psi_manager?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2b8&allowPublicKeyRetrieval=true
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 100MB
|
||||
max-request-size: 100MB
|
||||
|
||||
# 配置mybatis实体和xml映射
|
||||
mybatis:
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
type-aliases-package: com.example.entity
|
||||
configuration:
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
map-underscore-to-camel-case: true
|
||||
|
||||
# 分页
|
||||
pagehelper:
|
||||
helper-dialect: mysql
|
||||
reasonable: true
|
||||
support-methods-arguments: true
|
||||
params: count=countSql
|
||||
|
||||
ip: localhost
|
@ -0,0 +1,91 @@
|
||||
<?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.example.mapper.AdminMapper">
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,username,password,name,phone,email,avatar,role
|
||||
</sql>
|
||||
|
||||
<select id="selectAll" resultType="com.example.entity.Admin">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from admin
|
||||
<where>
|
||||
<if test="id != null"> and id= #{id}</if>
|
||||
<if test="username != null"> and username like concat('%', #{username}, '%')</if>
|
||||
<if test="password != null"> and password= #{password}</if>
|
||||
<if test="name != null"> and name= #{name}</if>
|
||||
<if test="phone != null"> and phone= #{phone}</if>
|
||||
<if test="email != null"> and email= #{email}</if>
|
||||
<if test="avatar != null"> and avatar= #{avatar}</if>
|
||||
<if test="role != null"> and role= #{role}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectById" resultType="com.example.entity.Admin">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from admin
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="deleteById">
|
||||
delete from admin
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
<insert id="insert" parameterType="com.example.entity.Admin" useGeneratedKeys="true">
|
||||
insert into admin
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="username != null">username,</if>
|
||||
<if test="password != null">password,</if>
|
||||
<if test="name != null">name,</if>
|
||||
<if test="phone != null">phone,</if>
|
||||
<if test="email != null">email,</if>
|
||||
<if test="avatar != null">avatar,</if>
|
||||
<if test="role != null">role,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="username != null">#{username},</if>
|
||||
<if test="password != null">#{password},</if>
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="phone != null">#{phone},</if>
|
||||
<if test="email != null">#{email},</if>
|
||||
<if test="avatar != null">#{avatar},</if>
|
||||
<if test="role != null">#{role},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateById" parameterType="com.example.entity.Admin">
|
||||
update admin
|
||||
<set>
|
||||
<if test="username != null">
|
||||
username = #{username},
|
||||
</if>
|
||||
<if test="password != null">
|
||||
password = #{password},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
name = #{name},
|
||||
</if>
|
||||
<if test="phone != null">
|
||||
phone = #{phone},
|
||||
</if>
|
||||
<if test="email != null">
|
||||
email = #{email},
|
||||
</if>
|
||||
<if test="avatar != null">
|
||||
avatar = #{avatar},
|
||||
</if>
|
||||
<if test="role != null">
|
||||
role = #{role},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,106 @@
|
||||
<?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.example.mapper.BackMapper">
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,supplier_id,goods_id,pay_type,time,user,num,unit,price,total,comment
|
||||
</sql>
|
||||
|
||||
<select id="selectAll" resultType="com.example.entity.Back">
|
||||
select
|
||||
back.*, supplier.name as supplierName, goods.name as goodsName
|
||||
from back
|
||||
left join supplier
|
||||
on back.supplier_id = supplier.id
|
||||
left join goods
|
||||
on back.goods_id = goods.id
|
||||
<where>
|
||||
<if test="id != null"> and back.id = #{id}</if>
|
||||
<if test="supplierName != null"> and supplier.name like concat('%', #{supplierName}, '%')</if>
|
||||
<if test="goodsName != null"> and goods.name like concat('%', #{goodsName}, '%')</if>
|
||||
</where>
|
||||
order by id desc
|
||||
</select>
|
||||
|
||||
<select id="selectById" resultType="com.example.entity.Back">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from back
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="deleteById">
|
||||
delete from back
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
<insert id="insert" parameterType="com.example.entity.Back" useGeneratedKeys="true">
|
||||
insert into back
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="supplierId != null">supplier_id,</if>
|
||||
<if test="goodsId != null">goods_id,</if>
|
||||
<if test="payType != null">pay_type,</if>
|
||||
<if test="time != null">time,</if>
|
||||
<if test="user != null">user,</if>
|
||||
<if test="num != null">num,</if>
|
||||
<if test="unit != null">unit,</if>
|
||||
<if test="price != null">price,</if>
|
||||
<if test="total != null">total,</if>
|
||||
<if test="comment != null">comment,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="supplierId != null">#{supplierId},</if>
|
||||
<if test="goodsId != null">#{goodsId},</if>
|
||||
<if test="payType != null">#{payType},</if>
|
||||
<if test="time != null">#{time},</if>
|
||||
<if test="user != null">#{user},</if>
|
||||
<if test="num != null">#{num},</if>
|
||||
<if test="unit != null">#{unit},</if>
|
||||
<if test="price != null">#{price},</if>
|
||||
<if test="total != null">#{total},</if>
|
||||
<if test="comment != null">#{comment},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateById" parameterType="com.example.entity.Back">
|
||||
update back
|
||||
<set>
|
||||
<if test="supplierId != null">
|
||||
supplier_id = #{supplierId},
|
||||
</if>
|
||||
<if test="goodsId != null">
|
||||
goods_id = #{goodsId},
|
||||
</if>
|
||||
<if test="payType != null">
|
||||
pay_type = #{payType},
|
||||
</if>
|
||||
<if test="time != null">
|
||||
time = #{time},
|
||||
</if>
|
||||
<if test="user != null">
|
||||
user = #{user},
|
||||
</if>
|
||||
<if test="num != null">
|
||||
num = #{num},
|
||||
</if>
|
||||
<if test="unit != null">
|
||||
unit = #{unit},
|
||||
</if>
|
||||
<if test="price != null">
|
||||
price = #{price},
|
||||
</if>
|
||||
<if test="total != null">
|
||||
total = #{total},
|
||||
</if>
|
||||
<if test="comment != null">
|
||||
comment = #{comment},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,110 @@
|
||||
<?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.example.mapper.CustomerMapper">
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,name,address,tel,email,zip_code,user,phone,bank,bank_card,status
|
||||
</sql>
|
||||
|
||||
<select id="selectAll" resultType="com.example.entity.Customer">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from customer
|
||||
<where>
|
||||
<if test="id != null"> and id = #{id}</if>
|
||||
<if test="name != null"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="address != null"> and address like concat('%', #{address}, '%')</if>
|
||||
<if test="tel != null"> and tel like concat('%', #{tel}, '%')</if>
|
||||
<if test="email != null"> and email like concat('%', #{email}, '%')</if>
|
||||
<if test="zipCode != null"> and zip_code like concat('%', #{zipCode}, '%')</if>
|
||||
<if test="user != null"> and user like concat('%', #{user}, '%')</if>
|
||||
<if test="phone != null"> and phone like concat('%', #{phone}, '%')</if>
|
||||
<if test="bank != null"> and bank like concat('%', #{bank}, '%')</if>
|
||||
<if test="bankCard != null"> and bank_card like concat('%', #{bankCard}, '%')</if>
|
||||
<if test="status != null"> and status like concat('%', #{status}, '%')</if>
|
||||
</where>
|
||||
order by id desc
|
||||
</select>
|
||||
|
||||
<select id="selectById" resultType="com.example.entity.Customer">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from customer
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="deleteById">
|
||||
delete from customer
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
<insert id="insert" parameterType="com.example.entity.Customer" useGeneratedKeys="true">
|
||||
insert into customer
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="name != null">name,</if>
|
||||
<if test="address != null">address,</if>
|
||||
<if test="tel != null">tel,</if>
|
||||
<if test="email != null">email,</if>
|
||||
<if test="zipCode != null">zip_code,</if>
|
||||
<if test="user != null">user,</if>
|
||||
<if test="phone != null">phone,</if>
|
||||
<if test="bank != null">bank,</if>
|
||||
<if test="bankCard != null">bank_card,</if>
|
||||
<if test="status != null">status,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="address != null">#{address},</if>
|
||||
<if test="tel != null">#{tel},</if>
|
||||
<if test="email != null">#{email},</if>
|
||||
<if test="zipCode != null">#{zipCode},</if>
|
||||
<if test="user != null">#{user},</if>
|
||||
<if test="phone != null">#{phone},</if>
|
||||
<if test="bank != null">#{bank},</if>
|
||||
<if test="bankCard != null">#{bankCard},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateById" parameterType="com.example.entity.Customer">
|
||||
update customer
|
||||
<set>
|
||||
<if test="name != null">
|
||||
name = #{name},
|
||||
</if>
|
||||
<if test="address != null">
|
||||
address = #{address},
|
||||
</if>
|
||||
<if test="tel != null">
|
||||
tel = #{tel},
|
||||
</if>
|
||||
<if test="email != null">
|
||||
email = #{email},
|
||||
</if>
|
||||
<if test="zipCode != null">
|
||||
zip_code = #{zipCode},
|
||||
</if>
|
||||
<if test="user != null">
|
||||
user = #{user},
|
||||
</if>
|
||||
<if test="phone != null">
|
||||
phone = #{phone},
|
||||
</if>
|
||||
<if test="bank != null">
|
||||
bank = #{bank},
|
||||
</if>
|
||||
<if test="bankCard != null">
|
||||
bank_card = #{bankCard},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|