feat:update search

This commit is contained in:
zhangwenjian committed 2020-08-28 00:52:16 +08:00
1 parent 1dffcb7199
commit 87edf1099c
6 files changed
+27 -47

No files matched your search

+6 -2
View File
@@ -76,10 +76,14 @@ func UpdateSysJob(c *gin.Context) {
func DeleteSysJob(c *gin.Context) { func DeleteSysJob(c *gin.Context) {
var data models.SysJob var data models.SysJob
var v tools.GeneralDelDto
err := c.BindUri(&v)
data.UpdateBy = tools.GetUserIdStr(c) data.UpdateBy = tools.GetUserIdStr(c)
IDS := tools.IdsStrToIdsIntGroup("jobId", c) IDS := tools.IdsStrToIdsIntGroupStr(v.Id)
_, err := data.BatchDelete(IDS) _, err = data.BatchDelete(IDS)
tools.HasError(err, msg.DeletedFail, 500) tools.HasError(err, msg.DeletedFail, 500)
app.OK(c, nil, msg.DeletedSuccess) app.OK(c, nil, msg.DeletedSuccess)
} }
+2 -2
View File
@@ -6,7 +6,7 @@ require (
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/casbin/casbin/v2 v2.11.2 github.com/casbin/casbin/v2 v2.11.2
github.com/casbin/gorm-adapter/v3 v3.0.2 // indirect github.com/casbin/gorm-adapter/v3 v3.0.2
github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/gin-gonic/gin v1.6.3 github.com/gin-gonic/gin v1.6.3
github.com/go-ole/go-ole v1.2.4 // indirect github.com/go-ole/go-ole v1.2.4 // indirect
@@ -33,5 +33,5 @@ require (
gorm.io/driver/mysql v0.3.2 gorm.io/driver/mysql v0.3.2
gorm.io/driver/postgres v0.2.9 gorm.io/driver/postgres v0.2.9
gorm.io/driver/sqlite v1.0.9 gorm.io/driver/sqlite v1.0.9
gorm.io/gorm v0.2.36 gorm.io/gorm v0.2.38
) )
-26
View File
@@ -78,35 +78,9 @@ func (e *SysJob) Get() (SysJob, error) {
func (e *SysJob) GetPage(pageSize int, pageIndex int, v interface{}) ([]SysJob, int, error) { func (e *SysJob) GetPage(pageSize int, pageIndex int, v interface{}) ([]SysJob, int, error) {
var doc []SysJob var doc []SysJob
//table := orm.Eloquent.Select("*").Table(e.TableName())
table := orm.Eloquent.Table(e.TableName()) table := orm.Eloquent.Table(e.TableName())
table = tools.SetQuery(table, v) table = tools.SetQuery(table, v)
//if e.JobId != 0 {
// table = table.Where("job_id = ?", e.JobId)
//}
//
//if e.JobName != "" {
// table = table.Where("job_name like ?", "%"+e.JobName+"%")
//}
//
//if e.JobGroup != "" {
// table = table.Where("job_group = ?", e.JobGroup)
//}
//
//if e.CronExpression != "" {
// table = table.Where("cron_expression = ?", e.CronExpression)
//}
//
//if e.InvokeTarget != "" {
// table = table.Where("invoke_target = ?", e.InvokeTarget)
//}
//
//if e.Status != 0 {
// table = table.Where("status = ?", e.Status)
//}
// 数据权限控制(如果不需要数据权限请将此处去掉) // 数据权限控制(如果不需要数据权限请将此处去掉)
dataPermission := new(DataPermission) dataPermission := new(DataPermission)
dataPermission.UserId, _ = tools.StringToInt(e.DataScope) dataPermission.UserId, _ = tools.StringToInt(e.DataScope)
+15 -13
View File
@@ -4,6 +4,8 @@ import (
"log" "log"
"github.com/casbin/casbin/v2" "github.com/casbin/casbin/v2"
"github.com/casbin/casbin/v2/model"
gormAdapter "github.com/casbin/gorm-adapter/v3"
_ "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql"
"go-admin/global" "go-admin/global"
@@ -25,19 +27,19 @@ m = r.sub == p.sub && (keyMatch2(r.obj, p.obj) || keyMatch(r.obj, p.obj)) && (r.
` `
func Setup() { func Setup() {
//Apter, err := gormAdapter.NewAdapterByDB(global.Eloquent) Apter, err := gormAdapter.NewAdapterByDB(global.Eloquent)
//if err != nil { if err != nil {
// panic(err) panic(err)
//} }
//m, err := model.NewModelFromString(text) m, err := model.NewModelFromString(text)
//if err != nil { if err != nil {
// panic(err) panic(err)
//} }
//e, err := casbin.NewSyncedEnforcer(m, Apter) e, err := casbin.NewSyncedEnforcer(m, Apter)
//if err != nil { if err != nil {
// panic(err) panic(err)
//} }
//global.CasbinEnforcer = e global.CasbinEnforcer = e
} }
func Casbin() (*casbin.SyncedEnforcer, error) { func Casbin() (*casbin.SyncedEnforcer, error) {
+2 -2
View File
@@ -111,10 +111,10 @@ func registerSysJobRouter(v1 *gin.RouterGroup) {
r := v1.Group("/sysjob") r := v1.Group("/sysjob")
{ {
r.GET("", sysjob.GetSysJobList) r.GET("", sysjob.GetSysJobList)
r.GET("/:jobId", sysjob.GetSysJob) r.GET("/:id", sysjob.GetSysJob)
r.POST("", sysjob.InsertSysJob) r.POST("", sysjob.InsertSysJob)
r.PUT("", sysjob.UpdateSysJob) r.PUT("", sysjob.UpdateSysJob)
r.DELETE("/:jobId", sysjob.DeleteSysJob) r.DELETE("/:id", sysjob.DeleteSysJob)
} }
v1.GET("/job/remove/:jobId", sysjob.RemoveJob) v1.GET("/job/remove/:jobId", sysjob.RemoveJob)
+2 -2
View File
@@ -8,10 +8,10 @@ import (
//获取URL中批量id并解析 //获取URL中批量id并解析
func IdsStrToIdsIntGroup(key string, c *gin.Context) []int { func IdsStrToIdsIntGroup(key string, c *gin.Context) []int {
return idsStrToIdsIntGroup(c.Param(key)) return IdsStrToIdsIntGroupStr(c.Param(key))
} }
func idsStrToIdsIntGroup(keys string) []int { func IdsStrToIdsIntGroupStr(keys string) []int {
IDS := make([]int, 0) IDS := make([]int, 0)
ids := strings.Split(keys, ",") ids := strings.Split(keys, ",")
for i := 0; i < len(ids); i++ { for i := 0; i < len(ids); i++ {