You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.2 KiB
80 lines
2.2 KiB
package service
|
|
|
|
import (
|
|
"bkb-seller/global"
|
|
"bkb-seller/model"
|
|
"bkb-seller/model/request"
|
|
)
|
|
|
|
//@author: [piexlmax](https://github.com/piexlmax)
|
|
//@function: CreateBusiness
|
|
//@description: 创建Business记录
|
|
//@param: business model.Business
|
|
//@return: err error
|
|
|
|
func CreateBusiness(business model.SellerStore) (err error) {
|
|
err = global.MG_DB.Create(&business).Error
|
|
return err
|
|
}
|
|
|
|
//@author: [piexlmax](https://github.com/piexlmax)
|
|
//@function: DeleteBusiness
|
|
//@description: 删除Business记录
|
|
//@param: business model.Business
|
|
//@return: err error
|
|
|
|
func DeleteBusiness(business model.SellerStore) (err error) {
|
|
err = global.MG_DB.Delete(&business).Error
|
|
return err
|
|
}
|
|
|
|
//@author: [piexlmax](https://github.com/piexlmax)
|
|
//@function: DeleteBusinessByIds
|
|
//@description: 批量删除Business记录
|
|
//@param: ids request.IdsReq
|
|
//@return: err error
|
|
|
|
func DeleteBusinessByIds(ids request.IdsReq) (err error) {
|
|
err = global.MG_DB.Delete(&[]model.SellerStore{}, "id in (?)", ids.Ids).Error
|
|
return err
|
|
}
|
|
|
|
//@author: [piexlmax](https://github.com/piexlmax)
|
|
//@function: UpdateBusiness
|
|
//@description: 更新Business记录
|
|
//@param: business *model.Business
|
|
//@return: err error
|
|
|
|
func UpdateBusiness(business model.SellerStore) (err error) {
|
|
err = global.MG_DB.Updates(&business).Error
|
|
return err
|
|
}
|
|
|
|
//@author: [piexlmax](https://github.com/piexlmax)
|
|
//@function: GetBusiness
|
|
//@description: 根据id获取Business记录
|
|
//@param: id uint
|
|
//@return: err error, business model.Business
|
|
|
|
func GetBusiness(id uint) (err error, business model.SellerStore) {
|
|
err = global.MG_DB.Where("id = ?", id).First(&business).Error
|
|
return
|
|
}
|
|
|
|
//@author: [piexlmax](https://github.com/piexlmax)
|
|
//@function: GetBusinessInfoList
|
|
//@description: 分页获取Business记录
|
|
//@param: info request.BusinessSearch
|
|
//@return: err error, list interface{}, total int64
|
|
|
|
func GetBusinessInfoList(info request.BusinessSearch) (err error, list interface{}, total int64) {
|
|
limit := info.PageSize
|
|
offset := info.PageSize * (info.Page - 1)
|
|
// 创建db
|
|
db := global.MG_DB.Model(&model.SellerStore{})
|
|
var businesss []model.SellerStore
|
|
// 如果有条件搜索 下方会自动创建搜索语句
|
|
err = db.Count(&total).Error
|
|
err = db.Limit(limit).Offset(offset).Find(&businesss).Error
|
|
return err, businesss, total
|
|
}
|
|
|