From 123ce171d2b8ca97d9f4011a33ce4e5e8d1cc339 Mon Sep 17 00:00:00 2001
From: panlinlin <648540858@qq.com>
Date: 星期二, 13 四月 2021 15:08:09 +0800
Subject: [PATCH] 使用数据库用户表代替配置文件

---
 src/main/java/com/genersoft/iot/vmp/web/AuthController.java |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/web/AuthController.java b/src/main/java/com/genersoft/iot/vmp/web/AuthController.java
index 702387c..1a02c1e 100644
--- a/src/main/java/com/genersoft/iot/vmp/web/AuthController.java
+++ b/src/main/java/com/genersoft/iot/vmp/web/AuthController.java
@@ -1,5 +1,8 @@
 package com.genersoft.iot.vmp.web;
 
+import com.genersoft.iot.vmp.service.IUserService;
+import com.genersoft.iot.vmp.storager.dao.dto.User;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
@@ -9,16 +12,13 @@
 @RequestMapping(value = "/auth")
 public class AuthController {
 
-    @Value("${auth.username}")
-    private String username;
-
-    @Value("${auth.password}")
-    private String password;
+    @Autowired
+    private IUserService userService;
 
     @RequestMapping("/login")
     public String devices(String name, String passwd){
-        if (!StringUtils.isEmpty(name) && name.equals(username)
-                && !StringUtils.isEmpty(passwd) && passwd.equals(password)) {
+        User user = userService.getUser(name, passwd);
+        if (user != null) {
             return "success";
         }else {
             return "fail";

--
Gitblit v1.8.0