Browse Source

解决时间格式LocalDateTime问题,统一恢复Date格式

master
牧羊人 4 years ago
parent
commit
e6584b1433
31 changed files with 537 additions and 207 deletions
  1. +12
    -0
      pom.xml
  2. +1
    -1
      src/main/java/com/taauav/admin/controller/SysDictController.java
  3. +1
    -1
      src/main/java/com/taauav/admin/controller/SysDictTypeController.java
  4. +10
    -2
      src/main/java/com/taauav/admin/entity/SysAdmin.java
  5. +4
    -3
      src/main/java/com/taauav/admin/service/impl/SysAdminServiceImpl.java
  6. +2
    -1
      src/main/java/com/taauav/admin/service/impl/SysAuthGroupServiceImpl.java
  7. +3
    -2
      src/main/java/com/taauav/admin/service/impl/SysConfigServiceImpl.java
  8. +3
    -2
      src/main/java/com/taauav/admin/service/impl/SysDepServiceImpl.java
  9. +3
    -2
      src/main/java/com/taauav/admin/service/impl/SysDictServiceImpl.java
  10. +3
    -2
      src/main/java/com/taauav/admin/service/impl/SysDictTypeServiceImpl.java
  11. +3
    -3
      src/main/java/com/taauav/admin/service/impl/SysLevelServiceImpl.java
  12. +5
    -4
      src/main/java/com/taauav/admin/service/impl/SysPositionServiceImpl.java
  13. +2
    -2
      src/main/java/com/taauav/admin/service/impl/TauvInspectDriverServiceImpl.java
  14. +9
    -14
      src/main/java/com/taauav/admin/service/impl/TauvInspectFileServiceImpl.java
  15. +2
    -2
      src/main/java/com/taauav/admin/service/impl/TauvInspectServiceImpl.java
  16. +3
    -2
      src/main/java/com/taauav/admin/service/impl/TauvQuestionOptionsServiceImpl.java
  17. +1
    -1
      src/main/java/com/taauav/admin/service/impl/TauvReportCheckServiceImpl.java
  18. +2
    -1
      src/main/java/com/taauav/admin/service/impl/TauvReportRemarkServiceImpl.java
  19. +3
    -2
      src/main/java/com/taauav/admin/service/impl/TauvReportServiceImpl.java
  20. +2
    -2
      src/main/java/com/taauav/common/domain/Entity.java
  21. +150
    -150
      src/main/java/com/taauav/common/job/GpsController.java
  22. +4
    -5
      src/main/java/com/taauav/common/service/impl/BaseServiceImpl.java
  23. +109
    -0
      src/main/java/com/taauav/common/util/JwtUtil.java
  24. +20
    -0
      src/main/java/com/taauav/front/controller/FrontBaseController.java
  25. +33
    -0
      src/main/java/com/taauav/front/controller/LsLoginController.java
  26. +21
    -0
      src/main/java/com/taauav/front/dto/LoginDto.java
  27. +1
    -1
      src/main/java/com/taauav/front/mapper/LsAdminMapper.java
  28. +1
    -1
      src/main/java/com/taauav/front/service/ILsAdminService.java
  29. +29
    -0
      src/main/java/com/taauav/front/service/ILsLoginService.java
  30. +1
    -1
      src/main/java/com/taauav/front/service/impl/LsAdminServiceImpl.java
  31. +94
    -0
      src/main/java/com/taauav/front/service/impl/LsLoginServiceImpl.java

+ 12
- 0
pom.xml View File

@@ -233,6 +233,18 @@
<artifactId>httpcore</artifactId>
<version>4.4.5</version>
</dependency>

<!-- JWT依赖 -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.4.0</version>
</dependency>
</dependencies>

<profiles>

+ 1
- 1
src/main/java/com/taauav/admin/controller/SysDictController.java View File

@@ -115,7 +115,7 @@ public class SysDictController {
return response.failure("对应数据不存在");
}
dict.setMark(0);
dict.setUpdateTime(LocalDateTime.now());
dict.setUpdateTime(DateUtil.now());
dict.setUpdateUser(ShiroUtils.getAdminId());
dictMapper.updateById(dict);
return response.success("操作成功");

+ 1
- 1
src/main/java/com/taauav/admin/controller/SysDictTypeController.java View File

@@ -104,7 +104,7 @@ public class SysDictTypeController {
return response.failure("字典分类信息不存在");
}
dictType.setMark(0);
dictType.setUpdateTime(LocalDateTime.now());
dictType.setUpdateTime(DateUtil.now());
dictType.setUpdateUser(ShiroUtils.getAdminId());
dictTypeMapper.updateById(dictType);
return response.success("操作成功");

+ 10
- 2
src/main/java/com/taauav/admin/entity/SysAdmin.java View File

@@ -15,6 +15,7 @@ import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Map;

