|
@@ -0,0 +1,91 @@
|
|
|
+package com.zhongzheng.controller.base;
|
|
|
+
|
|
|
+import com.zhongzheng.common.annotation.Log;
|
|
|
+import com.zhongzheng.common.core.controller.BaseController;
|
|
|
+import com.zhongzheng.common.core.domain.AjaxResult;
|
|
|
+import com.zhongzheng.common.core.page.TableDataInfo;
|
|
|
+import com.zhongzheng.common.core.redis.RedisCache;
|
|
|
+import com.zhongzheng.common.enums.BusinessType;
|
|
|
+import com.zhongzheng.common.utils.SecurityUtils;
|
|
|
+import com.zhongzheng.common.utils.ServletUtils;
|
|
|
+import com.zhongzheng.framework.web.service.WxTokenService;
|
|
|
+import com.zhongzheng.modules.base.bo.ActionLockQueryBo;
|
|
|
+import com.zhongzheng.modules.base.bo.ApplyAreasQueryBo;
|
|
|
+import com.zhongzheng.modules.base.domain.ApplyAreas;
|
|
|
+import com.zhongzheng.modules.base.service.IApplyAreasService;
|
|
|
+import com.zhongzheng.modules.base.vo.ApplyAreasVo;
|
|
|
+import com.zhongzheng.modules.grade.bo.UserPeriodEditBo;
|
|
|
+import com.zhongzheng.modules.user.entity.ClientLoginUser;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 锁定防多端Controller
|
|
|
+ *
|
|
|
+ * @author hjl
|
|
|
+ * @date 2021-10-08
|
|
|
+ */
|
|
|
+@Api(value = "锁定防多端", tags = {"锁定防多端"})
|
|
|
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
|
|
+@RestController
|
|
|
+@RequestMapping("/lock")
|
|
|
+public class LockController extends BaseController {
|
|
|
+
|
|
|
+ private final WxTokenService wxTokenService;
|
|
|
+
|
|
|
+ private final RedisCache redisCache;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 锁定学时审核页面
|
|
|
+ */
|
|
|
+ @ApiOperation("锁定行为")
|
|
|
+ @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
|
|
|
+ @Log(title = "锁定行为", businessType = BusinessType.UPDATE)
|
|
|
+ @PostMapping("/lockAction")
|
|
|
+ public AjaxResult<Void> lockAction(@RequestBody ActionLockQueryBo bo) {
|
|
|
+ ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
+ String key = "LockAppAction_"+bo.getAction()+"-"+loginUser.getUser().getUserId();
|
|
|
+ redisCache.setCacheObject(key, SecurityUtils.getUsername(),13, TimeUnit.SECONDS);//13秒锁定
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看学时审核锁定状态
|
|
|
+ */
|
|
|
+ @ApiOperation("查看行为锁定状态")
|
|
|
+ @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
|
|
|
+ @Log(title = "查看行为锁定状态", businessType = BusinessType.UPDATE)
|
|
|
+ @PostMapping("/lockStatus")
|
|
|
+ public AjaxResult<Void> lockStatus(@RequestBody ActionLockQueryBo bo) {
|
|
|
+ ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
+ String key = "LockAppAction_"+bo.getAction()+"-"+loginUser.getUser().getUserId();
|
|
|
+ String username = redisCache.getCacheObject(key);
|
|
|
+ if(SecurityUtils.getUsername().equals(username)){
|
|
|
+ username = null;//同个用户不返回
|
|
|
+ }
|
|
|
+ return AjaxResult.success(username);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看学时审核锁定状态
|
|
|
+ */
|
|
|
+ @ApiOperation("删除锁定状态")
|
|
|
+ @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
|
|
|
+ @Log(title = "删除锁定状态", businessType = BusinessType.UPDATE)
|
|
|
+ @PostMapping("/delLock")
|
|
|
+ public AjaxResult delLock(@RequestBody ActionLockQueryBo bo) {
|
|
|
+ ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
+ String key = "LockAppAction_"+bo.getAction()+"-"+loginUser.getUser().getUserId();
|
|
|
+ return AjaxResult.success(redisCache.deleteObject(key));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|