代码拉取完成,页面将自动刷新
同步操作将从 pixel/gin-vue-admin 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package manager
import (
"gitee.com/g-qs/gin-vue-admin/server/global"
"gitee.com/g-qs/gin-vue-admin/server/model/common/request"
"gitee.com/g-qs/gin-vue-admin/server/model/manager"
managerReq "gitee.com/g-qs/gin-vue-admin/server/model/manager/request"
"gitee.com/g-qs/gin-vue-admin/server/model/system"
"gorm.io/gorm"
)
type FdHealthManagerRegisterService struct {
}
// CreateFdHealthManagerRegister 创建健康师注册记录
// Author [piexlmax](https://github.com/piexlmax)
func (fdHealthManagerRegisterService *FdHealthManagerRegisterService) CreateFdHealthManagerRegister(fdHealthManagerRegister *manager.FdHealthManagerRegister) (err error) {
err = global.GVA_DB.Create(fdHealthManagerRegister).Error
return err
}
// DeleteFdHealthManagerRegister 删除健康师注册记录
// Author [piexlmax](https://github.com/piexlmax)
func (fdHealthManagerRegisterService *FdHealthManagerRegisterService) DeleteFdHealthManagerRegister(fdHealthManagerRegister manager.FdHealthManagerRegister) (err error) {
err = global.GVA_DB.Delete(&fdHealthManagerRegister).Error
return err
}
// DeleteFdHealthManagerRegisterByIds 批量删除健康师注册记录
// Author [piexlmax](https://github.com/piexlmax)
func (fdHealthManagerRegisterService *FdHealthManagerRegisterService) DeleteFdHealthManagerRegisterByIds(ids request.IdsReq) (err error) {
err = global.GVA_DB.Delete(&[]manager.FdHealthManagerRegister{}, "id in ?", ids.Ids).Error
return err
}
// UpdateFdHealthManagerRegister 更新健康师注册记录
// Author [piexlmax](https://github.com/piexlmax)
func (fdHealthManagerRegisterService *FdHealthManagerRegisterService) UpdateFdHealthManagerRegister(fdHealthManagerRegister manager.FdHealthManagerRegister) (err error) {
return global.GVA_DB.Transaction(func(tx *gorm.DB) error {
if fdHealthManagerRegister.RegisterStatus != nil && *fdHealthManagerRegister.RegisterStatus == 1 {
fdHealthManagerRegister.RegisterInfo = "通过"
err = global.GVA_DB.First(&manager.FdHealthManager{}, "hm_id = ?", fdHealthManagerRegister.HmId).Update("is_register", true).Error
if err != nil {
return err
}
}
err = global.GVA_DB.Save(&fdHealthManagerRegister).Error
return err
})
}
// GetFdHealthManagerRegister 根据id获取健康师注册记录
// Author [piexlmax](https://github.com/piexlmax)
func (fdHealthManagerRegisterService *FdHealthManagerRegisterService) GetFdHealthManagerRegister(id uint) (fdHealthManagerRegister manager.FdHealthManagerRegister, err error) {
err = global.GVA_DB.Preload("FdHealthManager").Where("id = ?", id).First(&fdHealthManagerRegister).Error
return
}
// GetFdHealthManagerRegisterInfoList 分页获取健康师注册记录
// Author [piexlmax](https://github.com/piexlmax)
func (fdHealthManagerRegisterService *FdHealthManagerRegisterService) GetFdHealthManagerRegisterInfoList(info managerReq.FdHealthManagerRegisterSearch) (list []manager.FdHealthManagerRegister, total int64, err error) {
limit := info.PageSize
offset := info.PageSize * (info.Page - 1)
// 创建db
db := global.GVA_DB.Where("store_id = ?", info.FdHealthManager.StoreId).Joins("FdHealthManager").Preload("FdHealthManager", func(db *gorm.DB) *gorm.DB {
return db.Omit("Password")
}).Model(&manager.FdHealthManagerRegister{})
var fdHealthManagerRegisters []manager.FdHealthManagerRegister
// 如果有条件搜索 下方会自动创建搜索语句
if info.StartCreatedAt != nil && info.EndCreatedAt != nil {
db = db.Where("created_at BETWEEN ? AND ?", info.StartCreatedAt, info.EndCreatedAt)
}
if info.Name != "" {
db = db.Where("FdHealthManager.name LIKE ?", "%"+info.Name+"%")
}
if info.Phone != "" {
db = db.Where("FdHealthManager.phone = ?", info.Phone)
}
err = db.Count(&total).Error
if err != nil {
return
}
if limit != 0 {
db = db.Limit(limit).Offset(offset)
}
err = db.Find(&fdHealthManagerRegisters).Error
return fdHealthManagerRegisters, total, err
}
// GetScHealthManagerRegisterList 获取健康师注册列表【服务中心】
// Author [g-qs](https://github.com/g-qs)
func (fdHealthManagerRegisterService *FdHealthManagerRegisterService) GetScHealthManagerRegisterList(info managerReq.FdHealthManagerRegisterSearch, ScID uint) (list []manager.FdHealthManagerRegister, total int64, err error) {
limit := info.PageSize
offset := info.PageSize * (info.Page - 1)
// 创建db
var serviceStations []system.SysUser
err = global.GVA_DB.Model(&system.SysUser{}).Where("creator = ?", ScID).Find(&serviceStations).Error
var ids []uint
for _, v := range serviceStations {
ids = append(ids, v.ID)
}
db := global.GVA_DB.Where("store_id IN (?)", ids).Joins("FdHealthManager").Preload("FdHealthManager", func(db *gorm.DB) *gorm.DB {
return db.Omit("Password")
}).Model(&manager.FdHealthManagerRegister{})
var fdHealthManagerRegisters []manager.FdHealthManagerRegister
// 如果有条件搜索 下方会自动创建搜索语句
if info.StartCreatedAt != nil && info.EndCreatedAt != nil {
db = db.Where("created_at BETWEEN ? AND ?", info.StartCreatedAt, info.EndCreatedAt)
}
if info.Name != "" {
db = db.Where("FdHealthManager.name LIKE ?", "%"+info.Name+"%")
}
if info.Phone != "" {
db = db.Where("FdHealthManager.phone = ?", info.Phone)
}
err = db.Count(&total).Error
if err != nil {
return
}
if limit != 0 {
db = db.Limit(limit).Offset(offset)
}
err = db.Find(&fdHealthManagerRegisters).Error
return fdHealthManagerRegisters, total, err
}
// GetAllHealthManagerRegisterInfoList 分页获取全部健康师注册记录【超管】
// Author [g-qs](https://gitee.com/g-qs)
func (fdHealthManagerRegisterService *FdHealthManagerRegisterService) GetAllHealthManagerRegisterInfoList(info managerReq.FdHealthManagerRegisterSearch) (list []manager.FdHealthManagerRegister, total int64, err error) {
limit := info.PageSize
offset := info.PageSize * (info.Page - 1)
// 创建db
db := global.GVA_DB.Joins("FdHealthManager").Preload("FdHealthManager", func(db *gorm.DB) *gorm.DB {
return db.Preload("HealthManageCenter").Omit("Password")
}).Model(&manager.FdHealthManagerRegister{})
var fdHealthManagerRegisters []manager.FdHealthManagerRegister
// 如果有条件搜索 下方会自动创建搜索语句
if info.StartCreatedAt != nil && info.EndCreatedAt != nil {
db = db.Where("FdHealthManager.created_at BETWEEN ? AND ?", info.StartCreatedAt, info.EndCreatedAt)
}
if info.Name != "" {
db = db.Where("FdHealthManager.name LIKE ?", "%"+info.Name+"%")
}
if info.Phone != "" {
db = db.Where("FdHealthManager.phone = ?", info.Phone)
}
err = db.Count(&total).Error
if err != nil {
return
}
if limit != 0 {
db = db.Limit(limit).Offset(offset)
}
err = db.Find(&fdHealthManagerRegisters).Error
return fdHealthManagerRegisters, total, err
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。