From 2e9ab75bdf3957f0a4ecb0a9e7e36c46b9e9b7af Mon Sep 17 00:00:00 2001 From: flykhan Date: Fri, 10 Mar 2023 23:56:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=20bot=20=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E8=A7=84=E5=88=99=EF=BC=9A=E9=99=90=E5=88=B6=20bot=20=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=95=B0=E9=87=8F=E4=B8=BA=2010=20=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/service/impl/user/bot/AddServiceImpl.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backendcloud/backend/src/main/java/com/kob/backend/service/impl/user/bot/AddServiceImpl.java b/backendcloud/backend/src/main/java/com/kob/backend/service/impl/user/bot/AddServiceImpl.java index df1afa5..a6f9a11 100644 --- a/backendcloud/backend/src/main/java/com/kob/backend/service/impl/user/bot/AddServiceImpl.java +++ b/backendcloud/backend/src/main/java/com/kob/backend/service/impl/user/bot/AddServiceImpl.java @@ -1,5 +1,6 @@ package com.kob.backend.service.impl.user.bot; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.kob.backend.mapper.BotMapper; import com.kob.backend.pojo.Bot; import com.kob.backend.pojo.User; @@ -49,7 +50,7 @@ public class AddServiceImpl implements AddService { description = "这个用户很懒,什么也没留下~"; } - if (description != null && description.length() > 300) { + if (description.length() > 300) { map.put("error_message", "描述信息长度不能大于300"); return map; } @@ -64,6 +65,13 @@ public class AddServiceImpl implements AddService { return map; } + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("user_id", user.getId()); + if (botMapper.selectCount(queryWrapper) >= 10) { + map.put("error_message", "每个用户最多可以创建 10 个 Bot"); + return map; + } + // 定义当前时间 Date now = new Date(); // 定义一个新 Bot ;创建时间和修改时间开始应该一样