feat: 限制用户单日提问次数
This commit is contained in:
@@ -46,3 +46,12 @@ func (s *AiChatHistoryService) DeleteHistory(userId, id string) error {
|
||||
func (s *AiChatHistoryService) ClearHistory(userId string) error {
|
||||
return global.DB.Where("user_id = ?", userId).Delete(&plantModel.AiChatHistory{}).Error
|
||||
}
|
||||
|
||||
// GetTodayCount 获取用户今日问答数量
|
||||
func (s *AiChatHistoryService) GetTodayCount(userId string) (int64, error) {
|
||||
var count int64
|
||||
err := global.DB.Model(&plantModel.AiChatHistory{}).
|
||||
Where("user_id = ? AND DATE(created_at) = CURDATE()", userId).
|
||||
Count(&count).Error
|
||||
return count, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user