mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
任务,通知功能完成
This commit is contained in:
6
apps/job/api/from/job.go
Normal file
6
apps/job/api/from/job.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package from
|
||||
|
||||
type JobStatus struct {
|
||||
JobId int64 `json:"jobId"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"pandax/apps/job/api/from"
|
||||
"pandax/apps/job/entity"
|
||||
"pandax/apps/job/jobs"
|
||||
"pandax/apps/job/services"
|
||||
@@ -151,3 +152,20 @@ func (l *JobApi) StartJobForService(rc *ctx.ReqCtx) {
|
||||
}
|
||||
l.JobApp.Update(*job)
|
||||
}
|
||||
|
||||
// @Summary 修改JOB状态
|
||||
// @Description 获取JSON
|
||||
// @Tags 任务
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param data body from.JobStatus true "body"
|
||||
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
|
||||
// @Success 200 {string} string "{"code": 400, "message": "添加失败"}"
|
||||
// @Router /job/changeStatus [put]
|
||||
// @Security X-TOKEN
|
||||
func (l *JobApi) UpdateStatusJob(rc *ctx.ReqCtx) {
|
||||
var job from.JobStatus
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &job)
|
||||
|
||||
l.JobApp.Update(entity.SysJob{JobId: job.JobId, Status: job.Status})
|
||||
}
|
||||
|
||||
@@ -114,7 +114,8 @@ func Setup() {
|
||||
}
|
||||
sysJob := entity.SysJob{}
|
||||
for i := 0; i < len(jobList); i++ {
|
||||
if jobList[i].Status != "0" && jobList[i].EntryId > 0 {
|
||||
//去除禁用的
|
||||
if jobList[i].Status != "0" {
|
||||
continue
|
||||
}
|
||||
if jobList[i].JobType == "1" {
|
||||
|
||||
@@ -48,4 +48,9 @@ func InitJobRouter(router *gin.RouterGroup) {
|
||||
job.GET("/start/:jobId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(starteJobLog).Handle(jobApi.StartJobForService)
|
||||
})
|
||||
|
||||
updateStatusJobLog := ctx.NewLogInfo("修改状态")
|
||||
job.PUT("/changeStatus", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(updateStatusJobLog).Handle(jobApi.UpdateStatusJob)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"log"
|
||||
entity "pandax/apps/system/entity"
|
||||
services "pandax/apps/system/services"
|
||||
"pandax/base/biz"
|
||||
@@ -91,7 +90,6 @@ func (m *MenuApi) GetMenuList(rc *ctx.ReqCtx) {
|
||||
status := rc.GinCtx.Query("status")
|
||||
|
||||
menu := entity.SysMenu{MenuName: menuName, Status: status}
|
||||
log.Println(menuName)
|
||||
if menu.MenuName == "" {
|
||||
rc.ResData = m.MenuApp.SelectMenu(menu)
|
||||
} else {
|
||||
|
||||
@@ -33,7 +33,8 @@ func (p *NoticeApi) GetNoticeList(rc *ctx.ReqCtx) {
|
||||
// 获取部门的子部门id
|
||||
one := p.DeptApp.FindOne(rc.LoginAccount.DeptId)
|
||||
split := strings.Split(strings.Trim(one.DeptPath, "/"), "/")
|
||||
ids := utils.DeptPCIds(split, rc.LoginAccount.DeptId, false)
|
||||
// 获取所有父部门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)
|
||||
|
||||
@@ -58,6 +59,7 @@ func (p *NoticeApi) GetNoticeList(rc *ctx.ReqCtx) {
|
||||
func (p *NoticeApi) InsertNotice(rc *ctx.ReqCtx) {
|
||||
var notice entity.SysNotice
|
||||
ginx.BindJsonAndValid(rc.GinCtx, ¬ice)
|
||||
notice.UserName = rc.LoginAccount.UserName
|
||||
p.NoticeApp.Insert(notice)
|
||||
}
|
||||
|
||||
|
||||
@@ -439,7 +439,7 @@ func Build(menus []entity.SysMenu) []vo.RouterVo {
|
||||
IsHide: equals("1", ms.IsHide),
|
||||
IsKeepAlive: equals("0", ms.IsKeepAlive),
|
||||
IsAffix: equals("0", ms.IsAffix),
|
||||
IsFrame: equals("0", ms.IsFrame),
|
||||
IsIframe: equals("0", ms.IsIframe),
|
||||
Auth: auth,
|
||||
Icon: ms.Icon,
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ type MetaVo struct {
|
||||
IsHide bool `json:"isHide"`
|
||||
IsKeepAlive bool `json:"isKeepAlive"`
|
||||
IsAffix bool `json:"isAffix"`
|
||||
IsFrame bool `json:"isFrame"`
|
||||
IsIframe bool `json:"isIframe"`
|
||||
Auth []string `json:"auth"`
|
||||
Icon string `json:"icon"`
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ type SysMenu struct {
|
||||
Icon string `json:"icon" gorm:"type:varchar(128);"`
|
||||
Path string `json:"path" gorm:"type:varchar(128);"`
|
||||
Component string `json:"component" gorm:"type:varchar(255);"` // 组件路径
|
||||
IsFrame string `json:"isFrame" gorm:"type:varchar(1);"` //是否为外链
|
||||
IsIframe string `json:"isIframe" gorm:"type:varchar(1);"` //是否为内嵌
|
||||
IsLink string `json:"isLink" gorm:"type:varchar(11);"` //是否超链接菜单
|
||||
MenuType string `json:"menuType" gorm:"type:varchar(1);"` //菜单类型(M目录 C菜单 F按钮)
|
||||
IsHide string `json:"isHide" gorm:"type:varchar(1);"` //显示状态(0显示 1隐藏)
|
||||
|
||||
@@ -6,8 +6,9 @@ type SysNotice struct {
|
||||
NoticeId int64 `json:"noticeId" gorm:"primary_key;AUTO_INCREMENT"`
|
||||
Title string `json:"title" gorm:"type:varchar(128);comment:标题"`
|
||||
Content string `json:"content" gorm:"type:text;comment:标题"`
|
||||
NoticeType string `json:"notice_type" gorm:"type:varchar(1);comment:通知类型"`
|
||||
NoticeType string `json:"noticeType" gorm:"type:varchar(1);comment:通知类型"`
|
||||
DeptId int64 `json:"deptId" gorm:"type:int(11);comment:部门Id,部门及子部门"`
|
||||
UserName string `json:"userName" gorm:"type:varchar(64);comment:发布人"`
|
||||
|
||||
DeptIds []int64 `json:"deptIds" gorm:"-"`
|
||||
model.BaseModel
|
||||
|
||||
@@ -30,7 +30,7 @@ func InitNoticeRouter(router *gin.RouterGroup) {
|
||||
})
|
||||
|
||||
deleteNoticeLog := ctx.NewLogInfo("删除通知信息")
|
||||
notice.DELETE(":postId", func(c *gin.Context) {
|
||||
notice.DELETE(":noticeId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(deleteNoticeLog).Handle(s.DeleteNotice)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -168,19 +168,6 @@ func (m *sysMenuModelImpl) GetMenuRole(data entity.MenuRole) *[]entity.MenuRole
|
||||
return &menus
|
||||
}
|
||||
|
||||
//func (m *sysMenuModelImpl) InitPaths(menu *entity.SysMenu) {
|
||||
// parentMenu := new(entity.SysMenu)
|
||||
// if int(menu.ParentId) != 0 {
|
||||
// parentMenu = m.FindOne(menu.ParentId)
|
||||
// biz.IsTrue(parentMenu.Paths != "", "父级paths异常,请尝试对当前节点父级菜单进行更新操作!")
|
||||
// menu.Paths = parentMenu.Paths + "/" + kgo.KConv.Int2Str(menu.MenuId)
|
||||
// } else {
|
||||
// menu.Paths = "/0/" + kgo.KConv.Int2Str(menu.MenuId)
|
||||
// }
|
||||
// global.Db.Table(m.table).Where("menu_id = ?", menu.MenuId).Update("paths", menu.Paths)
|
||||
// return
|
||||
//}
|
||||
|
||||
func DiguiMenu(menulist *[]entity.SysMenu, menu entity.SysMenu) entity.SysMenu {
|
||||
list := *menulist
|
||||
|
||||
@@ -201,6 +188,7 @@ func DiguiMenu(menulist *[]entity.SysMenu, menu entity.SysMenu) entity.SysMenu {
|
||||
mi.Permission = list[j].Permission
|
||||
mi.ParentId = list[j].ParentId
|
||||
mi.IsAffix = list[j].IsAffix
|
||||
mi.IsIframe = list[j].IsIframe
|
||||
mi.IsLink = list[j].IsLink
|
||||
mi.Component = list[j].Component
|
||||
mi.Sort = list[j].Sort
|
||||
|
||||
@@ -50,7 +50,7 @@ func (m *sysNoticeModelImpl) FindListPage(page, pageSize int, data entity.SysNot
|
||||
db = db.Where("notice_type = ?", data.NoticeType)
|
||||
}
|
||||
if len(data.DeptIds) > 0 {
|
||||
db = db.Where("`dept_id` in (?)", data.DeptIds)
|
||||
db = db.Where("dept_id in (?)", data.DeptIds)
|
||||
}
|
||||
db.Where("delete_time IS NULL")
|
||||
err := db.Count(&total).Error
|
||||
@@ -65,5 +65,5 @@ func (m *sysNoticeModelImpl) Update(data entity.SysNotice) *entity.SysNotice {
|
||||
}
|
||||
|
||||
func (m *sysNoticeModelImpl) Delete(postIds []int64) {
|
||||
biz.ErrIsNil(global.Db.Table(m.table).Delete(&entity.SysNotice{}, "`notice_id` in (?)", postIds).Error, "删除通知失败")
|
||||
biz.ErrIsNil(global.Db.Table(m.table).Delete(&entity.SysNotice{}, "notice_id in (?)", postIds).Error, "删除通知失败")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user