14 lines
568 B
Go
14 lines
568 B
Go
package gmodel
|
|
|
|
import "context"
|
|
|
|
// TODO: 使用model的属性做你想做的
|
|
func (m *FsMerchantCategoryModel) FindOne(ctx context.Context, id int64) (resp *FsMerchantCategory, err error) {
|
|
err = m.db.WithContext(ctx).Model(&FsMerchantCategory{}).Where("id = ? and status = ?", id, 1).Take(&resp).Error
|
|
return resp, err
|
|
}
|
|
func (m *FsMerchantCategoryModel) FindRandOne(ctx context.Context) (resp *FsMerchantCategory, err error) {
|
|
err = m.db.WithContext(ctx).Model(&FsMerchantCategory{}).Where("status = ?", 1).Order("RAND()").Take(&resp).Error
|
|
return resp, err
|
|
}
|