|
@@ -0,0 +1,89 @@
|
|
|
|
|
+package com.zhongzheng.controller.base;
|
|
|
|
|
+
|
|
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
|
|
+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.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.validation.annotation.Validated;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+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(@Validated @RequestBody ActionLockQueryBo bo) {
|
|
|
|
|
+ ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
|
|
+ String key = "LockAppAction_"+bo.getAction()+"-"+loginUser.getUser().getUserId();
|
|
|
|
|
+ redisCache.setCacheObject(key, bo.getAction(),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 action = redisCache.getCacheObject(key);
|
|
|
|
|
+ if(Validator.isEmpty(action)){
|
|
|
|
|
+ return AjaxResult.error("无其他端在操作");
|
|
|
|
|
+ }else{
|
|
|
|
|
+ return AjaxResult.success("有其他端在操作");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查看学时审核锁定状态
|
|
|
|
|
+ */
|
|
|
|
|
+ @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));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|