del: 删除通知公告接口

This commit is contained in:
TsMask
2023-11-17 17:40:16 +08:00
parent c69e90a69e
commit 73500ba39f
6 changed files with 0 additions and 573 deletions

View File

@@ -1,24 +0,0 @@
package service
import "ems.agt/src/modules/system/model"
// ISysNotice 公告 服务层接口
type ISysNotice interface {
// SelectNoticePage 分页查询公告列表
SelectNoticePage(query map[string]any) map[string]any
// SelectNoticeList 查询公告列表
SelectNoticeList(sysNotice model.SysNotice) []model.SysNotice
// SelectNoticeById 查询公告信息
SelectNoticeById(noticeId string) model.SysNotice
// InsertNotice 新增公告
InsertNotice(sysNotice model.SysNotice) string
// UpdateNotice 修改公告
UpdateNotice(sysNotice model.SysNotice) int64
// DeleteNoticeByIds 批量删除公告信息
DeleteNoticeByIds(noticeIds []string) (int64, error)
}

View File

@@ -1,73 +0,0 @@
package service
import (
"fmt"
"ems.agt/src/modules/system/model"
"ems.agt/src/modules/system/repository"
)
// 实例化服务层 SysNoticeImpl 结构体
var NewSysNoticeImpl = &SysNoticeImpl{
sysNoticeRepository: repository.NewSysNoticeImpl,
}
// SysNoticeImpl 公告 服务层处理
type SysNoticeImpl struct {
// 公告服务
sysNoticeRepository repository.ISysNotice
}
// SelectNoticePage 分页查询公告列表
func (r *SysNoticeImpl) SelectNoticePage(query map[string]any) map[string]any {
return r.sysNoticeRepository.SelectNoticePage(query)
}
// SelectNoticeList 查询公告列表
func (r *SysNoticeImpl) SelectNoticeList(sysNotice model.SysNotice) []model.SysNotice {
return r.sysNoticeRepository.SelectNoticeList(sysNotice)
}
// SelectNoticeById 查询公告信息
func (r *SysNoticeImpl) SelectNoticeById(noticeId string) model.SysNotice {
if noticeId == "" {
return model.SysNotice{}
}
configs := r.sysNoticeRepository.SelectNoticeByIds([]string{noticeId})
if len(configs) > 0 {
return configs[0]
}
return model.SysNotice{}
}
// InsertNotice 新增公告
func (r *SysNoticeImpl) InsertNotice(sysNotice model.SysNotice) string {
return r.sysNoticeRepository.InsertNotice(sysNotice)
}
// UpdateNotice 修改公告
func (r *SysNoticeImpl) UpdateNotice(sysNotice model.SysNotice) int64 {
return r.sysNoticeRepository.UpdateNotice(sysNotice)
}
// DeleteNoticeByIds 批量删除公告信息
func (r *SysNoticeImpl) DeleteNoticeByIds(noticeIds []string) (int64, error) {
// 检查是否存在
notices := r.sysNoticeRepository.SelectNoticeByIds(noticeIds)
if len(notices) <= 0 {
return 0, fmt.Errorf("there is no accessible bulletin information data")
}
for _, notice := range notices {
// 检查是否为已删除
if notice.DelFlag == "1" {
// 【%s】公告信息已经删除
return 0, fmt.Errorf("the [%s] announcement message has been deleted", notice.NoticeID)
}
}
if len(notices) == len(noticeIds) {
rows := r.sysNoticeRepository.DeleteNoticeByIds(noticeIds)
return rows, nil
}
// 删除公告信息失败!
return 0, fmt.Errorf("failed to delete the announcement message")
}