2025-04-18 17:17:23 +08:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"admin/apps/game/model/dto"
|
|
|
|
"admin/internal/context"
|
2025-05-05 10:30:33 +08:00
|
|
|
stdContext "context"
|
2025-04-18 17:17:23 +08:00
|
|
|
)
|
|
|
|
|
2025-04-24 20:39:31 +08:00
|
|
|
func (ctl *controller) CommonList(ctx *context.WebContext, params *dto.CommonListReq, rsp *dto.CommonListRsp) error {
|
|
|
|
projectId, resource := getCtxURIProjectIdAndResource(ctx)
|
2025-05-07 15:03:19 +08:00
|
|
|
|
|
|
|
ctx1 := stdContext.WithValue(ctx.Context, "user_id", ctx.Header.UserId)
|
|
|
|
ctx1 = stdContext.WithValue(ctx1, "user_name", ctx.Header.UserName)
|
|
|
|
|
|
|
|
list, err := ctl.svc.CommonList(ctx1, projectId, resource, params)
|
2025-04-18 17:17:23 +08:00
|
|
|
if err != nil {
|
2025-04-22 15:46:48 +08:00
|
|
|
return err
|
2025-04-18 17:17:23 +08:00
|
|
|
}
|
2025-04-22 15:46:48 +08:00
|
|
|
*rsp = *list
|
|
|
|
return nil
|
2025-04-18 17:17:23 +08:00
|
|
|
}
|
|
|
|
|
2025-04-24 20:39:31 +08:00
|
|
|
func (ctl *controller) CommonPost(ctx *context.WebContext, params *dto.CommonPostReq, rsp *dto.CommonPostRsp) error {
|
|
|
|
projectId, resource := getCtxURIProjectIdAndResource(ctx)
|
2025-05-05 10:30:33 +08:00
|
|
|
|
|
|
|
ctx1 := stdContext.WithValue(ctx.Context, "user_id", ctx.Header.UserId)
|
2025-05-07 15:03:19 +08:00
|
|
|
ctx1 = stdContext.WithValue(ctx1, "user_name", ctx.Header.UserName)
|
2025-05-05 10:30:33 +08:00
|
|
|
|
|
|
|
newObj, err := ctl.svc.CommonPost(ctx1, projectId, resource, *params.Dto)
|
2025-04-18 17:17:23 +08:00
|
|
|
if err != nil {
|
2025-04-22 15:46:48 +08:00
|
|
|
return err
|
2025-04-18 17:17:23 +08:00
|
|
|
}
|
2025-04-22 15:46:48 +08:00
|
|
|
rsp.Dto = &newObj
|
|
|
|
return nil
|
2025-04-18 17:17:23 +08:00
|
|
|
}
|
|
|
|
|
2025-04-24 20:39:31 +08:00
|
|
|
func (ctl *controller) CommonPut(ctx *context.WebContext, params *dto.CommonPutReq, rsp *dto.CommonPutRsp) error {
|
|
|
|
projectId, resource := getCtxURIProjectIdAndResource(ctx)
|
2025-05-07 15:03:19 +08:00
|
|
|
|
|
|
|
ctx1 := stdContext.WithValue(ctx.Context, "user_id", ctx.Header.UserId)
|
|
|
|
ctx1 = stdContext.WithValue(ctx1, "user_name", ctx.Header.UserName)
|
|
|
|
|
|
|
|
err := ctl.svc.CommonPut(ctx1, projectId, resource, *params.Dto)
|
2025-04-18 17:17:23 +08:00
|
|
|
if err != nil {
|
2025-04-22 15:46:48 +08:00
|
|
|
return err
|
2025-04-18 17:17:23 +08:00
|
|
|
}
|
2025-04-24 20:39:31 +08:00
|
|
|
rsp.Dto = params.Dto
|
2025-04-22 15:46:48 +08:00
|
|
|
return nil
|
2025-04-18 17:17:23 +08:00
|
|
|
}
|
|
|
|
|
2025-04-24 20:39:31 +08:00
|
|
|
func (ctl *controller) CommonDelete(ctx *context.WebContext, params *dto.CommonDeleteReq, rsp *dto.CommonDeleteRsp) error {
|
|
|
|
projectId, resource := getCtxURIProjectIdAndResource(ctx)
|
2025-05-07 15:03:19 +08:00
|
|
|
|
|
|
|
ctx1 := stdContext.WithValue(ctx.Context, "user_id", ctx.Header.UserId)
|
|
|
|
ctx1 = stdContext.WithValue(ctx1, "user_name", ctx.Header.UserName)
|
|
|
|
|
|
|
|
err := ctl.svc.CommonDelete(ctx1, projectId, resource, params.Id)
|
2025-04-18 17:17:23 +08:00
|
|
|
if err != nil {
|
2025-04-22 15:46:48 +08:00
|
|
|
return err
|
2025-04-18 17:17:23 +08:00
|
|
|
}
|
2025-04-22 15:46:48 +08:00
|
|
|
return nil
|
2025-04-18 17:17:23 +08:00
|
|
|
}
|
2025-04-26 13:50:26 +08:00
|
|
|
|
2025-05-12 18:43:41 +08:00
|
|
|
func (ctl *controller) CommonRowsSelection(ctx *context.WebContext, params *dto.CommonRowsSelectionReq, rsp *dto.CommonRowsSelectionRsp) error {
|
|
|
|
projectId, resource := getCtxURIProjectIdAndResource(ctx)
|
|
|
|
|
|
|
|
ctx1 := stdContext.WithValue(ctx.Context, "user_id", ctx.Header.UserId)
|
|
|
|
ctx1 = stdContext.WithValue(ctx1, "user_name", ctx.Header.UserName)
|
|
|
|
|
2025-05-13 18:13:22 +08:00
|
|
|
result, err := ctl.svc.CommonRowsSelection(ctx1, projectId, resource, params)
|
2025-05-12 18:43:41 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2025-05-13 18:13:22 +08:00
|
|
|
*rsp = *result
|
2025-05-12 18:43:41 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2025-04-26 13:50:26 +08:00
|
|
|
func (ctl *controller) OnClickCustomButton(ctx *context.WebContext, params *dto.CommonDeleteReq, rsp *dto.CommonDeleteRsp) error {
|
|
|
|
return nil
|
|
|
|
}
|
2025-05-04 22:07:13 +08:00
|
|
|
|
|
|
|
func (ctl *controller) GetProjectAllItems(ctx *context.WebContext, params *dto.NilReq, rsp *dto.GetProjectAllItemsRsp) error {
|
|
|
|
projectId := getCtxURIProjectId(ctx)
|
|
|
|
items, err := ctl.svc.GetAllItems(projectId)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
rsp.Items = items
|
|
|
|
return nil
|
|
|
|
}
|