接口修改

ExcelUtil删除了模板写法
session过期时间设为8小时
master
toesbieya 6 years ago
parent 2429454e70
commit 5d8cc0e0db
  1. 5
      java/pom.xml
  2. 2
      java/src/main/java/com/toesbieya/my/config/HttpSessionConfig.java
  3. 2
      java/src/main/java/com/toesbieya/my/config/WebConfig.java
  4. 54
      java/src/main/java/com/toesbieya/my/controller/AccountController.java
  5. 40
      java/src/main/java/com/toesbieya/my/controller/RecController.java
  6. 76
      java/src/main/java/com/toesbieya/my/controller/SysUserController.java
  7. 3
      java/src/main/java/com/toesbieya/my/controller/TestController.java
  8. 9
      java/src/main/java/com/toesbieya/my/module/redis/RedisModule.java
  9. 2
      java/src/main/java/com/toesbieya/my/service/BizStockService.java
  10. 23
      java/src/main/java/com/toesbieya/my/utils/ExcelUtil.java
  11. 5
      java/src/main/java/com/toesbieya/my/utils/FileUtil.java
  12. 26
      java/src/main/resources/application.yml
  13. 0
      java/src/main/resources/mapper/BizDocumentHistory.xml
  14. 0
      java/src/main/resources/mapper/BizPurchaseInbound.xml
  15. 0
      java/src/main/resources/mapper/BizPurchaseOrder.xml
  16. 0
      java/src/main/resources/mapper/BizSellOrder.xml
  17. 0
      java/src/main/resources/mapper/BizSellOutbound.xml
  18. 0
      java/src/main/resources/mapper/BizStock.xml
  19. 0
      java/src/main/resources/mapper/Msg.xml
  20. 0
      java/src/main/resources/mapper/RecAttachment.xml
  21. 0
      java/src/main/resources/mapper/RecLoginHistory.xml
  22. 0
      java/src/main/resources/mapper/RecUserAction.xml
  23. 0
      java/src/main/resources/mapper/Statistic.xml
  24. 0
      java/src/main/resources/mapper/SysCategory.xml
  25. 0
      java/src/main/resources/mapper/SysCustomer.xml
  26. 0
      java/src/main/resources/mapper/SysDepartment.xml
  27. 0
      java/src/main/resources/mapper/SysResource.xml
  28. 0
      java/src/main/resources/mapper/SysRole.xml
  29. 0
      java/src/main/resources/mapper/SysSupplier.xml
  30. 0
      java/src/main/resources/mapper/SysUser.xml

@ -49,6 +49,11 @@
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>

