| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package com.uas.sso.controller;
- import com.uas.sso.service.RelationService;
- import com.uas.sso.util.encry.Md5Utils;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.ui.ModelMap;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- /**
- * 用户企业关系管理controller
- *
- * @author wangmh
- * @date 2018/1/2
- */
- @RestController
- @RequestMapping("/api/relation")
- public class RelationManagerController extends BaseController {
- @Autowired
- private RelationService relationService;
- private static final Logger LOGGER = LoggerFactory.getLogger(RelationManagerController.class);
- /**
- * 分页获取用户企业关系信息
- * @param pageNumber 当前页数
- * @param pageSize 每页大小
- * @param timestamp 时间戳,与当前时间不能相差10分钟
- * @param encro 签名 md5(#{pageNumber}, #{pageSize}, #{timestamp}, ssoAccountSync),
- * @return
- */
- @GetMapping("/paging/info")
- public ModelMap getRelationByUpdateTime(int pageNumber, int pageSize, long timestamp, String encro) {
- // 验证时间
- long current = System.currentTimeMillis();
- if (Math.abs(current - timestamp) > 10 * 60 * 1000) {
- LOGGER.warn("全量更新:分页获取企业信息请求过期,当前时间:{},请求时间:{}", current, timestamp);
- return error("请求过期");
- }
- // 验证签名
- String laws = String.format("%s, %s, %s, %s", pageNumber, pageSize, timestamp, "ssoAccountSync");
- String str = Md5Utils.encode(laws, null);
- if (!str.equals(encro)) {
- LOGGER.warn("全量更新:分页获取企业信息签名错误,明文:{},签名:{}", laws, encro);
- return error("签名错误");
- }
- return success(relationService.getRelationInfo(pageNumber, pageSize));
- }
- }
|