mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
61 lines
1.6 KiB
Go
61 lines
1.6 KiB
Go
package api
|
|
|
|
import (
|
|
"github.com/XM-GO/PandaKit/restfulx"
|
|
"github.com/XM-GO/PandaKit/utils"
|
|
"pandax/apps/system/entity"
|
|
"pandax/apps/system/services"
|
|
"strings"
|
|
)
|
|
|
|
type NoticeApi struct {
|
|
DeptApp services.SysDeptModel
|
|
NoticeApp services.SysNoticeModel
|
|
}
|
|
|
|
// GetNoticeList 通知列表数据
|
|
func (p *NoticeApi) GetNoticeList(rc *restfulx.ReqCtx) {
|
|
pageNum := restfulx.QueryInt(rc, "pageNum", 1)
|
|
pageSize := restfulx.QueryInt(rc, "pageSize", 10)
|
|
noticeType := restfulx.QueryParam(rc, "noticeType")
|
|
title := restfulx.QueryParam(rc, "title")
|
|
|
|
// 获取部门的子部门id
|
|
one := p.DeptApp.FindOne(rc.LoginAccount.DeptId)
|
|
split := strings.Split(strings.Trim(one.DeptPath, "/"), "/")
|
|
// 获取所有父部门id
|
|
ids := utils.DeptPCIds(split, rc.LoginAccount.DeptId, true)
|
|
notice := entity.SysNotice{NoticeType: noticeType, Title: title, DeptIds: ids}
|
|
list, total := p.NoticeApp.FindListPage(pageNum, pageSize, notice)
|
|
|
|
rc.ResData = map[string]any{
|
|
"data": list,
|
|
"total": total,
|
|
"pageNum": pageNum,
|
|
"pageSize": pageSize,
|
|
}
|
|
}
|
|
|
|
// InsertNotice 添加通知
|
|
func (p *NoticeApi) InsertNotice(rc *restfulx.ReqCtx) {
|
|
var notice entity.SysNotice
|
|
restfulx.BindQuery(rc, ¬ice)
|
|
notice.UserName = rc.LoginAccount.UserName
|
|
p.NoticeApp.Insert(notice)
|
|
}
|
|
|
|
// UpdateNotice 修改通知
|
|
func (p *NoticeApi) UpdateNotice(rc *restfulx.ReqCtx) {
|
|
var notice entity.SysNotice
|
|
restfulx.BindQuery(rc, ¬ice)
|
|
|
|
p.NoticeApp.Update(notice)
|
|
}
|
|
|
|
// DeleteNotice 删除通知
|
|
func (p *NoticeApi) DeleteNotice(rc *restfulx.ReqCtx) {
|
|
noticeId := restfulx.PathParam(rc, "noticeId")
|
|
noticeIds := utils.IdsStrToIdsIntGroup(noticeId)
|
|
p.NoticeApp.Delete(noticeIds)
|
|
}
|