Commit a2b41886 authored by suhuiguang's avatar suhuiguang

1.账号绑定校验bug,编辑时会把自己算上导致不能编辑

parent 16c2909a
package com.yeejoin.amos.boot.biz.common.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author DELL
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ResubmitCheck {
/**
* 失效时间,即可以第二次提交间隔时长,单位秒
*/
long expireTime() default 3;
/**
* 提示消息
*/
String message() default "您的操作过于频繁,请稍后重试";
}
package com.yeejoin.amos.boot.biz.common.aop;
import com.yeejoin.amos.boot.biz.common.annotation.ResubmitCheck;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
/**
* @author DELL
*/
@Aspect
@Component
@Slf4j
public class ResubmitCheckAspect {
@Resource
HttpServletRequest request;
@Autowired
RedisUtils redisUtils;
@Pointcut(value = "@annotation(com.yeejoin.amos.boot.biz.common.annotation.ResubmitCheck)")
public void submit() {
}
@Before("submit()&&@annotation(resubmitCheck)")
public void doBefore(JoinPoint joinPoint, ResubmitCheck resubmitCheck) {
String token = !StringUtils.isEmpty(request.getHeader("token")) ? request.getHeader("token") : RequestContext.getToken();
StringBuilder md5Builder = new StringBuilder(StringUtils.isEmpty(token) ? "unknown" : token);
if (joinPoint.getArgs() != null) {
for (Object obj : joinPoint.getArgs()) {
md5Builder.append(obj.toString());
}
}
String md5String = DigestUtils.md5DigestAsHex(md5Builder.toString().getBytes());
Object cache = redisUtils.get(md5String);
if (cache != null) {
throw new RuntimeException(resubmitCheck.message());
}
redisUtils.set(md5String, 1, resubmitCheck.expireTime());
}
}
...@@ -86,7 +86,7 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> { ...@@ -86,7 +86,7 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
*/ */
List< OrgUsrExcelDto> exportPersonToExcelByParentId(Long parentId); List< OrgUsrExcelDto> exportPersonToExcelByParentId(Long parentId);
int amosIdExist(String amosId); int amosIdExist(@Param("amosId") String amosId, @Param("orgUsrId") String orgUsrId);
int amosIdExistTeam(String amosId); int amosIdExistTeam(String amosId);
......
...@@ -671,14 +671,18 @@ GROUP BY ...@@ -671,14 +671,18 @@ GROUP BY
</select> </select>
<select id="amosIdExist" resultType="int"> <select id="amosIdExist" resultType="int">
SELECT
count(*) AS num
FROM cb_org_usr
SELECT count(*) AS num FROM cb_org_usr WHERE amos_org_id = #{amosId} and is_delete = 0; WHERE
amos_org_id = #{amosId}
<if test="orgUsrId != null ">
and sequence_nbr != #{orgUsrId}
</if>
and is_delete = 0
</select> </select>
<select id="amosIdExistTeam" resultType="int"> <select id="amosIdExistTeam" resultType="int">
SELECT count(*) AS num FROM cb_firefighters WHERE amos_user_id = #{amosId} and is_delete = 0; SELECT count(*) AS num FROM cb_firefighters WHERE amos_user_id = #{amosId} and is_delete = 0;
</select> </select>
......
...@@ -625,8 +625,9 @@ public class OrgUsrController extends BaseController { ...@@ -625,8 +625,9 @@ public class OrgUsrController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/getAmosId/{amosId}", method = RequestMethod.GET) @RequestMapping(value = "/getAmosId/{amosId}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "判断关联账户是否已关联", notes = "判断关联账户是否已关联") @ApiOperation(httpMethod = "GET", value = "判断关联账户是否已关联", notes = "判断关联账户是否已关联")
public ResponseModel<Object> getAmosId(@PathVariable String amosId) { public ResponseModel<Object> getAmosId(@PathVariable String amosId,
return ResponseHelper.buildResponse(iOrgUsrService.amosIdExist(amosId)); @RequestParam(required = false) String orgUsrId) {
return ResponseHelper.buildResponse(iOrgUsrService.amosIdExist(amosId, orgUsrId));
} }
/** /**
......
...@@ -2067,12 +2067,10 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp ...@@ -2067,12 +2067,10 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
return orgUser; return orgUser;
} }
public Object amosIdExist(String amosId) { public Object amosIdExist(String amosId, String orgUsrId) {
int num = orgUsrMapper.amosIdExist(amosId); // 增加逻辑:orgUsrId不为空时(编辑逻辑),进行筛选,解决自己页面编辑成自己,导致校验不通过
if (num > 0) { int num = orgUsrMapper.amosIdExist(amosId,orgUsrId);
return false; return num <= 0;
}
return true;
} }
public Object amosIdExistTeam(String amosId) { public Object amosIdExistTeam(String amosId) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment