任务,通知功能完成

This commit is contained in:
PandaGoAdmin
2021-12-26 22:24:44 +08:00
parent 816791f148
commit e85bbbc030
17 changed files with 48 additions and 40 deletions

6
apps/job/api/from/job.go Normal file
View File

@@ -0,0 +1,6 @@
package from
type JobStatus struct {
JobId int64 `json:"jobId"`
Status string `json:"status"`
}

View File

@@ -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})
}

View File

@@ -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" {

View File

@@ -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)
})
}

View File

@@ -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 {

View File

@@ -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, &notice)
notice.UserName = rc.LoginAccount.UserName
p.NoticeApp.Insert(notice)
}

View File

@@ -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,
}

View File

@@ -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"`
}

View File

@@ -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隐藏

View File

@@ -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

View File

@@ -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)
})
}

View File

@@ -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

View File

@@ -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, "删除通知失败")
}