书籍列表接口新增参数
This commit is contained in:
36
internal/logic/user_read_history/user_read_history.go
Normal file
36
internal/logic/user_read_history/user_read_history.go
Normal file
@ -0,0 +1,36 @@
|
||||
package userreadhistory
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/dao"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
"server/utility/ecode"
|
||||
)
|
||||
|
||||
type sUserReadHistory struct{}
|
||||
|
||||
func New() service.IUserReadHistory {
|
||||
return &sUserReadHistory{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.RegisterUserReadHistory(New())
|
||||
}
|
||||
|
||||
func (s *sUserReadHistory) Remove(ctx context.Context, in *model.UserReadHistoryDelIn) (out *model.UserReadHistoryCRUDOut, err error) {
|
||||
// 参数校验
|
||||
if in.UserId == 0 || len(in.BookIds) == 0 {
|
||||
return nil, ecode.Params.Sub("user_read_history_remove_param_invalid")
|
||||
}
|
||||
|
||||
_, err = dao.UserReadHistory.Ctx(ctx).
|
||||
Where(dao.UserReadHistory.Columns().UserId, in.UserId).
|
||||
WhereIn(dao.UserReadHistory.Columns().BookId, in.BookIds).
|
||||
Delete()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("user_read_history_remove_failed")
|
||||
}
|
||||
|
||||
return &model.UserReadHistoryCRUDOut{Success: true}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user