This commit is contained in:
2025-03-28 17:51:34 +08:00
parent da612380e0
commit 5c8802d2f0
68 changed files with 3422 additions and 630 deletions

View File

@@ -1,16 +1,12 @@
package system
import (
"encoding/json"
"net/http"
"strconv"
"strings"
"time"
"management/internal/db/model/dto"
db "management/internal/db/sqlc"
"management/internal/global/auth"
"management/internal/pkg/session"
"management/internal/router/manage/util"
systemservice "management/internal/service/system"
"management/internal/tpl"
@@ -189,20 +185,20 @@ func (h *SysMenuHandler) Save(w http.ResponseWriter, r *http.Request) {
}
func (h *SysMenuHandler) UserMenus(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
b := session.GetBytes(ctx, auth.StoreName)
var u dto.AuthorizeUser
if err := json.Unmarshal(b, &u); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
menus, err := systemservice.RecursiveSysMenus(ctx, u.RoleID)
if err != nil {
tpl.JSON(w, tpl.Response{Success: false, Message: err.Error()})
return
}
// ctx := r.Context()
// b := session.GetBytes(ctx, auth.StoreName)
// var u dto.AuthorizeUser
// if err := json.Unmarshal(b, &u); err != nil {
// http.Error(w, err.Error(), http.StatusInternalServerError)
// return
// }
// menus, err := systemservice.RecursiveSysMenus(ctx, u.RoleID)
// if err != nil {
// tpl.JSON(w, tpl.Response{Success: false, Message: err.Error()})
// return
// }
tpl.JSON(w, menus)
tpl.JSON(w, nil)
}
func (h *SysMenuHandler) XmSelectTree(w http.ResponseWriter, r *http.Request) {

View File

@@ -8,6 +8,7 @@ import (
"management/internal/db/model/dto"
db "management/internal/db/sqlc"
"management/internal/pkg/convertor"
"management/internal/router/manage/util"
systemservice "management/internal/service/system"
"management/internal/tpl"
@@ -25,14 +26,13 @@ func (h *SysRoleHandler) List(w http.ResponseWriter, r *http.Request) {
func (h *SysRoleHandler) PostList(w http.ResponseWriter, r *http.Request) {
var q dto.SearchDto
q.SearchStatus = util.ConvertInt(r.PostFormValue("SearchStatus"), 9999)
q.SearchParentID = util.ConvertInt(r.PostFormValue("SearchParentID"), 0)
q.SearchName = r.PostFormValue("SearchName")
q.SearchKey = r.PostFormValue("SearchKey")
q.Page = util.ConvertInt(r.PostFormValue("page"), 1)
q.Rows = util.ConvertInt(r.PostFormValue("rows"), 10)
ctx := r.Context()
res, count, err := systemservice.ListSysRoleCondition(ctx, q)
q.SearchStatus = convertor.ConvertInt(r.PostFormValue("status"), 9999)
q.SearchParentID = convertor.ConvertInt(r.PostFormValue("parentId"), 0)
q.SearchName = r.PostFormValue("name")
q.SearchID = convertor.ConvertInt[int64](r.PostFormValue("id"), 0)
q.Page = convertor.ConvertInt(r.PostFormValue("page"), 1)
q.Rows = convertor.ConvertInt(r.PostFormValue("rows"), 10)
res, count, err := systemservice.ListSysRoleCondition(r.Context(), q)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -141,7 +141,7 @@ func (h *SysRoleHandler) Save(w http.ResponseWriter, r *http.Request) {
func (h *SysRoleHandler) XmSelect(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
res, err := systemservice.XmSelectSysRole(ctx)
res, err := systemservice.XmSelectSysRole(ctx, 0)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return