添加用户登录

This commit is contained in:
wuweida 2022-06-23 11:31:35 +08:00
parent 3ed870ce4e
commit 5a401ffd80
6 changed files with 79 additions and 2 deletions

View File

@ -22,7 +22,7 @@ import java.util.Map;
@RestController @RestController
@RequestMapping("api/project") @RequestMapping("api/project")
@Api(tags = "启迪中台") @Api(tags = "启迪中台")
public class QiDiController { public class QidiController {
@Autowired @Autowired
private SedimentTrailService sedimentTrailService; private SedimentTrailService sedimentTrailService;

View File

@ -0,0 +1,24 @@
package com.hisense.monitormanage.controller;
import com.hisense.monitormanage.entity.Result;
import com.hisense.monitormanage.service.UserLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("api/project")
public class UserLoginController {
@Autowired
private UserLoginService userLoginService;
@PostMapping("login")
public Result login(String username,String password){
String login = userLoginService.login(username, password);
Result success = Result.success(login);
return success;
}
}

View File

@ -0,0 +1,16 @@
package com.hisense.monitormanage.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("t_user_login")
public class UserLogin {
@TableId
private Integer id;
private String username;
private String password;
}

View File

@ -0,0 +1,12 @@
package com.hisense.monitormanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hisense.monitormanage.entity.UserLogin;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
public interface UserLoginMapper extends BaseMapper<UserLogin> {
@Select("select * from t_user_login")
UserLogin getUserByName();
}

View File

@ -589,7 +589,7 @@ public class MonitorService {
//获取当前时间和前一天的UTC时间 //获取当前时间和前一天的UTC时间
Map<String,Object> condition = new HashMap<>(); Map<String,Object> condition = new HashMap<>();
ZonedDateTime endUTC = ZonedDateTime.now(ZoneOffset.UTC); ZonedDateTime endUTC = ZonedDateTime.now(ZoneOffset.UTC);
ZonedDateTime startUTC = endUTC.minusDays(60); ZonedDateTime startUTC = endUTC.minusDays(30);
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmss'Z'"); DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmss'Z'");
condition.put("checkStatus",0); condition.put("checkStatus",0);
condition.put("startTime",dateTimeFormatter.format(startUTC)); condition.put("startTime",dateTimeFormatter.format(startUTC));
@ -626,6 +626,7 @@ public class MonitorService {
ResponseEntity<JSONObject> responseEntity2 = restTemplate.exchange(url, HttpMethod.POST, request2, JSONObject.class ); ResponseEntity<JSONObject> responseEntity2 = restTemplate.exchange(url, HttpMethod.POST, request2, JSONObject.class );
JSONObject entityBody2 = responseEntity2.getBody(); JSONObject entityBody2 = responseEntity2.getBody();
List<Map> results2 = (List<Map>) entityBody2.get("results"); List<Map> results2 = (List<Map>) entityBody2.get("results");
log.info("循环次数:" + i);
if(!results2.isEmpty()){ if(!results2.isEmpty()){
list.addAll(results); list.addAll(results);
} }

View File

@ -0,0 +1,24 @@
package com.hisense.monitormanage.service;
import cn.hutool.crypto.SecureUtil;
import com.hisense.monitormanage.entity.UserLogin;
import com.hisense.monitormanage.mapper.UserLoginMapper;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
@Log4j2
public class UserLoginService {
@Autowired
private UserLoginMapper userLoginMapper;
public String login(String username,String password){
UserLogin user = userLoginMapper.getUserByName();
if (user.getUsername().equals(username) && user.getPassword().equals(SecureUtil.md5(password))){
return "登录成功";
}
return "账号或密码错误";
}
}