73 lines
2.1 KiB
Go
73 lines
2.1 KiB
Go
package service
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"be.ems/src/modules/practical_training/model"
|
|
"be.ems/src/modules/practical_training/repository"
|
|
)
|
|
|
|
// NewPtNeConfigApplyService 实例化服务层
|
|
var NewPtNeConfigApplyService = &PtNeConfigApplyService{
|
|
ptNeConfigApplyRepository: repository.NewPtNeConfigApplyRepository,
|
|
}
|
|
|
|
// PtNeConfigApplyService 服务层处理
|
|
type PtNeConfigApplyService struct {
|
|
// 实训教学_网元参数配置表
|
|
ptNeConfigApplyRepository repository.IPtNeConfigApplyRepository
|
|
}
|
|
|
|
// SelectNeHostPage 分页查询列表数据
|
|
func (r *PtNeConfigApplyService) SelectPage(query map[string]any) map[string]any {
|
|
return r.ptNeConfigApplyRepository.SelectPage(query)
|
|
}
|
|
|
|
// SelectConfigList 查询列表
|
|
func (r *PtNeConfigApplyService) SelectList(param model.PtNeConfigApply) []model.PtNeConfigApply {
|
|
return r.ptNeConfigApplyRepository.SelectList(param)
|
|
}
|
|
|
|
// SelectByIds 通过ID查询
|
|
func (r *PtNeConfigApplyService) SelectById(paramId string) model.PtNeConfigApply {
|
|
if paramId == "" {
|
|
return model.PtNeConfigApply{}
|
|
}
|
|
neHosts := r.ptNeConfigApplyRepository.SelectByIds([]string{paramId})
|
|
if len(neHosts) > 0 {
|
|
return neHosts[0]
|
|
}
|
|
return model.PtNeConfigApply{}
|
|
}
|
|
|
|
// Insert 新增信息
|
|
func (r *PtNeConfigApplyService) Insert(param model.PtNeConfigApply) string {
|
|
return r.ptNeConfigApplyRepository.Insert(param)
|
|
}
|
|
|
|
// Update 修改信息
|
|
func (r *PtNeConfigApplyService) Update(param model.PtNeConfigApply) int64 {
|
|
return r.ptNeConfigApplyRepository.Update(param)
|
|
}
|
|
|
|
// DeleteByIds 批量删除信息
|
|
func (r *PtNeConfigApplyService) DeleteByIds(paramIds []string) (int64, error) {
|
|
// 检查是否存在
|
|
ids := r.ptNeConfigApplyRepository.SelectByIds(paramIds)
|
|
if len(ids) <= 0 {
|
|
return 0, fmt.Errorf("ptNeConfigApply.noData")
|
|
}
|
|
|
|
if len(ids) == len(paramIds) {
|
|
rows := r.ptNeConfigApplyRepository.DeleteByIds(paramIds)
|
|
return rows, nil
|
|
}
|
|
// 删除信息失败!
|
|
return 0, fmt.Errorf("delete fail")
|
|
}
|
|
|
|
// SelectListByClass 查询班级学生信息
|
|
func (r *PtNeConfigApplyService) SelectListByClass(deptId, userName string) []map[string]any {
|
|
return r.ptNeConfigApplyRepository.SelectListByClass(deptId, userName)
|
|
}
|