Files
ai-agent/internal/handlers/dashboard/permission_handler.go
T
mlogclub 5d7c10aeab refactor: rename agent widget references to AI agent for consistency
- Updated runtime configuration to use __CS_AI_AGENT_WIDGET_CONFIG__ instead of __CS_AGENT_WIDGET_CONFIG__.
- Changed message types in support host bridge from "cs-agent" to "cs-ai-agent".
- Minified SDK script updated to reflect new AI agent naming conventions.
- Adjusted scrollbar styles in main.scss to use .cs-ai-agent-scrollbar instead of .cs-agent-scrollbar.
2026-05-30 21:19:36 +08:00

77 lines
2.0 KiB
Go

package dashboard
import (
"cs-ai-agent/internal/pkg/constants"
"cs-ai-agent/internal/pkg/dto/response"
"cs-ai-agent/internal/pkg/httpx"
"cs-ai-agent/internal/services"
"cs-ai-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/common/strs"
"github.com/mlogclub/simple/web"
)
func PermissionAnyList(ctx *gin.Context) {
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionPermissionView); err != nil {
httpx.WriteJSON(ctx, err)
return
}
cnd := params.NewPagedSqlCnd(ctx,
params.QueryFilter{ParamName: "groupName"},
params.QueryFilter{ParamName: "type"},
params.QueryFilter{ParamName: "status"},
).Desc("id")
if keyword, _ := params.Get(ctx, "keyword"); strs.IsNotBlank(keyword) {
cnd.Where("(name LIKE ? OR code LIKE ?)", "%"+keyword+"%", "%"+keyword+"%")
}
list, paging := services.PermissionService.FindPageByCnd(cnd)
results := make([]response.PermissionResponse, 0, len(list))
for _, item := range list {
results = append(results, response.PermissionResponse{
ID: item.ID,
Name: item.Name,
Code: item.Code,
Type: item.Type,
GroupName: item.GroupName,
Method: item.Method,
ApiPath: item.APIPath,
Status: item.Status,
SortNo: item.SortNo,
})
}
httpx.WriteJSON(ctx, &web.PageResult{Results: results, Page: paging})
}
func PermissionGetBy(ctx *gin.Context) {
id, ok := httpx.GetPathInt64(ctx, "id")
if !ok {
return
}
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionPermissionView); err != nil {
httpx.WriteJSON(ctx, err)
return
}
item := services.PermissionService.Get(id)
if item == nil {
httpx.WriteJSON(ctx, web.JsonErrorMsg("权限不存在"))
return
}
httpx.WriteJSON(ctx, &response.PermissionResponse{
ID: item.ID,
Name: item.Name,
Code: item.Code,
Type: item.Type,
GroupName: item.GroupName,
Method: item.Method,
ApiPath: item.APIPath,
Status: item.Status,
SortNo: item.SortNo,
})
}