@@ -97,6 +98,7 @@ public class SysAdmin extends Entity {
@Override
public String toString() {
return "SysAdmin{" +
"id=" + id +
", realname='" + realname + '\'' +
", username='" + username + '\'' +
", password='" + password + '\'' +
@@ -110,7 +112,13 @@ public class SysAdmin extends Entity {
", loginFailure=" + loginFailure +
", lastIp=" + lastIp +
", lastTime=" + lastTime +
", status=" + this.getStatus() +
", sort=" + sort +
", createUser=" + createUser +
", updateUser=" + updateUser +
", createTime=" + createTime +
", updateTime=" + updateTime +
", mark=" + mark +
'}';
}

@@ -168,7 +176,7 @@ public class SysAdmin extends Entity {
@TableField("create_time")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
private Date createTime;

/**
* 更新时间
@@ -176,7 +184,7 @@ public class SysAdmin extends Entity {
@TableField("update_time")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
private Date updateTime;

/**
* 有效标记

+ 4
- 3
src/main/java/com/taauav/admin/service/impl/SysAdminServiceImpl.java View File

@@ -17,6 +17,7 @@ import com.taauav.admin.service.ISysAuthGroupAccessService;
import com.taauav.admin.service.ISysAuthRuleService;
import com.taauav.admin.service.ISysCityService;
import com.taauav.common.service.impl.BaseServiceImpl;
import com.taauav.common.util.DateUtil;
import com.taauav.common.util.FunctionUtils;
import com.taauav.common.util.ShiroUtils;
import org.apache.shiro.SecurityUtils;
@@ -328,11 +329,11 @@ public class SysAdminServiceImpl extends BaseServiceImpl<SysAdminMapper, SysAdmi
}
if (id != null && id > 0) {
admin.setUpdateUser(ShiroUtils.getAdminId());
admin.setUpdateTime(LocalDateTime.now());
admin.setUpdateTime(DateUtil.now());
Integer res = sysAdminMapper.updateById(admin);
} else {
admin.setCreateUser(ShiroUtils.getAdminId());
admin.setCreateTime(LocalDateTime.now());
admin.setCreateTime(DateUtil.now());
Integer res = sysAdminMapper.insert(admin);
id = admin.getId();
}
@@ -398,7 +399,7 @@ public class SysAdminServiceImpl extends BaseServiceImpl<SysAdminMapper, SysAdmi
return response.failure("操作方法不存在");
}
admin.setUpdateUser(ShiroUtils.getAdminId());
admin.setUpdateTime(LocalDateTime.now());
admin.setUpdateTime(DateUtil.now());
boolean result = updateById(admin);
if (!result) {
return response.failure("操作失败");

+ 2
- 1
src/main/java/com/taauav/admin/service/impl/SysAuthGroupServiceImpl.java View File

@@ -12,6 +12,7 @@ import com.taauav.admin.service.ISysAuthGroupAccessService;
import com.taauav.admin.service.ISysAuthGroupService;
import com.taauav.admin.service.ISysConfigService;
import com.taauav.common.service.impl.BaseServiceImpl;
import com.taauav.common.util.DateUtil;
import com.taauav.common.util.FunctionUtils;
import com.taauav.common.util.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -169,7 +170,7 @@ public class SysAuthGroupServiceImpl extends BaseServiceImpl<SysAuthGroupMapper,
return response.failure("角色名称已经存在");
}
Integer adminId = ShiroUtils.getAdminId();
authGroup.setCreateTime(LocalDateTime.now());
authGroup.setCreateTime(DateUtil.now());
authGroup.setCreateUser(adminId);
Integer id = authGroupMapper.insert(authGroup);
return response.success("操作成功", id);

+ 3
- 2
src/main/java/com/taauav/admin/service/impl/SysConfigServiceImpl.java View File

@@ -8,6 +8,7 @@ import com.taauav.admin.entity.SysConfig;
import com.taauav.admin.mapper.SysConfigMapper;
import com.taauav.admin.service.ISysConfigService;
import com.taauav.common.service.impl.BaseServiceImpl;
import com.taauav.common.util.DateUtil;
import com.taauav.common.util.FunctionUtils;
import com.taauav.common.util.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -139,11 +140,11 @@ public class SysConfigServiceImpl extends BaseServiceImpl<SysConfigMapper, SysCo
}
}
if (map.getId() != null && map.getId() > 0) {
map.setUpdateTime(LocalDateTime.now());
map.setUpdateTime(DateUtil.now());
map.setUpdateUser(ShiroUtils.getAdminId());
updateById(map);
} else {
map.setCreateTime(LocalDateTime.now());
map.setCreateTime(DateUtil.now());
map.setCreateUser(ShiroUtils.getAdminId());
save(map);
}

+ 3
- 2
src/main/java/com/taauav/admin/service/impl/SysDepServiceImpl.java View File

@@ -9,6 +9,7 @@ import com.taauav.admin.mapper.SysDepMapper;
import com.taauav.admin.service.ISysAdminService;
import com.taauav.admin.service.ISysDepService;
import com.taauav.common.service.impl.BaseServiceImpl;
import com.taauav.common.util.DateUtil;
import com.taauav.common.util.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -220,11 +221,11 @@ public class SysDepServiceImpl extends BaseServiceImpl<SysDepMapper, SysDep> imp
Integer id = map.getId();
if (id == null) {
dep.setCreateUser(ShiroUtils.getAdminId());
dep.setCreateTime(LocalDateTime.now());
dep.setCreateTime(DateUtil.now());
} else {
dep.setId(id);
dep.setUpdateUser(ShiroUtils.getAdminId());
dep.setUpdateTime(LocalDateTime.now());
dep.setUpdateTime(DateUtil.now());
}
dep.setName(map.getName());
dep.setPid(map.getPid());

+ 3
- 2
src/main/java/com/taauav/admin/service/impl/SysDictServiceImpl.java View File

@@ -9,6 +9,7 @@ import com.taauav.admin.mapper.SysDictMapper;
import com.taauav.admin.service.ISysAdminService;
import com.taauav.admin.service.ISysDictService;
import com.taauav.common.service.impl.BaseServiceImpl;
import com.taauav.common.util.DateUtil;
import com.taauav.common.util.FunctionUtils;
import com.taauav.common.util.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -153,11 +154,11 @@ public class SysDictServiceImpl extends BaseServiceImpl<SysDictMapper, SysDict>
}
}
if (map.getId() != null && map.getId() > 0) {
map.setUpdateTime(LocalDateTime.now());
map.setUpdateTime(DateUtil.now());
map.setUpdateUser(ShiroUtils.getAdminId());
updateById(map);
} else {
map.setCreateTime(LocalDateTime.now());
map.setCreateTime(DateUtil.now());
map.setCreateUser(ShiroUtils.getAdminId());
save(map);
}

+ 3
- 2
src/main/java/com/taauav/admin/service/impl/SysDictTypeServiceImpl.java View File

@@ -9,6 +9,7 @@ import com.taauav.admin.mapper.SysDictTypeMapper;
import com.taauav.admin.service.ISysAdminService;
import com.taauav.admin.service.ISysDictTypeService;
import com.taauav.common.service.impl.BaseServiceImpl;
import com.taauav.common.util.DateUtil;
import com.taauav.common.util.FunctionUtils;
import com.taauav.common.util.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -126,11 +127,11 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeMapper, S
}
}
if (map.getId() != null && map.getId() > 0) {
map.setUpdateTime(LocalDateTime.now());
map.setUpdateTime(DateUtil.now());
map.setUpdateUser(ShiroUtils.getAdminId());
updateById(map);
} else {
map.setCreateTime(LocalDateTime.now());
map.setCreateTime(DateUtil.now());
map.setCreateUser(ShiroUtils.getAdminId());
save(map);
}

+ 3
- 3
src/main/java/com/taauav/admin/service/impl/SysLevelServiceImpl.java View File

@@ -11,6 +11,7 @@ import com.taauav.admin.mapper.SysAdminMapper;
import com.taauav.admin.mapper.SysLevelMapper;
import com.taauav.admin.service.ISysLevelService;
import com.taauav.common.service.impl.BaseServiceImpl;
import com.taauav.common.util.DateUtil;
import com.taauav.common.util.FunctionUtils;
import com.taauav.common.util.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -20,7 +21,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.time.LocalDateTime;
import java.util.*;

/**
@@ -226,7 +226,7 @@ public class SysLevelServiceImpl extends BaseServiceImpl<SysLevelMapper, SysLeve
return response.failure("职级数据不存在");
}
level.setUpdateUser(ShiroUtils.getAdminId());
level.setUpdateTime(LocalDateTime.now());
level.setUpdateTime(DateUtil.now());
level.setMark(0);
Boolean res = updateById(level);
if (res.equals(false)) {
@@ -259,7 +259,7 @@ public class SysLevelServiceImpl extends BaseServiceImpl<SysLevelMapper, SysLeve
}
info.setStatus(st);
info.setUpdateUser(ShiroUtils.getAdminId());
info.setUpdateTime(LocalDateTime.now());
info.setUpdateTime(DateUtil.now());
Boolean res = updateById(info);
if (res.equals(false)) {
return response.failure("操作失败");

+ 5
- 4
src/main/java/com/taauav/admin/service/impl/SysPositionServiceImpl.java View File

@@ -12,6 +12,7 @@ import com.taauav.admin.mapper.SysAdminMapper;
import com.taauav.admin.mapper.SysPositionMapper;
import com.taauav.admin.service.ISysPositionService;
import com.taauav.common.service.impl.BaseServiceImpl;
import com.taauav.common.util.DateUtil;
import com.taauav.common.util.FunctionUtils;
import com.taauav.common.util.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -166,12 +167,12 @@ public class SysPositionServiceImpl extends BaseServiceImpl<SysPositionMapper, S
Integer id = map.getId();
Boolean res;
if (id != null && id > 0) {
position.setUpdateTime(LocalDateTime.now());
position.setUpdateTime(DateUtil.now());
position.setUpdateUser(ShiroUtils.getAdminId());
position.setId(id);
res = updateById(position);
} else {
position.setCreateTime(LocalDateTime.now());
position.setCreateTime(DateUtil.now());
position.setCreateUser(ShiroUtils.getAdminId());
res = save(position);
}
@@ -254,7 +255,7 @@ public class SysPositionServiceImpl extends BaseServiceImpl<SysPositionMapper, S
}
position.setMark(0);
position.setUpdateUser(ShiroUtils.getAdminId());
position.setUpdateTime(LocalDateTime.now());
position.setUpdateTime(DateUtil.now());
Boolean res = updateById(position);
if (res.equals(false)) {
return response.failure("操作失败");
@@ -286,7 +287,7 @@ public class SysPositionServiceImpl extends BaseServiceImpl<SysPositionMapper, S
}
info.setStatus(st);
info.setUpdateUser(ShiroUtils.getAdminId());
info.setUpdateTime(LocalDateTime.now());
info.setUpdateTime(DateUtil.now());
Boolean res = updateById(info);
if (res.equals(false)) {
return response.failure("操作失败");

+ 2
- 2
src/main/java/com/taauav/admin/service/impl/TauvInspectDriverServiceImpl.java View File

@@ -9,6 +9,7 @@ import com.taauav.admin.mapper.TauvInspectDriverMapper;
import com.taauav.admin.mapper.TauvInspectMapper;
import com.taauav.admin.service.*;
import com.taauav.common.service.impl.BaseServiceImpl;
import com.taauav.common.util.DateUtil;
import com.taauav.common.util.FileUtil;
import com.taauav.common.util.FunctionUtils;
import com.taauav.common.util.ShiroUtils;
@@ -22,7 +23,6 @@ import org.springframework.util.StringUtils;
import java.io.File;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*;

/**
@@ -116,7 +116,7 @@ public class TauvInspectDriverServiceImpl extends BaseServiceImpl<TauvInspectDri
}
driver.setInspectId(inspectId);
driver.setInspectNo(inspect.getInspectNo());
driver.setCreateTime(LocalDateTime.now());
driver.setCreateTime(DateUtil.now());
driver.setCreateUser(ShiroUtils.getAdminId());
driver.setNum(i * 10);
i++;

+ 9
- 14
src/main/java/com/taauav/admin/service/impl/TauvInspectFileServiceImpl.java View File

@@ -1,7 +1,6 @@
package com.taauav.admin.service.impl;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -13,12 +12,8 @@ import com.taauav.admin.mapper.TauvInspectFileMapper;
import com.taauav.admin.mapper.TauvQuestionOptionsMapper;
import com.taauav.admin.mapper.TauvReportMapper;
import com.taauav.admin.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.taauav.common.service.impl.BaseServiceImpl;
import com.taauav.common.util.FileUtil;
import com.taauav.common.util.FunctionUtils;
import com.taauav.common.util.ImageUtil;
import com.taauav.common.util.ShiroUtils;
import com.taauav.common.util.*;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -86,8 +81,8 @@ public class TauvInspectFileServiceImpl extends BaseServiceImpl<TauvInspectFileM
String startTimeStr = inspectTimeArr[0];
String endTimeStr = inspectTimeArr[1];
if (!StringUtils.isEmpty(startTimeStr) && !StringUtils.isEmpty(endTimeStr)) {
DateTime startDate = DateUtil.parse(startTimeStr, format);
DateTime endDate = DateUtil.parse(endTimeStr, format);
Date startDate = DateUtil.parse(startTimeStr, format);
Date endDate = DateUtil.parse(endTimeStr, format);
Long startDateL = startDate.getTime() / 1000;
Long endDateL = endDate.getTime() / 1000;
Integer startTime = startDateL.intValue();
@@ -273,7 +268,7 @@ public class TauvInspectFileServiceImpl extends BaseServiceImpl<TauvInspectFileM
inspectFile.setSrc(filePath);
inspectFile.setOriginalImg(filePath);
inspectFile.setCreateUser(ShiroUtils.getAdminId());
inspectFile.setCreateTime(LocalDateTime.now());
inspectFile.setCreateTime(DateUtil.now());
inspectFile.setThumbImg(thumbImg);
inspectFileMapper.insert(inspectFile);
mapReturn.put("msg", "success");
@@ -372,7 +367,7 @@ public class TauvInspectFileServiceImpl extends BaseServiceImpl<TauvInspectFileM
inspectFile.setId(id);
inspectFile.setSrc(newFilePath);
inspectFile.setStatus(1);
inspectFile.setUpdateTime(LocalDateTime.now());
inspectFile.setUpdateTime(DateUtil.now());
inspectFile.setUpdateUser(ShiroUtils.getAdminId());
if (!StringUtils.isEmpty(questionId)) {
inspectFile.setQuestionId(Integer.valueOf(questionId));
@@ -403,7 +398,7 @@ public class TauvInspectFileServiceImpl extends BaseServiceImpl<TauvInspectFileM
inspectFile.setId(id);
inspectFile.setStatus(Integer.valueOf("2"));
inspectFile.setSrc("");
inspectFile.setUpdateTime(LocalDateTime.now());
inspectFile.setUpdateTime(DateUtil.now());
inspectFile.setUpdateUser(ShiroUtils.getAdminId());
inspectFileMapper.updateById(inspectFile);
return response.success("操作成功");
@@ -455,7 +450,7 @@ public class TauvInspectFileServiceImpl extends BaseServiceImpl<TauvInspectFileM
TauvInspectFile inspectFile = new TauvInspectFile();
inspectFile.setId(id);
inspectFile.setMark(0);
inspectFile.setUpdateTime(LocalDateTime.now());
inspectFile.setUpdateTime(DateUtil.now());
inspectFile.setUpdateUser(ShiroUtils.getAdminId());
inspectFileMapper.updateById(inspectFile);
return response.success("操作成功");
@@ -529,7 +524,7 @@ public class TauvInspectFileServiceImpl extends BaseServiceImpl<TauvInspectFileM
TauvInspectDriver inspectDriver = new TauvInspectDriver();
inspectDriver.setStatus(Integer.valueOf("5"));
inspectDriver.setId(id);
inspectDriver.setUpdateTime(LocalDateTime.now());
inspectDriver.setUpdateTime(DateUtil.now());
inspectDriver.setUpdateUser(ShiroUtils.getAdminId());
inspectDriverMapper.updateById(inspectDriver);
return response.success("操作成功");
@@ -752,7 +747,7 @@ public class TauvInspectFileServiceImpl extends BaseServiceImpl<TauvInspectFileM
report.setInspectEndTime(inspectDriver.getExecutionEndTime());
report.setFlightGroup(inspectDriver.getFlightGroup());
report.setDriverExam(inspectDriver.getDriverExam());
report.setCreateTime(LocalDateTime.now());
report.setCreateTime(DateUtil.now());
report.setCreateUser(ShiroUtils.getAdminId());
reportMapper.insert(report);
return response.success("操作成功");

+ 2
- 2
src/main/java/com/taauav/admin/service/impl/TauvInspectServiceImpl.java View File

@@ -6,13 +6,13 @@ import com.taauav.admin.mapper.TauvInspectMapper;
import com.taauav.admin.service.ITauvInspectDriverService;
import com.taauav.admin.service.ITauvInspectService;
import com.taauav.common.service.impl.BaseServiceImpl;
import com.taauav.common.util.DateUtil;
import com.taauav.common.util.FunctionUtils;
import com.taauav.common.util.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.time.LocalDateTime;

/**
* <p>
@@ -43,7 +43,7 @@ public class TauvInspectServiceImpl extends BaseServiceImpl<TauvInspectMapper, T
if (type.equals(2) && StringUtils.isEmpty(inspect.getExecutionCycle())) {
return response.failure("巡检周期不能为空");
}
inspect.setCreateTime(LocalDateTime.now());
inspect.setCreateTime(DateUtil.now());
inspect.setCreateUser(ShiroUtils.getAdminId());
inspectMapper.insert(inspect);
//生成巡检任务单号

+ 3
- 2
src/main/java/com/taauav/admin/service/impl/TauvQuestionOptionsServiceImpl.java View File

@@ -11,6 +11,7 @@ import com.taauav.admin.service.ISysAdminService;
import com.taauav.admin.service.ITauvQuestionOptionsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.taauav.common.service.impl.BaseServiceImpl;
import com.taauav.common.util.DateUtil;
import com.taauav.common.util.FunctionUtils;
import com.taauav.common.util.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -104,7 +105,7 @@ public class TauvQuestionOptionsServiceImpl extends BaseServiceImpl<TauvQuestion
*/
@Override
public Response edit(TauvQuestionOptions questionOptions) {
questionOptions.setUpdateTime(LocalDateTime.now());
questionOptions.setUpdateTime(DateUtil.now());
questionOptions.setUpdateUser(ShiroUtils.getAdminId());
questionOptionsMapper.updateById(questionOptions);
return response.success("添加成功");
@@ -118,7 +119,7 @@ public class TauvQuestionOptionsServiceImpl extends BaseServiceImpl<TauvQuestion
*/
@Override
public Response add(TauvQuestionOptions questionOptions) {
questionOptions.setCreateTime(LocalDateTime.now());
questionOptions.setCreateTime(DateUtil.now());
questionOptions.setCreateUser(ShiroUtils.getAdminId());
questionOptionsMapper.insert(questionOptions);
return response.success("添加成功");

+ 1
- 1
src/main/java/com/taauav/admin/service/impl/TauvReportCheckServiceImpl.java View File

@@ -44,7 +44,7 @@ public class TauvReportCheckServiceImpl extends BaseServiceImpl<TauvReportCheckM
@Override
public void addData(TauvReportCheck reportCheck) {
reportCheck.setCheckUser(ShiroUtils.getAdminId());
reportCheck.setCreateTime(LocalDateTime.now());
reportCheck.setCreateTime(DateUtil.now());
saveOrUpdate(reportCheck);
}
}

+ 2
- 1
src/main/java/com/taauav/admin/service/impl/TauvReportRemarkServiceImpl.java View File

@@ -5,6 +5,7 @@ import com.taauav.admin.entity.TauvReportRemark;
import com.taauav.admin.mapper.TauvReportRemarkMapper;
import com.taauav.admin.service.ITauvReportRemarkService;
import com.taauav.common.service.impl.BaseServiceImpl;
import com.taauav.common.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@@ -55,7 +56,7 @@ public class TauvReportRemarkServiceImpl extends BaseServiceImpl<TauvReportRemar

@Override
public void addData(TauvReportRemark reportRemark) {
reportRemark.setCreateTime(LocalDateTime.now());
reportRemark.setCreateTime(DateUtil.now());
tauvReportRemarkMapper.insert(reportRemark);
}
}

+ 3
- 2
src/main/java/com/taauav/admin/service/impl/TauvReportServiceImpl.java View File

@@ -11,6 +11,7 @@ import com.taauav.admin.mapper.TauvInspectDriverMapper;
import com.taauav.admin.mapper.TauvReportMapper;
import com.taauav.admin.service.*;
import com.taauav.common.service.impl.BaseServiceImpl;
import com.taauav.common.util.DateUtil;
import com.taauav.common.util.FunctionUtils;
import com.taauav.common.util.ShiroUtils;
import org.apache.commons.beanutils.ConvertUtils;
@@ -457,7 +458,7 @@ public class TauvReportServiceImpl extends BaseServiceImpl<TauvReportMapper, Tau
if (null != reportChecksList) {
for (TauvReportCheck reportCheck : reportChecksList) {
Integer checkUser = reportCheck.getCheckUser();
LocalDateTime createTime = reportCheck.getCreateTime();
Date createTime = reportCheck.getCreateTime();
reportCheck.setFormatCreateTime(createTime.toString());
// reportCheck.setFormatCreateTime(FunctionUtils.formatTime(createTime, "yyyy-MM-dd HH:mm:ss"));
SysAdmin adminInfo = iSysAdminService.getAdminInfo(checkUser);
@@ -648,7 +649,7 @@ public class TauvReportServiceImpl extends BaseServiceImpl<TauvReportMapper, Tau
tauvReport.setVideoUrl(videoUrl);
tauvReport.setImageUrl(imgUrl);
tauvReport.setReportUrl(reportUrl);
tauvReport.setUpdateTime(LocalDateTime.now());
tauvReport.setUpdateTime(DateUtil.now());
tauvReport.setUpdateUser(ShiroUtils.getAdminId());
tauvReport.setId(id);
reportMapper.updateById(tauvReport);

+ 2
- 2
src/main/java/com/taauav/common/domain/Entity.java View File

@@ -40,7 +40,7 @@ public class Entity extends BaseEntity {
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
private Date createTime;
/**
* 更新人
@@ -52,7 +52,7 @@ public class Entity extends BaseEntity {
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
private Date updateTime;
/**
* 有效标识:1有效 0删除

+ 150
- 150
src/main/java/com/taauav/common/job/GpsController.java View File

@@ -1,150 +1,150 @@
package com.taauav.common.job;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.drew.imaging.ImageMetadataReader;
import com.drew.metadata.Directory;
import com.drew.metadata.Metadata;
import com.drew.metadata.Tag;
import com.taauav.admin.entity.TauvInspectFile;
import com.taauav.admin.service.IMapService;
import com.taauav.admin.service.ITauvInspectFileService;
import com.taauav.common.util.FunctionUtils;
import com.taauav.common.util.RedisUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p>GPS </p>
*
* @author : dyg
* @date : 2019-12-17 15:12
**/
@Component
public class GpsController {
private Logger logger = LoggerFactory.getLogger(GpsController.class);
@Value("${file.uploadFolder}")
private String fileFolder;
@Autowired
@Qualifier("baiduMap")
private IMapService baiduMap;
@Autowired
@Qualifier("gaodeMap")
private IMapService gaodeMap;
@Autowired
private ITauvInspectFileService iTauvInspectFileService;
@Autowired
private RedisUtils redisUtils;
@Scheduled(fixedRate = 40000)
public void run() {
QueryWrapper<TauvInspectFile> wrapper = new QueryWrapper<>();
wrapper.eq("check_status",2);
wrapper.eq("mark", 1);
wrapper.isNotNull("original_img");
wrapper.last("limit 10");
List<TauvInspectFile> list = iTauvInspectFileService.list(wrapper);
if (list!= null) {
list.forEach(info->{
String file = fileFolder+info.getOriginalImg();
Map<String,String> gpsInfo = getGpsInfo(file);
String baiduAddress = "";
String gaodeAddress = "";
String gaodeLat = "";
String gaodeLon = "";
String baiduLat = "";
String baiduLon = "";
if (gpsInfo != null) {
String latitude = FunctionUtils.Dms2D(gpsInfo.get("GPS Latitude"));//纬度
String longitude = FunctionUtils.Dms2D(gpsInfo.get("GPS Longitude"));//经度
//获取百度坐标
List<Map<String,String>> gpsList = baiduMap.getGpsList(longitude+","+latitude);
if (!StringUtils.isEmpty(gpsList) && gpsList.size()>0) {
Map<String,String> gpsData = gpsList.get(0);
baiduLat = gpsData.get("lat");
baiduLon = gpsData.get("lon");
baiduAddress = baiduMap.getMapInfo(baiduLon,baiduLat);
}
//获取高德地图坐标
List<Map<String,String>> gpsGaodeList = gaodeMap.getGpsList(longitude+","+latitude);
if (!StringUtils.isEmpty(gpsGaodeList) && gpsGaodeList.size()>0) {
Map<String,String> gpsGdData = gpsGaodeList.get(0);
gaodeLat = gpsGdData.get("lat");
gaodeLon = gpsGdData.get("lon");
gaodeAddress = gaodeMap.getMapInfo(gaodeLon, gaodeLat);
}
TauvInspectFile inspectFile = new TauvInspectFile();
inspectFile.setId(info.getId());
if (StringUtils.isEmpty(latitude) || StringUtils.isEmpty(longitude)) {
inspectFile.setCheckStatus(Integer.valueOf("3"));
} else {
inspectFile.setLatitude(latitude);
inspectFile.setLongitude(longitude);
inspectFile.setBaiduLatitude(baiduLat);
inspectFile.setBaiduLongitude(baiduLon);
inspectFile.setBaiduAddress(baiduAddress);
inspectFile.setGaodeLatitude(gaodeLat);
inspectFile.setGaodeLongitude(gaodeLon);
inspectFile.setGaodeAddress(gaodeAddress);
inspectFile.setCheckStatus(Integer.valueOf("1"));
}
//iTauvInspectFileService.updateData(inspectFile);
iTauvInspectFileService.updateById(inspectFile);
}else {
TauvInspectFile inspectFile = new TauvInspectFile();
inspectFile.setId(info.getId());
inspectFile.setCheckStatus(Integer.valueOf("3"));
iTauvInspectFileService.updateById(inspectFile);
}
String key = "HK_InspectFile_info_"+info.getId();
redisUtils.del(key);
});
}
}
private Map<String,String> getGpsInfo(String fileStr)
{
File file = new File(fileStr);
if (!file.exists()) {
System.out.println("文件"+fileStr+"不存在");
return null;
}
Map<String,String> mapInfo = new HashMap<>();
try{
Metadata metadata = ImageMetadataReader.readMetadata(file);
for (Directory directory : metadata.getDirectories()) {
for (Tag tag : directory.getTags()) {
String name = tag.getTagName();
if (name.contains("GPS")) {
String value = tag.getDescription();
mapInfo.put(name,value);
}
}
}
}catch (Exception e) {
logger.info(e.getMessage());
return mapInfo;
}
return mapInfo;
}
}
//package com.taauav.common.job;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.drew.imaging.ImageMetadataReader;
//import com.drew.metadata.Directory;
//import com.drew.metadata.Metadata;
//import com.drew.metadata.Tag;
//import com.taauav.admin.entity.TauvInspectFile;
//import com.taauav.admin.service.IMapService;
//import com.taauav.admin.service.ITauvInspectFileService;
//import com.taauav.common.util.FunctionUtils;
//import com.taauav.common.util.RedisUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//import org.springframework.util.StringUtils;
//import java.io.File;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
///**
// * <p>GPS </p>
// *
// * @author : dyg
// * @date : 2019-12-17 15:12
// **/
//@Component
//public class GpsController {
//
// private Logger logger = LoggerFactory.getLogger(GpsController.class);
//
// @Value("${file.uploadFolder}")
// private String fileFolder;
//
// @Autowired
// @Qualifier("baiduMap")
// private IMapService baiduMap;
// @Autowired
// @Qualifier("gaodeMap")
// private IMapService gaodeMap;
// @Autowired
// private ITauvInspectFileService iTauvInspectFileService;
// @Autowired
// private RedisUtils redisUtils;
// @Scheduled(fixedRate = 40000)
// public void run() {
// QueryWrapper<TauvInspectFile> wrapper = new QueryWrapper<>();
// wrapper.eq("check_status",2);
// wrapper.eq("mark", 1);
// wrapper.isNotNull("original_img");
// wrapper.last("limit 10");
// List<TauvInspectFile> list = iTauvInspectFileService.list(wrapper);
// if (list!= null) {
// list.forEach(info->{
// String file = fileFolder+info.getOriginalImg();
// Map<String,String> gpsInfo = getGpsInfo(file);
// String baiduAddress = "";
// String gaodeAddress = "";
// String gaodeLat = "";
// String gaodeLon = "";
// String baiduLat = "";
// String baiduLon = "";
// if (gpsInfo != null) {
// String latitude = FunctionUtils.Dms2D(gpsInfo.get("GPS Latitude"));//纬度
// String longitude = FunctionUtils.Dms2D(gpsInfo.get("GPS Longitude"));//经度
// //获取百度坐标
// List<Map<String,String>> gpsList = baiduMap.getGpsList(longitude+","+latitude);
// if (!StringUtils.isEmpty(gpsList) && gpsList.size()>0) {
// Map<String,String> gpsData = gpsList.get(0);
// baiduLat = gpsData.get("lat");
// baiduLon = gpsData.get("lon");
// baiduAddress = baiduMap.getMapInfo(baiduLon,baiduLat);
// }
// //获取高德地图坐标
// List<Map<String,String>> gpsGaodeList = gaodeMap.getGpsList(longitude+","+latitude);
//
// if (!StringUtils.isEmpty(gpsGaodeList) && gpsGaodeList.size()>0) {
// Map<String,String> gpsGdData = gpsGaodeList.get(0);
// gaodeLat = gpsGdData.get("lat");
// gaodeLon = gpsGdData.get("lon");
// gaodeAddress = gaodeMap.getMapInfo(gaodeLon, gaodeLat);
// }
//
// TauvInspectFile inspectFile = new TauvInspectFile();
// inspectFile.setId(info.getId());
// if (StringUtils.isEmpty(latitude) || StringUtils.isEmpty(longitude)) {
// inspectFile.setCheckStatus(Integer.valueOf("3"));
// } else {
// inspectFile.setLatitude(latitude);
// inspectFile.setLongitude(longitude);
//
// inspectFile.setBaiduLatitude(baiduLat);
// inspectFile.setBaiduLongitude(baiduLon);
// inspectFile.setBaiduAddress(baiduAddress);
//
// inspectFile.setGaodeLatitude(gaodeLat);
// inspectFile.setGaodeLongitude(gaodeLon);
// inspectFile.setGaodeAddress(gaodeAddress);
//
// inspectFile.setCheckStatus(Integer.valueOf("1"));
//
// }
//
// //iTauvInspectFileService.updateData(inspectFile);
// iTauvInspectFileService.updateById(inspectFile);
// }else {
// TauvInspectFile inspectFile = new TauvInspectFile();
// inspectFile.setId(info.getId());
// inspectFile.setCheckStatus(Integer.valueOf("3"));
// iTauvInspectFileService.updateById(inspectFile);
// }
// String key = "HK_InspectFile_info_"+info.getId();
// redisUtils.del(key);
// });
// }
// }
//
// private Map<String,String> getGpsInfo(String fileStr)
// {
// File file = new File(fileStr);
// if (!file.exists()) {
// System.out.println("文件"+fileStr+"不存在");
// return null;
// }
// Map<String,String> mapInfo = new HashMap<>();
// try{
// Metadata metadata = ImageMetadataReader.readMetadata(file);
// for (Directory directory : metadata.getDirectories()) {
// for (Tag tag : directory.getTags()) {
// String name = tag.getTagName();
// if (name.contains("GPS")) {
// String value = tag.getDescription();
// mapInfo.put(name,value);
// }
// }
// }
// }catch (Exception e) {
// logger.info(e.getMessage());
// return mapInfo;
// }
//
//
// return mapInfo;
// }
//}

+ 4
- 5
src/main/java/com/taauav/common/service/impl/BaseServiceImpl.java View File

@@ -9,6 +9,7 @@ import com.taauav.common.core.mps.BaseQuery;
import com.taauav.common.domain.BaseEntity;
import com.taauav.common.domain.Entity;
import com.taauav.common.service.IBaseService;
import com.taauav.common.util.DateUtil;
import com.taauav.common.util.ShiroUtils;
import org.apache.ibatis.logging.Log;
import org.apache.ibatis.logging.LogFactory;
@@ -38,10 +39,9 @@ public class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> exte
@Override
public boolean addData(Entity entity) {
LocalDateTime localDateTime = LocalDateTime.now();
Integer adminId = ShiroUtils.getAdminId();
entity.setCreateTime(localDateTime);
entity.setUpdateTime(localDateTime);
entity.setCreateTime(DateUtil.now());
entity.setUpdateTime(DateUtil.now());
entity.setCreateUser(adminId);
entity.setUpdateUser(adminId);
entity.setMark(1);
@@ -50,9 +50,8 @@ public class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> exte
@Override
public boolean editData(Entity entity) {
LocalDateTime localDateTime = LocalDateTime.now();
Integer adminId = ShiroUtils.getAdminId();
entity.setUpdateTime(localDateTime);
entity.setUpdateTime(DateUtil.now());
entity.setUpdateUser(adminId);
return super.updateById((T) entity);
}

+ 109
- 0
src/main/java/com/taauav/common/util/JwtUtil.java View File

@@ -0,0 +1,109 @@
package com.taauav.common.util;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
* Jwt工具类
*/
public class JwtUtil {

/**
* token秘钥
*/
public static final String key = "KfxcZITlSBpzE2mgb3eJno";

/**
* token 过期时间(10个小时)
*/
public static final long ttlMillis = 3600_000_000L;

/**
* 用户登录成功后生成Jwt
* 使用Hs256算法 私匙使用用户密码
*
* @param userId 登录成功userId
* @return
*/
public static String createJWT(Integer userId) {
//指定签名的时候使用的签名算法,也就是header那部分,jjwt已经将这部分内容封装好了。
SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256;

//生成JWT的时间
long nowMillis = System.currentTimeMillis();
Date now = new Date(nowMillis);

//创建payload的私有声明(根据特定的业务需要添加,如果要拿这个做验证,一般是需要和jwt的接收方提前沟通好验证方式的)
Map<String, Object> claims = new HashMap<String, Object>();
claims.put("id", userId);

//生成签发人
String subject = "JWT";

//下面就是在为payload添加各种标准声明和私有声明了
//这里其实就是new一个JwtBuilder,设置jwt的body
JwtBuilder builder = Jwts.builder()
//如果有私有声明,一定要先设置这个自己创建的私有的声明,这个是给builder的claim赋值,一旦写在标准的声明赋值之后,就是覆盖了那些标准的声明的
.setClaims(claims)
//设置jti(JWT ID):是JWT的唯一标识,根据业务需要,这个可以设置为一个不重复的值,主要用来作为一次性token,从而回避重放攻击。
.setId(UUID.randomUUID().toString())
//iat: jwt的签发时间
.setIssuedAt(now)
//代表这个JWT的主体,即它的所有人,这个是一个json格式的字符串,可以存放什么userid,roldid之类的,作为什么用户的唯一标志。
.setSubject(subject)
//设置签名使用的签名算法和签名使用的秘钥
.signWith(signatureAlgorithm, key);
if (ttlMillis >= 0) {
long expMillis = nowMillis + ttlMillis;
Date exp = new Date(expMillis);
//设置过期时间
builder.setExpiration(exp);
}
return builder.compact();
}

/**
* Token的解密
*
* @param token 加密后的token
* @return
*/
public static Claims parseJWT(String token) {
//得到DefaultJwtParser
Claims claims = Jwts.parser()
//设置签名的秘钥
.setSigningKey(key)
//设置需要解析的jwt
.parseClaimsJws(token).getBody();
return claims;
}

/**
* 校验token
* 在这里可以使用官方的校验,我这里校验的是token中携带的密码于数据库一致的话就校验通过
*
* @param token
* @param userId
* @return
*/
public static Boolean isVerify(String token, Integer userId) {
//得到DefaultJwtParser
Claims claims = Jwts.parser()
//设置签名的秘钥
.setSigningKey(key)
//设置需要解析的jwt
.parseClaimsJws(token).getBody();

if (claims.get("id").equals(userId)) {
return true;
}
return false;
}
}

+ 20
- 0
src/main/java/com/taauav/front/controller/FrontBaseController.java View File

@@ -0,0 +1,20 @@
package com.taauav.front.controller;

import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;


/**
* 前台基类
*/
public class FrontBaseController {

/**
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
*/
@InitBinder
public void initBinder(WebDataBinder binder) {
System.out.println("初始化基类");
}

}

+ 33
- 0
src/main/java/com/taauav/front/controller/LsLoginController.java View File

@@ -0,0 +1,33 @@
package com.taauav.front.controller;

import com.taauav.common.bean.Response;
import com.taauav.front.dto.LoginDto;
import com.taauav.front.service.ILsLoginService;
import org.springframework.beans.factory.annotation.Autowired;
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;

@RestController
@RequestMapping("/front/login")
public class LsLoginController extends FrontBaseController {

@Autowired
private ILsLoginService loginService;

@Autowired
private Response response;

/**
* 系统登录
*
* @param loginDto 参数
* @return
*/
@PostMapping("/login")
public Response login(@RequestBody LoginDto loginDto) {
return loginService.login(loginDto);
}

}

+ 21
- 0
src/main/java/com/taauav/front/dto/LoginDto.java View File

@@ -0,0 +1,21 @@
package com.taauav.front.dto;

import lombok.Data;

/**
* 外部人员登录Dto
*/
@Data
public class LoginDto {

/**
* 登录用户名
*/
private String username;

/**
* 登录密码
*/
private String password;

}

+ 1
- 1
src/main/java/com/taauav/front/mapper/LsAdminMapper.java View File

@@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
* <p>
* 外人员表 Mapper 接口
* 外人员表 Mapper 接口
* </p>
*
* @author dyg

+ 1
- 1
src/main/java/com/taauav/front/service/ILsAdminService.java View File

@@ -9,7 +9,7 @@ import java.util.Map;

/**
* <p>
* 外人员表 服务类
* 外人员表 服务类
* </p>
*
* @author dyg

+ 29
- 0
src/main/java/com/taauav/front/service/ILsLoginService.java View File

@@ -0,0 +1,29 @@
package com.taauav.front.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.taauav.common.bean.Response;
import com.taauav.front.dto.LoginDto;
import com.taauav.front.entity.LsAdmin;
import com.taauav.front.query.LsAdminQuery;

import java.util.Map;

/**
* <p>
* 外部人员表 服务类
* </p>
*
* @author dyg
* @since 2020-04-01
*/
public interface ILsLoginService {

/**
* 系统登录
*
* @param loginDto 参数
* @return
*/
Response login(LoginDto loginDto);

}

+ 1
- 1
src/main/java/com/taauav/front/service/impl/LsAdminServiceImpl.java View File

@@ -25,7 +25,7 @@ import java.util.Map;

/**
* <p>
* 外人员表 服务实现类
* 外人员表 服务实现类
* </p>
*
* @author dyg

+ 94
- 0
src/main/java/com/taauav/front/service/impl/LsLoginServiceImpl.java View File

@@ -0,0 +1,94 @@
package com.taauav.front.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.taauav.admin.constant.CommonConstant;
import com.taauav.common.bean.Response;
import com.taauav.common.util.FunctionUtils;
import com.taauav.common.util.JwtUtil;
import com.taauav.common.util.ShiroUtils;
import com.taauav.common.util.StringUtils;
import com.taauav.front.dto.LoginDto;
import com.taauav.front.entity.LsAdmin;
import com.taauav.front.mapper.LsAdminMapper;
import com.taauav.front.query.LsAdminQuery;
import com.taauav.front.service.ILsAdminService;
import com.taauav.front.service.ILsLoginService;
import com.taauav.front.vo.LsAdminListVo;
import io.jsonwebtoken.Claims;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* <p>
* 外部人员表 服务实现类
* </p>
*
* @author dyg
* @since 2020-04-01
*/
@Service
public class LsLoginServiceImpl extends ServiceImpl<LsAdminMapper, LsAdmin> implements ILsLoginService {

@Autowired
private Response response;

@Autowired
private LsAdminMapper adminMapper;

/**
* 系统登录
*
* @param loginDto 参数
* @return
*/
@Override
public Response login(LoginDto loginDto) {
// 用户名校验
if (StringUtils.isEmpty(loginDto.getUsername())) {
return response.failure("登录用户名不能为空");
}
// 登录密码校验
if (StringUtils.isEmpty(loginDto.getPassword())) {
return response.failure("登录密码不能为空");
}
// 根据用户名获取用户信息
QueryWrapper<LsAdmin> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("username", loginDto.getUsername());
queryWrapper.eq("mark", 1);
LsAdmin adminInfo = adminMapper.selectOne(queryWrapper);
if (adminInfo == null) {
return response.failure("用户信息不存在");
}
// 校验密码是否正确
if (!adminInfo.getPassword().equals(FunctionUtils.password(loginDto.getPassword()))) {
return response.failure("登录密码不正确");
}
// 校验用户状态
if (adminInfo.getStatus() != 1) {
return response.failure("您已被禁用,请联系管理员");
}
// 生成token给前端
String token = JwtUtil.createJWT(1);
// System.out.print("token:" + token);
// Claims data = JwtUtil.parseJWT(token);
// System.out.println(data);
// System.out.println("用户ID:" + data.get("id"));
//
// Boolean isOK = JwtUtil.isVerify(token, 1);
// System.out.print(isOK);

Map<String, String> result = new HashMap<>();
result.put("token", token);
return response.success("登录成功", result);
}

}

Loading…
Cancel
Save