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
package service
|
|
|
|
import (
|
|
"pure-admin/global"
|
|
"pure-admin/model"
|
|
"pure-admin/model/request"
|
|
)
|
|
|
|
//@author: [piexlmax](https://github.com/piexlmax)
|
|
//@function: CreateApplication
|
|
//@description: 创建Application记录
|
|
//@param: application model.Application
|
|
//@return: err error
|
|
|
|
func CreateApplication(application model.Application) (err error) {
|
|
err = global.MG_DB.Create(&application).Error
|
|
return err
|
|
}
|
|
|
|
//@author: [piexlmax](https://github.com/piexlmax)
|
|
//@function: DeleteApplication
|
|
//@description: 删除Application记录
|
|
//@param: application model.Application
|
|
//@return: err error
|
|
|
|
func DeleteApplication(application model.Application) (err error) {
|
|
err = global.MG_DB.Delete(&application).Error
|
|
return err
|
|
}
|
|
|
|
//@author: [piexlmax](https://github.com/piexlmax)
|
|
//@function: DeleteApplicationByIds
|
|
//@description: 批量删除Application记录
|
|
//@param: ids request.IdsReq
|
|
//@return: err error
|
|
|
|
func DeleteApplicationByIds(ids request.IdsReq) (err error) {
|
|
err = global.MG_DB.Delete(&[]model.Application{},"id in (?)",ids.Ids).Error
|
|
return err
|
|
}
|
|
|
|
//@author: [piexlmax](https://github.com/piexlmax)
|
|
//@function: UpdateApplication
|
|
//@description: 更新Application记录
|
|
//@param: application *model.Application
|
|
//@return: err error
|
|
|
|
func UpdateApplication(application model.Application) (err error) {
|
|
err = global.MG_DB.Updates(&application).Error
|
|
return err
|
|
}
|
|
|
|
//@author: [piexlmax](https://github.com/piexlmax)
|
|
//@function: GetApplication
|
|
//@description: 根据id获取Application记录
|
|
//@param: id uint
|
|
//@return: err error, application model.Application
|
|
|
|
func GetApplication(id uint) (err error, application model.Application) {
|
|
err = global.MG_DB.Where("id = ?", id).First(&application).Error
|
|
return
|
|
}
|
|
|
|
//@author: [piexlmax](https://github.com/piexlmax)
|
|
//@function: GetApplicationInfoList
|
|
//@description: 分页获取Application记录
|
|
//@param: info request.ApplicationSearch
|
|
//@return: err error, list interface{}, total int64
|
|
|
|
func GetApplicationInfoList(info request.ApplicationSearch) (err error, list interface{}, total int64) {
|
|
limit := info.PageSize
|
|
offset := info.PageSize * (info.Page - 1)
|
|
// 创建db
|
|
db := global.MG_DB.Model(&model.Application{})
|
|
var applications []model.Application
|
|
// 如果有条件搜索 下方会自动创建搜索语句
|
|
err = db.Count(&total).Error
|
|
err = db.Limit(limit).Offset(offset).Find(&applications).Error
|
|
return err, applications, total
|
|
}
|