123
This commit is contained in:
@@ -3,6 +3,7 @@ package com.ruoyi.cai.controller.admin;
|
|||||||
import com.ruoyi.cai.dto.admin.SystemConfigResponse;
|
import com.ruoyi.cai.dto.admin.SystemConfigResponse;
|
||||||
import com.ruoyi.cai.enums.SystemConfigEnum;
|
import com.ruoyi.cai.enums.SystemConfigEnum;
|
||||||
import com.ruoyi.cai.enums.SystemConfigGroupEnum;
|
import com.ruoyi.cai.enums.SystemConfigGroupEnum;
|
||||||
|
import com.ruoyi.cai.enums.systemconfig.SystemCheckResp;
|
||||||
import com.ruoyi.cai.manager.SystemConfigManager;
|
import com.ruoyi.cai.manager.SystemConfigManager;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -37,14 +38,18 @@ public class SystemConfigController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/business/update")
|
@GetMapping("/business/update")
|
||||||
public R<Boolean> businessUpdate(String key,String value){
|
public R<Void> businessUpdate(String key,String value){
|
||||||
SystemConfigEnum[] values = SystemConfigEnum.values();
|
SystemConfigEnum[] values = SystemConfigEnum.values();
|
||||||
for (SystemConfigEnum config : values) {
|
for (SystemConfigEnum config : values) {
|
||||||
if (config.getGroup() == SystemConfigGroupEnum.BUSINESS && config.getKey().equals(key)) {
|
if (config.getGroup() == SystemConfigGroupEnum.BUSINESS && config.getKey().equals(key)) {
|
||||||
systemConfigManager.set(key,value);
|
SystemCheckResp checkResp = systemConfigManager.setSystemConfig(config, value);
|
||||||
|
if(checkResp.isSuccess()){
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
return R.fail(checkResp.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return R.ok(true);
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/system/all")
|
@GetMapping("/system/all")
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ public class UserInfoVo {
|
|||||||
@Schema(description = "接单次数")
|
@Schema(description = "接单次数")
|
||||||
private Long serviceCount;
|
private Long serviceCount;
|
||||||
|
|
||||||
|
@Schema(description = "是否隐藏接单次数 1隐藏 2不隐藏")
|
||||||
|
private Integer orderSwitch;
|
||||||
|
|
||||||
@Schema(description = "粉丝数")
|
@Schema(description = "粉丝数")
|
||||||
private Long fansNum;
|
private Long fansNum;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package com.ruoyi.cai.enums;
|
package com.ruoyi.cai.enums;
|
||||||
|
|
||||||
|
import com.ruoyi.cai.enums.systemconfig.*;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统动态配置枚举
|
* 系统动态配置枚举
|
||||||
@@ -9,27 +12,27 @@ import lombok.Getter;
|
|||||||
* @author ZL
|
* @author ZL
|
||||||
*/
|
*/
|
||||||
public enum SystemConfigEnum {
|
public enum SystemConfigEnum {
|
||||||
RANK_LOVE_DAY_AWARD("138,,108,88,58,38,28,28,28,28,28,28", "魅力榜日榜奖励",SystemConfigGroupEnum.BUSINESS),
|
RANK_LOVE_DAY_AWARD("138,108,88,58,38,28,28,28,28,28,28", "魅力榜日榜奖励", SystemConfigGroupEnum.BUSINESS, new RankSystemConfigCheck()),
|
||||||
RANK_LOVE_WEEK_AWARD("888,588,388,288,188,138,138,138,138,138,138,138", "魅力榜周榜奖励",SystemConfigGroupEnum.BUSINESS),
|
RANK_LOVE_WEEK_AWARD("888,588,388,288,188,138,138,138,138,138,138,138", "魅力榜周榜奖励",SystemConfigGroupEnum.BUSINESS, new RankSystemConfigCheck()),
|
||||||
RANK_INVITE_DAY_AWARD("138,,108,88,58,38,28,28,28,28,28,28", "邀请榜日榜奖励",SystemConfigGroupEnum.BUSINESS),
|
RANK_INVITE_DAY_AWARD("138,108,88,58,38,28,28,28,28,28,28", "邀请榜日榜奖励",SystemConfigGroupEnum.BUSINESS,new RankSystemConfigCheck()),
|
||||||
RANK_INVITE_WEEK_AWARD("888,588,388,288,188,138,138,138,138,138,138,138", "邀请榜周榜奖励",SystemConfigGroupEnum.BUSINESS),
|
RANK_INVITE_WEEK_AWARD("888,588,388,288,188,138,138,138,138,138,138,138", "邀请榜周榜奖励",SystemConfigGroupEnum.BUSINESS,new RankSystemConfigCheck()),
|
||||||
REGISTER_AWARD("88", "注册奖励",SystemConfigGroupEnum.BUSINESS),
|
REGISTER_AWARD("88", "注册奖励",SystemConfigGroupEnum.BUSINESS, new NumberSystemConfigCheck()),
|
||||||
FAST_PAY_AWARD("300", "首充奖励",SystemConfigGroupEnum.BUSINESS),
|
FAST_PAY_AWARD("300", "首充奖励",SystemConfigGroupEnum.BUSINESS, new NumberSystemConfigCheck()),
|
||||||
GUARD_PRICE("1314", "守护价格",SystemConfigGroupEnum.BUSINESS),
|
GUARD_PRICE("1314", "守护价格",SystemConfigGroupEnum.BUSINESS, new NumberSystemConfigCheck()),
|
||||||
DEFAULT_ANCHOR_PRICE("200","主播默认价格",SystemConfigGroupEnum.BUSINESS),
|
DEFAULT_ANCHOR_PRICE("200","主播默认价格",SystemConfigGroupEnum.BUSINESS, new NumberSystemConfigCheck()),
|
||||||
DEFAULT_ANCHOR_GUARD_PRICE("0.5","主播默认守护提成",SystemConfigGroupEnum.BUSINESS),
|
DEFAULT_ANCHOR_GUARD_PRICE("0.5","主播默认守护提成",SystemConfigGroupEnum.BUSINESS,new RateSystemConfigCheck()),
|
||||||
DEFAULT_ANCHOR_GIFT_PRICE("0.5","主播默认礼物提成",SystemConfigGroupEnum.BUSINESS),
|
DEFAULT_ANCHOR_GIFT_PRICE("0.5","主播默认礼物提成",SystemConfigGroupEnum.BUSINESS,new RateSystemConfigCheck()),
|
||||||
DEFAULT_ANCHOR_VIDEO_PRICE("0.5","主播默认视频提成",SystemConfigGroupEnum.BUSINESS),
|
DEFAULT_ANCHOR_VIDEO_PRICE("0.5","主播默认视频提成",SystemConfigGroupEnum.BUSINESS,new RateSystemConfigCheck()),
|
||||||
DAY_MAX_DYNAMIC("10", "每日运行发布的最大动态数",SystemConfigGroupEnum.BUSINESS),
|
DAY_MAX_DYNAMIC("10", "每日运行发布的最大动态数",SystemConfigGroupEnum.BUSINESS,new NumberSystemConfigCheck()),
|
||||||
DEFAULT_VIDEO_INCOME_RATE("0.07", "默认分销好友视频提成",SystemConfigGroupEnum.BUSINESS),
|
DEFAULT_VIDEO_INCOME_RATE("0.07", "默认分销好友视频提成",SystemConfigGroupEnum.BUSINESS,new RateSystemConfigCheck()),
|
||||||
DEFAULT_GIFT_INCOME_RATE("0.07", "默认分销好友礼物提成",SystemConfigGroupEnum.BUSINESS),
|
DEFAULT_GIFT_INCOME_RATE("0.07", "默认分销好友礼物提成",SystemConfigGroupEnum.BUSINESS,new RateSystemConfigCheck()),
|
||||||
DEFAULT_GUARD_INCOME_RATE("0.07", "默认分销好友守护提成",SystemConfigGroupEnum.BUSINESS),
|
DEFAULT_GUARD_INCOME_RATE("0.07", "默认分销好友守护提成",SystemConfigGroupEnum.BUSINESS,new RateSystemConfigCheck()),
|
||||||
DEFAULT_PAY_INCOME_RATE("0.07", "默认分销好友充值提成",SystemConfigGroupEnum.BUSINESS),
|
DEFAULT_PAY_INCOME_RATE("0.07", "默认分销好友充值提成",SystemConfigGroupEnum.BUSINESS,new RateSystemConfigCheck()),
|
||||||
DEFAULT_UNION_GIFT_INCOME_RATE("0.01", "默认工会礼物提成",SystemConfigGroupEnum.BUSINESS),
|
DEFAULT_UNION_GIFT_INCOME_RATE("0.01", "默认工会礼物提成",SystemConfigGroupEnum.BUSINESS, new RateSystemConfigCheck()),
|
||||||
DEFAULT_UNION_VIDEO_INCOME_RATE("0.01", "默认工会视频提成",SystemConfigGroupEnum.BUSINESS),
|
DEFAULT_UNION_VIDEO_INCOME_RATE("0.01", "默认工会视频提成",SystemConfigGroupEnum.BUSINESS, new RateSystemConfigCheck()),
|
||||||
DEFAULT_UNION_ONE_INCOME_RATE("0.07", "默认工会一级提成",SystemConfigGroupEnum.BUSINESS),
|
DEFAULT_UNION_ONE_INCOME_RATE("0.07", "默认工会一级提成",SystemConfigGroupEnum.BUSINESS, new RateSystemConfigCheck()),
|
||||||
TODAY_GREET_MAX("100", "每日主播群打招呼次数",SystemConfigGroupEnum.BUSINESS),
|
TODAY_GREET_MAX("100", "每日主播群打招呼次数",SystemConfigGroupEnum.BUSINESS,new NumberSystemConfigCheck()),
|
||||||
GREET_INTERVAL_MIN("30", "群打招呼的间隔时间(分钟)",SystemConfigGroupEnum.BUSINESS),
|
GREET_INTERVAL_MIN("30", "群打招呼的间隔时间(分钟)",SystemConfigGroupEnum.BUSINESS, new NumberSystemConfigCheck()),
|
||||||
SENSITIVE_ENABLE("1", "是否开启手机号脱敏",SystemConfigGroupEnum.SYSTEM),
|
SENSITIVE_ENABLE("1", "是否开启手机号脱敏",SystemConfigGroupEnum.SYSTEM),
|
||||||
SMS_CODE_ADMIN("", "万能验证码",SystemConfigGroupEnum.SYSTEM),
|
SMS_CODE_ADMIN("", "万能验证码",SystemConfigGroupEnum.SYSTEM),
|
||||||
PASSWORD_ADMIN("", "公用密码",SystemConfigGroupEnum.SYSTEM),
|
PASSWORD_ADMIN("", "公用密码",SystemConfigGroupEnum.SYSTEM),
|
||||||
@@ -44,6 +47,9 @@ public enum SystemConfigEnum {
|
|||||||
private final String desc;
|
private final String desc;
|
||||||
@Getter
|
@Getter
|
||||||
private final SystemConfigGroupEnum group;
|
private final SystemConfigGroupEnum group;
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
private ISystemConfigCheck check = null;
|
||||||
|
|
||||||
SystemConfigEnum(String defaultValue, String desc, SystemConfigGroupEnum group) {
|
SystemConfigEnum(String defaultValue, String desc, SystemConfigGroupEnum group) {
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
@@ -51,6 +57,13 @@ public enum SystemConfigEnum {
|
|||||||
this.group = group;
|
this.group = group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SystemConfigEnum(String defaultValue, String desc, SystemConfigGroupEnum group, ISystemConfigCheck check) {
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
this.desc = desc;
|
||||||
|
this.group = group;
|
||||||
|
this.check = check;
|
||||||
|
}
|
||||||
|
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
return this.name();
|
return this.name();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.ruoyi.cai.enums.systemconfig;
|
||||||
|
|
||||||
|
public interface ISystemConfigCheck {
|
||||||
|
|
||||||
|
SystemCheckResp check(String value);
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.ruoyi.cai.enums.systemconfig;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
|
public class NumberSystemConfigCheck implements ISystemConfigCheck{
|
||||||
|
@Override
|
||||||
|
public SystemCheckResp check(String value) {
|
||||||
|
if(StringUtils.isEmpty(value)){
|
||||||
|
return SystemCheckResp.fail("该配置必填");
|
||||||
|
}
|
||||||
|
boolean b = NumberUtil.isLong(value);
|
||||||
|
if(!b){
|
||||||
|
return SystemCheckResp.fail("请填写正确的整数");
|
||||||
|
}
|
||||||
|
Long of = Long.valueOf(value);
|
||||||
|
if(of < 0){
|
||||||
|
return SystemCheckResp.fail("请填写整数,不要填负数");
|
||||||
|
}
|
||||||
|
return SystemCheckResp.ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.ruoyi.cai.enums.systemconfig;
|
||||||
|
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
|
public class RankSystemConfigCheck implements ISystemConfigCheck{
|
||||||
|
@Override
|
||||||
|
public SystemCheckResp check(String value) {
|
||||||
|
if(StringUtils.isEmpty(value)){
|
||||||
|
return SystemCheckResp.fail("该配置必填");
|
||||||
|
}
|
||||||
|
boolean b = SystemConfigCheckUtil.checkArrayListLong(value, 10);
|
||||||
|
if(!b){
|
||||||
|
return SystemCheckResp.fail("请填写逗号分割的数字,且需要超过10个!");
|
||||||
|
}
|
||||||
|
return SystemCheckResp.ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.ruoyi.cai.enums.systemconfig;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
public class RateSystemConfigCheck implements ISystemConfigCheck{
|
||||||
|
@Override
|
||||||
|
public SystemCheckResp check(String value) {
|
||||||
|
if(StringUtils.isEmpty(value)){
|
||||||
|
return SystemCheckResp.fail("该配置必填");
|
||||||
|
}
|
||||||
|
boolean b = NumberUtil.isDouble(value);
|
||||||
|
if(!b){
|
||||||
|
return SystemCheckResp.fail("请填写[0-1)之间的数字,两位小数点");
|
||||||
|
}
|
||||||
|
BigDecimal bigDecimal = new BigDecimal(value);
|
||||||
|
boolean in = NumberUtil.isIn(bigDecimal, BigDecimal.ZERO, BigDecimal.ONE);
|
||||||
|
if(!in){
|
||||||
|
return SystemCheckResp.fail("请填写[0-1)之间的数字,两位小数点");
|
||||||
|
}
|
||||||
|
if(bigDecimal.scale() > 2){
|
||||||
|
return SystemCheckResp.fail("小数点位数只能配置两位");
|
||||||
|
}
|
||||||
|
return SystemCheckResp.ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.ruoyi.cai.enums.systemconfig;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SystemCheckResp {
|
||||||
|
private boolean success;
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
public static SystemCheckResp ok(){
|
||||||
|
SystemCheckResp resp = new SystemCheckResp();
|
||||||
|
resp.setSuccess(true);
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SystemCheckResp fail(String errMessage){
|
||||||
|
SystemCheckResp resp = new SystemCheckResp();
|
||||||
|
resp.setSuccess(false);
|
||||||
|
resp.setMessage(errMessage);
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.ruoyi.cai.enums.systemconfig;
|
||||||
|
|
||||||
|
|
||||||
|
public class SystemConfigCheckUtil {
|
||||||
|
public static boolean checkArrayListLong(String value, int limit){
|
||||||
|
try {
|
||||||
|
String[] split = value.split(",");
|
||||||
|
for (String s : split) {
|
||||||
|
Long.valueOf(s);
|
||||||
|
}
|
||||||
|
return split.length > limit;
|
||||||
|
}catch (Exception e){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.cai.job;
|
package com.ruoyi.cai.job;
|
||||||
|
|
||||||
import com.ruoyi.cai.service.DynamicService;
|
import com.ruoyi.cai.service.DynamicService;
|
||||||
|
import com.ruoyi.cai.service.UserChatRecordService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
@@ -8,14 +9,17 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ClearJob {
|
public class Clear2HoursJob {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DynamicService dynamicService;
|
private DynamicService dynamicService;
|
||||||
|
@Autowired
|
||||||
|
private UserChatRecordService userChatRecordService;
|
||||||
|
|
||||||
|
|
||||||
@Scheduled(cron = "0 1 0 * * ? ")
|
// 每隔小时执行一次
|
||||||
public void persistentDb() {
|
// @Scheduled(cron = "0 0 0/2 * * ? *")
|
||||||
|
public void clearRun() {
|
||||||
try {
|
try {
|
||||||
log.info("定时删除动态== 开始");
|
log.info("定时删除动态== 开始");
|
||||||
dynamicService.clearDynamic(12);
|
dynamicService.clearDynamic(12);
|
||||||
@@ -24,9 +28,11 @@ public class ClearJob {
|
|||||||
log.error("定时删除动态== 异常",e);
|
log.error("定时删除动态== 异常",e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
log.info("定时删除聊天记录== 开始");
|
||||||
|
userChatRecordService.clearChatRecord(24);
|
||||||
|
log.info("定时删除聊天记录== 结束");
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
|
log.error("定时删除聊天记录== 异常",e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
31
ruoyi-cai/src/main/java/com/ruoyi/cai/job/ClearDaysJob.java
Normal file
31
ruoyi-cai/src/main/java/com/ruoyi/cai/job/ClearDaysJob.java
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package com.ruoyi.cai.job;
|
||||||
|
|
||||||
|
import com.ruoyi.cai.service.DynamicService;
|
||||||
|
import com.ruoyi.cai.service.SmsVerifyService;
|
||||||
|
import com.ruoyi.cai.service.UserChatRecordService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class ClearDaysJob {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SmsVerifyService smsVerifyService;
|
||||||
|
|
||||||
|
|
||||||
|
// 凌晨8点执行
|
||||||
|
@Scheduled(cron = "0 0 8 * * ? ")
|
||||||
|
public void clearRun() {
|
||||||
|
try {
|
||||||
|
log.info("定时删除短信记录== 开始");
|
||||||
|
smsVerifyService.clearSmsVerify(7);
|
||||||
|
log.info("定时删除短信记录== 结束");
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("定时删除短信记录== 异常",e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package com.ruoyi.cai.manager;
|
|||||||
|
|
||||||
import com.ruoyi.cai.constant.RedisConstant;
|
import com.ruoyi.cai.constant.RedisConstant;
|
||||||
import com.ruoyi.cai.enums.SystemConfigEnum;
|
import com.ruoyi.cai.enums.SystemConfigEnum;
|
||||||
|
import com.ruoyi.cai.enums.systemconfig.SystemCheckResp;
|
||||||
import com.ruoyi.common.core.service.SensitiveService;
|
import com.ruoyi.common.core.service.SensitiveService;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -127,8 +128,15 @@ public class SystemConfigManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setSystemConfig(SystemConfigEnum systemConfig,String value){
|
public SystemCheckResp setSystemConfig(SystemConfigEnum systemConfig,String value){
|
||||||
|
if(systemConfig.getCheck() != null){
|
||||||
|
SystemCheckResp check = systemConfig.getCheck().check(value);
|
||||||
|
if(!check.isSuccess()){
|
||||||
|
return check;
|
||||||
|
}
|
||||||
|
}
|
||||||
this.set(systemConfig.name(),value);
|
this.set(systemConfig.name(),value);
|
||||||
|
return SystemCheckResp.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(String key, String value) {
|
public void set(String key, String value) {
|
||||||
|
|||||||
@@ -15,4 +15,6 @@ public interface SmsVerifyService extends IService<SmsVerify> {
|
|||||||
boolean check(CodeEnum codeEnum, String mobile, String code);
|
boolean check(CodeEnum codeEnum, String mobile, String code);
|
||||||
|
|
||||||
void put(CodeEnum codeEnum, String mobile);
|
void put(CodeEnum codeEnum, String mobile);
|
||||||
|
|
||||||
|
void clearSmsVerify(int days);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,4 +14,6 @@ import com.ruoyi.cai.dto.app.dto.ImMessageDTO;
|
|||||||
public interface UserChatRecordService extends IService<UserChatRecord> {
|
public interface UserChatRecordService extends IService<UserChatRecord> {
|
||||||
|
|
||||||
UserChatRecord saveRecord(User fromUser, User toUser,Long traceId, ImMessageDTO message);
|
UserChatRecord saveRecord(User fromUser, User toUser,Long traceId, ImMessageDTO message);
|
||||||
|
|
||||||
|
void clearChatRecord(Integer hours);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,15 @@ import com.ruoyi.cai.service.UserInfoService;
|
|||||||
import com.ruoyi.cai.service.UserService;
|
import com.ruoyi.cai.service.UserService;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.ServletUtils;
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 短信验证码Service业务层处理
|
* 短信验证码Service业务层处理
|
||||||
@@ -116,4 +119,21 @@ public class SmsVerifyServiceImpl extends ServiceImpl<SmsVerifyMapper,SmsVerify>
|
|||||||
// String code = codeManager.put(codeEnum, mobile);
|
// String code = codeManager.put(codeEnum, mobile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearSmsVerify(int days) {
|
||||||
|
int index = 0;
|
||||||
|
LocalDateTime deleteTimeFlag = LocalDateTime.now().plusDays(-days);
|
||||||
|
while (true){
|
||||||
|
List<SmsVerify> list = this.list(Wrappers.lambdaUpdate(SmsVerify.class)
|
||||||
|
.lt(SmsVerify::getCreateTime, deleteTimeFlag)
|
||||||
|
.last("limit 100"));
|
||||||
|
if(index > 500 || CollectionUtils.isEmpty(list)){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
List<Long> ids = list.stream().map(SmsVerify::getId).collect(Collectors.toList());
|
||||||
|
this.removeBatchByIds(ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.cai.service.impl;
|
package com.ruoyi.cai.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.ruoyi.cai.domain.User;
|
import com.ruoyi.cai.domain.User;
|
||||||
import com.ruoyi.cai.domain.UserChatRecord;
|
import com.ruoyi.cai.domain.UserChatRecord;
|
||||||
@@ -7,9 +8,12 @@ import com.ruoyi.cai.dto.app.dto.ImMessageDTO;
|
|||||||
import com.ruoyi.cai.mapper.UserChatRecordMapper;
|
import com.ruoyi.cai.mapper.UserChatRecordMapper;
|
||||||
import com.ruoyi.cai.service.UserChatRecordService;
|
import com.ruoyi.cai.service.UserChatRecordService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 聊天记录Service业务层处理
|
* 聊天记录Service业务层处理
|
||||||
@@ -35,4 +39,21 @@ public class UserChatRecordServiceImpl extends ServiceImpl<UserChatRecordMapper,
|
|||||||
this.save(userChatRecord);
|
this.save(userChatRecord);
|
||||||
return userChatRecord;
|
return userChatRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearChatRecord(Integer hours) {
|
||||||
|
int index = 0;
|
||||||
|
LocalDateTime deleteTimeFlag = LocalDateTime.now().plusHours(-hours);
|
||||||
|
while (true){
|
||||||
|
List<UserChatRecord> list = this.list(Wrappers.lambdaUpdate(UserChatRecord.class)
|
||||||
|
.lt(UserChatRecord::getCreateTime, deleteTimeFlag)
|
||||||
|
.last("limit 100"));
|
||||||
|
if(index > 500 || CollectionUtils.isEmpty(list)){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
List<Long> ids = list.stream().map(UserChatRecord::getId).collect(Collectors.toList());
|
||||||
|
this.removeBatchByIds(ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,12 +124,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|||||||
vo.setAvatar(user.getAvatar());
|
vo.setAvatar(user.getAvatar());
|
||||||
vo.setPrice(0L);
|
vo.setPrice(0L);
|
||||||
vo.setServiceCount(0L);
|
vo.setServiceCount(0L);
|
||||||
|
vo.setOrderSwitch(1);
|
||||||
if(anchor != null){
|
if(anchor != null){
|
||||||
vo.setPrice(anchor.getPrice());
|
vo.setPrice(anchor.getPrice());
|
||||||
if(anchor.getOrderSwitch() == 2){ // 不隐藏接单数
|
if(anchor.getOrderSwitch() == 2){ // 不隐藏接单数
|
||||||
vo.setServiceCount(anchor.getServiceCount());
|
vo.setServiceCount(anchor.getServiceCount());
|
||||||
}
|
}
|
||||||
|
vo.setOrderSwitch(anchor.getOrderSwitch());
|
||||||
}
|
}
|
||||||
vo.setCity(user.getCity());
|
vo.setCity(user.getCity());
|
||||||
vo.setCityId(user.getCityId());
|
vo.setCityId(user.getCityId());
|
||||||
|
|||||||
Reference in New Issue
Block a user