|
@@ -8,10 +8,12 @@ import com.management.platform.mapper.CompanyMapper;
|
|
|
import com.management.platform.service.UserService;
|
|
|
import com.management.platform.service.impl.AuthService;
|
|
|
import com.management.platform.service.impl.DingTalkService;
|
|
|
+import com.management.platform.util.HttpRespMsg;
|
|
|
import com.management.platform.util.MessageUtils;
|
|
|
import com.management.platform.util.UserAgentUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.tomcat.util.codec.binary.Base64;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.*;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -23,9 +25,16 @@ import org.springframework.web.servlet.ModelAndView;
|
|
|
import org.springframework.web.servlet.view.RedirectView;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.crypto.Mac;
|
|
|
+import javax.crypto.spec.SecretKeySpec;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.security.InvalidKeyException;
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.HashMap;
|
|
@@ -98,6 +107,36 @@ public class DingTalkController {
|
|
|
return modelAndView;
|
|
|
}
|
|
|
|
|
|
+ /*@GetMapping("/getSign")
|
|
|
+ public HttpRespMsg getSign() {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ try {
|
|
|
+ String timestamp = String.valueOf(System.currentTimeMillis());
|
|
|
+ System.out.println("timestamp=="+timestamp);
|
|
|
+ String stringToSign = timestamp + "\n" + "o-TWFLkFe8YbJsa_025JOj_JEWydP5GR3eigt1Yn1rtx5dTcryTJiSA6KEih3Bi4";
|
|
|
+ Mac mac = Mac.getInstance("HmacSHA256");
|
|
|
+ mac.init(new SecretKeySpec("o-TWFLkFe8YbJsa_025JOj_JEWydP5GR3eigt1Yn1rtx5dTcryTJiSA6KEih3Bi4".getBytes("UTF-8"), "HmacSHA256"));
|
|
|
+ byte[] signatureBytes = mac.doFinal(stringToSign.getBytes("UTF-8"));
|
|
|
+ String signature = new String(Base64.encodeBase64(signatureBytes));
|
|
|
+ if("".equals(signature)) {
|
|
|
+ msg.setError("生成签名失败");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ String encoded = URLEncoder.encode(signature, "UTF-8");
|
|
|
+ String urlEncodeSignature = encoded.replace("+", "%20").replace("*", "%2A").replace("~", "%7E").replace("/", "%2F");
|
|
|
+
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ map.put("timestamp", timestamp);
|
|
|
+ map.put("sign", urlEncodeSignature);
|
|
|
+ msg.data=map;
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException("生成签名失败", e);
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private HashMap getCompExpireInfo(Integer companyId) {
|
|
|
Company company = companyMapper.selectById(companyId);
|
|
|
int version = 1;
|