|
@@ -1,9 +1,6 @@
|
|
|
package cn.hnthyy.thmz.controller;
|
|
|
|
|
|
-import cn.hnthyy.thmz.Utils.DateUtil;
|
|
|
-import cn.hnthyy.thmz.Utils.HttpUtil;
|
|
|
-import cn.hnthyy.thmz.Utils.JsonUtil;
|
|
|
-import cn.hnthyy.thmz.Utils.TokenUtil;
|
|
|
+import cn.hnthyy.thmz.Utils.*;
|
|
|
import cn.hnthyy.thmz.comment.UserLoginToken;
|
|
|
import cn.hnthyy.thmz.common.Constants;
|
|
|
import cn.hnthyy.thmz.entity.his.mz.Employee;
|
|
@@ -27,13 +24,11 @@ import cn.hutool.core.map.MapUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
@@ -231,8 +226,22 @@ public class LoginController {
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ @GetMapping("/getToken")
|
|
|
+ public R getToken(@RequestParam String userCode,String password) {
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put("userCode", userCode);
|
|
|
+ map.put("password", password);
|
|
|
+ String userJson = JsonUtil.object2Json(map);
|
|
|
+ System.out.println("收到的用户信息: " + JsonUtil.object2Json(map));
|
|
|
+ // 创建Calendar实例并设置为当前时间
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ // 增加24小时
|
|
|
+ calendar.add(Calendar.HOUR_OF_DAY, 24);
|
|
|
+ // 获取Date对象
|
|
|
+// Date deadTime = calendar.getTime();
|
|
|
+ Date deadTime = DateUtil.getDate(Constants.JWT_TTL);
|
|
|
+ return R.ok().put("data", TokenUtil.createJWT(userJson,deadTime));
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|