Skip to content

Commit

Permalink
update gtoken group middleware \ getMap \ lastInsertId
Browse files Browse the repository at this point in the history
  • Loading branch information
zcool321 committed Dec 28, 2020
1 parent 5d9ce31 commit e7ddc9b
Show file tree
Hide file tree
Showing 18 changed files with 156 additions and 118 deletions.
10 changes: 5 additions & 5 deletions app/api/config/configAction.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (action *Action) Delete(r *ghttp.Request) {
// path: /save
func (action *Action) Save(r *ghttp.Request) {
request := new(config.Request)
err := gconv.Struct(r.GetQueryMap(), request)
err := gconv.Struct(r.GetMap(), request)
if err != nil {
glog.Error("save struct error", err)
base.Error(r, "获取参数异常")
Expand All @@ -68,7 +68,7 @@ func (action *Action) Save(r *ghttp.Request) {

// path: /list
func (action *Action) List(r *ghttp.Request) {
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())

list, err := config.List(&form)
if err != nil {
Expand All @@ -81,7 +81,7 @@ func (action *Action) List(r *ghttp.Request) {

// path: /page
func (action *Action) Page(r *ghttp.Request) {
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())
page, err := config.Page(&form)
if err != nil {
glog.Error("page error", err)
Expand All @@ -99,7 +99,7 @@ func (action *Action) Page(r *ghttp.Request) {

// path: /jqgrid
func (action *Action) Jqgrid(r *ghttp.Request) {
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())
page, err := config.Page(&form)
if err != nil {
glog.Error("jqgrid error", err)
Expand All @@ -116,7 +116,7 @@ func (action *Action) Jqgrid(r *ghttp.Request) {

// path: /type
func (action *Action) Type(r *ghttp.Request) {
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())

//userId := base.GetUser(r).Id
//user := SysUser{Id: userId}.Get()
Expand Down
8 changes: 4 additions & 4 deletions app/api/department/departmentAction.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (action *Action) Delete(r *ghttp.Request) {
// path: /save
func (action *Action) Save(r *ghttp.Request) {
request := new(department.Request)
err := gconv.Struct(r.GetQueryMap(), request)
err := gconv.Struct(r.GetMap(), request)
if err != nil {
glog.Error("save struct error", err)
base.Error(r, "save error")
Expand All @@ -77,7 +77,7 @@ func (action *Action) Save(r *ghttp.Request) {

// path: /list
func (action *Action) List(r *ghttp.Request) {
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())

list, err := department.List(&form)
if err != nil {
Expand All @@ -90,7 +90,7 @@ func (action *Action) List(r *ghttp.Request) {

// path: /page
func (action *Action) Page(r *ghttp.Request) {
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())
page, err := department.Page(&form)
if err != nil {
glog.Error("page error", err)
Expand All @@ -108,7 +108,7 @@ func (action *Action) Page(r *ghttp.Request) {

// path: /jqgrid
func (action *Action) Jqgrid(r *ghttp.Request) {
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())
page, err := department.Page(&form)
if err != nil {
glog.Error("jqgrid error", err)
Expand Down
8 changes: 4 additions & 4 deletions app/api/log/logAction.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (action *Action) Delete(r *ghttp.Request) {
// path: /save
func (action *Action) Save(r *ghttp.Request) {
request := new(log.Request)
err := gconv.Struct(r.GetQueryMap(), request)
err := gconv.Struct(r.GetMap(), request)
if err != nil {
glog.Error("save struct error", err)
base.Error(r, "save error")
Expand All @@ -68,7 +68,7 @@ func (action *Action) Save(r *ghttp.Request) {

// path: /list
func (action *Action) List(r *ghttp.Request) {
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())

list, err := log.List(&form)
if err != nil {
Expand All @@ -81,7 +81,7 @@ func (action *Action) List(r *ghttp.Request) {

// path: /page
func (action *Action) Page(r *ghttp.Request) {
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())
page, err := log.Page(&form)
if err != nil {
glog.Error("page error", err)
Expand All @@ -99,7 +99,7 @@ func (action *Action) Page(r *ghttp.Request) {

// path: /jqgrid
func (action *Action) Jqgrid(r *ghttp.Request) {
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())
page, err := log.Page(&form)
if err != nil {
glog.Error("jqgrid error", err)
Expand Down
8 changes: 4 additions & 4 deletions app/api/menu/menuAction.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (action *Action) Delete(r *ghttp.Request) {
// path: /save
func (action *Action) Save(r *ghttp.Request) {
request := new(menu.Request)
err := gconv.Struct(r.GetQueryMap(), request)
err := gconv.Struct(r.GetMap(), request)
if err != nil {
glog.Error("save struct error", err)
base.Error(r, "save error")
Expand All @@ -82,7 +82,7 @@ func (action *Action) Tree(r *ghttp.Request) {

// path: /list
func (action *Action) List(r *ghttp.Request) {
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())

list, err := menu.List(&form)
if err != nil {
Expand All @@ -95,7 +95,7 @@ func (action *Action) List(r *ghttp.Request) {

// path: /page
func (action *Action) Page(r *ghttp.Request) {
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())
page, err := menu.Page(&form)
if err != nil {
glog.Error("page error", err)
Expand All @@ -113,7 +113,7 @@ func (action *Action) Page(r *ghttp.Request) {

// path: /jqgrid
func (action *Action) Jqgrid(r *ghttp.Request) {
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())
page, err := menu.Page(&form)
if err != nil {
glog.Error("jqgrid error", err)
Expand Down
10 changes: 5 additions & 5 deletions app/api/role/roleAction.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (action *Action) Delete(r *ghttp.Request) {
// path: /save
func (action *Action) Save(r *ghttp.Request) {
request := new(role.Request)
err := gconv.Struct(r.GetQueryMap(), request)
err := gconv.Struct(r.GetMap(), request)
if err != nil {
glog.Error("save struct error", err)
base.Error(r, "save error")
Expand All @@ -73,7 +73,7 @@ func (action *Action) Save(r *ghttp.Request) {

// path: /list
func (action *Action) List(r *ghttp.Request) {
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())

list, err := role.List(&form)
if err != nil {
Expand All @@ -86,7 +86,7 @@ func (action *Action) List(r *ghttp.Request) {

// path: /page
func (action *Action) Page(r *ghttp.Request) {
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())
page, err := role.Page(&form)
if err != nil {
glog.Error("page error", err)
Expand All @@ -104,7 +104,7 @@ func (action *Action) Page(r *ghttp.Request) {

// path: /jqgrid
func (action *Action) Jqgrid(r *ghttp.Request) {
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())
page, err := role.Page(&form)
if err != nil {
glog.Error("jqgrid error", err)
Expand All @@ -125,7 +125,7 @@ func (action *Action) Info(r *ghttp.Request) {
if roleId == 0 {
base.Fail(r, "参数错误")
}
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())
form.SetParam("roleId", gconv.String(roleId))

// 选择的列表
Expand Down
10 changes: 5 additions & 5 deletions app/api/user/userAction.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (action *Action) Delete(r *ghttp.Request) {
// path: /save
func (action *Action) Save(r *ghttp.Request) {
request := new(user.Request)
err := gconv.Struct(r.GetQueryMap(), request)
err := gconv.Struct(r.GetMap(), request)
if err != nil {
glog.Error("save struct error", err)
base.Error(r, "save error")
Expand All @@ -73,7 +73,7 @@ func (action *Action) Save(r *ghttp.Request) {

// path: /list
func (action *Action) List(r *ghttp.Request) {
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())

list, err := user.List(&form)
if err != nil {
Expand All @@ -86,7 +86,7 @@ func (action *Action) List(r *ghttp.Request) {

// path: /page
func (action *Action) Page(r *ghttp.Request) {
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())
page, err := user.Page(&form)
if err != nil {
glog.Error("page error", err)
Expand All @@ -104,7 +104,7 @@ func (action *Action) Page(r *ghttp.Request) {

// path: /jqgrid
func (action *Action) Jqgrid(r *ghttp.Request) {
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())
page, err := user.Page(&form)
if err != nil {
glog.Error("jqgrid error", err)
Expand All @@ -125,7 +125,7 @@ func (action *Action) RoleInfo(r *ghttp.Request) {
if userId == 0 {
base.Fail(r, "参数错误")
}
form := base.NewForm(r.GetQueryMap())
form := base.NewForm(r.GetMap())
form.SetParam("userId", gconv.String(userId))

// 角色列表
Expand Down
4 changes: 2 additions & 2 deletions app/component/middle/MiddlewareLog.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ func MiddlewareLog(r *ghttp.Request) {
}

if r.Method == "GET" {
params = r.GetQueryMap()
params = r.GetMap()
} else if r.Method == "POST" {
params = r.GetQueryMap()
params = r.GetMap()
} else {
base.Error(r, "Request Method is ERROR! ")
return
Expand Down
8 changes: 7 additions & 1 deletion app/service/config/configSvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func Delete(id int64, userId int) (int64, error) {
// 保存实体
func Save(request *Request) (int64, error) {
entity := (*config.Entity)(nil)
err := gconv.StructDeep(request.Entity, &entity)
err := gconv.Struct(request.Entity, &entity)
if err != nil {
return 0, errors.New("数据错误")
}
Expand All @@ -83,6 +83,12 @@ func Save(request *Request) (int64, error) {
if err != nil {
return 0, err
}
// 回写主键
lastId, err := r.LastInsertId()
if err != nil {
return 0, err
}
entity.Id = gconv.Int(lastId)

log.SaveLog(entity, constants.INSERT)
return r.RowsAffected()
Expand Down
8 changes: 7 additions & 1 deletion app/service/department/departmentSvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func Delete(id int64, userId int) (int64, error) {
// 保存实体
func Save(request *Request) (int64, error) {
entity := (*department.Entity)(nil)
err := gconv.StructDeep(request.Entity, &entity)
err := gconv.Struct(request.Entity, &entity)
if err != nil {
return 0, errors.New("数据错误")
}
Expand All @@ -87,6 +87,12 @@ func Save(request *Request) (int64, error) {
if err != nil {
return 0, err
}
// 回写主键
lastId, err := r.LastInsertId()
if err != nil {
return 0, err
}
entity.Id = gconv.Int(lastId)

log.SaveLog(entity, constants.INSERT)
return r.RowsAffected()
Expand Down
8 changes: 7 additions & 1 deletion app/service/log/logSvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func Delete(id int64, userId int) (int64, error) {
// 保存实体
func Save(request *Request) (int64, error) {
entity := (*log.Entity)(nil)
err := gconv.StructDeep(request.Entity, &entity)
err := gconv.Struct(request.Entity, &entity)
if err != nil {
return 0, errors.New("数据错误")
}
Expand All @@ -75,6 +75,12 @@ func Save(request *Request) (int64, error) {
if err != nil {
return 0, err
}
// 回写主键
lastId, err := r.LastInsertId()
if err != nil {
return 0, err
}
entity.Id = gconv.Int(lastId)

return r.RowsAffected()
} else {
Expand Down
8 changes: 7 additions & 1 deletion app/service/menu/menuSvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func Delete(id int64, userId int) (int64, error) {
// 保存实体
func Save(request *Request) (int64, error) {
entity := (*menu.Entity)(nil)
err := gconv.StructDeep(request.Entity, &entity)
err := gconv.Struct(request.Entity, &entity)
if err != nil {
return 0, errors.New("数据错误")
}
Expand Down Expand Up @@ -102,6 +102,12 @@ func Save(request *Request) (int64, error) {
if err != nil {
return 0, err
}
// 回写主键
lastId, err := r.LastInsertId()
if err != nil {
return 0, err
}
entity.Id = gconv.Int(lastId)

log.SaveLog(entity, constants.INSERT)
return r.RowsAffected()
Expand Down
11 changes: 8 additions & 3 deletions app/service/role/roleSvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func Delete(id int64, userId int) (int64, error) {
// 保存实体
func Save(request *Request) (int64, error) {
entity := (*role.Entity)(nil)
err := gconv.StructDeep(request.Entity, &entity)
err := gconv.Struct(request.Entity, &entity)
if err != nil {
return 0, errors.New("数据错误")
}
Expand All @@ -85,9 +85,14 @@ func Save(request *Request) (int64, error) {
if err != nil {
return 0, err
}

// 回写主键
request.Id = entity.Id
lastId, err := r.LastInsertId()
if err != nil {
return 0, err
}
entity.Id = gconv.Int(lastId)
request.Id = gconv.Int(lastId)

log.SaveLog(entity, constants.INSERT)
return r.RowsAffected()
} else {
Expand Down
8 changes: 7 additions & 1 deletion app/service/user/userSvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func Delete(id int64, userId int) (int64, error) {
// 保存实体
func Save(request *Request) (int64, error) {
entity := (*user.Entity)(nil)
err := gconv.StructDeep(request.Entity, &entity)
err := gconv.Struct(request.Entity, &entity)
if err != nil {
return 0, errors.New("数据错误")
}
Expand All @@ -95,6 +95,12 @@ func Save(request *Request) (int64, error) {
if err != nil {
return 0, err
}
// 回写主键
lastId, err := r.LastInsertId()
if err != nil {
return 0, err
}
entity.Id = gconv.Int(lastId)

log.SaveLog(entity, constants.INSERT)
return r.RowsAffected()
Expand Down
2 changes: 1 addition & 1 deletion public/resources/js/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ var vm = new Vue({
});
}
, logout: function () {
dudu.get(dudu.ctx + "/user/logout?_" + $.now(), function (r) {
dudu.get(dudu.ctx + "/system/user/logout?_" + $.now(), function (r) {
if (r.code == 0) {
window.top.location.href = "login";
} else {
Expand Down
Loading

0 comments on commit e7ddc9b

Please sign in to comment.