fix(resource_pool): 资源池列表排序,大模型的永远放到第一条

main
youys 5 days ago
parent 48732e31b3
commit ac03fae49a

@ -17,4 +17,4 @@ create table nodes(
update_time timestamp default current_timestamp on update current_timestamp
);
INSERT INTO hami.resource_pool (pool_name) VALUES ('大模型资源池');
INSERT INTO hami.resource_pool (id, pool_name) VALUES (1, '大模型资源池');

@ -58,7 +58,7 @@ func QueryResourcePoolById(poolId int64) (*ResourcePool, error) {
func QueryResourcePoolListAll() ([]*ResourcePool, error) {
// 执行查询
rows, err := db.Query("SELECT id, pool_name, create_time, update_time FROM resource_pool order by id asc")
rows, err := db.Query("SELECT id, pool_name, create_time, update_time FROM resource_pool order by create_time desc")
if err != nil {
log.Infof("Query failed: %v", err)
return nil, err

@ -127,6 +127,17 @@ func (s *ResourcePoolService) List(ctx context.Context, req *pb.ResourcePoolList
return nil, errors.New("获取资源池列表失败")
}
// Sort the resourcePoolList to put ID 1 first
sort.Slice(resourcePoolList, func(i, j int) bool {
if resourcePoolList[i].Id == 1 {
return true
}
if resourcePoolList[j].Id == 1 {
return false
}
return resourcePoolList[i].CreateTime.After(resourcePoolList[j].CreateTime)
})
var data []*pb.ResourcePoolListData
k8sNodes := s.getK8sNodes(ctx)
for _, resourcePool := range resourcePoolList {

Loading…
Cancel
Save