模型插件方法添加

main
liushujing 5 months ago
parent e76b44dc0c
commit 8abd6e600e

@ -27,7 +27,7 @@ import java.util.Map;
* @since 1.0.0 2024-12-20 * @since 1.0.0 2024-12-20
*/ */
@RestController @RestController
@RequestMapping("robot/appaimodel") @RequestMapping(Constant.BASE_PATH+"appaimodel")
@Api(tags="AI模型表") @Api(tags="AI模型表")
public class AppAiModelController { public class AppAiModelController {
@ -49,7 +49,12 @@ public class AppAiModelController {
return new Result<PageData<AppAiModelDTO>>().ok(page); return new Result<PageData<AppAiModelDTO>>().ok(page);
} }
@GetMapping("getAllAiModel")
@ApiOperation("获取所有收藏")
public Result<List<Map<String, Object>>> getAllAiModel(@RequestParam("userid") String userid){
List<Map<String, Object>> allTools = appAiModelService.getAllAiModel(userid);
return new Result<List<Map<String, Object>>>().ok(allTools);
}
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
public Result<AppAiModelDTO> get(@PathVariable("id") Long id){ public Result<AppAiModelDTO> get(@PathVariable("id") Long id){
@ -87,5 +92,13 @@ public class AppAiModelController {
return new Result(); return new Result();
} }
@GetMapping("deleteByIdentifier")
@ApiOperation("删除")
public Result deleteByIdentifier(@RequestParam("userid") String userid, @RequestParam("identifier") String identifier){
//效验数据
appAiModelService.deleteByIdentifier(userid,identifier);
return new Result();
}
} }

@ -27,7 +27,7 @@ import java.util.Map;
* @since 1.0.0 2024-12-20 * @since 1.0.0 2024-12-20
*/ */
@RestController @RestController
@RequestMapping("robot/appaiplugin") @RequestMapping(Constant.BASE_PATH+"appaiplugin")
@Api(tags="AI插件表") @Api(tags="AI插件表")
public class AppAiPluginController { public class AppAiPluginController {
@ -49,7 +49,12 @@ public class AppAiPluginController {
return new Result<PageData<AppAiPluginDTO>>().ok(page); return new Result<PageData<AppAiPluginDTO>>().ok(page);
} }
@GetMapping("getAllAiPlugin")
@ApiOperation("获取所有收藏")
public Result<List<Map<String, Object>>> getAllAiPlugin(@RequestParam("userid") String userid){
List<Map<String, Object>> allTools = appAiPluginService.getAllAiPlugin(userid);
return new Result<List<Map<String, Object>>>().ok(allTools);
}
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
public Result<AppAiPluginDTO> get(@PathVariable("id") Long id){ public Result<AppAiPluginDTO> get(@PathVariable("id") Long id){
@ -87,5 +92,12 @@ public class AppAiPluginController {
return new Result(); return new Result();
} }
@GetMapping("deleteByIdentifier")
@ApiOperation("删除")
public Result deleteByIdentifier(@RequestParam("userid") String userid, @RequestParam("identifier") String identifier){
//效验数据
appAiPluginService.deleteByIdentifier(userid,identifier);
return new Result();
}
} }

@ -4,6 +4,9 @@ import com.pjilisense.flxai.base.service.CrudService;
import com.pjilisense.flxai.dto.AppAiModelDTO; import com.pjilisense.flxai.dto.AppAiModelDTO;
import com.pjilisense.flxai.entity.AppAiModelEntity; import com.pjilisense.flxai.entity.AppAiModelEntity;
import java.util.List;
import java.util.Map;
/** /**
* AI * AI
* *
@ -12,4 +15,7 @@ import com.pjilisense.flxai.entity.AppAiModelEntity;
*/ */
public interface AppAiModelService extends CrudService<AppAiModelEntity, AppAiModelDTO> { public interface AppAiModelService extends CrudService<AppAiModelEntity, AppAiModelDTO> {
int deleteByIdentifier(String userid, String identifier);
List<Map<String, Object>> getAllAiModel(String userid);
} }

