删除了所有TODO和FIXME,在代码中添加了实际的限流代码,将原本的调用系统控制台输出的打印改为了log.debug
parent
2b964c907d
commit
8ba644811a
|
@ -7,7 +7,6 @@ import java.util.concurrent.TimeUnit;
|
|||
* @author 佘语殊
|
||||
* @since 2022/7/11 16:57
|
||||
*/
|
||||
//TODO: 加到代码里
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Target({ElementType.METHOD})
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|||
* @author 张韬
|
||||
* created at 2022/6/28 19:44
|
||||
*/
|
||||
//TODO: 整机限流
|
||||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
@Bean
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.springframework.web.bind.annotation.*;
|
|||
* @author 佘语殊
|
||||
* @since 2022/7/7 11:29
|
||||
*/
|
||||
//TODO: TEST
|
||||
@RestController
|
||||
@RequestMapping("/project/{projectId}/announcement")
|
||||
public class AnnouncementController {
|
||||
|
|
|
@ -34,7 +34,7 @@ public class ProjectController {
|
|||
private IProjectGroupService projectGroupService;
|
||||
|
||||
@Operation(summary = "根据Token获取该员工的ProjectList")
|
||||
//@RateLimit(permitsPerSecond = 1, maxBurstSeconds = 5)
|
||||
@RateLimit(key = "ProjectPage", permitsPerSecond = 50, maxBurstSeconds = 15, timeout = 1200)
|
||||
@SneakyThrows
|
||||
@GetMapping
|
||||
public ResponseList<ProjectDTO> getProjectListOfStaff(
|
||||
|
|
|
@ -140,7 +140,6 @@ public class ProjectGroupController {
|
|||
throw new BadRequestException(BadRequestException.OPERATE_FAILED);
|
||||
}
|
||||
|
||||
//TODO: TEST
|
||||
@Operation(description = "将staffId的所有工作项转移至targetStaffId")
|
||||
@SneakyThrows
|
||||
@PutMapping("/{staffId}/transfer/{targetStaffId}")
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
||||
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.annotation.RateLimit;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDTO;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDTO;
|
||||
|
@ -39,6 +40,7 @@ public class TaskController {
|
|||
}
|
||||
|
||||
@SneakyThrows
|
||||
@RateLimit(key = "TaskMine", permitsPerSecond = 40, maxBurstSeconds = 15, timeout = 1200)
|
||||
@GetMapping("/mine")
|
||||
public ResponseList<TaskDTO> getMyTasks(@RequestHeader(TokenUtils.HEADER_TOKEN) String token, @PathVariable("projectId") Integer projectId) {
|
||||
List<TaskDTO> result = taskService.listMyTasks(token, projectId);
|
||||
|
@ -71,6 +73,7 @@ public class TaskController {
|
|||
}
|
||||
|
||||
@SneakyThrows
|
||||
@RateLimit(key = "TaskModify", permitsPerSecond = 40, maxBurstSeconds = 15, timeout = 1200)
|
||||
@PutMapping("/{taskId}")
|
||||
public ResponseMap modifyTask(
|
||||
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
||||
|
@ -88,6 +91,7 @@ public class TaskController {
|
|||
}
|
||||
|
||||
@SneakyThrows
|
||||
@RateLimit(key = "TaskModify", permitsPerSecond = 40, maxBurstSeconds = 15, timeout = 1200)
|
||||
@DeleteMapping("/{taskId}")
|
||||
public ResponseMap deleteTaskAndSubTask(
|
||||
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
||||
|
@ -101,6 +105,7 @@ public class TaskController {
|
|||
}
|
||||
|
||||
@SneakyThrows
|
||||
@RateLimit(key = "TaskTrend", permitsPerSecond = 50, maxBurstSeconds = 15, timeout = 1200)
|
||||
@GetMapping("/stats/trend")
|
||||
public ResponseMap getTaskTrend(
|
||||
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
||||
|
|
|
@ -20,6 +20,5 @@ public class Staff {
|
|||
private String staffPassword;
|
||||
@DoNotSerialize
|
||||
private String staffSalt;
|
||||
//TODO: 详细测试
|
||||
private Integer staffGlobalLevel;
|
||||
}
|
||||
|
|
|
@ -23,10 +23,9 @@ public class TokenInterceptor implements HandlerInterceptor {
|
|||
@Autowired
|
||||
private RedisTemplate<Object, Object> redisTemplate;
|
||||
|
||||
//FIXME: 最终上线时要把这里的输出删掉
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object object) throws TokenException {
|
||||
// System.out.println(httpServletRequest.getRequestURL() + " " + httpServletRequest.getMethod());
|
||||
// log.debug(httpServletRequest.getRequestURL() + " " + httpServletRequest.getMethod());
|
||||
String token = httpServletRequest.getHeader(TokenUtils.HEADER_TOKEN);
|
||||
if (null == token || "".equals(token.trim())) {
|
||||
throw new TokenException("缺少Token");
|
||||
|
@ -37,8 +36,8 @@ public class TokenInterceptor implements HandlerInterceptor {
|
|||
if (TokenUtils.checkTimeOut(token)) {
|
||||
throw new TokenException("Token已过期");
|
||||
}
|
||||
// System.out.println(Objects.requireNonNull(TokenUtils.getStaffId(token)));
|
||||
// System.out.println(token);
|
||||
// log.debug(Objects.requireNonNull(TokenUtils.getStaffId(token)));
|
||||
// log.debug(token);
|
||||
if (!token.equals(redisTemplate.opsForValue().get(Objects.<Integer>requireNonNull(TokenUtils.getStaffId(token))))) {
|
||||
throw new TokenException("请重新登录");
|
||||
}
|
||||
|
|
|
@ -98,7 +98,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|||
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
|
||||
}
|
||||
|
||||
//FIXME: 改为特定Exception处理
|
||||
try {
|
||||
if (baseMapper.insert(project) == 1) {
|
||||
return projectGroupService.addCreator(project.getProjectId(), TokenUtils.getStaffId(token));
|
||||
|
|
|
@ -146,28 +146,28 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
|||
if (totalCount < 1) {
|
||||
throw new BadRequestException("读取不到条目");
|
||||
}
|
||||
// System.out.println(totalCount);
|
||||
// System.out.println(staffUsernameC);
|
||||
// log.debug(totalCount);
|
||||
// log.debug(staffUsernameC);
|
||||
if (!xlsxColumnGetter("staffPassword", 1, staffPasswordC, sheet) ||
|
||||
staffPasswordC.size() != totalCount) {
|
||||
throw new BadRequestException("读取列staffPassword失败");
|
||||
}
|
||||
// System.out.println(staffPasswordC);
|
||||
// log.debug(staffPasswordC);
|
||||
if (!xlsxColumnGetter("staffFullname", 2, staffFullnameC, sheet) ||
|
||||
staffFullnameC.size() != totalCount) {
|
||||
throw new BadRequestException("读取列staffFullname失败");
|
||||
}
|
||||
// System.out.println(staffFullnameC);
|
||||
// log.debug(staffFullnameC);
|
||||
if (!xlsxColumnGetter("staffGender", 3, staffGenderC, sheet) ||
|
||||
staffGenderC.size() != totalCount) {
|
||||
throw new BadRequestException("读取列staffGender失败");
|
||||
}
|
||||
// System.out.println(staffGenderC);
|
||||
// log.debug(staffGenderC);
|
||||
if (!xlsxColumnGetter("staffGlobalLevel", 4, staffGlobalLevelC, sheet) ||
|
||||
staffGlobalLevelC.size() != totalCount) {
|
||||
throw new BadRequestException("读取列staffGlobalLevel失败");
|
||||
}
|
||||
// System.out.println(staffGlobalLevelC);
|
||||
// log.debug(staffGlobalLevelC);
|
||||
if (staffGlobalLevelC.stream().anyMatch(level -> Integer.parseInt(level) < 2)) {
|
||||
throw new BadRequestException("列staffGlobalLevel无效");
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
|||
staff.setStaffFullname(staffFullnameC.get(i));
|
||||
staff.setStaffGender(staffGenderC.get(i));
|
||||
staff.setStaffGlobalLevel(Integer.parseInt(staffGlobalLevelC.get(i)));
|
||||
// System.out.println(staff);
|
||||
// log.debug(staff);
|
||||
if (baseMapper.insert(staff) != 1) {
|
||||
throw new BadRequestException("第" + (i + 1) + "行数据错误");
|
||||
}
|
||||
|
|
|
@ -276,7 +276,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
|||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) { //TODO: 需要调整
|
||||
} catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
|||
if (task.getTaskStatus().equals(Task.STATUS_CLOSED))
|
||||
typeChangeValue = 2;
|
||||
}
|
||||
// System.out.println(!task.checkModification(rawTask));
|
||||
// log.debug(!task.checkModification(rawTask));
|
||||
if (!task.checkModification(rawTask) || !task.checkInsert()) {
|
||||
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
|
||||
}
|
||||
|
@ -414,7 +414,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
|
|||
taskList.add(taskTrend);
|
||||
iterDate = iterDate.plusDays(1);
|
||||
lastNum = taskTrend.getTaskNum();
|
||||
// System.out.println(taskTrend.toString());
|
||||
// log.debug(taskTrend.toString());
|
||||
}
|
||||
res.put(iterTask.getTaskStatus(), taskList);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import java.util.Date;
|
|||
* @author 张韬
|
||||
* created at 2022/6/28 18:20
|
||||
*/
|
||||
//TODO: 演示的时候把expireTime改短点儿
|
||||
@Component
|
||||
public final class TokenUtils {
|
||||
private final static String PV_KEY = "SignedByRMDJZZ";
|
||||
|
|
Loading…
Reference in New Issue