feat:完善项目信息
This commit is contained in:
42
app/api/website/controller/user/collect.go
Normal file
42
app/api/website/controller/user/collect.go
Normal file
@ -0,0 +1,42 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/website/model"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
)
|
||||
|
||||
type Collect struct {
|
||||
*session.Enterprise
|
||||
}
|
||||
|
||||
type CollectHandle func(session *session.Enterprise) *Collect
|
||||
|
||||
// Launch 收藏发起
|
||||
func (c *Collect) Launch(kind int, objectID uint64) error {
|
||||
mUserCollect := model.NewUserCollect()
|
||||
|
||||
where := []*model2.ModelWhere{
|
||||
model2.NewWhere("uid", c.UID),
|
||||
model2.NewWhere("kind", kind),
|
||||
model2.NewWhere("object_id", objectID),
|
||||
}
|
||||
isExist, err := model2.FirstField(mUserCollect.UserCollect, []string{"id"}, where...)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if isExist {
|
||||
return model2.Delete(mUserCollect.UserCollect)
|
||||
}
|
||||
mUserCollect.UID = c.UID
|
||||
mUserCollect.Kind = model2.UserCollectKind(kind)
|
||||
mUserCollect.ObjectID = objectID
|
||||
return model2.Create(mUserCollect.UserCollect)
|
||||
}
|
||||
|
||||
func NewCollect() CollectHandle {
|
||||
return func(session *session.Enterprise) *Collect {
|
||||
return &Collect{session}
|
||||
}
|
||||
}
|
3
app/api/website/controller/user/instance.go
Normal file
3
app/api/website/controller/user/instance.go
Normal file
@ -0,0 +1,3 @@
|
||||
package user
|
||||
|
||||
type User func()
|
Reference in New Issue
Block a user