| 
					
				 | 
			
			
				@@ -1,13 +1,17 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.zanxiang.game.data.serve.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.zanxiang.game.data.serve.pojo.dto.GameDTO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.zanxiang.game.data.serve.pojo.dto.GameUserConfigCreateOrUpdateDTO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.zanxiang.game.data.serve.pojo.dto.GameUserConfigListDTO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.zanxiang.game.data.serve.pojo.entity.GameUserConfig; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.zanxiang.game.data.serve.pojo.vo.GameUserConfigListVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.zanxiang.game.data.serve.service.IGameUserConfigService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.zanxiang.game.data.serve.utils.Page; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.zanxiang.module.util.exception.BaseException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.nutz.dao.Cnd; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.nutz.dao.Dao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.nutz.dao.FieldFilter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.nutz.dao.Sqls; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.nutz.dao.pager.Pager; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.nutz.dao.sql.Criteria; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -15,6 +19,7 @@ import org.nutz.dao.sql.Sql; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.time.LocalDateTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.function.Function; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -25,7 +30,7 @@ import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @author ZhangXianyu 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @date 2024/4/18 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- * @description TODO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @description 创角配置 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class GameUserConfigServiceImpl implements IGameUserConfigService { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -68,6 +73,48 @@ public class GameUserConfigServiceImpl implements IGameUserConfigService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return new Page<>(list, pager); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public Boolean create(GameUserConfigCreateOrUpdateDTO dto) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int gameId = dao.count(GameUserConfig.class, Cnd.where("game_id", "=", dto.getGameId())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (gameId > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           throw new BaseException("该游戏已存在创角配置"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        GameUserConfig gameUserConfig = new GameUserConfig(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        gameUserConfig.setSourceSystem("ZX_ONE"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        gameUserConfig.setGameId(dto.getGameId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        gameUserConfig.setRoleLevel(dto.getRoleLevel()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        gameUserConfig.setCreateTime(LocalDateTime.now()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        gameUserConfig.setUpdateTime(LocalDateTime.now()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        dao.insert(gameUserConfig); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public Boolean delete(Long id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        dao.delete(GameUserConfig.class, id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public Boolean update(GameUserConfigCreateOrUpdateDTO dto) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(dto.getId()==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new BaseException("id不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int count = dao.count(GameUserConfig.class, Cnd.where("game_id", "=", dto.getGameId()).and("id", "!=", dto.getId())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (count > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new BaseException("该游戏已存在创角配置"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        GameUserConfig old = dao.fetch(GameUserConfig.class, Cnd.where("id", "=", dto.getId())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (old == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new BaseException("创角配置不存在"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        old.setUpdateTime(LocalDateTime.now()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        old.setGameId(dto.getGameId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        old.setRoleLevel(dto.getRoleLevel()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        dao.update(old, FieldFilter.create(GameUserConfig.class, "gameId|roleLevel|updateTime")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public String getGameUserConfigSql(Criteria criA) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String sql = """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 select  
			 |