feat: 完成图片模型单独扣费

This commit is contained in:
chenchun
2026-01-04 12:32:31 +08:00
parent 9ec9ace8e2
commit bd30a40a6f
4 changed files with 68 additions and 11 deletions

View File

@@ -64,6 +64,13 @@ public class ImageGenerationJob : AsyncBackgroundJob<ImageGenerationJobArgs>, IT
{
contents = new[]
{
new
{
role = "user", parts = new List<object>
{
new { text = "我只要图片,直接生成图片,不要询问我" }
}
},
new { role = "user", parts }
}
};

View File

@@ -264,7 +264,7 @@ public class AiImageService : ApplicationService
ErrorInfo = x.ErrorInfo,
UserName = x.UserName,
UserId = x.UserId,
IsAnonymous =x.IsAnonymous
IsAnonymous = x.IsAnonymous
})
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
@@ -272,6 +272,17 @@ public class AiImageService : ApplicationService
return new PagedResult<ImageTaskOutput>(total, output);
}
/// <summary>
/// 删除个人图片
/// </summary>
/// <param name="ids"></param>
[HttpDelete("ai-image/my-tasks")]
public async Task DeleteMyTaskAsync([FromBody] List<Guid> ids)
{
var userId = CurrentUser.GetId();
await _imageTaskRepository.DeleteAsync(x => ids.Contains(x.Id) && x.UserId == userId);
}
/// <summary>
/// 分页查询图片广场(已发布的图片)
/// </summary>
@@ -285,8 +296,9 @@ public class AiImageService : ApplicationService
.Where(x => x.TaskStatus == TaskStatusEnum.Success)
.WhereIF(input.TaskStatus is not null, x => x.TaskStatus == input.TaskStatus)
.WhereIF(!string.IsNullOrWhiteSpace(input.Prompt), x => x.Prompt.Contains(input.Prompt))
.WhereIF(!string.IsNullOrWhiteSpace(input.Categories), x => SqlFunc.JsonLike(x.Categories, input.Categories))
.WhereIF(!string.IsNullOrWhiteSpace(input.UserName),x=>x.UserName.Contains(input.UserName) )
.WhereIF(!string.IsNullOrWhiteSpace(input.Categories),
x => SqlFunc.JsonLike(x.Categories, input.Categories))
.WhereIF(!string.IsNullOrWhiteSpace(input.UserName), x => x.UserName.Contains(input.UserName))
.WhereIF(input.StartTime is not null && input.EndTime is not null,
x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime)
.OrderByDescending(x => x.CreationTime)
@@ -303,9 +315,9 @@ public class AiImageService : ApplicationService
ErrorInfo = null,
UserName = x.UserName,
UserId = x.UserId,
})
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total); ;
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
;
output.ForEach(x =>
@@ -316,7 +328,7 @@ public class AiImageService : ApplicationService
x.UserId = null;
}
});
return new PagedResult<ImageTaskOutput>(total, output);
}
@@ -345,7 +357,7 @@ public class AiImageService : ApplicationService
}
//设置发布
task.SetPublish(input.IsAnonymous,input.Categories);
task.SetPublish(input.IsAnonymous, input.Categories);
await _imageTaskRepository.UpdateAsync(task);
}