登录页面接口对接
This commit is contained in:
@@ -72,12 +72,19 @@ public class HttpRequestHandler {
|
||||
public void handle() {
|
||||
ChannelHandlerContext context = HttpContextHolder.getChannelHandlerContext();
|
||||
HttpRequestWrapper requestParser = HttpContextHolder.getHttpRequestWrapper();
|
||||
HttpResponseWrapper responseWrapper = HttpContextHolder.getHttpResponseWrapper();
|
||||
log.info("HttpRequest method:{} url:{} query:{}", requestParser.getMethod().name(), requestParser.getUrl(), requestParser.getQueryParamMap());
|
||||
|
||||
try {
|
||||
String routePath = requestParser.getRoutePath();
|
||||
HttpMethod httpMethod = HttpMethod.of(requestParser.getMethod().name());
|
||||
if (httpMethod == HttpMethod.OPTIONS) {
|
||||
responseWrapper.headers().add("Access-Control-Allow-Origin", "*");
|
||||
responseWrapper.headers().add("Access-Control-Allow-Methods", "POST, GET, OPTIONS");
|
||||
responseWrapper.headers().add("Access-Control-Max-Age", "86400");
|
||||
responseWrapper.headers().add("Access-Control-Allow-Headers", "*");
|
||||
responseWrapper.headers().add("Access-Control-Allow-Credentials", "true");
|
||||
responseWrapper.headers().add("XDomainRequestAllowed", "1");
|
||||
HttpServerUtil.sendResponse(HttpResponseStatus.OK);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function login(data) {
|
||||
return request({
|
||||
url: '/login',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
@@ -36,6 +36,7 @@
|
||||
import { isvalidUsername } from '@/utils/validate'
|
||||
import LangSelect from '@/components/LangSelect'
|
||||
import SocialSign from './socialsignin'
|
||||
import { login } from '@/api/system'
|
||||
|
||||
export default {
|
||||
components: { LangSelect, SocialSign },
|
||||
@@ -58,7 +59,7 @@ export default {
|
||||
return {
|
||||
loginForm: {
|
||||
username: 'admin',
|
||||
password: '1111111'
|
||||
password: '123456'
|
||||
},
|
||||
loginRules: {
|
||||
username: [{ required: true, trigger: 'blur', validator: validateUsername }],
|
||||
@@ -81,11 +82,16 @@ export default {
|
||||
this.$refs.loginForm.validate(valid => {
|
||||
if (valid) {
|
||||
this.loading = true
|
||||
this.$store.dispatch('LoginByUsername', this.loginForm).then(() => {
|
||||
this.loading = false
|
||||
this.$router.push({ path: '/' })
|
||||
}).catch(() => {
|
||||
this.loading = false
|
||||
login({
|
||||
loginName: this.loginForm.username,
|
||||
loginPassword: this.loginForm.password
|
||||
}).then(() => {
|
||||
this.$store.dispatch('LoginByUsername', this.loginForm).then(() => {
|
||||
this.loading = false
|
||||
this.$router.push({ path: '/' })
|
||||
}).catch(() => {
|
||||
this.loading = false
|
||||
})
|
||||
})
|
||||
} else {
|
||||
console.log('error submit!!')
|
||||
|
||||
-2
@@ -29,9 +29,7 @@ import fun.asgc.neutrino.core.web.annotation.RequestMapping;
|
||||
import fun.asgc.neutrino.core.web.annotation.RestController;
|
||||
import fun.asgc.neutrino.proxy.server.base.rest.Authorization;
|
||||
import fun.asgc.neutrino.proxy.server.controller.req.LoginReq;
|
||||
import fun.asgc.neutrino.proxy.server.controller.req.LogoutReq;
|
||||
import fun.asgc.neutrino.proxy.server.controller.res.LoginRes;
|
||||
import fun.asgc.neutrino.proxy.server.controller.res.LogoutRes;
|
||||
import fun.asgc.neutrino.proxy.server.service.UserService;
|
||||
import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil;
|
||||
|
||||
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022 aoshiguchen
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package fun.asgc.neutrino.proxy.server.controller;
|
||||
|
||||
import fun.asgc.neutrino.core.annotation.Autowired;
|
||||
import fun.asgc.neutrino.core.web.annotation.GetMapping;
|
||||
import fun.asgc.neutrino.core.web.annotation.RequestMapping;
|
||||
import fun.asgc.neutrino.core.web.annotation.RestController;
|
||||
import fun.asgc.neutrino.core.web.context.HttpContextHolder;
|
||||
import fun.asgc.neutrino.proxy.server.service.Test1Service;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author: aoshiguchen
|
||||
* @date: 2022/7/17
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/test1")
|
||||
public class Test1Controller {
|
||||
@Autowired
|
||||
private Test1Service test1Service;
|
||||
|
||||
@GetMapping("hello")
|
||||
public String hello() {
|
||||
System.out.println("拿到参数 a = " + HttpContextHolder.getHttpRequestWrapper().getParameter("a"));
|
||||
if ("aaa".equals(HttpContextHolder.getHttpRequestWrapper().getParameter("a"))) {
|
||||
throw new RuntimeException("hhhh 异常了!");
|
||||
}
|
||||
return test1Service.hello();
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -48,6 +48,7 @@ public interface UserTokenMapper extends SqlMapper {
|
||||
/**
|
||||
* 根据token查询单条记录
|
||||
* @param token
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
@Select("select * from user_token where token = ? and expiration_time > ?")
|
||||
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package fun.asgc.neutrino.proxy.server.service;
|
||||
|
||||
import fun.asgc.neutrino.core.annotation.Component;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author: aoshiguchen
|
||||
* @date: 2022/7/20
|
||||
*/
|
||||
@Component
|
||||
public class Test1Service {
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat( "yyyy-MM-dd :HH:mm:ss");
|
||||
|
||||
public String hello() {
|
||||
return "hello 现在时间是:" + SDF.format(new Date());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user