From 2573b03aea800b7e88e8ccb0f0f187a42d7a3983 Mon Sep 17 00:00:00 2001 From: "DESKTOP-G8BCEP0\\HP" <2037158277@qq.com> Date: Fri, 6 Aug 2021 16:32:57 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=B7=BB=E5=8A=A0=E4=BA=86=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E6=9F=A5=E8=AF=A2=E6=89=80=E6=9C=89=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BF=A1=E6=81=AF=E7=9A=84=E6=8E=A5=E5=8F=A3=202?= =?UTF-8?q?=E3=80=81=E6=B7=BB=E5=8A=A0=E4=BA=86=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E5=90=AF=E7=94=A8=E5=92=8C=E7=A6=81=E7=94=A8=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E7=9A=84=E6=8E=A5=E5=8F=A3=203=E3=80=81?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E7=AE=A1=E7=90=86=E5=91=98=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E7=94=A8=E6=88=B7=E5=AF=86=E7=A0=81=E7=9A=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xkrs/controller/SysUserController.java | 14 ++++++++++++++ .../java/com/xkrs/service/SysUserService.java | 8 ++++++++ .../com/xkrs/service/impl/SysUserServiceImpl.java | 15 +++++++++++++++ src/main/java/com/xkrs/utils/DateTimeUtil.java | 8 ++++---- src/main/java/com/xkrs/utils/PhotoUtil.java | 6 +++--- src/main/resources/application.properties | 8 ++++---- 6 files changed, 48 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/xkrs/controller/SysUserController.java b/src/main/java/com/xkrs/controller/SysUserController.java index 8b9ae2c..f711c79 100644 --- a/src/main/java/com/xkrs/controller/SysUserController.java +++ b/src/main/java/com/xkrs/controller/SysUserController.java @@ -285,4 +285,18 @@ public class SysUserController { } } + /** + * 修改账号到期时间 + * @param map + * @param token + * @return + */ + @PostMapping("/updateOverTime") + @PreAuthorize("hasAnyAuthority('auth_administor')") + public String updateOverTime(@RequestBody Map map,@RequestHeader(value="Authorization") String token){ + Integer userId = (Integer) map.get("userId"); + String overTime = (String) map.get("overTime"); + return sysUserService.updateOverTime(userId,overTime); + } + } diff --git a/src/main/java/com/xkrs/service/SysUserService.java b/src/main/java/com/xkrs/service/SysUserService.java index 2380a3a..d8d0886 100644 --- a/src/main/java/com/xkrs/service/SysUserService.java +++ b/src/main/java/com/xkrs/service/SysUserService.java @@ -135,4 +135,12 @@ public interface SysUserService { * @return */ String updatePermanent(Integer userId); + + /** + * 修改账号到期时间 + * @param userId + * @param overTime + * @return + */ + String updateOverTime(Integer userId,String overTime); } diff --git a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java index 29ec83b..b85ef74 100644 --- a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java @@ -342,6 +342,7 @@ public class SysUserServiceImpl implements SysUserService { * @param userId * @return */ + @Transactional(rollbackFor=Exception.class) @Override public String updatePermanent(Integer userId) { Locale locale = LocaleContextHolder.getLocale(); @@ -349,4 +350,18 @@ public class SysUserServiceImpl implements SysUserService { return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功",locale); } + /** + * 修改账号到期时间 + * @param userId + * @param overTime + * @return + */ + @Transactional(rollbackFor=Exception.class) + @Override + public String updateOverTime(Integer userId, String overTime) { + Locale locale = LocaleContextHolder.getLocale(); + sysUserDao.updateOverTime(userId,overTime); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功",locale); + } + } diff --git a/src/main/java/com/xkrs/utils/DateTimeUtil.java b/src/main/java/com/xkrs/utils/DateTimeUtil.java index 78990c8..0e311e5 100644 --- a/src/main/java/com/xkrs/utils/DateTimeUtil.java +++ b/src/main/java/com/xkrs/utils/DateTimeUtil.java @@ -210,11 +210,11 @@ public class DateTimeUtil { } public static void main(String[] args) { - long l = dateToTimeMillis(LocalDateTime.now()); + LocalDateTime overTime = DateTimeUtil.stringToDateTime("2021-08-15 00:00:00"); + // 计算距离结束时间的天数作为token + Duration duration = Duration.between(LocalDateTime.now(), overTime); + long l = duration.toDays(); System.out.println(l); - LocalDateTime localDateTime = LocalDateTime.ofEpochSecond(1627616812, 0, ZoneOffset.ofHours(8)); - String s = timeMillisToString(1627616812); - System.out.println(s); } } diff --git a/src/main/java/com/xkrs/utils/PhotoUtil.java b/src/main/java/com/xkrs/utils/PhotoUtil.java index 021805a..10ff940 100644 --- a/src/main/java/com/xkrs/utils/PhotoUtil.java +++ b/src/main/java/com/xkrs/utils/PhotoUtil.java @@ -65,7 +65,7 @@ public class PhotoUtil { */ public static List uploadImage(MultipartFile[] files, String fireCode) throws IOException { //String uploadPath = "http://139.199.98.175:2099/forestTaskImage/"; - String uploadPath = "http://192.168.2.139/"; + String uploadPath = "http://118.24.27.47:2088/"; String newName = ""; String oldName = ""; List fireTaskPhotos = new ArrayList<>(); @@ -79,12 +79,12 @@ public class PhotoUtil { //uuid生成新的文件名 newName = UUID.randomUUID().toString() + suffix; //将图片保存到本地/usr/etc/images/Folder - File file1 = new File("/home/sxy/image/firePointImage/"); + File file1 = new File("/home/sxy/server/fire_point/firePointImage/"); //File file1 = new File("E:/file/work/image/"); if (!file1.exists()) { file1.mkdirs(); } - String path = "/home/sxy/image/firePointImage/" + newName; + String path = "/home/sxy/server/fire_point/firePointImage/" + newName; //String path = "E:/file/work/image/" + newName; String uploadPaths = "/firePointImage/" + newName; //实现上传 diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 4aab479..67f3fd5 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,9 +1,9 @@ -server.port = 6700 +server.port = 6801 ## 数据源配置 -spring.datasource.url = jdbc:postgresql://192.168.2.9:5432/fire_point -spring.datasource.userName = fire_point -spring.datasource.password = fire_point123 +spring.datasource.url = jdbc:postgresql://118.24.27.47:5432/fire_point +spring.datasource.userName = fire_manage +spring.datasource.password = fire456 spring.datasource.driverClassName = org.postgresql.Driver server.tomcat.uri-encoding=UTF-8