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.4 KiB
80 lines
2.4 KiB
9 months ago
|
package service
|
||
|
|
||
|
import (
|
||
|
"pure-admin/global"
|
||
|
"pure-admin/model"
|
||
|
"pure-admin/model/request"
|
||
|
)
|
||
|
|
||
|
//@author: [piexlmax](https://github.com/piexlmax)
|
||
|
//@function: CreateOrganization
|
||
|
//@description: 创建Organization记录
|
||
|
//@param: organization model.Organization
|
||
|
//@return: err error
|
||
|
|
||
|
func CreateOrganization(organization model.Organization) (err error) {
|
||
|
err = global.MG_DB.Create(&organization).Error
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
//@author: [piexlmax](https://github.com/piexlmax)
|
||
|
//@function: DeleteOrganization
|
||
|
//@description: 删除Organization记录
|
||
|
//@param: organization model.Organization
|
||
|
//@return: err error
|
||
|
|
||
|
func DeleteOrganization(organization model.Organization) (err error) {
|
||
|
err = global.MG_DB.Delete(&organization).Error
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
//@author: [piexlmax](https://github.com/piexlmax)
|
||
|
//@function: DeleteOrganizationByIds
|
||
|
//@description: 批量删除Organization记录
|
||
|
//@param: ids request.IdsReq
|
||
|
//@return: err error
|
||
|
|
||
|
func DeleteOrganizationByIds(ids request.IdsReq) (err error) {
|
||
|
err = global.MG_DB.Delete(&[]model.Organization{},"id in (?)",ids.Ids).Error
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
//@author: [piexlmax](https://github.com/piexlmax)
|
||
|
//@function: UpdateOrganization
|
||
|
//@description: 更新Organization记录
|
||
|
//@param: organization *model.Organization
|
||
|
//@return: err error
|
||
|
|
||
|
func UpdateOrganization(organization model.Organization) (err error) {
|
||
|
err = global.MG_DB.Updates(&organization).Error
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
//@author: [piexlmax](https://github.com/piexlmax)
|
||
|
//@function: GetOrganization
|
||
|
//@description: 根据id获取Organization记录
|
||
|
//@param: id uint
|
||
|
//@return: err error, organization model.Organization
|
||
|
|
||
|
func GetOrganization(id uint) (err error, organization model.Organization) {
|
||
|
err = global.MG_DB.Where("id = ?", id).First(&organization).Error
|
||
|
return
|
||
|
}
|
||
|
|
||
|
//@author: [piexlmax](https://github.com/piexlmax)
|
||
|
//@function: GetOrganizationInfoList
|
||
|
//@description: 分页获取Organization记录
|
||
|
//@param: info request.OrganizationSearch
|
||
|
//@return: err error, list interface{}, total int64
|
||
|
|
||
|
func GetOrganizationInfoList(info request.OrganizationSearch) (err error, list interface{}, total int64) {
|
||
|
limit := info.PageSize
|
||
|
offset := info.PageSize * (info.Page - 1)
|
||
|
// 创建db
|
||
|
db := global.MG_DB.Model(&model.Organization{})
|
||
|
var organizations []model.Organization
|
||
|
// 如果有条件搜索 下方会自动创建搜索语句
|
||
|
err = db.Count(&total).Error
|
||
|
err = db.Limit(limit).Offset(offset).Find(&organizations).Error
|
||
|
return err, organizations, total
|
||
|
}
|