添加用户认证和登录逻辑

在YdoolPurchaseOrderController中,我添加了用户认证和登录的逻辑。这包括从UserDetailsService加载用户,调用AuthController进行登录,并将用户信息添加到会话中。这些更改为系统增加了用户认证功能,提高了安全性。
This commit is contained in:
lijiaqi 2024-10-14 17:00:04 +08:00
parent ed9b38c123
commit 751e88f6cd
1 changed files with 12 additions and 0 deletions

View File

@ -2,6 +2,9 @@ package com.lframework.xingyun.sc.controller.ydool;
import com.lframework.starter.web.annotations.OpenApi; import com.lframework.starter.web.annotations.OpenApi;
import com.lframework.starter.web.annotations.security.HasPermission; import com.lframework.starter.web.annotations.security.HasPermission;
import com.lframework.starter.web.common.security.AbstractUserDetails;
import com.lframework.starter.web.common.utils.ApplicationUtil;
import com.lframework.starter.web.components.security.UserDetailsService;
import com.lframework.starter.web.controller.DefaultBaseController; import com.lframework.starter.web.controller.DefaultBaseController;
import com.lframework.starter.web.resp.InvokeResult; import com.lframework.starter.web.resp.InvokeResult;
import com.lframework.starter.web.resp.InvokeResultBuilder; import com.lframework.starter.web.resp.InvokeResultBuilder;
@ -10,6 +13,8 @@ import com.lframework.xingyun.sc.bo.purchase.GetPurchaseOrderBo;
import com.lframework.xingyun.sc.dto.purchase.PurchaseOrderFullDto; import com.lframework.xingyun.sc.dto.purchase.PurchaseOrderFullDto;
import com.lframework.xingyun.sc.service.purchase.PurchaseOrderService; import com.lframework.xingyun.sc.service.purchase.PurchaseOrderService;
import com.lframework.xingyun.sc.vo.ydool.YdoolApproveOrderVo; import com.lframework.xingyun.sc.vo.ydool.YdoolApproveOrderVo;
import com.lframework.xingyun.template.inner.controller.AuthController;
import com.lframework.xingyun.template.inner.dto.LoginDto;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -57,6 +62,13 @@ public class YdoolPurchaseOrderController extends DefaultBaseController {
@GetMapping @GetMapping
public InvokeResult<GetPurchaseOrderBo> findById( public InvokeResult<GetPurchaseOrderBo> findById(
@NotBlank(message = "订单ID不能为空") String id) { @NotBlank(message = "订单ID不能为空") String id) {
// AuthController authController = ApplicationUtil.getBean(AuthController.class);
// UserDetailsService userDetailsService = ApplicationUtil.getBean(UserDetailsService.class);
// AbstractUserDetails user = userDetailsService.loadUserByUsername("yanxiaomao1");
//
// LoginDto dto = authController.doLogin(user);
//
// authController.addAttributesToSession(user);
PurchaseOrderFullDto data = purchaseOrderService.getDetail(id); PurchaseOrderFullDto data = purchaseOrderService.getDetail(id);