| | |
| | | package com.jilongda.manage.authority.controller; |
| | | |
| | | import com.jilongda.manage.authority.dto.LoginDTO; |
| | | import com.jilongda.manage.authority.model.SecUser; |
| | | import com.jilongda.manage.model.TStore; |
| | | import com.jilongda.manage.service.TStoreService; |
| | | import com.jilongda.manage.utils.MsgUtils; |
| | | import com.jilongda.common.basic.ApiResult; |
| | | import com.jilongda.common.basic.Constant; |
| | |
| | | private final RedisAutoTemplate redisAutoTemplate; |
| | | private final MsgUtils msgUtils; |
| | | private final SecUserService secUserService; |
| | | @Autowired |
| | | private TStoreService storeService; |
| | | |
| | | @Autowired |
| | | public LoginController(AuthenticationManager authenticationManager, SecurityUtils securityUtils, PasswordEncoder passwordEncoder, RedisAutoTemplate redisAutoTemplate, MsgUtils msgUtils, SecUserService secUserService) { |
| | |
| | | // 先检验是否登录 |
| | | String username = loginDto.getAccount(); |
| | | String password = loginDto.getPassword(); |
| | | // 超级管理员不做校验 |
| | | if (!username.equals("admin")){ |
| | | SecUser user = secUserService.lambdaQuery().eq(SecUser::getAccount, username).one(); |
| | | TStore store = storeService.getById(user.getStoreId()); |
| | | if (store==null){ |
| | | return ApiResult.failed(500, "门店不存在"); |
| | | } |
| | | if (store.getStatus() == 2){ |
| | | return ApiResult.failed(500, "门店已被禁用"); |
| | | } |
| | | } |
| | | try { |
| | | Map<String, Object> token = securityUtils.login(username, password, authenticationManager, SecurityUserDetails.class, 1); |
| | | return ApiResult.success(token); |