liuxinxin 1 yıl önce
ebeveyn
işleme
ecc5f49124
4 değiştirilmiş dosya ile 73 ekleme ve 13 silme
  1. +0
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/fiscal/controller/CompanyFiscalCodeController.java
  2. +2
    -5
      pmapi/src/main/java/com/ningdatech/pmapi/organization/controller/DingOrganizationController.java
  3. +3
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/user/controller/NdUserInfoController.java
  4. +68
    -4
      pmapi/src/main/java/com/ningdatech/pmapi/user/controller/UserAuthController.java

+ 0
- 1
pmapi/src/main/java/com/ningdatech/pmapi/fiscal/controller/CompanyFiscalCodeController.java Dosyayı Görüntüle

@@ -33,5 +33,4 @@ public class CompanyFiscalCodeController {
companyFiscalCodeManage.fiscalCodeConfigure(reqCompanyFiscalCodeAndSealSnPO);
}


}

+ 2
- 5
pmapi/src/main/java/com/ningdatech/pmapi/organization/controller/DingOrganizationController.java Dosyayı Görüntüle

@@ -2,14 +2,13 @@ package com.ningdatech.pmapi.organization.controller;


import io.swagger.annotations.ApiModelProperty;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;

/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author Lierbao
@@ -25,6 +24,4 @@ public class DingOrganizationController {

}



}

+ 3
- 3
pmapi/src/main/java/com/ningdatech/pmapi/user/controller/NdUserInfoController.java Dosyayı Görüntüle

@@ -1,13 +1,12 @@
package com.ningdatech.pmapi.user.controller;


import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author Lierbao
@@ -17,4 +16,5 @@ import org.springframework.stereotype.Controller;
@RequestMapping("/pmapi.user/nd-user-info")
public class NdUserInfoController {


}

+ 68
- 4
pmapi/src/main/java/com/ningdatech/pmapi/user/controller/UserAuthController.java Dosyayı Görüntüle

@@ -1,9 +1,23 @@
package com.ningdatech.pmapi.user.controller;


import org.springframework.web.bind.annotation.RequestMapping;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ningdatech.basic.util.StrPool;
import com.ningdatech.pmapi.common.constant.BizConst;
import com.ningdatech.pmapi.user.security.auth.constants.SessionTimeConstant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
* <p>
@@ -13,8 +27,58 @@ import org.springframework.stereotype.Controller;
* @author Liuxinxin
* @since 2023-01-04
*/
@Controller
@RequestMapping("/pmapi.user/user-auth")

@RestController
@RequestMapping("/api/v1/user/auth")
@Api(tags = {"用户鉴权-相关接口"})
@RequiredArgsConstructor
public class UserAuthController {

private final ObjectMapper objectMapper;

@PostMapping(value = "/login/password", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
@ApiOperation(value = "账号密码的登陆方式")
@ApiImplicitParams({
@ApiImplicitParam(name = "username", value = "用户名", required = true, paramType = "form", dataType = "String"),
@ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "form", dataType = "String"),
@ApiImplicitParam(name = "loginPlatform", value = "PC_PLATFORM PC 端,DRIVER_PLATFORM 驾驶员端,ENTERPRISE_PLATFORM 企业端"
, required = true, paramType = "form", dataType = "String")})
public void loginByUsernameAndPassword(@RequestParam("username") String username,
@RequestParam("password") String password,
@RequestParam("loginPlatform") String loginPlatform) {
// 不实现任何内容,只是为了出api文档
}

@PostMapping(value = "/logout")
@ApiOperation(value = "退出登陆")
public void logout() {
// 不实现任何内容,具体实现交由Spring Security进行管理
}

/**
* 当需要身份认证时,跳转到这里
*/
@GetMapping("/auth-require")
@CrossOrigin(originPatterns = "*", allowCredentials = "true", maxAge = 3600)
public void requireAuthentication(HttpServletResponse response) throws IOException {
response.setContentType(StrPool.CONTENT_TYPE);
response.setStatus(HttpStatus.UNAUTHORIZED.value());
response.getWriter().write(objectMapper.writeValueAsString(BizConst.UNAUTHENTICATED));
}

/**
* 设置session失效
*/
@GetMapping("/invalid-session")
@CrossOrigin(originPatterns = "*", allowCredentials = "true", maxAge = 3600)
public void invalidSession(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType(StrPool.CONTENT_TYPE);
Cookie cookie = new Cookie(BizConst.COOKIE_KEY, null);
cookie.setPath(request.getContextPath() + "/");
cookie.setMaxAge(SessionTimeConstant.SESSION_TIME_SECONDS);
response.addCookie(cookie);
response.setStatus(HttpStatus.UNAUTHORIZED.value());
response.getWriter().write(objectMapper.writeValueAsString(BizConst.UNAUTHENTICATED));
}

}

Yükleniyor…
İptal
Kaydet