Commit 31cd04db authored by zhaobiyan's avatar zhaobiyan

新增会员编码字段,刷新历史数据

parent 868a5bf7
package cn.iocoder.yudao.module.member.controller.admin.job;
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* 会员编号刷新任务
* @author zhaobiyan
*/
@Component
@Slf4j
public class MemberCodeFlushTask implements JobHandler {
@Resource
private MemberUserService userService;
@Override
public String execute(String param) throws Exception {
userService.historyCodeFlush();
return "";
}
}
...@@ -459,13 +459,4 @@ public class MemberUserController { ...@@ -459,13 +459,4 @@ public class MemberUserController {
} }
return success(null); return success(null);
} }
@PutMapping("/history/code/flush")
@ApiOperation("历史会员编码刷新")
@PreAuthorize("@ss.hasPermission('member:user:info')")
public CommonResult<Boolean> historyCodeFlush() {
userService.historyCodeFlush();
return success(true);
}
} }
...@@ -177,4 +177,6 @@ public interface MemberUserMapper extends BaseMapperX<MemberUserDO> { ...@@ -177,4 +177,6 @@ public interface MemberUserMapper extends BaseMapperX<MemberUserDO> {
String getCurrentMaxMemberCode(); String getCurrentMaxMemberCode();
void updateMemberCodeById(@Param("code")String memberCode, @Param("id")Long id); void updateMemberCodeById(@Param("code")String memberCode, @Param("id")Long id);
void clearMemberCode();
} }
...@@ -548,6 +548,8 @@ public class MemberUserServiceImpl implements MemberUserService { ...@@ -548,6 +548,8 @@ public class MemberUserServiceImpl implements MemberUserService {
public void historyCodeFlush() { public void historyCodeFlush() {
Long startUserId = 0L; Long startUserId = 0L;
long limit = 500; long limit = 500;
memberUserMapper.clearMemberCode();
redisHelper.delete("memberCode:max:number");
while(true) { while(true) {
List<MemberUserDO> result = this.getByCursor(startUserId, limit); List<MemberUserDO> result = this.getByCursor(startUserId, limit);
if (CollectionUtils.isEmpty(result)) { if (CollectionUtils.isEmpty(result)) {
......
...@@ -91,4 +91,7 @@ ...@@ -91,4 +91,7 @@
<update id="updateMemberCodeById" > <update id="updateMemberCodeById" >
update member_user set code = #{code} where id = #{id} update member_user set code = #{code} where id = #{id}
</update> </update>
<update id="clearMemberCode">
update member_user set code = ''
</update>
</mapper> </mapper>
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