删除无用代码

This commit is contained in:
liuchengqian 2022-06-08 11:29:05 +08:00
parent 12e5320abf
commit 088155b2d6
7 changed files with 2 additions and 252 deletions

View File

@ -3,7 +3,6 @@ package com.xkrs.common.account;
import com.xkrs.common.encapsulation.OutputEncapsulation;
import com.xkrs.common.encapsulation.PromptMessageEnum;
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;
@ -28,10 +27,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
/**
* jwt登录过滤器
@ -45,9 +41,6 @@ public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter {
@Resource
private SysUserService sysUserService;
@Resource
private StreetService streetService;
public JwtLoginFilter(String url, AuthenticationManager authManager) {
super(new AntPathRequestMatcher(url));
setAuthenticationManager(authManager);
@ -101,11 +94,6 @@ 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());
@ -113,25 +101,7 @@ public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter {
response.setHeader("Access-Control-Allow-Credentials", "false");
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
Map map = new HashMap(3);
if (9 == userByUserName.getCountyCode().length()) {
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")) {
List<Map<String, String>> cityByProCode = sysUserService.findCityByProCode(userByUserName.getCountyCode());
map.put("city", cityByProCode);
List<Map<String, String>> countyByProCode = sysUserService.findCountyByProCode(userByUserName.getCountyCode());
map.put("county", countyByProCode);
TokenAuthenticationService.addAuthentication(response, auth.getName(), auth.getAuthorities(), userByUserName, map);
} else if (userByUserName.getCountyCode().substring(4).equals("00") && !userByUserName.getCountyCode().substring(2).equals("0000")) {
List<Map<String, String>> countyByCityCode = sysUserService.findCountyByCityCode(userByUserName.getCountyCode());
map.put("county", countyByCityCode);
TokenAuthenticationService.addAuthentication(response, auth.getName(), auth.getAuthorities(), userByUserName, map);
} else {
map.put("county", null);
TokenAuthenticationService.addAuthentication(response, auth.getName(), auth.getAuthorities(), userByUserName, map);
}
TokenAuthenticationService.addAuthentication(response, auth.getName(), auth.getAuthorities(), userByUserName);
}
/**

View File

@ -54,7 +54,7 @@ public class TokenAuthenticationService {
* @param userName
* @param authorities
*/
static void addAuthentication(HttpServletResponse response, String userName, Collection<? extends GrantedAuthority> authorities, SysUserVo sysUserEntity, Map map1) {
static void addAuthentication(HttpServletResponse response, String userName, Collection<? extends GrantedAuthority> authorities, SysUserVo sysUserEntity) {
Locale locale = new Locale("zh", "CN");
Map map = new HashMap(3);
@ -89,7 +89,6 @@ public class TokenAuthenticationService {
.signWith(key).compact();
map.put("token", jwt);
map.put("user", sysUserEntity);
map.put("cityAndCounty", map1);
} else {
/**
* 过期时间6小时
@ -106,7 +105,6 @@ public class TokenAuthenticationService {
.signWith(key).compact();
map.put("token", jwt);
map.put("user", sysUserEntity);
map.put("cityAndCounty", map1);
}
// JWT 写入 body
PrintWriter out = null;

View File

@ -1,40 +0,0 @@
package com.xkrs.dao;
import com.xkrs.model.entity.Nationwide;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/**
* @author XinYi Song
*/
@Component
public interface NationwideDao extends JpaRepository<Nationwide,Long> {
/**
* 通过省编码查询市名称和编码
* @param proCode
* @return
*/
@Query(value = "select DISTINCT city_name,city_code from nationwide where pro_code = ?",nativeQuery = true)
List<Map<String,String>> findCityByProCode(String proCode);
/**
* 通过省编码查询县名称和编码
* @param proCode
* @return
*/
@Query(value = "select county_name,county_code from nationwide where pro_code = ?",nativeQuery = true)
List<Map<String,String>> findCountyByProCode(String proCode);
/**
* 通过市编码查询区县名称和编码
* @param cityCode
* @return
*/
@Query(value = "select county_name,county_code from nationwide where city_code = ?",nativeQuery = true)
List<Map<String,String>> findCountyByCityCode(String cityCode);
}

View File

@ -1,137 +0,0 @@
package com.xkrs.model.entity;
import javax.persistence.*;
/**
* @author XinYi Song
* 全国省市区
*/
@Entity
@Table(name = "nationwide")
public class Nationwide {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "nationwide_seq_gen")
@SequenceGenerator(name = "nationwide_seq_gen", sequenceName = "nationwide_id_seq",allocationSize = 1)
private Integer id;
/**
* 省名称
*/
@Column(length = 65, columnDefinition = "varchar(65)")
private String proName;
/**
* 省编码
*/
@Column(length = 65, columnDefinition = "varchar(65)")
private String proCode;
/**
* 市名称
*/
@Column(length = 65, columnDefinition = "varchar(65)")
private String cityName;
/**
* 市编码
*/
@Column(length = 65, columnDefinition = "varchar(65)")
private String cityCode;
/**
* 区县名称
*/
@Column(length = 65, columnDefinition = "varchar(65)")
private String countyName;
/**
* 区县编码
*/
@Column(length = 65, columnDefinition = "varchar(65)")
private String countyCode;
public Nationwide() {
}
public Nationwide(Integer id, String proName, String proCode, String cityName, String cityCode, String countyName, String countyCode) {
this.id = id;
this.proName = proName;
this.proCode = proCode;
this.cityName = cityName;
this.cityCode = cityCode;
this.countyName = countyName;
this.countyCode = countyCode;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getProName() {
return proName;
}
public void setProName(String proName) {
this.proName = proName;
}
public String getProCode() {
return proCode;
}
public void setProCode(String proCode) {
this.proCode = proCode;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName;
}
public String getCityCode() {
return cityCode;
}
public void setCityCode(String cityCode) {
this.cityCode = cityCode;
}
public String getCountyName() {
return countyName;
}
public void setCountyName(String countyName) {
this.countyName = countyName;
}
public String getCountyCode() {
return countyCode;
}
public void setCountyCode(String countyCode) {
this.countyCode = countyCode;
}
@Override
public String toString() {
return "Nationwide{" +
"id=" + id +
", proName='" + proName + '\'' +
", proCode='" + proCode + '\'' +
", cityName='" + cityName + '\'' +
", cityCode='" + cityCode + '\'' +
", countyName='" + countyName + '\'' +
", countyCode='" + countyCode + '\'' +
'}';
}
}

View File

@ -6,7 +6,6 @@ import com.xkrs.model.vo.SysUserVo;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/**
* 系统用户服务接口
@ -182,22 +181,4 @@ public interface SysUserService {
*/
void updateLoginLastTime(Integer userId, String loginLastTime);
List<Map<String, String>> findCityByProCode(String proCode);
/**
* 通过省编码查询县名称和编码
*
* @param proCode
* @return
*/
List<Map<String, String>> findCountyByProCode(String proCode);
/**
* 通过市编码查询区县名称和编码
*
* @param cityCode
* @return
*/
List<Map<String, String>> findCountyByCityCode(String cityCode);
}

View File

@ -76,9 +76,6 @@ public class FirePointServiceImpl implements FirePointService {
@Resource
private StreetDao streetDao;
@Resource
private NationwideDao nationwideDao;
@Resource
private CountyCodeWeiXinDao countyCodeWeiXinDao;

View File

@ -19,7 +19,6 @@ import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
import static com.xkrs.utils.DateTimeUtil.dateTimeToString;
@ -48,9 +47,6 @@ public class SysUserServiceImpl implements SysUserService {
@Resource
private RedisService redisService;
@Resource
private NationwideDao nationwideDao;
@Resource
private StreetDao streetDao;
@ -468,19 +464,4 @@ public class SysUserServiceImpl implements SysUserService {
sysUserDao.updateLoginLastTime(userId, loginLastTime);
}
@Override
public List<Map<String, String>> findCityByProCode(String proCode) {
return nationwideDao.findCityByProCode(proCode);
}
@Override
public List<Map<String, String>> findCountyByProCode(String proCode) {
return nationwideDao.findCountyByProCode(proCode);
}
@Override
public List<Map<String, String>> findCountyByCityCode(String cityCode) {
return nationwideDao.findCountyByCityCode(cityCode);
}
}