diff --git a/apps/job/api/from/job.go b/apps/job/api/from/job.go new file mode 100644 index 0000000..7f1a385 --- /dev/null +++ b/apps/job/api/from/job.go @@ -0,0 +1,6 @@ +package from + +type JobStatus struct { + JobId int64 `json:"jobId"` + Status string `json:"status"` +} diff --git a/apps/job/api/job.go b/apps/job/api/job.go index 44dc78b..d279e3c 100644 --- a/apps/job/api/job.go +++ b/apps/job/api/job.go @@ -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}) +} diff --git a/apps/job/jobs/jobbase.go b/apps/job/jobs/jobbase.go index 2373f2d..0e03c4e 100644 --- a/apps/job/jobs/jobbase.go +++ b/apps/job/jobs/jobbase.go @@ -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" { diff --git a/apps/job/router/job.go b/apps/job/router/job.go index f30e2d0..4f79f51 100644 --- a/apps/job/router/job.go +++ b/apps/job/router/job.go @@ -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) + }) } diff --git a/apps/system/api/menu.go b/apps/system/api/menu.go index 934832c..090b135 100644 --- a/apps/system/api/menu.go +++ b/apps/system/api/menu.go @@ -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 { diff --git a/apps/system/api/notice.go b/apps/system/api/notice.go index 68ac897..52deab1 100644 --- a/apps/system/api/notice.go +++ b/apps/system/api/notice.go @@ -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) } diff --git a/apps/system/api/user.go b/apps/system/api/user.go index 2021434..e0723b8 100644 --- a/apps/system/api/user.go +++ b/apps/system/api/user.go @@ -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, } diff --git a/apps/system/api/vo/metaVo.go b/apps/system/api/vo/metaVo.go index ea023a2..ce869eb 100644 --- a/apps/system/api/vo/metaVo.go +++ b/apps/system/api/vo/metaVo.go @@ -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"` } diff --git a/apps/system/entity/menu.go b/apps/system/entity/menu.go index 96ac299..f1d6972 100644 --- a/apps/system/entity/menu.go +++ b/apps/system/entity/menu.go @@ -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隐藏) diff --git a/apps/system/entity/notice.go b/apps/system/entity/notice.go index c77d117..abfb0f1 100644 --- a/apps/system/entity/notice.go +++ b/apps/system/entity/notice.go @@ -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 diff --git a/apps/system/router/notice.go b/apps/system/router/notice.go index 2f5c9cc..f29df46 100644 --- a/apps/system/router/notice.go +++ b/apps/system/router/notice.go @@ -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) }) } diff --git a/apps/system/services/menu.go b/apps/system/services/menu.go index eb9ac2b..2399ba2 100644 --- a/apps/system/services/menu.go +++ b/apps/system/services/menu.go @@ -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 diff --git a/apps/system/services/notice.go b/apps/system/services/notice.go index 1f86b12..ae554e1 100644 --- a/apps/system/services/notice.go +++ b/apps/system/services/notice.go @@ -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, "删除通知失败") } diff --git a/base/utils/str_utils.go b/base/utils/str_utils.go index 9a8305e..01f4e5b 100644 --- a/base/utils/str_utils.go +++ b/base/utils/str_utils.go @@ -3,7 +3,6 @@ package utils import ( "bytes" "github.com/kakuilan/kgo" - "log" "strings" "text/template" ) @@ -78,7 +77,6 @@ func DeptPCIds(deptIds []string, id int64, isP bool) []int64 { is := true for _, deptId := range deptIds { did := kgo.KConv.Str2Int64(deptId) - log.Println(did) if is { pRes = append(pRes, did) } diff --git a/base/utils/str_utils_test.go b/base/utils/str_utils_test.go index 6bf14d3..9f42174 100644 --- a/base/utils/str_utils_test.go +++ b/base/utils/str_utils_test.go @@ -17,10 +17,8 @@ func TestGetRealAddressByIP(t *testing.T) { } func TestDeptPCIds(t *testing.T) { - ss := strings.Trim("/0/2/6/4", "/") - - split := strings.Split(ss, "/") + split := strings.Split(strings.Trim("/0/2", "/"), "/") log.Println("split", split) - ids := DeptPCIds(split, 4, false) + ids := DeptPCIds(split, 2, true) t.Log(ids) } diff --git a/go.mod b/go.mod index e05b831..9a17463 100644 --- a/go.mod +++ b/go.mod @@ -25,16 +25,13 @@ require ( github.com/mojocn/base64Captcha v1.3.5 github.com/mssola/user_agent v0.5.3 github.com/onsi/ginkgo v1.16.4 // indirect - github.com/robfig/cron/v3 v3.0.1 // indirect + github.com/robfig/cron/v3 v3.0.1 github.com/sirupsen/logrus v1.8.1 - github.com/swaggo/gin-swagger v1.3.3 // indirect + github.com/swaggo/gin-swagger v1.3.3 github.com/swaggo/swag v1.7.6 - github.com/urfave/cli v1.20.0 // indirect github.com/xuri/excelize/v2 v2.4.1 golang.org/x/net v0.0.0-20211116231205-47ca1ff31462 // indirect golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1 // indirect - gopkg.in/go-playground/assert.v1 v1.2.1 // indirect - gopkg.in/go-playground/validator.v8 v8.18.2 // indirect gorm.io/driver/mysql v1.2.0 gorm.io/driver/postgres v1.2.3 ) diff --git a/go.sum b/go.sum index 5f1a71e..578a029 100644 --- a/go.sum +++ b/go.sum @@ -37,12 +37,11 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gin-contrib/gzip v0.0.3 h1:etUaeesHhEORpZMp18zoOhepboiWnFtXrBZxszWUn4k= github.com/gin-contrib/gzip v0.0.3/go.mod h1:YxxswVZIqOvcHEQpsSn+QF5guQtO1dCfy0shBPy4jFc= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= -github.com/gin-gonic/gin v1.7.2 h1:Tg03T9yM2xa8j6I3Z3oqLaQRSmKvxPd6g/2HJ6zICFA= -github.com/gin-gonic/gin v1.7.2/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/gin-gonic/gin v1.7.4 h1:QmUZXrvJ9qZ3GfWvQ+2wnW/1ePrTEJqPKMYEU3lD/DM= github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= @@ -274,7 +273,6 @@ github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/xuri/efp v0.0.0-20210322160811-ab561f5b45e3 h1:EpI0bqf/eX9SdZDwlMmahKM+CDBgNbsXMhsN28XrM8o= github.com/xuri/efp v0.0.0-20210322160811-ab561f5b45e3/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI= @@ -401,8 +399,6 @@ gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8X gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= -gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=