@ -16,7 +16,7 @@ import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
@Configuration
@EnableRedisHttpSession()
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 28800)
public class HttpSessionConfig {
@Bean
public HttpSessionListener httpSessionEventPublisher() {

@ -54,7 +54,7 @@ public class WebConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
String[] exclude = {"/test/**", "/login", "/logout", "/register", "/error", "/system/user/checkName"};
String[] exclude = {"/test/**", "/account/login", "/account/logout", "/account/register", "/account/checkName", "/error"};
addInterceptor(registry, new SecurityInterceptor(), exclude);
addInterceptor(registry, new RateControlInterceptor(), exclude);
addInterceptor(registry, new UserActionInterceptor(), exclude);

@ -2,24 +2,26 @@ package com.toesbieya.my.controller;
import com.toesbieya.my.enumeration.RecLoginHistoryEnum;
import com.toesbieya.my.model.entity.SysUser;
import com.toesbieya.my.model.vo.update.UserUpdatePwd;
import com.toesbieya.my.service.RecService;
import com.toesbieya.my.service.SysUserService;
import com.toesbieya.my.utils.IpUtil;
import com.toesbieya.my.utils.Result;
import com.toesbieya.my.utils.Util;
import org.springframework.util.DigestUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Map;
@RestController
public class LoginController {
@RequestMapping("account")
public class AccountController {
@Resource
private SysUserService userService;
@ -59,6 +61,39 @@ public class LoginController {
return Result.success("登出成功");
}
@PostMapping("updatePwd")
public Result updatePwd(@RequestBody UserUpdatePwd vo) {
SysUser user = Util.getUser();
vo.setId(user.getId());
String errMsg = validateUpdatePwdParam(vo);
if (errMsg != null) return Result.fail(errMsg);
vo.setOld_pwd(DigestUtils.md5DigestAsHex(vo.getOld_pwd().getBytes()));
vo.setNew_pwd(DigestUtils.md5DigestAsHex(vo.getNew_pwd().getBytes()));
return userService.updatePwd(vo);
}
@GetMapping("updateAvatar")
public Result updateAvatar(@RequestParam String key) throws UnsupportedEncodingException {
if (StringUtils.isEmpty(key)) return Result.fail("参数错误");
return userService.updateAvatar(Util.getUser(), URLDecoder.decode(key, "utf-8"), Util.getSession());
}
@GetMapping("validate")
public Result validate(@RequestParam String pwd) {
SysUser current = Util.getUser();
if (!pwd.equals(current.getPwd())) return Result.fail("校验失败");
return Result.success("校验通过");
}
@GetMapping("checkName")
public Result checkName(@RequestParam String name) {
return Result.success(userService.checkName(name) ? null : "该用户名已存在");
}
private String validate(String username, String password) {
if ((StringUtils.isEmpty(username)
|| StringUtils.isEmpty(password)
@ -68,4 +103,13 @@ public class LoginController {
}
return null;
}
private String validateUpdatePwdParam(UserUpdatePwd vo) {
if (vo.getId() == null) return "修改失败,参数错误";
if (StringUtils.isEmpty(vo.getOld_pwd())) return "修改失败,原密码不能为空";
if (StringUtils.isEmpty(vo.getNew_pwd())) return "修改失败,新密码不能为空";
if (vo.getOld_pwd().equals(vo.getNew_pwd())) return "修改失败,新密码不得与旧密码相同";
if (vo.getNew_pwd().length() < 6 || vo.getNew_pwd().length() > 32) return "修改失败,密码长度为6-32位";
return null;
}
}

@ -0,0 +1,40 @@
package com.toesbieya.my.controller;
import com.toesbieya.my.model.entity.SysUser;
import com.toesbieya.my.model.vo.search.LoginHistorySearch;
import com.toesbieya.my.model.vo.search.UserActionSearch;
import com.toesbieya.my.service.RecService;
import com.toesbieya.my.utils.DateUtil;
import com.toesbieya.my.utils.Result;
import com.toesbieya.my.utils.Util;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@RequestMapping("record")
public class RecController {
@Resource
private RecService recService;
@PostMapping("searchLoginHistory")
public Result searchLoginHistory(@RequestBody LoginHistorySearch vo) {
SysUser user = Util.getUser();
vo.setUid(user.getId());
vo.setStartTime(DateUtil.getTimestampBeforeNow(7));
return Result.success(recService.searchLoginHistory(vo));
}
@PostMapping("searchUserAction")
public Result searchUserAction(@RequestBody UserActionSearch vo) {
SysUser user = Util.getUser();
vo.setUid(user.getId());
vo.setStartTime(DateUtil.getTimestampBeforeNow(7));
return Result.success(recService.searchUserAction(vo));
}
}

@ -2,23 +2,17 @@ package com.toesbieya.my.controller;
import com.toesbieya.my.model.entity.RecUserAction;
import com.toesbieya.my.model.entity.SysUser;
import com.toesbieya.my.model.vo.search.LoginHistorySearch;
import com.toesbieya.my.model.vo.search.UserActionSearch;
import com.toesbieya.my.model.vo.search.UserSearch;
import com.toesbieya.my.model.vo.update.UserUpdatePwd;
import com.toesbieya.my.service.RecService;
import com.toesbieya.my.service.SysUserService;
import com.toesbieya.my.utils.DateUtil;
import com.toesbieya.my.utils.Result;
import com.toesbieya.my.utils.ThreadUtil;
import com.toesbieya.my.utils.Util;
import org.springframework.util.DigestUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;
import java.util.stream.Collectors;
@ -27,32 +21,12 @@ import java.util.stream.Collectors;
public class SysUserController {
@Resource
private SysUserService userService;
@Resource
private RecService recService;
@PostMapping("search")
public Result search(@RequestBody UserSearch vo) {
return Result.success(userService.search(vo));
}
@PostMapping("getLoginHistory")
public Result getLoginHistory(@RequestBody LoginHistorySearch vo) {
SysUser user = Util.getUser();
vo.setUid(user.getId());
vo.setStartTime(DateUtil.getTimestampBeforeNow(7));
return Result.success(recService.searchLoginHistory(vo));
}
@PostMapping("getUserAction")
public Result getUserAction(@RequestBody UserActionSearch vo) {
SysUser user = Util.getUser();
vo.setUid(user.getId());
vo.setStartTime(DateUtil.getTimestampBeforeNow(7));
return Result.success(recService.searchUserAction(vo));
}
@PostMapping("add")
public Result add(@RequestBody SysUser user) {
String errMsg = validateUserCreateParam(user);
@ -92,20 +66,6 @@ public class SysUserController {
return userService.kick(users);
}
@PostMapping("updatePwd")
public Result updatePwd(@RequestBody UserUpdatePwd vo) {
SysUser user = Util.getUser();
vo.setId(user.getId());
String errMsg = validateUpdatePwdParam(vo);
if (errMsg != null) return Result.fail(errMsg);
vo.setOld_pwd(DigestUtils.md5DigestAsHex(vo.getOld_pwd().getBytes()));
vo.setNew_pwd(DigestUtils.md5DigestAsHex(vo.getNew_pwd().getBytes()));
return userService.updatePwd(vo);
}
@PostMapping("resetPwd")
public Result resetPwd(@RequestBody SysUser user) {
if (user.getId() == null || StringUtils.isEmpty(user.getName())) {
@ -114,25 +74,6 @@ public class SysUserController {
return userService.resetPwd(user);
}
@GetMapping("updateAvatar")
public Result updateAvatar(@RequestParam String key) throws UnsupportedEncodingException {
if (StringUtils.isEmpty(key)) return Result.fail("参数错误");
return userService.updateAvatar(Util.getUser(), URLDecoder.decode(key, "utf-8"), Util.getSession());
}
@GetMapping("validate")
public Result validate(@RequestParam String pwd) {
SysUser current = Util.getUser();
if (!pwd.equals(current.getPwd())) return Result.fail("校验失败");
return Result.success("校验通过");
}
@GetMapping("checkName")
public Result checkName(@RequestParam String name) {
return Result.success(userService.checkName(name) ? null : "该用户名已存在");
}
private String validateUserCreateParam(SysUser user) {
if (user.getId() != null) return "创建失败,参数错误";
if (StringUtils.isEmpty(user.getName())) return "创建失败,用户名称不能为空";
@ -147,13 +88,4 @@ public class SysUserController {
if (user.getStatus() == null) return "修改失败,用户状态不能为空";
return null;
}
private String validateUpdatePwdParam(UserUpdatePwd vo) {
if (vo.getId() == null) return "修改失败,参数错误";
if (StringUtils.isEmpty(vo.getOld_pwd())) return "修改失败,原密码不能为空";
if (StringUtils.isEmpty(vo.getNew_pwd())) return "修改失败,新密码不能为空";
if (vo.getOld_pwd().equals(vo.getNew_pwd())) return "修改失败,新密码不得与旧密码相同";
if (vo.getNew_pwd().length() < 6 || vo.getNew_pwd().length() > 32) return "修改失败,密码长度为6-32位";
return null;
}
}

@ -37,12 +37,13 @@ public class TestController {
@PostMapping("upload")
@ResponseBody
public Result upload(MultipartFile file, @RequestParam String extraParam1, @RequestParam String extraParam2) throws IOException {
public Result upload(MultipartFile file, @RequestParam(required = false) String extraParam1, @RequestParam(required = false) String extraParam2) throws IOException {
/*System.out.println("extraParam1:" + extraParam1);
System.out.println("extraParam2:" + extraParam2);
System.out.println("文件名称:" + file.getOriginalFilename());
String tempPath = "C:/static/" + file.getOriginalFilename();
file.transferTo(Paths.get(tempPath));*/
System.out.println("文件名称:" + file.getOriginalFilename());
return Result.success("ok");
}
}

@ -3,7 +3,7 @@ package com.toesbieya.my.module.redis;
import com.toesbieya.my.utils.DateUtil;
import com.toesbieya.my.utils.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.DependsOn;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@ -17,10 +17,10 @@ import java.util.Map;
@Component
@Slf4j
@DependsOn("redisUtil")
public class RedisModule {
public static final String DOCUMENTS_KEY = "documentsID";
public static final String[] DOCUMENTS_TYPE = {"CGDD", "CGRK", "CGTH", "XSDD", "XSCK", "XSTH"};
private RedisUtil redisUtil;
@PostConstruct
public void init() {
@ -89,9 +89,4 @@ public class RedisModule {
log.error("定时更新单据ID失败", e);
}
}
@Autowired
public void setRedisUtil(RedisUtil redisUtil) {
this.redisUtil = redisUtil;
}
}

@ -40,6 +40,6 @@ public class BizStockService {
public void export(StockSearch vo, HttpServletResponse response) throws Exception {
List<StockExport> list = stockMapper.export(vo);
ExcelUtil.exportWithMerge(list, response, "库存导出", mergeOptions);
ExcelUtil.export(list, response, "库存导出", mergeOptions);
}
}

@ -23,7 +23,6 @@ import java.util.Arrays;
import java.util.List;
public class ExcelUtil {
public static final String EXCEL_TEMPLATE_DIR = (String) YmlUtil.get("file.template");
private static final WriteCellStyle defaultCellStyle = new WriteCellStyle();
static {
@ -35,22 +34,13 @@ public class ExcelUtil {
List list,
HttpServletResponse response,
String filename) throws Exception {
export(list, response, filename, null, null);
}
public static void exportWithMerge(
List list,
HttpServletResponse response,
String filename,
CommonMergeOptions mergeOptions) throws Exception {
export(list, response, filename, null, mergeOptions);
export(list, response, filename, null);
}
public static void export(
List list,
HttpServletResponse response,
String filename,
String template,
CommonMergeOptions mergeOptions) throws Exception {
String name = URLEncoder.encode(filename, "utf-8") + ".xlsx";
response.setHeader("Content-disposition", "attachment;filename=" + name);
@ -70,19 +60,16 @@ public class ExcelUtil {
Class clazz = list.get(0).getClass();
ExcelWriterBuilder builder = EasyExcel.write(response.getOutputStream(), clazz);
ExcelWriterBuilder writerBuilder = EasyExcel.write(response.getOutputStream(), clazz);
builder.registerWriteHandler(getDefaultStyle());
writerBuilder.registerWriteHandler(getDefaultStyle());
if (!StringUtils.isEmpty(template)) {
builder.needHead(false).withTemplate(EXCEL_TEMPLATE_DIR + template + ".xlsx");
}
if (mergeOptions != null) {
CommonMerge commonMerge = new CommonMerge(list, clazz, mergeOptions);
builder.registerWriteHandler(commonMerge);
writerBuilder.registerWriteHandler(commonMerge);
}
builder.sheet().doWrite(list);
writerBuilder.sheet(0, "Sheet1").doWrite(list);
}
private static AbstractVerticalCellStyleStrategy getDefaultStyle() {

@ -1,5 +0,0 @@
package com.toesbieya.my.utils;
public class FileUtil {
public static final String FILE_TEMP_DIR = (String) YmlUtil.get("file.temp");
}

@ -7,20 +7,20 @@ server:
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/your repo?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true
username: your name
password: your password
url: jdbc:mysql://localhost:3306/repo?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true
username: username
password: password
redis:
host: localhost
port: 6379
password: password
timeout: 3000
jedis:
lettuce:
pool:
max-idle: 500
min-idle: 50
max-active: 2000
max-wait: 1000
password: your password,if no use password,remove this node
session:
store-type: redis
servlet:
@ -31,7 +31,8 @@ spring:
max-request-size: 10MB
mybatis:
mapper-locations: classpath:mapping/*.xml
mapper-locations:
- classpath*:/mapper/**/*.xml
pagehelper:
helperDialect: mysql
@ -40,6 +41,7 @@ pagehelper:
params: count=countSql
socket:
#hostname: 172.24.52.184
hostname: localhost
port: 12580
max-frame-payload: 1048576
@ -48,16 +50,10 @@ socket:
logout: logout
new-message: new-message
file:
#临时文件保存目录
temp: C:\static\
#excel模板目录
template: C:\static\template\
qiniu:
access-key: your key
secret-key: your key
bucket: your bucket
access-key: access-key
secret-key: secret-key
bucket: bucket
#七牛的临时上传凭证的有效期,单位秒
token-expires: 3600
#七牛的临时上传凭证的redis键名

Loading…
Cancel
Save