update
This commit is contained in:
parent
417d0671de
commit
b171122a32
@ -29,11 +29,11 @@ func (a *app) list(w http.ResponseWriter, r *http.Request) {
|
|||||||
a.render.Render(ctx, w, auditlog.List(ctx))
|
a.render.Render(ctx, w, auditlog.List(ctx))
|
||||||
case http.MethodPost:
|
case http.MethodPost:
|
||||||
var q dto.SearchDto
|
var q dto.SearchDto
|
||||||
q.SearchTimeBegin, q.SearchTimeEnd = convertor.DefaultStartTimeAndEndTime(r.PostFormValue("timeBegin"), r.PostFormValue("timeEnd"))
|
q.SearchTimeBegin, q.SearchTimeEnd = convertor.DefaultTime(r.PostFormValue("timeBegin"), r.PostFormValue("timeEnd"))
|
||||||
q.SearchName = r.PostFormValue("name")
|
q.SearchName = r.PostFormValue("name")
|
||||||
q.SearchEmail = r.PostFormValue("email")
|
q.SearchEmail = r.PostFormValue("email")
|
||||||
q.Page = convertor.ConvertInt(r.PostFormValue("page"), 1)
|
q.Page = convertor.Int(r.PostFormValue("page"), 1)
|
||||||
q.Rows = convertor.ConvertInt(r.PostFormValue("rows"), 10)
|
q.Rows = convertor.Int(r.PostFormValue("rows"), 10)
|
||||||
res, count, err := a.auditLogService.List(r.Context(), q)
|
res, count, err := a.auditLogService.List(r.Context(), q)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.render.JSONErr(w, err.Error())
|
a.render.JSONErr(w, err.Error())
|
||||||
|
|||||||
@ -34,10 +34,10 @@ func (a *app) list(w http.ResponseWriter, r *http.Request) {
|
|||||||
a.render.Render(ctx, w, config.List(ctx))
|
a.render.Render(ctx, w, config.List(ctx))
|
||||||
case http.MethodPost:
|
case http.MethodPost:
|
||||||
var q dto.SearchDto
|
var q dto.SearchDto
|
||||||
q.SearchTimeBegin, q.SearchTimeEnd = convertor.DefaultStartTimeAndEndTime(r.PostFormValue("timeBegin"), r.PostFormValue("timeEnd"))
|
q.SearchTimeBegin, q.SearchTimeEnd = convertor.DefaultTime(r.PostFormValue("timeBegin"), r.PostFormValue("timeEnd"))
|
||||||
q.SearchName = r.PostFormValue("name")
|
q.SearchName = r.PostFormValue("name")
|
||||||
q.Page = convertor.ConvertInt(r.PostFormValue("page"), 1)
|
q.Page = convertor.Int(r.PostFormValue("page"), 1)
|
||||||
q.Rows = convertor.ConvertInt(r.PostFormValue("rows"), 10)
|
q.Rows = convertor.Int(r.PostFormValue("rows"), 10)
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
res, count, err := a.configService.List(ctx, q)
|
res, count, err := a.configService.List(ctx, q)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -71,7 +71,7 @@ func (a *app) edit(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *app) save(w http.ResponseWriter, r *http.Request) {
|
func (a *app) save(w http.ResponseWriter, r *http.Request) {
|
||||||
id := convertor.ConvertInt[int32](r.PostFormValue("ID"), 0)
|
id := convertor.Int[int32](r.PostFormValue("ID"), 0)
|
||||||
key := r.PostFormValue("Key")
|
key := r.PostFormValue("Key")
|
||||||
value := r.PostFormValue("Value")
|
value := r.PostFormValue("Value")
|
||||||
if len(key) == 0 {
|
if len(key) == 0 {
|
||||||
|
|||||||
@ -32,13 +32,13 @@ func (a *app) list(w http.ResponseWriter, r *http.Request) {
|
|||||||
a.render.Render(ctx, w, department.List(ctx))
|
a.render.Render(ctx, w, department.List(ctx))
|
||||||
case http.MethodPost:
|
case http.MethodPost:
|
||||||
var q dto.SearchDto
|
var q dto.SearchDto
|
||||||
q.SearchTimeBegin, q.SearchTimeEnd = convertor.DefaultStartTimeAndEndTime(r.PostFormValue("timeBegin"), r.PostFormValue("timeEnd"))
|
q.SearchTimeBegin, q.SearchTimeEnd = convertor.DefaultTime(r.PostFormValue("timeBegin"), r.PostFormValue("timeEnd"))
|
||||||
q.SearchStatus = convertor.ConvertInt(r.PostFormValue("status"), 9999)
|
q.SearchStatus = convertor.Int(r.PostFormValue("status"), 9999)
|
||||||
q.SearchParentID = convertor.ConvertInt(r.PostFormValue("parentId"), 0)
|
q.SearchParentID = convertor.Int(r.PostFormValue("parentId"), 0)
|
||||||
q.SearchName = r.PostFormValue("name")
|
q.SearchName = r.PostFormValue("name")
|
||||||
q.SearchID = convertor.ConvertInt[int64](r.PostFormValue("id"), 0)
|
q.SearchID = convertor.Int[int64](r.PostFormValue("id"), 0)
|
||||||
q.Page = convertor.ConvertInt(r.PostFormValue("page"), 1)
|
q.Page = convertor.Int(r.PostFormValue("page"), 1)
|
||||||
q.Rows = convertor.ConvertInt(r.PostFormValue("rows"), 10)
|
q.Rows = convertor.Int(r.PostFormValue("rows"), 10)
|
||||||
res, count, err := a.departmentService.List(r.Context(), q)
|
res, count, err := a.departmentService.List(r.Context(), q)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.render.JSONErr(w, err.Error())
|
a.render.JSONErr(w, err.Error())
|
||||||
|
|||||||
@ -29,10 +29,10 @@ func (a *app) list(w http.ResponseWriter, r *http.Request) {
|
|||||||
a.render.Render(ctx, w, loginlog.List(ctx))
|
a.render.Render(ctx, w, loginlog.List(ctx))
|
||||||
case http.MethodPost:
|
case http.MethodPost:
|
||||||
var q dto.SearchDto
|
var q dto.SearchDto
|
||||||
q.SearchTimeBegin, q.SearchTimeEnd = convertor.DefaultStartTimeAndEndTime(r.PostFormValue("timeBegin"), r.PostFormValue("timeEnd"))
|
q.SearchTimeBegin, q.SearchTimeEnd = convertor.DefaultTime(r.PostFormValue("timeBegin"), r.PostFormValue("timeEnd"))
|
||||||
q.SearchEmail = r.PostFormValue("email")
|
q.SearchEmail = r.PostFormValue("email")
|
||||||
q.Page = convertor.ConvertInt(r.PostFormValue("page"), 1)
|
q.Page = convertor.Int(r.PostFormValue("page"), 1)
|
||||||
q.Rows = convertor.ConvertInt(r.PostFormValue("rows"), 10)
|
q.Rows = convertor.Int(r.PostFormValue("rows"), 10)
|
||||||
res, count, err := a.loginLogService.List(r.Context(), q)
|
res, count, err := a.loginLogService.List(r.Context(), q)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.render.JSONErr(w, err.Error())
|
a.render.JSONErr(w, err.Error())
|
||||||
|
|||||||
@ -93,7 +93,7 @@ func (a *app) edit(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *app) save(w http.ResponseWriter, r *http.Request) {
|
func (a *app) save(w http.ResponseWriter, r *http.Request) {
|
||||||
id := convertor.ConvertInt[int32](r.PostFormValue("ID"), 0)
|
id := convertor.Int[int32](r.PostFormValue("ID"), 0)
|
||||||
name := r.PostFormValue("Name")
|
name := r.PostFormValue("Name")
|
||||||
displayName := r.PostFormValue("DisplayName")
|
displayName := r.PostFormValue("DisplayName")
|
||||||
t := r.PostFormValue("Type")
|
t := r.PostFormValue("Type")
|
||||||
@ -103,11 +103,11 @@ func (a *app) save(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
avatar := r.PostFormValue("Avatar")
|
avatar := r.PostFormValue("Avatar")
|
||||||
style := r.PostFormValue("Style")
|
style := r.PostFormValue("Style")
|
||||||
parentID := convertor.ConvertInt[int32](r.PostFormValue("ParentID"), 0)
|
parentID := convertor.Int[int32](r.PostFormValue("ParentID"), 0)
|
||||||
visible := convertor.ConvertBool(r.PostFormValue("Visible"), false)
|
visible := convertor.Bool(r.PostFormValue("Visible"), false)
|
||||||
isList := convertor.ConvertBool(r.PostFormValue("IsList"), false)
|
isList := convertor.Bool(r.PostFormValue("IsList"), false)
|
||||||
sort := convertor.ConvertInt[int32](r.PostFormValue("Sort"), 6666)
|
sort := convertor.Int[int32](r.PostFormValue("Sort"), 6666)
|
||||||
status := convertor.ConvertInt[int32](r.PostFormValue("Status"), 0)
|
status := convertor.Int[int32](r.PostFormValue("Status"), 0)
|
||||||
|
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
if len(avatar) > 0 && !strings.Contains(avatar, "layui-icon ") {
|
if len(avatar) > 0 && !strings.Contains(avatar, "layui-icon ") {
|
||||||
|
|||||||
@ -36,13 +36,13 @@ func (a *app) list(w http.ResponseWriter, r *http.Request) {
|
|||||||
a.render.Render(ctx, w, role.List(ctx))
|
a.render.Render(ctx, w, role.List(ctx))
|
||||||
case http.MethodPost:
|
case http.MethodPost:
|
||||||
var q dto.SearchDto
|
var q dto.SearchDto
|
||||||
q.SearchTimeBegin, q.SearchTimeEnd = convertor.DefaultStartTimeAndEndTime(r.PostFormValue("timeBegin"), r.PostFormValue("timeEnd"))
|
q.SearchTimeBegin, q.SearchTimeEnd = convertor.DefaultTime(r.PostFormValue("timeBegin"), r.PostFormValue("timeEnd"))
|
||||||
q.SearchStatus = convertor.ConvertInt(r.PostFormValue("status"), 9999)
|
q.SearchStatus = convertor.Int(r.PostFormValue("status"), 9999)
|
||||||
q.SearchParentID = convertor.ConvertInt(r.PostFormValue("parentId"), 0)
|
q.SearchParentID = convertor.Int(r.PostFormValue("parentId"), 0)
|
||||||
q.SearchName = r.PostFormValue("name")
|
q.SearchName = r.PostFormValue("name")
|
||||||
q.SearchID = convertor.ConvertInt[int64](r.PostFormValue("id"), 0)
|
q.SearchID = convertor.Int[int64](r.PostFormValue("id"), 0)
|
||||||
q.Page = convertor.ConvertInt(r.PostFormValue("page"), 1)
|
q.Page = convertor.Int(r.PostFormValue("page"), 1)
|
||||||
q.Rows = convertor.ConvertInt(r.PostFormValue("rows"), 10)
|
q.Rows = convertor.Int(r.PostFormValue("rows"), 10)
|
||||||
res, count, err := a.roleService.List(r.Context(), q)
|
res, count, err := a.roleService.List(r.Context(), q)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.render.JSONErr(w, err.Error())
|
a.render.JSONErr(w, err.Error())
|
||||||
@ -149,7 +149,7 @@ func (a *app) refreshRoleMenus(w http.ResponseWriter, r *http.Request) {
|
|||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
|
|
||||||
// 获取需要刷新的角色ID
|
// 获取需要刷新的角色ID
|
||||||
roleID := convertor.ConvertInt[int32](r.PostFormValue("roleID"), 0)
|
roleID := convertor.Int[int32](r.PostFormValue("roleID"), 0)
|
||||||
roleModel, err := a.roleService.Get(ctx, roleID)
|
roleModel, err := a.roleService.Get(ctx, roleID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.render.JSONErr(w, err.Error())
|
a.render.JSONErr(w, err.Error())
|
||||||
@ -204,7 +204,7 @@ func (a *app) setMenu(w http.ResponseWriter, r *http.Request) {
|
|||||||
a.render.Render(ctx, w, role.SetMenu(ctx, vm))
|
a.render.Render(ctx, w, role.SetMenu(ctx, vm))
|
||||||
case http.MethodPost:
|
case http.MethodPost:
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
id := convertor.ConvertInt[int32](r.PostFormValue("ID"), 0)
|
id := convertor.Int[int32](r.PostFormValue("ID"), 0)
|
||||||
if id == 0 {
|
if id == 0 {
|
||||||
a.render.JSONErr(w, "角色异常, 请刷新重试")
|
a.render.JSONErr(w, "角色异常, 请刷新重试")
|
||||||
return
|
return
|
||||||
@ -228,7 +228,7 @@ func (a *app) setMenu(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
var rms []*system.RoleMenu
|
var rms []*system.RoleMenu
|
||||||
for _, v := range menuArr {
|
for _, v := range menuArr {
|
||||||
menuID := convertor.ConvertInt(v, 0)
|
menuID := convertor.Int(v, 0)
|
||||||
if menuID > 0 {
|
if menuID > 0 {
|
||||||
menu, err := a.menuService.Get(ctx, int32(menuID))
|
menu, err := a.menuService.Get(ctx, int32(menuID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -51,9 +51,8 @@ func (a *app) add(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
func (a *app) edit(w http.ResponseWriter, r *http.Request) {
|
func (a *app) edit(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
vars := r.URL.Query()
|
|
||||||
id := convertor.QueryInt[int32](vars, "id", 0)
|
|
||||||
vm := &systemmodel.User{}
|
vm := &systemmodel.User{}
|
||||||
|
id := convertor.QueryInt[int32](r.URL.Query(), "id", 0)
|
||||||
if id > 0 {
|
if id > 0 {
|
||||||
if u, err := a.userService.Get(ctx, id); err == nil {
|
if u, err := a.userService.Get(ctx, id); err == nil {
|
||||||
vm = u
|
vm = u
|
||||||
@ -110,13 +109,13 @@ func (a *app) list(w http.ResponseWriter, r *http.Request) {
|
|||||||
a.render.Render(ctx, w, user.List(ctx))
|
a.render.Render(ctx, w, user.List(ctx))
|
||||||
case http.MethodPost:
|
case http.MethodPost:
|
||||||
var q dto.SearchDto
|
var q dto.SearchDto
|
||||||
q.SearchTimeBegin, q.SearchTimeEnd = convertor.DefaultStartTimeAndEndTime(r.PostFormValue("timeBegin"), r.PostFormValue("timeEnd"))
|
q.SearchTimeBegin, q.SearchTimeEnd = convertor.DefaultTime(r.PostFormValue("timeBegin"), r.PostFormValue("timeEnd"))
|
||||||
q.SearchStatus = convertor.ConvertInt(r.PostFormValue("status"), 9999)
|
q.SearchStatus = convertor.Int(r.PostFormValue("status"), 9999)
|
||||||
q.SearchName = r.PostFormValue("name")
|
q.SearchName = r.PostFormValue("name")
|
||||||
q.SearchEmail = r.PostFormValue("email")
|
q.SearchEmail = r.PostFormValue("email")
|
||||||
q.SearchID = convertor.ConvertInt[int64](r.PostFormValue("id"), 0)
|
q.SearchID = convertor.Int[int64](r.PostFormValue("id"), 0)
|
||||||
q.Page = convertor.ConvertInt(r.PostFormValue("page"), 1)
|
q.Page = convertor.Int(r.PostFormValue("page"), 1)
|
||||||
q.Rows = convertor.ConvertInt(r.PostFormValue("rows"), 10)
|
q.Rows = convertor.Int(r.PostFormValue("rows"), 10)
|
||||||
res, count, err := a.userService.List(r.Context(), q)
|
res, count, err := a.userService.List(r.Context(), q)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.render.JSONErr(w, err.Error())
|
a.render.JSONErr(w, err.Error())
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ConvertInt[T int | int16 | int32 | int64](value string, defaultValue T) T {
|
func Int[T int | int16 | int32 | int64](value string, defaultValue T) T {
|
||||||
i, err := strconv.Atoi(value)
|
i, err := strconv.Atoi(value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return defaultValue
|
return defaultValue
|
||||||
@ -14,7 +14,7 @@ func ConvertInt[T int | int16 | int32 | int64](value string, defaultValue T) T {
|
|||||||
return T(i)
|
return T(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConvertBool(value string, defaultValue bool) bool {
|
func Bool(value string, defaultValue bool) bool {
|
||||||
b, err := strconv.ParseBool(value)
|
b, err := strconv.ParseBool(value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return defaultValue
|
return defaultValue
|
||||||
@ -37,7 +37,7 @@ func QueryInt[T int | int16 | int32 | int64](vars url.Values, key string, defaul
|
|||||||
return T(i)
|
return T(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DefaultStartTimeAndEndTime(start string, end string) (string, string) {
|
func DefaultTime(start string, end string) (string, string) {
|
||||||
if len(start) == 0 {
|
if len(start) == 0 {
|
||||||
start = "2000-01-01 00:00:00"
|
start = "2000-01-01 00:00:00"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user