maxmall-provider/maxmall-provider-merchant/src/main/java/com/maxmall/provider/merchant/service/impl/UacUserDetailsServiceImpl.java
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
package com.maxmall.provider.merchant.service.impl;
import com.maxmall.common.base.constant.GlobalConstant;
import com.maxmall.common.security.SecurityUser;
import com.maxmall.provider.merchant.model.domain.account.AccountDO;
import com.maxmall.provider.merchant.model.domain.merchant.MerchantDO;
import com.maxmall.provider.merchant.service.AccountService;
import com.maxmall.provider.merchant.service.MerchantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Collection;
/**
* The class Uac user details service.
*
* @author maxmall.net@gmail.com
*/
@Component
public class UacUserDetailsServiceImpl implements UserDetailsService {
@Resource
private AccountService accountService;
@Autowired
private MerchantService merchantService;
/**
* Load user by username user details.
*
* @param username the username
* @return the user details
*/
@Override
public UserDetails loadUserByUsername(String username) {
Collection<GrantedAuthority> grantedAuthorities;
AccountDO user = accountService.findByLoginName(username);
if (user == null) {
throw new BadCredentialsException("用户名不存在或者密码错误");
}
Long merchantId = user.getMerchantId();
//查询商户
if (GlobalConstant.CommonStatusEnum.AUDIT.getStatus()==user.getStatus() || merchantId==null){
throw new BadCredentialsException("商户审核中,请耐心等待");
}
if(GlobalConstant.CommonStatusEnum.ENABLE.getStatus() != user.getStatus()){
throw new BadCredentialsException("禁用用户,请联系商户管理员");
}
MerchantDO merchantDO = merchantService.selectByKey(merchantId);
if (merchantDO == null || GlobalConstant.CommonStatusEnum.ENABLE.getStatus()!= merchantDO.getStatus()){
throw new BadCredentialsException("禁用商户,请联系管理员");
}
grantedAuthorities = accountService.loadUserAuthorities(user.getId());
SecurityUser securityUser = new SecurityUser(user.getId(), user.getLoginName(), user.getLoginPwd(),user.getUserName(), user.getStatus(), grantedAuthorities);
securityUser.setIsMaster(user.getIsMaster());
后面还有 8 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
