修改登录接口
This commit is contained in:
parent
3a3b76afc1
commit
2aa8b7ca4c
@ -2,8 +2,8 @@ package com.xkrs.common.account;
|
||||
|
||||
import com.xkrs.common.encapsulation.OutputEncapsulation;
|
||||
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.dao.StreetDao;
|
||||
import com.xkrs.model.vo.SysUserVo;
|
||||
import com.xkrs.service.StreetService;
|
||||
import com.xkrs.service.SysUserService;
|
||||
import com.xkrs.utils.IpUtil;
|
||||
import org.slf4j.Logger;
|
||||
@ -46,7 +46,7 @@ public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter {
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@Resource
|
||||
private StreetDao streetDao;
|
||||
private StreetService streetService;
|
||||
|
||||
public JwtLoginFilter(String url, AuthenticationManager authManager) {
|
||||
super(new AntPathRequestMatcher(url));
|
||||
@ -101,6 +101,11 @@ public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter {
|
||||
WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
|
||||
sysUserService = webApplicationContext.getBean(SysUserService.class);
|
||||
}
|
||||
if (streetService == null) {
|
||||
ServletContext servletContext = req.getServletContext();
|
||||
WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
|
||||
streetService = webApplicationContext.getBean(StreetService.class);
|
||||
}
|
||||
//更新用户登录信息
|
||||
sysUserService.updateSysUserLogin(auth.getName(), IpUtil.getIpAddr(req));
|
||||
SysUserVo userByUserName = sysUserService.getUserByUserName(auth.getName());
|
||||
@ -110,7 +115,7 @@ public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
Map map = new HashMap(3);
|
||||
if (9 == userByUserName.getCountyCode().length()) {
|
||||
List<Map<String, String>> streetByCountyCode = streetDao.selectStreetList(userByUserName.getCountyCode());
|
||||
List<Map<String, String>> streetByCountyCode = streetService.selectStreetList(userByUserName.getCountyCode());
|
||||
map.put("county", streetByCountyCode);
|
||||
TokenAuthenticationService.addAuthentication(response, auth.getName(), auth.getAuthorities(), userByUserName, map);
|
||||
} else if (userByUserName.getCountyCode().substring(2).equals("0000")) {
|
||||
|
@ -65,6 +65,10 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers(HttpMethod.GET,"/api/user/getVerificationCode").permitAll()
|
||||
.antMatchers(HttpMethod.POST,"/api/user/userUnRememberPassword").permitAll()
|
||||
.antMatchers(HttpMethod.POST,"/updateBeforeFireAndAfterFireImage").permitAll()
|
||||
.antMatchers(HttpMethod.GET,"/getProvinceList").permitAll()//获取省列表
|
||||
.antMatchers(HttpMethod.GET,"/getCityList").permitAll()//根据省编号获取市列表
|
||||
.antMatchers(HttpMethod.GET,"/getCountyList").permitAll()//根据市编号获取区县列表
|
||||
.antMatchers(HttpMethod.GET,"/getStreetList").permitAll()//根据区县编号获取街道列表
|
||||
// 所有其它请求需要身份认证
|
||||
.anyRequest().authenticated()
|
||||
.and()
|
||||
|
@ -8,7 +8,6 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Component
|
||||
public interface StreetDao extends JpaRepository<StreetEntity, Integer>, JpaSpecificationExecutor<StreetEntity> {
|
||||
@ -25,9 +24,9 @@ public interface StreetDao extends JpaRepository<StreetEntity, Integer>, JpaSpec
|
||||
|
||||
List<StreetEntity> findByCountyCode(String countyCode);
|
||||
|
||||
Optional<StreetEntity> findByStreetName(String streetName);
|
||||
List<StreetEntity> findByStreetName(String streetName);
|
||||
|
||||
Optional<StreetEntity> findByStreetCode(String streetCode);
|
||||
List<StreetEntity> findByStreetCode(String streetCode);
|
||||
|
||||
@Query(value = "SELECT DISTINCT t.pro_code AS code, t.pro_name AS name FROM street AS t", nativeQuery = true)
|
||||
List<Map<String, String>> selectProvinceList();
|
||||
|
33
src/main/java/com/xkrs/service/StreetService.java
Normal file
33
src/main/java/com/xkrs/service/StreetService.java
Normal file
@ -0,0 +1,33 @@
|
||||
package com.xkrs.service;
|
||||
|
||||
import com.xkrs.model.entity.StreetEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface StreetService {
|
||||
|
||||
List<StreetEntity> findByProName(String proName);
|
||||
|
||||
List<StreetEntity> findByProCode(String proCode);
|
||||
|
||||
List<StreetEntity> findByCityName(String cityName);
|
||||
|
||||
List<StreetEntity> findByCityCode(String cityCode);
|
||||
|
||||
List<StreetEntity> findByCountyName(String countyName);
|
||||
|
||||
List<StreetEntity> findByCountyCode(String countyCode);
|
||||
|
||||
List<StreetEntity> findByStreetName(String streetName);
|
||||
|
||||
List<StreetEntity> findByStreetCode(String streetCode);
|
||||
|
||||
List<Map<String, String>> selectProvinceList();
|
||||
|
||||
List<Map<String, String>> selectCityList(String provinceCode);
|
||||
|
||||
List<Map<String, String>> selectCountyList(String cityCode);
|
||||
|
||||
List<Map<String, String>> selectStreetList(String countyCode);
|
||||
}
|
77
src/main/java/com/xkrs/service/impl/StreetServiceImpl.java
Normal file
77
src/main/java/com/xkrs/service/impl/StreetServiceImpl.java
Normal file
@ -0,0 +1,77 @@
|
||||
package com.xkrs.service.impl;
|
||||
|
||||
import com.xkrs.dao.StreetDao;
|
||||
import com.xkrs.model.entity.StreetEntity;
|
||||
import com.xkrs.service.StreetService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class StreetServiceImpl implements StreetService {
|
||||
|
||||
@Resource
|
||||
private StreetDao streetDao;
|
||||
|
||||
@Override
|
||||
public List<StreetEntity> findByProName(String proName) {
|
||||
return streetDao.findByProName(proName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StreetEntity> findByProCode(String proCode) {
|
||||
return streetDao.findByProCode(proCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StreetEntity> findByCityName(String cityName) {
|
||||
return streetDao.findByCityName(cityName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StreetEntity> findByCityCode(String cityCode) {
|
||||
return streetDao.findByCityCode(cityCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StreetEntity> findByCountyName(String countyName) {
|
||||
return streetDao.findByCountyName(countyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StreetEntity> findByCountyCode(String countyCode) {
|
||||
return streetDao.findByCountyCode(countyCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StreetEntity> findByStreetName(String streetName) {
|
||||
return streetDao.findByStreetName(streetName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StreetEntity> findByStreetCode(String streetCode) {
|
||||
return streetDao.findByStreetCode(streetCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> selectProvinceList() {
|
||||
return streetDao.selectProvinceList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> selectCityList(String provinceCode) {
|
||||
return streetDao.selectCityList(provinceCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> selectCountyList(String cityCode) {
|
||||
return streetDao.selectCountyList(cityCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> selectStreetList(String countyCode) {
|
||||
return streetDao.selectStreetList(countyCode);
|
||||
}
|
||||
}
|
@ -19,7 +19,6 @@ import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
import static com.xkrs.utils.DateTimeUtil.dateTimeToString;
|
||||
@ -110,12 +109,12 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
}
|
||||
|
||||
if (9 == countyCode.length()) {
|
||||
Optional<StreetEntity> byStreetCodeOptional = streetDao.findByStreetCode(countyCode);
|
||||
if (byStreetCodeOptional.isEmpty()) {
|
||||
List<StreetEntity> byStreetCode = streetDao.findByStreetCode(countyCode);
|
||||
if (byStreetCode == null || byStreetCode.isEmpty()) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "街道编码不存在!", locale);
|
||||
}
|
||||
Optional<StreetEntity> byStreetNameOptional = streetDao.findByStreetName(countyName);
|
||||
if (byStreetNameOptional.isEmpty()) {
|
||||
List<StreetEntity> byStreetName = streetDao.findByStreetName(countyName);
|
||||
if (byStreetName == null || byStreetName.isEmpty()) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale);
|
||||
}
|
||||
sysUserEntity.setActiveFlag(0);
|
||||
|
Loading…
Reference in New Issue
Block a user