Browse Source

添加身份验证功能

lwx_dev
erdanergou 2 years ago
parent
commit
22899fc510
  1. 2
      src/main/java/com/dreamchaser/depository_manage/config/WebMvcConfig.java
  2. 7
      src/main/java/com/dreamchaser/depository_manage/controller/QyWxOperationController.java
  3. 2
      src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/UserMapper.java
  4. 16
      src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java

2
src/main/java/com/dreamchaser/depository_manage/config/WebMvcConfig.java

@ -15,7 +15,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new UserInterceptor())
.addPathPatterns("/**")
.excludePathPatterns("/webSocket/{number}","/login", "/register", "/sendCode", "/error","/callback","/QyWxLogin","/getMaterialAll","/approvalcallback","/identity/**")
.excludePathPatterns("/webSocket/{number}","/login", "/register", "/sendCode", "/error","/callback","/QyWxLogin","/getMaterialAll","/approvalcallback","/identityVerify")
.excludePathPatterns("classpath:/static/**")
.excludePathPatterns("/static/**");
}

7
src/main/java/com/dreamchaser/depository_manage/controller/QyWxOperationController.java

@ -21,11 +21,13 @@ import com.dreamchaser.depository_manage.utils.Md5;
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil;
import com.dreamchaser.depository_manage.utils.QyWxXMLUtils;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.xmlbeans.impl.store.Public2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@ -39,7 +41,6 @@ import java.util.concurrent.TimeUnit;
/**
* 用于企业微信相关操作的控制器
*/
@RestController
@Controller
public class QyWxOperationController {
@ -262,6 +263,7 @@ public class QyWxOperationController {
String header = request.getHeader("user-agent");
String crypt = Md5.crypt(header);
JSONObject jsonObject = QyWxConfig.GetQYWXUserId(crypt);
Integer errCode = jsonObject.getInteger("errcode");
String userId = jsonObject.getString("userid");
if (errCode == 0) {
@ -274,6 +276,9 @@ public class QyWxOperationController {
String key = userKeyAndUserToken.get("key");
String token = userKeyAndUserToken.get("token");
if (userByPort != null) {
PublicConfig.findUserByQyWxUserId(userId);
// 如果数据库中存在该用户
// 设置放入时间
userByPort.setInstant(Instant.now());

2
src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/UserMapper.java

@ -14,9 +14,9 @@ import java.util.Map;
*
* @author Dreamchaser
*/
@Repository
@Mapper
@DS("hr_new")
@Repository
public interface UserMapper {
/**
* 通过id获取用户信息

16
src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java

@ -43,29 +43,29 @@ public class ExcelServiceImpl implements ExcelService {
// excel导入工具类
@Autowired
excelUtil excelutil;
private excelUtil excelutil;
@Autowired
MaterialService materialService;
private MaterialService materialService;
@Autowired
MaterialTypeService materialTypeService;
private MaterialTypeService materialTypeService;
@Autowired
PlaceService placeService;
private PlaceService placeService;
@Autowired
MaterialMapper materialMapper;
private MaterialMapper materialMapper;
@Autowired
SplitUnitService splitUnitService;
private SplitUnitService splitUnitService;
@Autowired
DepositoryRecordMapper depositoryRecordMapper;
private DepositoryRecordMapper depositoryRecordMapper;
@Autowired
ConstructionUnitMapper constructionUnitMapper;
private ConstructionUnitMapper constructionUnitMapper;
/**

Loading…
Cancel
Save