Kaynağa Gözat

fix(backend): 勋章创建自动生成badgeId避免唯一键500

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
E2E Test Bot 3 hafta önce
ebeveyn
işleme
5d87adea0f

+ 4 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/BadgeService.java

@@ -50,6 +50,10 @@ public class BadgeService {
 
     @Transactional
     public void createBadge(Badge badge) {
+        // badge_id 为唯一非空字段,前端未传时自动生成,避免 NOT NULL 约束报 500
+        if (badge.getBadgeId() == null || badge.getBadgeId().trim().isEmpty()) {
+            badge.setBadgeId("b_" + java.util.UUID.randomUUID().toString().replace("-", "").substring(0, 12));
+        }
         badge.setCreatedAt(new Date());
         badge.setUpdatedAt(new Date());
         badgeMapper.insert(badge);