-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
79 changed files
with
5,767 additions
and
2,824 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/gogf/gf/frame/g" | ||
"github.com/gogf/gf/net/ghttp" | ||
"github.com/gogf/gf/os/glog" | ||
"github.com/gogf/gf/os/gtime" | ||
"github.com/gogf/gf/util/gconv" | ||
"gmanager/app/service/config" | ||
"gmanager/library/base" | ||
) | ||
|
||
type Action struct { | ||
base.BaseRouter | ||
} | ||
|
||
// path: /index | ||
func (action *Action) Index(r *ghttp.Request) { | ||
tplFile := "pages/system/config_index.html" | ||
err := r.Response.WriteTpl(tplFile, g.Map{ | ||
"now": gtime.Datetime(), | ||
}) | ||
|
||
if err != nil { | ||
glog.Error(err) | ||
} | ||
} | ||
|
||
// path: /get/{id} | ||
func (action *Action) Get(r *ghttp.Request) { | ||
id := r.GetInt64("id") | ||
model, err := config.GetById(id) | ||
if err != nil { | ||
base.Fail(r, err.Error()) | ||
} | ||
|
||
base.Succ(r, model) | ||
} | ||
|
||
// path: /delete/{id} | ||
func (action *Action) Delete(r *ghttp.Request) { | ||
id := r.GetInt64("id") | ||
_, err := config.Delete(id, base.GetUser(r).Id) | ||
if err != nil { | ||
base.Fail(r, err.Error()) | ||
} | ||
|
||
base.Succ(r, "") | ||
} | ||
|
||
// path: /save | ||
func (action *Action) Save(r *ghttp.Request) { | ||
request := new(config.Request) | ||
err := gconv.Struct(r.GetQueryMap(), request) | ||
if err != nil { | ||
glog.Error("save struct error", err) | ||
base.Error(r, "获取参数异常") | ||
} | ||
|
||
request.UserId = base.GetUser(r).Id | ||
_, err = config.Save(request) | ||
if err != nil { | ||
base.Fail(r, "保存失败") | ||
} | ||
|
||
base.Succ(r, "") | ||
} | ||
|
||
// path: /list | ||
func (action *Action) List(r *ghttp.Request) { | ||
form := base.NewForm(r.GetQueryMap()) | ||
|
||
list, err := config.List(&form) | ||
if err != nil { | ||
glog.Error("page error", err) | ||
base.Error(r, err.Error()) | ||
} | ||
|
||
base.Succ(r, list) | ||
} | ||
|
||
// path: /page | ||
func (action *Action) Page(r *ghttp.Request) { | ||
form := base.NewForm(r.GetQueryMap()) | ||
page, err := config.Page(&form) | ||
if err != nil { | ||
glog.Error("page error", err) | ||
base.Error(r, err.Error()) | ||
} | ||
|
||
base.Succ(r, | ||
g.Map{ | ||
"page": form.Page, | ||
"rows": page, | ||
"total": form.TotalPage, | ||
"records": form.TotalSize, | ||
}) | ||
} | ||
|
||
// path: /jqgrid | ||
func (action *Action) Jqgrid(r *ghttp.Request) { | ||
form := base.NewForm(r.GetQueryMap()) | ||
page, err := config.Page(&form) | ||
if err != nil { | ||
glog.Error("jqgrid error", err) | ||
base.Error(r, err.Error()) | ||
} | ||
|
||
r.Response.WriteJson(g.Map{ | ||
"page": form.Page, | ||
"rows": page, | ||
"total": form.TotalPage, | ||
"records": form.TotalSize, | ||
}) | ||
} | ||
|
||
// path: /type | ||
func (action *Action) Type(r *ghttp.Request) { | ||
form := base.NewForm(r.GetQueryMap()) | ||
|
||
//userId := base.GetUser(r).Id | ||
//user := SysUser{Id: userId}.Get() | ||
form.SetParam("parentId", "0") | ||
form.OrderBy = "sort asc,create_time desc" | ||
|
||
list, err := config.List(&form) | ||
if err != nil { | ||
glog.Error("type error", err) | ||
base.Error(r, err.Error()) | ||
} | ||
base.Succ(r, list) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
package department | ||
|
||
import ( | ||
"github.com/gogf/gf/frame/g" | ||
"github.com/gogf/gf/net/ghttp" | ||
"github.com/gogf/gf/os/glog" | ||
"github.com/gogf/gf/os/gtime" | ||
"github.com/gogf/gf/util/gconv" | ||
"gmanager/app/service/department" | ||
"gmanager/library/base" | ||
) | ||
|
||
type Action struct { | ||
base.BaseRouter | ||
} | ||
|
||
// path: /index | ||
func (action *Action) Index(r *ghttp.Request) { | ||
tplFile := "pages/system/department_index.html" | ||
err := r.Response.WriteTpl(tplFile, g.Map{ | ||
"now": gtime.Datetime(), | ||
}) | ||
|
||
if err != nil { | ||
glog.Error(err) | ||
} | ||
} | ||
|
||
// path: /get/{id} | ||
func (action *Action) Get(r *ghttp.Request) { | ||
id := r.GetInt64("id") | ||
model, err := department.GetById(id) | ||
if err != nil { | ||
base.Fail(r, err.Error()) | ||
} | ||
|
||
base.Succ(r, model) | ||
} | ||
|
||
// path: /delete/{id} | ||
func (action *Action) Delete(r *ghttp.Request) { | ||
id := r.GetInt64("id") | ||
|
||
form := base.NewForm(g.Map{"parentId": id}) | ||
childModel, err := department.GetOne(&form) | ||
if err != nil { | ||
base.Fail(r, err.Error()) | ||
} else if childModel != nil && childModel.Id > 0 { | ||
base.Fail(r, "请先删除子机构") | ||
} | ||
|
||
_, err = department.Delete(id, base.GetUser(r).Id) | ||
if err != nil { | ||
base.Fail(r, err.Error()) | ||
} | ||
|
||
base.Succ(r, "") | ||
} | ||
|
||
// path: /save | ||
func (action *Action) Save(r *ghttp.Request) { | ||
request := new(department.Request) | ||
err := gconv.Struct(r.GetQueryMap(), request) | ||
if err != nil { | ||
glog.Error("save struct error", err) | ||
base.Error(r, "save error") | ||
} | ||
|
||
request.UserId = base.GetUser(r).Id | ||
_, err = department.Save(request) | ||
if err != nil { | ||
base.Fail(r, "保存失败") | ||
} | ||
|
||
base.Succ(r, "") | ||
} | ||
|
||
// path: /list | ||
func (action *Action) List(r *ghttp.Request) { | ||
form := base.NewForm(r.GetQueryMap()) | ||
|
||
list, err := department.List(&form) | ||
if err != nil { | ||
glog.Error("page error", err) | ||
base.Error(r, err.Error()) | ||
} | ||
|
||
base.Succ(r, list) | ||
} | ||
|
||
// path: /page | ||
func (action *Action) Page(r *ghttp.Request) { | ||
form := base.NewForm(r.GetQueryMap()) | ||
page, err := department.Page(&form) | ||
if err != nil { | ||
glog.Error("page error", err) | ||
base.Error(r, err.Error()) | ||
} | ||
|
||
base.Succ(r, | ||
g.Map{ | ||
"page": form.Page, | ||
"rows": page, | ||
"total": form.TotalPage, | ||
"records": form.TotalSize, | ||
}) | ||
} | ||
|
||
// path: /jqgrid | ||
func (action *Action) Jqgrid(r *ghttp.Request) { | ||
form := base.NewForm(r.GetQueryMap()) | ||
page, err := department.Page(&form) | ||
if err != nil { | ||
glog.Error("jqgrid error", err) | ||
base.Error(r, err.Error()) | ||
} | ||
|
||
r.Response.WriteJson(g.Map{ | ||
"page": form.Page, | ||
"rows": page, | ||
"total": form.TotalPage, | ||
"records": form.TotalSize, | ||
}) | ||
} |
Oops, something went wrong.