@ -4,6 +4,9 @@ import com.pjilisense.flxai.base.service.CrudService;
import com.pjilisense.flxai.dto.AppAiPluginDTO; import com.pjilisense.flxai.dto.AppAiPluginDTO;
import com.pjilisense.flxai.entity.AppAiPluginEntity; import com.pjilisense.flxai.entity.AppAiPluginEntity;
import java.util.List;
import java.util.Map;
/** /**
* AI * AI
* *
@ -12,4 +15,7 @@ import com.pjilisense.flxai.entity.AppAiPluginEntity;
*/ */
public interface AppAiPluginService extends CrudService<AppAiPluginEntity, AppAiPluginDTO> { public interface AppAiPluginService extends CrudService<AppAiPluginEntity, AppAiPluginDTO> {
List<Map<String, Object>> getAllAiPlugin(String userid);
int deleteByIdentifier(String userid, String identifier);
} }

@ -58,7 +58,7 @@ public class AppAiAssistantServiceImpl extends CrudServiceImpl<AppAiAssistantDao
meta.put("title", mapx.get("title")); meta.put("title", mapx.get("title"));
meta.put("category", mapx.get("category")); meta.put("category", mapx.get("category"));
String tags = (String) mapx.get("tags"); String tags = (String) mapx.get("tags");
if (tags.length() > 0) { if (tags!=null && tags.length() > 0) {
meta.put("tags", Arrays.asList(tags.split("\\,"))); meta.put("tags", Arrays.asList(tags.split("\\,")));
} else { } else {
meta.put("tags", new ArrayList<>()); meta.put("tags", new ArrayList<>());

@ -5,11 +5,13 @@ import com.pjilisense.flxai.base.service.impl.CrudServiceImpl;
import com.pjilisense.flxai.dao.AppAiModelDao; import com.pjilisense.flxai.dao.AppAiModelDao;
import com.pjilisense.flxai.dto.AppAiModelDTO; import com.pjilisense.flxai.dto.AppAiModelDTO;
import com.pjilisense.flxai.entity.AppAiModelEntity; import com.pjilisense.flxai.entity.AppAiModelEntity;
import com.pjilisense.flxai.entity.AppAiPluginEntity;
import com.pjilisense.flxai.service.AppAiModelService; import com.pjilisense.flxai.service.AppAiModelService;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.pjilisense.flxai.utils.MapUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Map; import java.util.*;
/** /**
* AI * AI
@ -30,5 +32,78 @@ public class AppAiModelServiceImpl extends CrudServiceImpl<AppAiModelDao, AppAiM
return wrapper; return wrapper;
} }
public QueryWrapper<AppAiModelEntity> getWrapperAll(Map<String, Object> params){
String userid = (String)params.get("userid");
QueryWrapper<AppAiModelEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StrUtil.isNotBlank(userid), "userid", userid);
wrapper.orderByDesc("created_at");
return wrapper;
}
@Override
public int deleteByIdentifier(String userid, String identifier) {
QueryWrapper<AppAiModelEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StrUtil.isNotBlank(identifier), "identifier", identifier);
wrapper.eq(StrUtil.isNotBlank(userid), "userid", userid);
return baseDao.delete(wrapper);
}
@Override
public List<Map<String, Object>> getAllAiModel(String userid) {
Map<String, Object> params =new HashMap<>();
params.put("userid",userid);
List<AppAiModelEntity> entityList = baseDao.selectList(getWrapperAll(params));
params.clear();
List<Map<String, Object>> retList = new ArrayList<>();
if(entityList!=null && entityList.size()>0) {
for (AppAiModelEntity entity : entityList) {
Map<String, Object> mapx = MapUtils.objectToMap(entity);
retList.add(mapx);
HashMap<String, Object> meta = new HashMap<>();
mapx.put("meta", meta);
meta.put("displayName", mapx.get("displayName"));
meta.put("description", mapx.get("description"));
meta.put("title", mapx.get("title"));
meta.put("enabled", mapx.get("enabled"));
meta.put("category", mapx.get("category"));
meta.put("metaId", mapx.get("metaId"));
meta.put("metaTokens", mapx.get("metaTokens"));
String tags = (String) mapx.get("tags");
if (tags!=null && tags.length() > 0) {
meta.put("tags", Arrays.asList(tags.split("\\,")));
} else {
meta.put("tags", new ArrayList<>());
}
mapx.remove("displayName");
mapx.remove("description");
mapx.remove("title");
mapx.remove("enabled");
mapx.remove("category");
mapx.remove("metaId");
mapx.remove("metaTokens");
String providers = (String) mapx.get("providers");
if (providers!=null && providers.length() > 0) {
meta.put("providers", Arrays.asList(providers.split("\\,")));
} else {
meta.put("providers", new ArrayList<>());
}
HashMap<String, Object> socialData = new HashMap<>();
mapx.put("socialData", socialData);
meta.put("conversations", mapx.get("conversations"));
meta.put("likes", mapx.get("likes"));
meta.put("tokens", mapx.get("tokens"));
mapx.remove("conversations");
mapx.remove("likes");
mapx.remove("tokens");
String suggestions = (String) mapx.get("suggestions");
if (suggestions!=null && suggestions.length() > 0) {
meta.put("suggestions", Arrays.asList(suggestions.split("\\,")));
} else {
meta.put("suggestions", new ArrayList<>());
}
}
}
return retList;
}
} }

@ -7,9 +7,10 @@ import com.pjilisense.flxai.dto.AppAiPluginDTO;
import com.pjilisense.flxai.entity.AppAiPluginEntity; import com.pjilisense.flxai.entity.AppAiPluginEntity;
import com.pjilisense.flxai.service.AppAiPluginService; import com.pjilisense.flxai.service.AppAiPluginService;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.pjilisense.flxai.utils.MapUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Map; import java.util.*;
/** /**
* AI * AI
@ -30,5 +31,52 @@ public class AppAiPluginServiceImpl extends CrudServiceImpl<AppAiPluginDao, AppA
return wrapper; return wrapper;
} }
public QueryWrapper<AppAiPluginEntity> getWrapperAll(Map<String, Object> params){
String userid = (String)params.get("userid");
QueryWrapper<AppAiPluginEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StrUtil.isNotBlank(userid), "userid", userid);
wrapper.orderByDesc("created_at");
return wrapper;
}
@Override
public List<Map<String, Object>> getAllAiPlugin(String userid) {
Map<String, Object> params =new HashMap<>();
params.put("userid",userid);
List<AppAiPluginEntity> entityList = baseDao.selectList(getWrapperAll(params));
params.clear();
List<Map<String, Object>> retList = new ArrayList<>();
if(entityList!=null && entityList.size()>0) {
for (AppAiPluginEntity entity : entityList) {
Map<String, Object> mapx = MapUtils.objectToMap(entity);
retList.add(mapx);
HashMap<String, Object> meta = new HashMap<>();
mapx.put("meta", meta);
meta.put("avatar", mapx.get("avatar"));
meta.put("description", mapx.get("description"));
meta.put("title", mapx.get("title"));
meta.put("category", mapx.get("category"));
String tags = (String) mapx.get("tags");
if (tags!=null && tags.length() > 0) {
meta.put("tags", Arrays.asList(tags.split("\\,")));
} else {
meta.put("tags", new ArrayList<>());
}
mapx.remove("avatar");
mapx.remove("description");
mapx.remove("title");
mapx.remove("category");
mapx.remove("tags");
}
}
return retList;
}
@Override
public int deleteByIdentifier(String userid, String identifier) {
QueryWrapper<AppAiPluginEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StrUtil.isNotBlank(identifier), "identifier", identifier);
wrapper.eq(StrUtil.isNotBlank(userid), "userid", userid);
return baseDao.delete(wrapper);
}
} }
Loading…
Cancel
Save