又优化了很多

This commit is contained in:
likun 2025-05-16 15:17:10 +08:00
parent 790d5d22ca
commit 20a6efe559
97 changed files with 1458 additions and 2471 deletions

View File

@ -3,9 +3,9 @@ package domain
import (
"admin/apps/game/domain/projects"
"admin/apps/game/domain/repo"
"admin/apps/game/model/dto"
"admin/internal/consts"
"admin/internal/errcode"
"admin/internal/model/dto"
"gorm.io/gorm"
)

View File

@ -3,8 +3,8 @@ package domain
import (
"admin/apps/game/domain/entity"
"admin/apps/game/domain/repo"
"admin/apps/game/model/dto"
"admin/internal/errcode"
"admin/internal/model/dto"
"admin/lib/cdkey"
"gorm.io/gorm"
"time"

View File

@ -6,10 +6,10 @@ import (
"admin/apps/game/domain/projects"
"admin/apps/game/domain/repo"
"admin/apps/game/model"
"admin/apps/game/model/dto"
"admin/internal/consts"
"admin/internal/errcode"
"admin/internal/event"
dto2 "admin/internal/model/dto"
"admin/lib/xlog"
"database/sql"
"encoding/json"
@ -104,7 +104,7 @@ func (svc *CommonResourceService) startLoadAllDelayInvokeDbData() {
}
}
func (svc *CommonResourceService) List(projectId int, resource string, listParams *dto.CommonListReq) (int, []*dto.CommonDtoFieldDesc, []dto.CommonDtoValues, error) {
func (svc *CommonResourceService) List(projectId int, resource string, listParams *dto2.CommonListReq) (int, []*dto2.CommonDtoFieldDesc, []dto2.CommonDtoValues, error) {
_, projectEt, find, err := svc.projectRepo.GetById(projectId)
if err != nil {
return 0, nil, nil, err
@ -118,7 +118,7 @@ func (svc *CommonResourceService) List(projectId int, resource string, listParam
if err != nil {
return 0, nil, nil, err
}
retList := make([]dto.CommonDtoValues, 0, len(etList))
retList := make([]dto2.CommonDtoValues, 0, len(etList))
for _, v := range etList {
retList = append(retList, v.ToCommonDto())
}
@ -136,7 +136,7 @@ func (svc *CommonResourceService) List(projectId int, resource string, listParam
return totalCount, fieldsDescInfo, retList, nil
}
func (svc *CommonResourceService) GetById(projectId int, resource string, id int) ([]*dto.CommonDtoFieldDesc, dto.CommonDtoValues, *entity.CommonResource, bool, error) {
func (svc *CommonResourceService) GetById(projectId int, resource string, id int) ([]*dto2.CommonDtoFieldDesc, dto2.CommonDtoValues, *entity.CommonResource, bool, error) {
_, projectEt, find, err := svc.projectRepo.GetById(projectId)
if err != nil {
return nil, nil, nil, false, err
@ -153,7 +153,7 @@ func (svc *CommonResourceService) GetById(projectId int, resource string, id int
return fieldsDescInfo, et.ToCommonDto(), et, find, nil
}
func (svc *CommonResourceService) Create(projectId int, resource string, dtoObj dto.CommonDtoValues) (dto.CommonDtoValues, error) {
func (svc *CommonResourceService) Create(projectId int, resource string, dtoObj dto2.CommonDtoValues) (dto2.CommonDtoValues, error) {
_, projectEt, find, err := svc.projectRepo.GetById(projectId)
if err != nil {
return nil, err
@ -162,7 +162,7 @@ func (svc *CommonResourceService) Create(projectId int, resource string, dtoObj
return nil, errcode.New(errcode.ServerError, "not found project %v db data", projectId)
}
createOne := func(obj dto.CommonDtoValues) (dto.CommonDtoValues, error) {
createOne := func(obj dto2.CommonDtoValues) (dto2.CommonDtoValues, error) {
resourceRepo := findCommResourceRepo(resource)
et, err := resourceRepo.Repo.Create(projectEt, resource, obj)
if err != nil {
@ -202,7 +202,7 @@ func (svc *CommonResourceService) Create(projectId int, resource string, dtoObj
return newObj, nil
}
var newDtoObj dto.CommonDtoValues
var newDtoObj dto2.CommonDtoValues
if resource == consts.ResourcesName_SupportAccount {
account, findAccount := dtoObj["Account"]
if findAccount {
@ -226,7 +226,7 @@ func (svc *CommonResourceService) Create(projectId int, resource string, dtoObj
return newDtoObj, err
}
func (svc *CommonResourceService) Edit(projectId int, resource string, dtoObj dto.CommonDtoValues) error {
func (svc *CommonResourceService) Edit(projectId int, resource string, dtoObj dto2.CommonDtoValues) error {
_, projectEt, find, err := svc.projectRepo.GetById(projectId)
if err != nil {
return err
@ -280,7 +280,7 @@ func (svc *CommonResourceService) Delete(projectId int, resource string, id int)
return oldEt, nil
}
func (svc *CommonResourceService) RowsSelection(projectId int, resourceName string, params *dto.CommonRowsSelectionReq) (*dto.CommonRowsSelectionRsp, error) {
func (svc *CommonResourceService) RowsSelection(projectId int, resourceName string, params *dto2.CommonRowsSelectionReq) (*dto2.CommonRowsSelectionRsp, error) {
_, projectEt, find, err := svc.projectRepo.GetById(projectId)
if err != nil {
return nil, err

View File

@ -2,9 +2,9 @@ package entity
import (
"admin/apps/game/model"
"admin/apps/game/model/dto"
"admin/internal/consts"
"admin/internal/errcode"
"admin/internal/model/dto"
"admin/lib/cdkey"
"time"
)

View File

@ -2,7 +2,7 @@ package entity
import (
"admin/apps/game/model"
"admin/apps/game/model/dto"
"admin/internal/model/dto"
"reflect"
)

View File

@ -2,7 +2,7 @@ package entity
import (
"admin/apps/game/model"
"admin/apps/game/model/dto"
"admin/internal/model/dto"
)
type Project struct {

View File

@ -2,7 +2,7 @@ package entity
import (
"admin/apps/game/model"
"admin/apps/game/model/dto"
"admin/internal/model/dto"
"admin/lib/xlog"
"database/sql"
"fmt"

View File

@ -1,7 +1,7 @@
package domain
import (
"admin/apps/game/model/dto"
"admin/internal/model/dto"
)
type IRestfulEntity interface {

View File

@ -5,8 +5,8 @@ import (
"admin/apps/game/domain/projects"
"admin/apps/game/domain/repo"
"admin/apps/game/model"
"admin/apps/game/model/dto"
"admin/internal/errcode"
"admin/internal/model/dto"
"gorm.io/gorm"
)

View File

@ -2,36 +2,36 @@ package projects
import (
"admin/apps/game/domain/entity"
"admin/apps/game/model/dto"
dto2 "admin/internal/model/dto"
)
type IPostResourceOpListHook interface {
List(projectInfo *entity.Project, resource string, params *dto.CommonListReq,
fields []*dto.CommonDtoFieldDesc, totalCount int, rows []dto.CommonDtoValues) (
int, []*dto.CommonDtoFieldDesc, []dto.CommonDtoValues, error)
List(projectInfo *entity.Project, resource string, params *dto2.CommonListReq,
fields []*dto2.CommonDtoFieldDesc, totalCount int, rows []dto2.CommonDtoValues) (
int, []*dto2.CommonDtoFieldDesc, []dto2.CommonDtoValues, error)
}
type IPostResourceOpCreateHook interface {
Create(projectInfo *entity.Project, resource string, dtoObj dto.CommonDtoValues) error
Create(projectInfo *entity.Project, resource string, dtoObj dto2.CommonDtoValues) error
}
type IPostResourceOpEditHook interface {
Edit(projectInfo *entity.Project, resource string, dtoObj dto.CommonDtoValues) error
Edit(projectInfo *entity.Project, resource string, dtoObj dto2.CommonDtoValues) error
}
type IPostResourceOpDeleteHook interface {
Delete(projectInfo *entity.Project, resource string, dtoObj dto.CommonDtoValues) error
Delete(projectInfo *entity.Project, resource string, dtoObj dto2.CommonDtoValues) error
}
type IPostResourceOpRowsHook interface {
RowsSelection(projectInfo *entity.Project, resource string, btnKey string, dtoObjs []dto.CommonDtoValues) (*dto.CommonRowsSelectionRsp, error)
RowsSelection(projectInfo *entity.Project, resource string, btnKey string, dtoObjs []dto2.CommonDtoValues) (*dto2.CommonRowsSelectionRsp, error)
}
type IGetAccountDetailHook interface {
GetDetail(projectInfo *entity.Project, account string) (*dto.GetAccountDetailRsp, error)
GetDetail(projectInfo *entity.Project, account string) (*dto2.GetAccountDetailRsp, error)
}
type IGetAllValueChoicesHook interface {
// 获取所有道具,可以用于前端页面做下拉选择等
GetItems(projectInfo *entity.Project) ([]*dto.CommonDtoFieldChoice, error)
GetItems(projectInfo *entity.Project) ([]*dto2.CommonDtoFieldChoice, error)
}

View File

@ -4,8 +4,8 @@ import (
"admin/apps/game/domain/entity"
"admin/apps/game/domain/projects/smdl/internal"
"admin/apps/game/model"
"admin/apps/game/model/dto"
"admin/internal/errcode"
dto2 "admin/internal/model/dto"
"admin/lib/httpclient"
"admin/lib/utils"
"math"
@ -17,9 +17,9 @@ import (
type AccountHook struct {
}
func (hook *AccountHook) List(projectInfo *entity.Project, resource string, params *dto.CommonListReq,
fields []*dto.CommonDtoFieldDesc, totalCount int, rows []dto.CommonDtoValues) (
int, []*dto.CommonDtoFieldDesc, []dto.CommonDtoValues, error) {
func (hook *AccountHook) List(projectInfo *entity.Project, resource string, params *dto2.CommonListReq,
fields []*dto2.CommonDtoFieldDesc, totalCount int, rows []dto2.CommonDtoValues) (
int, []*dto2.CommonDtoFieldDesc, []dto2.CommonDtoValues, error) {
alisrvAddr := projectInfo.GetApiAddr()
if alisrvAddr == "" {
return 0, nil, nil, errcode.New(errcode.ServerError, "项目%v没有配置api服务器地址", projectInfo.Po.Name)
@ -111,8 +111,8 @@ type AccountDetailOrderInfo struct {
PurchaseAt int64 `json:"purchase_at"`
}
func (info *AccountDetailOrderInfo) toDto() *dto.AccountDetailOrderInfo {
return &dto.AccountDetailOrderInfo{
func (info *AccountDetailOrderInfo) toDto() *dto2.AccountDetailOrderInfo {
return &dto2.AccountDetailOrderInfo{
ServerId: info.ServerId,
AccountId: info.AccountId,
RoleId: info.RoleId,
@ -131,7 +131,7 @@ type AccountDetailRoleInfo struct {
Name string `json:"name"`
RoleId string `json:"roleId"`
Level int `json:"level"`
CurrencyItems []*dto.ItemInfo `json:"item_list"`
CurrencyItems []*dto2.ItemInfo `json:"item_list"`
Ip string `json:"ip"`
Channel string `json:"channel"`
CreatedAt int64 `json:"created_at"`
@ -139,8 +139,8 @@ type AccountDetailRoleInfo struct {
OrderList []*AccountDetailOrderInfo `json:"order_list"`
}
func (info *AccountDetailRoleInfo) toDto() *dto.AccountDetailRoleInfo {
retInfo := &dto.AccountDetailRoleInfo{
func (info *AccountDetailRoleInfo) toDto() *dto2.AccountDetailRoleInfo {
retInfo := &dto2.AccountDetailRoleInfo{
Platform: info.Platform,
ServerId: info.ServerId,
Name: info.Name,
@ -166,8 +166,8 @@ type AccountDetailInfo struct {
RoleList []*AccountDetailRoleInfo `json:"role_list"`
}
func (info *AccountDetailInfo) toDto() *dto.AccountDetailInfo {
retInfo := &dto.AccountDetailInfo{
func (info *AccountDetailInfo) toDto() *dto2.AccountDetailInfo {
retInfo := &dto2.AccountDetailInfo{
AccountId: info.AccountId,
}
var earliestRole *AccountDetailRoleInfo
@ -212,7 +212,7 @@ func (info *AccountDetailInfo) toDto() *dto.AccountDetailInfo {
return retInfo
}
func (hook *AccountHook) GetDetail(projectInfo *entity.Project, account string) (*dto.GetAccountDetailRsp, error) {
func (hook *AccountHook) GetDetail(projectInfo *entity.Project, account string) (*dto2.GetAccountDetailRsp, error) {
accountId := account
if accountId == "" {
return nil, errcode.New(errcode.ParamsInvalid, "not found account id:%v", accountId)
@ -254,11 +254,11 @@ func (hook *AccountHook) GetDetail(projectInfo *entity.Project, account string)
}
accountDetailTotal := &AccountDetailInfo{AccountId: accountId, RoleList: roleList}
return &dto.GetAccountDetailRsp{AccountInfo: accountDetailTotal.toDto()}, nil
return &dto2.GetAccountDetailRsp{AccountInfo: accountDetailTotal.toDto()}, nil
}
func getPaginationServerReqList(projectInfo *entity.Project, serverInfoList internal.ServerInfoList,
params *dto.CommonListReq, queryCountField func(*internal.ServerInfo) int) (
params *dto2.CommonListReq, queryCountField func(*internal.ServerInfo) int) (
totalCount int, reqServerInfoList []*internal.PageServerCountInfo, err error) {
pageNo := params.PageNo
@ -302,7 +302,7 @@ func getPaginationServerReqList(projectInfo *entity.Project, serverInfoList inte
return totalCount, reqServerList, nil
}
func findWhereConditionSpecServer(whereConditions []*dto.GetWhereCondition, serverInfoList internal.ServerInfoList) (string, *internal.ServerInfo, bool) {
func findWhereConditionSpecServer(whereConditions []*dto2.GetWhereCondition, serverInfoList internal.ServerInfoList) (string, *internal.ServerInfo, bool) {
if len(whereConditions) > 1 {
// 第一个是ProjectId条件
for _, cond := range whereConditions {

View File

@ -3,9 +3,9 @@ package smdl
import (
"admin/apps/game/domain/entity"
"admin/apps/game/model"
"admin/apps/game/model/dto"
"admin/internal/consts"
"admin/internal/errcode"
"admin/internal/model/dto"
"admin/lib/httpclient"
"admin/lib/xlog"
"net/url"

View File

@ -2,8 +2,8 @@ package smdl
import (
"admin/apps/game/domain/entity"
"admin/apps/game/model/dto"
"admin/internal/errcode"
"admin/internal/model/dto"
"admin/lib/httpclient"
)

View File

@ -4,8 +4,8 @@ import (
"admin/apps/game/domain/entity"
"admin/apps/game/domain/repo"
"admin/apps/game/model"
"admin/apps/game/model/dto"
"admin/internal/errcode"
"admin/internal/model/dto"
"admin/lib/httpclient"
"admin/lib/xlog"
"net/url"

View File

@ -3,8 +3,8 @@ package smdl
import (
"admin/apps/game/domain/entity"
"admin/apps/game/model"
"admin/apps/game/model/dto"
"admin/internal/errcode"
"admin/internal/model/dto"
"admin/lib/httpclient"
"admin/lib/xlog"
"net/url"

View File

@ -3,9 +3,9 @@ package smdl
import (
"admin/apps/game/domain/entity"
"admin/apps/game/model"
"admin/apps/game/model/dto"
"admin/internal/consts"
"admin/internal/errcode"
"admin/internal/model/dto"
"admin/lib/httpclient"
"admin/lib/xlog"
"net/url"

View File

@ -4,8 +4,8 @@ import (
"admin/apps/game/domain/entity"
"admin/apps/game/domain/projects/smdl/internal"
"admin/apps/game/model"
"admin/apps/game/model/dto"
"admin/internal/errcode"
dto2 "admin/internal/model/dto"
"admin/lib/httpclient"
"admin/lib/utils"
"net/url"
@ -28,9 +28,9 @@ type Role struct {
type RoleHook struct {
}
func (hook *RoleHook) List(projectInfo *entity.Project, resource string, params *dto.CommonListReq,
fields []*dto.CommonDtoFieldDesc, totalCount int, rows []dto.CommonDtoValues) (
int, []*dto.CommonDtoFieldDesc, []dto.CommonDtoValues, error) {
func (hook *RoleHook) List(projectInfo *entity.Project, resource string, params *dto2.CommonListReq,
fields []*dto2.CommonDtoFieldDesc, totalCount int, rows []dto2.CommonDtoValues) (
int, []*dto2.CommonDtoFieldDesc, []dto2.CommonDtoValues, error) {
alisrvAddr := projectInfo.GetApiAddr()
if alisrvAddr == "" {
return 0, nil, nil, errcode.New(errcode.ServerError, "项目%v没有配置api服务器地址", projectInfo.Po.Name)

View File

@ -5,9 +5,9 @@ import (
"admin/apps/game/domain/projects/smdl/internal"
"admin/apps/game/domain/repo"
"admin/apps/game/model"
"admin/apps/game/model/dto"
"admin/internal/consts"
"admin/internal/errcode"
dto2 "admin/internal/model/dto"
"admin/lib/xlog"
"fmt"
)
@ -15,9 +15,9 @@ import (
type ServerHook struct {
}
func (hook *ServerHook) List(projectInfo *entity.Project, resource string, params *dto.CommonListReq,
fields []*dto.CommonDtoFieldDesc, totalCount int, rows []dto.CommonDtoValues) (
int, []*dto.CommonDtoFieldDesc, []dto.CommonDtoValues, error) {
func (hook *ServerHook) List(projectInfo *entity.Project, resource string, params *dto2.CommonListReq,
fields []*dto2.CommonDtoFieldDesc, totalCount int, rows []dto2.CommonDtoValues) (
int, []*dto2.CommonDtoFieldDesc, []dto2.CommonDtoValues, error) {
alisrvAddr := projectInfo.GetApiAddr()
if alisrvAddr == "" {
return 0, nil, nil, errcode.New(errcode.ServerError, "项目%v没有配置api服务器地址", projectInfo.Po.Name)
@ -60,7 +60,7 @@ func (hook *ServerHook) List(projectInfo *entity.Project, resource string, param
return totalCount, fields, rows, nil
}
func (hook *ServerHook) RowsSelection(projectInfo *entity.Project, resource string, btnKey string, dtoObjs []dto.CommonDtoValues) (*dto.CommonRowsSelectionRsp, error) {
func (hook *ServerHook) RowsSelection(projectInfo *entity.Project, resource string, btnKey string, dtoObjs []dto2.CommonDtoValues) (*dto2.CommonRowsSelectionRsp, error) {
msg := ""
serverIds := make([]string, 0, len(dtoObjs))
@ -134,7 +134,7 @@ func (hook *ServerHook) RowsSelection(projectInfo *entity.Project, resource stri
}
}
return &dto.CommonRowsSelectionRsp{
return &dto2.CommonRowsSelectionRsp{
Msg: fmt.Sprintf("执行%v操作成功!", msg),
NeedRefresh: true,
}, nil

View File

@ -3,8 +3,8 @@ package smdl
import (
"admin/apps/game/domain/entity"
"admin/apps/game/model"
"admin/apps/game/model/dto"
"admin/internal/errcode"
"admin/internal/model/dto"
"admin/lib/httpclient"
"net/url"
)

View File

@ -3,8 +3,8 @@ package smdl
import (
"admin/apps/game/domain/entity"
"admin/apps/game/model"
"admin/apps/game/model/dto"
"admin/internal/errcode"
"admin/internal/model/dto"
"admin/lib/httpclient"
"net/url"
)
@ -96,6 +96,6 @@ func (hook *WhitelistHook) Delete(projectInfo *entity.Project, resource string,
}
}
}
return nil
}

View File

@ -3,9 +3,9 @@ package repo
import (
"admin/apps/game/domain/entity"
"admin/apps/game/model"
"admin/apps/game/model/dto"
"admin/internal/errcode"
"admin/internal/global"
dto2 "admin/internal/model/dto"
"errors"
"gorm.io/gorm"
"time"
@ -16,15 +16,15 @@ type ICDKeyRepo interface {
GetByKey(projectId int, key string) (*entity.CDKey, bool, error)
AddCount(projectId, id int, delta int) (*entity.CDKey, error)
GetUsedHistory(batchInfo *entity.CDKey, key string, serverId, roleId string) (*model.CDKeyUsed, bool, error)
RecordUse(batchInfo *entity.CDKey, params *dto.CDKeyUseReq) error
GetUsedHistoryList(projectId, id int) ([]*dto.CDKeyUsedInfo, error)
RecordUse(batchInfo *entity.CDKey, params *dto2.CDKeyUseReq) error
GetUsedHistoryList(projectId, id int) ([]*dto2.CDKeyUsedInfo, error)
}
func NewCDKeyRepo(db *gorm.DB) ICDKeyRepo {
return &cdKeyRepoImpl{db: db}
}
func cdKeyPreCreateHook(projectEt *entity.Project, dtoObj dto.CommonDtoValues) error {
func cdKeyPreCreateHook(projectEt *entity.Project, dtoObj dto2.CommonDtoValues) error {
et := (&entity.CommonResource{}).FromPo(&model.CDKey{}).FromDto(dtoObj)
do := entity.NewCDKey(et.Po.(*model.CDKey))
if do.IsGlobalType() {
@ -101,7 +101,7 @@ func (impl *cdKeyRepoImpl) GetUsedHistory(batchInfo *entity.CDKey, key string, s
return po, true, nil
}
func (impl *cdKeyRepoImpl) RecordUse(batchInfo *entity.CDKey, params *dto.CDKeyUseReq) error {
func (impl *cdKeyRepoImpl) RecordUse(batchInfo *entity.CDKey, params *dto2.CDKeyUseReq) error {
po := &model.CDKeyUsed{
ProjectId: batchInfo.Po.ProjectId,
CDKeyId: batchInfo.Po.ID,
@ -120,15 +120,15 @@ func (impl *cdKeyRepoImpl) RecordUse(batchInfo *entity.CDKey, params *dto.CDKeyU
return nil
}
func (impl *cdKeyRepoImpl) GetUsedHistoryList(projectId, id int) ([]*dto.CDKeyUsedInfo, error) {
func (impl *cdKeyRepoImpl) GetUsedHistoryList(projectId, id int) ([]*dto2.CDKeyUsedInfo, error) {
list := make([]*model.CDKeyUsed, 0)
err := impl.db.Where("project_id = ? and cd_key_id = ?", projectId, id).Find(&list).Error
if err != nil {
return nil, errcode.New(errcode.DBError, "GetUsedHistoryList %v %v error:%v", projectId, id, err)
}
retList := make([]*dto.CDKeyUsedInfo, 0, len(list))
retList := make([]*dto2.CDKeyUsedInfo, 0, len(list))
for _, v := range list {
retList = append(retList, &dto.CDKeyUsedInfo{
retList = append(retList, &dto2.CDKeyUsedInfo{
ServerID: v.ServerID,
Account: v.Account,
RoleID: v.RoleID,

View File

@ -3,9 +3,9 @@ package repo
import (
"admin/apps/game/domain/entity"
"admin/apps/game/model"
"admin/apps/game/model/dto"
"admin/internal/consts"
"admin/internal/errcode"
dto2 "admin/internal/model/dto"
"admin/lib/xlog"
"database/sql"
"errors"
@ -17,15 +17,15 @@ import (
"time"
)
var createHooks = map[string]func(projectEt *entity.Project, et dto.CommonDtoValues) error{
var createHooks = map[string]func(projectEt *entity.Project, et dto2.CommonDtoValues) error{
consts.ResourcesName_CDKey: cdKeyPreCreateHook,
}
type ICommonResourceRepo interface {
List(project *entity.Project, params *dto.CommonListReq) (int, []*dto.CommonDtoFieldDesc, []*entity.CommonResource, error)
GetById(projectEt *entity.Project, id int) ([]*dto.CommonDtoFieldDesc, *entity.CommonResource, bool, error)
Create(projectEt *entity.Project, resource string, et dto.CommonDtoValues) (*entity.CommonResource, error)
Edit(projectEt *entity.Project, et dto.CommonDtoValues) error
List(project *entity.Project, params *dto2.CommonListReq) (int, []*dto2.CommonDtoFieldDesc, []*entity.CommonResource, error)
GetById(projectEt *entity.Project, id int) ([]*dto2.CommonDtoFieldDesc, *entity.CommonResource, bool, error)
Create(projectEt *entity.Project, resource string, et dto2.CommonDtoValues) (*entity.CommonResource, error)
Edit(projectEt *entity.Project, et dto2.CommonDtoValues) error
Delete(projectEt *entity.Project, id int) (*entity.CommonResource, bool, error)
ListPagination(whereSql string, whereArgs []any, f func(po model.IModel)) error
UpdateClearDelayInvokeCreateHookFieldN(id int) error
@ -38,7 +38,7 @@ func NewCommonResourceRepo(db *gorm.DB, poTemplate model.IModel) ICommonResource
type commonResourceRepoImpl struct {
db *gorm.DB
poTemplate model.IModel
fieldsDescInfoFun func(project *entity.Project) []*dto.CommonDtoFieldDesc
fieldsDescInfoFun func(project *entity.Project) []*dto2.CommonDtoFieldDesc
}
func newCommonResourceRepoImpl(db *gorm.DB, poTemplate model.IModel) *commonResourceRepoImpl {
@ -46,7 +46,7 @@ func newCommonResourceRepoImpl(db *gorm.DB, poTemplate model.IModel) *commonReso
return &commonResourceRepoImpl{db: db, poTemplate: poTemplate, fieldsDescInfoFun: fieldsInfo}
}
func (repo *commonResourceRepoImpl) List(projectEt *entity.Project, params *dto.CommonListReq) (int, []*dto.CommonDtoFieldDesc, []*entity.CommonResource, error) {
func (repo *commonResourceRepoImpl) List(projectEt *entity.Project, params *dto2.CommonListReq) (int, []*dto2.CommonDtoFieldDesc, []*entity.CommonResource, error) {
pageNo := params.PageNo
pageLen := params.PageLen
@ -98,7 +98,7 @@ func (repo *commonResourceRepoImpl) List(projectEt *entity.Project, params *dto.
return int(totalCount), repo.fieldsDescInfoFun(projectEt), entityList, nil
}
func (repo *commonResourceRepoImpl) GetById(projectEt *entity.Project, id int) ([]*dto.CommonDtoFieldDesc, *entity.CommonResource, bool, error) {
func (repo *commonResourceRepoImpl) GetById(projectEt *entity.Project, id int) ([]*dto2.CommonDtoFieldDesc, *entity.CommonResource, bool, error) {
po := repo.makeEmptyPo()
err := repo.db.Where("id = ?", id).First(po).Error
if err != nil {
@ -110,7 +110,7 @@ func (repo *commonResourceRepoImpl) GetById(projectEt *entity.Project, id int) (
return repo.fieldsDescInfoFun(projectEt), (&entity.CommonResource{}).FromPo(po), true, nil
}
func (repo *commonResourceRepoImpl) Create(projectEt *entity.Project, resource string, dtoObj dto.CommonDtoValues) (*entity.CommonResource, error) {
func (repo *commonResourceRepoImpl) Create(projectEt *entity.Project, resource string, dtoObj dto2.CommonDtoValues) (*entity.CommonResource, error) {
et := (&entity.CommonResource{}).FromPo(repo.makeEmptyPo()).FromDto(dtoObj)
if handler, find := createHooks[resource]; find {
if err := handler(projectEt, dtoObj); err != nil {
@ -129,7 +129,7 @@ func (repo *commonResourceRepoImpl) Create(projectEt *entity.Project, resource s
return et, nil
}
func (repo *commonResourceRepoImpl) Edit(projectEt *entity.Project, dtoObj dto.CommonDtoValues) error {
func (repo *commonResourceRepoImpl) Edit(projectEt *entity.Project, dtoObj dto2.CommonDtoValues) error {
et := (&entity.CommonResource{}).FromPo(repo.makeEmptyPo()).FromDto(dtoObj)
err := repo.db.Where("id=?", et.Po.GetId()).Save(et.Po).Error
if err != nil {
@ -203,7 +203,7 @@ func (repo *commonResourceRepoImpl) makeEmptyPo() model.IModel {
return reflect.New(reflect.TypeOf(repo.poTemplate).Elem()).Interface().(model.IModel)
}
func (repo *commonResourceRepoImpl) parseWhereConditions2Sql(conditions []*dto.GetWhereCondition) (whereSql string, args []any) {
func (repo *commonResourceRepoImpl) parseWhereConditions2Sql(conditions []*dto2.GetWhereCondition) (whereSql string, args []any) {
namer := new(schema.NamingStrategy)
to := reflect.TypeOf(repo.poTemplate).Elem()
whereClause := make([]string, 0, len(conditions))

View File

@ -3,8 +3,8 @@ package repo
import (
"admin/apps/game/domain/entity"
"admin/apps/game/model"
"admin/apps/game/model/dto"
"admin/internal/errcode"
"admin/internal/model/dto"
"errors"
"gorm.io/gorm"
)

View File

@ -1,8 +1,8 @@
package model
import (
"admin/apps/game/model/dto"
"admin/internal/db"
"admin/internal/model/dto"
"time"
)

View File

@ -1,9 +1,9 @@
package model
import (
"admin/apps/game/model/dto"
"admin/internal/consts"
"admin/internal/db"
"admin/internal/model/dto"
"database/sql"
"time"
)

View File

@ -1,9 +1,9 @@
package model
import (
"admin/apps/game/model/dto"
"admin/internal/consts"
"admin/internal/db"
"admin/internal/model/dto"
"database/sql"
"time"
)

View File

@ -1,8 +1,8 @@
package model
import (
"admin/apps/game/model/dto"
"admin/internal/db"
"admin/internal/model/dto"
"database/sql"
"time"
)

View File

@ -1,7 +1,7 @@
package model
import (
"admin/apps/game/model/dto"
"admin/internal/model/dto"
)
type IModel interface {

View File

@ -1,10 +1,10 @@
package model
import (
"admin/apps/game/model/dto"
"admin/internal/db"
"admin/internal/errcode"
"admin/internal/global"
"admin/internal/model/dto"
"time"
)

View File

@ -1,8 +1,8 @@
package model
import (
"admin/apps/game/model/dto"
"admin/internal/db"
"admin/internal/model/dto"
"time"
)

View File

@ -1,10 +1,10 @@
package model
import (
"admin/apps/game/model/dto"
"admin/internal/consts"
"admin/internal/db"
"admin/internal/global"
"admin/internal/model/dto"
"errors"
"gorm.io/gorm"
"time"

View File

@ -1,8 +1,8 @@
package model
import (
"admin/apps/game/model/dto"
"admin/internal/db"
"admin/internal/model/dto"
"time"
)

View File

@ -1,8 +1,8 @@
package model
import (
"admin/apps/game/model/dto"
"admin/internal/db"
"admin/internal/model/dto"
"time"
)

View File

@ -1,8 +1,8 @@
package model
import (
"admin/apps/game/model/dto"
"admin/internal/db"
"admin/internal/model/dto"
"time"
)

View File

@ -1,8 +1,8 @@
package model
import (
"admin/apps/game/model/dto"
"admin/internal/db"
"admin/internal/model/dto"
"time"
)

View File

@ -1,8 +1,8 @@
package server
import (
"admin/apps/game/model/dto"
"admin/internal/context"
"admin/internal/model/dto"
)
func (ctl *controller) GetAccountDetail(ctx *context.WebContext, params *dto.GetAccountDetailReq, rsp *dto.GetAccountDetailRsp) error {

View File

@ -1,8 +1,8 @@
package server
import (
"admin/apps/game/model/dto"
"admin/internal/context"
"admin/internal/model/dto"
"bytes"
"fmt"
"strings"

View File

@ -1,8 +1,8 @@
package server
import (
"admin/apps/game/model/dto"
"admin/internal/context"
"admin/internal/model/dto"
stdContext "context"
)

View File

@ -1,9 +1,9 @@
package server
import (
"admin/apps/game/model/dto"
"admin/internal/consts"
"admin/internal/context"
"admin/internal/model/dto"
"admin/lib/httpclient"
"admin/lib/xlog"
"strconv"

View File

@ -3,10 +3,10 @@ package service
import (
"admin/apps/game/api"
"admin/apps/game/domain"
"admin/apps/game/model/dto"
"admin/internal/consts"
"admin/internal/errcode"
"admin/internal/event"
dto2 "admin/internal/model/dto"
"context"
"encoding/json"
"fmt"
@ -37,9 +37,9 @@ func New(db *gorm.DB) (*Service, error) {
return svc, nil
}
func (svc *Service) CommonList(ctx context.Context, projectId int, resourceName string, params *dto.CommonListReq) (*dto.CommonDtoList, error) {
func (svc *Service) CommonList(ctx context.Context, projectId int, resourceName string, params *dto2.CommonListReq) (*dto2.CommonDtoList, error) {
params.ParsedWhereConditions = &dto.ListWhereConditionInfo{}
params.ParsedWhereConditions = &dto2.ListWhereConditionInfo{}
if params.WhereConditions != "" {
err := json.Unmarshal([]byte(params.WhereConditions), params.ParsedWhereConditions)
if err != nil {
@ -51,7 +51,7 @@ func (svc *Service) CommonList(ctx context.Context, projectId int, resourceName
switch resourceName {
case consts.ResourcesName_Project:
default:
params.ParsedWhereConditions.Conditions = append([]*dto.GetWhereCondition{&dto.GetWhereCondition{
params.ParsedWhereConditions.Conditions = append([]*dto2.GetWhereCondition{&dto2.GetWhereCondition{
Key: "ProjectId",
Op: "eq",
Value1: projectId,
@ -62,10 +62,10 @@ func (svc *Service) CommonList(ctx context.Context, projectId int, resourceName
if err != nil {
return nil, err
}
return &dto.CommonDtoList{FieldsDesc: fieldsDescInfo, TotalCount: totalCount, Rows: rows, ItemBags: itemBags}, err
return &dto2.CommonDtoList{FieldsDesc: fieldsDescInfo, TotalCount: totalCount, Rows: rows, ItemBags: itemBags}, err
}
func (svc *Service) CommonPost(ctx context.Context, projectId int, resourceName string, params dto.CommonDtoValues) (dto.CommonDtoValues, error) {
func (svc *Service) CommonPost(ctx context.Context, projectId int, resourceName string, params dto2.CommonDtoValues) (dto2.CommonDtoValues, error) {
if resourceName != consts.ResourcesName_Project {
params["ProjectId"] = projectId
}
@ -87,7 +87,7 @@ func (svc *Service) CommonPost(ctx context.Context, projectId int, resourceName
return values, err
}
func (svc *Service) CommonPut(ctx context.Context, projectId int, resourceName string, params dto.CommonDtoValues) error {
func (svc *Service) CommonPut(ctx context.Context, projectId int, resourceName string, params dto2.CommonDtoValues) error {
if resourceName != consts.ResourcesName_Project {
params["ProjectId"] = projectId
}
@ -129,7 +129,7 @@ func (svc *Service) CommonDelete(ctx context.Context, projectId int, resourceNam
return err
}
func (svc *Service) CommonRowsSelection(ctx context.Context, projectId int, resourceName string, param *dto.CommonRowsSelectionReq) (*dto.CommonRowsSelectionRsp, error) {
func (svc *Service) CommonRowsSelection(ctx context.Context, projectId int, resourceName string, param *dto2.CommonRowsSelectionReq) (*dto2.CommonRowsSelectionRsp, error) {
rsp, err := svc.resourceSvc.RowsSelection(projectId, resourceName, param)
if err != nil {
return rsp, err

View File

@ -1,7 +1,7 @@
package service
import (
"admin/apps/game/model/dto"
"admin/internal/model/dto"
)
func (svc *Service) GetAccountDetail(projectId int, params *dto.GetAccountDetailReq) (*dto.GetAccountDetailRsp, error) {

View File

@ -2,8 +2,8 @@ package service
import (
"admin/apps/game/domain/entity"
"admin/apps/game/model/dto"
"admin/internal/errcode"
"admin/internal/model/dto"
)
func (svc *Service) GetCDKeyAllKeys(projectId int, id int) (*entity.CDKey, []string, error) {

View File

@ -3,8 +3,8 @@ package service
import (
"admin/apps/game/api"
"admin/apps/game/domain/entity"
"admin/apps/game/model/dto"
"admin/internal/consts"
"admin/internal/model/dto"
"admin/internal/permission"
"sort"
)

View File

@ -1,28 +0,0 @@
package mockpro
import (
internalGlobal "admin/apps/mockpro/internal/global"
"admin/apps/mockpro/server"
"admin/apps/mockpro/service"
"admin/internal/global"
"admin/lib/node"
)
func initFun(app *node.Application) error {
internalGlobal.GLOB_DB = global.GLOB_DB
svc := service.New(global.GLOB_DB)
server.New(svc) // 初始化http服务
return nil
}
func New() *node.ApplicationDescInfo {
app := node.NewApplicationDescInfo("mock_project", initFun).
WithOptions(node.WithAppBootFlag(internalGlobal.GLOB_BOOT_FLAGS))
return app
}
func must(err error) {
if err != nil {
panic(err)
}
}

View File

@ -1,48 +0,0 @@
package domain
import (
"admin/apps/mockpro/domain/entity"
"admin/apps/mockpro/domain/repo"
"admin/apps/mockpro/internal/model/dto"
"gorm.io/gorm"
)
type BanSvc struct {
BanRepo repo.IBanRepo
}
func NewBanSvc(db *gorm.DB) *BanSvc {
svc := &BanSvc{
BanRepo: repo.NewBanRepo(db),
}
registerRestfulSvc("ban", svc)
return svc
}
func (svc *BanSvc) List(pageNo, pageLen int) ([]*dto.CommonDtoFieldDesc, []IRestfulEntity, error) {
entityList, err := svc.BanRepo.List(pageNo, pageLen)
if err != nil {
return nil, nil, err
}
iList := make([]IRestfulEntity, 0, len(entityList))
for _, v := range entityList {
iList = append(iList, v)
}
return entity.BanDtoFieldsDescInfo, iList, nil
}
func (svc *BanSvc) Post(obj dto.CommonDtoValues) (IRestfulEntity, error) {
et := entity.FromBanDto(obj)
err := svc.BanRepo.Create(et)
return et, err
}
func (svc *BanSvc) Put(obj dto.CommonDtoValues) (IRestfulEntity, error) {
et := entity.FromBanDto(obj)
err := svc.BanRepo.Edit(et)
return et, err
}
func (svc *BanSvc) Delete(id int) error {
return svc.BanRepo.Delete(id)
}

View File

@ -1,89 +0,0 @@
package entity
import (
"admin/apps/mockpro/internal/model"
"admin/apps/mockpro/internal/model/dto"
"reflect"
)
var BanDtoFieldsDescInfo = DefaultBan().GetDtoFieldsDescInfo()
type Ban struct {
Id int
po *model.Ban
}
func DefaultBan() *Ban {
return &Ban{
po: &model.Ban{},
}
}
func FromBanPo(po *model.Ban) *Ban {
return &Ban{
Id: po.ID,
po: po,
}
}
func FromBanDto(dto dto.CommonDtoValues) *Ban {
et := DefaultBan()
po := et.po
//to := reflect.TypeOf(po)
vo := reflect.ValueOf(po)
for k, v := range dto {
fo := vo.FieldByName(k)
fo.Set(reflect.ValueOf(v))
}
return et
}
func (et *Ban) ToPo() *model.Ban {
return et.po
}
func (et *Ban) ToCommonDto() dto.CommonDtoValues {
obj := make(dto.CommonDtoValues)
to := reflect.TypeOf(et.po).Elem()
vo := reflect.ValueOf(et.po).Elem()
for i := 0; i < vo.NumField(); i++ {
ft := to.Field(i)
fo := vo.Field(i)
obj[ft.Name] = fo.Interface()
}
return obj
}
func (et *Ban) GetDtoFieldsDescInfo() []*dto.CommonDtoFieldDesc {
to := reflect.TypeOf(et.po).Elem()
vo := reflect.ValueOf(et.po).Elem()
obj := make([]*dto.CommonDtoFieldDesc, 0, to.NumField())
for i := 0; i < vo.NumField(); i++ {
ft := to.Field(i)
//fo := vo.Field(i)
f1 := &dto.CommonDtoFieldDesc{
Name: ft.Name,
Key: ft.Name,
Type: ft.Type.Name(),
HelpText: ft.Tag.Get("desc"),
Editable: true,
Require: true,
Choices: make([]*dto.CommonDtoFieldChoice, 0),
MultiChoice: false,
}
obj = append(obj, f1)
}
return obj
}

View File

@ -1,89 +0,0 @@
package entity
import (
"admin/apps/mockpro/internal/model"
"admin/apps/mockpro/internal/model/dto"
"reflect"
)
var WhiteListDtoFieldsDescInfo = DefaultWhiteList().GetDtoFieldsDescInfo()
type WhiteList struct {
Id int
po *model.WhiteList
}
func DefaultWhiteList() *WhiteList {
return &WhiteList{
po: &model.WhiteList{},
}
}
func FromWhiteListPo(po *model.WhiteList) *WhiteList {
return &WhiteList{
Id: po.ID,
po: po,
}
}
func FromWhiteListDto(dto dto.CommonDtoValues) *WhiteList {
et := DefaultWhiteList()
po := et.po
//to := reflect.TypeOf(po)
vo := reflect.ValueOf(po)
for k, v := range dto {
fo := vo.FieldByName(k)
fo.Set(reflect.ValueOf(v))
}
return et
}
func (et *WhiteList) ToPo() *model.WhiteList {
return et.po
}
func (et *WhiteList) ToCommonDto() dto.CommonDtoValues {
obj := make(dto.CommonDtoValues)
to := reflect.TypeOf(et.po).Elem()
vo := reflect.ValueOf(et.po).Elem()
for i := 0; i < vo.NumField(); i++ {
ft := to.Field(i)
fo := vo.Field(i)
obj[ft.Name] = fo.Interface()
}
return obj
}
func (et *WhiteList) GetDtoFieldsDescInfo() []*dto.CommonDtoFieldDesc {
to := reflect.TypeOf(et.po).Elem()
vo := reflect.ValueOf(et.po).Elem()
obj := make([]*dto.CommonDtoFieldDesc, 0, to.NumField())
for i := 0; i < vo.NumField(); i++ {
ft := to.Field(i)
//fo := vo.Field(i)
f1 := &dto.CommonDtoFieldDesc{
Name: ft.Name,
Key: ft.Name,
Type: ft.Type.Name(),
HelpText: ft.Tag.Get("desc"),
Editable: true,
Require: true,
Choices: make([]*dto.CommonDtoFieldChoice, 0),
MultiChoice: false,
}
obj = append(obj, f1)
}
return obj
}

View File

@ -1,31 +0,0 @@
package domain
import (
"admin/apps/mockpro/internal/model/dto"
"admin/internal/errcode"
)
type IRestfulEntity interface {
ToCommonDto() dto.CommonDtoValues
}
type IRestfulResourceSvc interface {
List(pageNo, pageLen int) ([]*dto.CommonDtoFieldDesc, []IRestfulEntity, error)
Post(obj dto.CommonDtoValues) (IRestfulEntity, error)
Put(obj dto.CommonDtoValues) (IRestfulEntity, error)
Delete(id int) error
}
var restfulResourceSvcMgr = make(map[string]IRestfulResourceSvc)
func registerRestfulSvc(name string, svc IRestfulResourceSvc) {
restfulResourceSvcMgr[name] = svc
}
func FindRestfulResourceSvc(name string) (IRestfulResourceSvc, error) {
svc, find := restfulResourceSvcMgr[name]
if !find {
return nil, errcode.New(errcode.ServerError, "not found %v restful svc", name)
}
return svc, nil
}

View File

@ -1,69 +0,0 @@
package repo
import (
"admin/apps/mockpro/domain/entity"
"admin/apps/mockpro/internal/model"
"admin/internal/errcode"
"gorm.io/gorm"
)
type IBanRepo interface {
List(pageNo, pageLen int) ([]*entity.Ban, error)
Create(et *entity.Ban) error
Edit(et *entity.Ban) error
Delete(id int) error
}
func NewBanRepo(db *gorm.DB) IBanRepo {
return newBanRepoImpl(db)
}
type BanRepoImpl struct {
db *gorm.DB
}
func newBanRepoImpl(db *gorm.DB) *BanRepoImpl {
return &BanRepoImpl{db: db}
}
func (repo *BanRepoImpl) List(pageNo, pageLen int) ([]*entity.Ban, error) {
list := make([]*model.Ban, 0)
err := repo.db.Find(&list).Error
if err != nil {
return nil, errcode.New(errcode.DBError, "find Ban error:%v", err)
}
entityList := make([]*entity.Ban, 0, len(list))
for _, Ban := range list {
entityList = append(entityList, entity.FromBanPo(Ban))
}
return entityList, nil
}
func (repo *BanRepoImpl) Create(et *entity.Ban) error {
po := et.ToPo()
err := repo.db.Create(po).Error
if err != nil {
return errcode.New(errcode.DBError, "create obj:%+v error:%v", et, err)
}
et.Id = po.ID
return nil
}
func (repo *BanRepoImpl) Edit(et *entity.Ban) error {
po := et.ToPo()
err := repo.db.Where("id=?", et.Id).Updates(po).Error
if err != nil {
return errcode.New(errcode.DBError, "edit obj:%+v error:%v", et, err)
}
return nil
}
func (repo *BanRepoImpl) Delete(id int) error {
err := repo.db.Where("id=?", id).Unscoped().Delete(&model.Ban{}).Error
if err != nil {
return errcode.New(errcode.DBError, "delete obj:%+v error:%v", id, err)
}
return nil
}

View File

@ -1,69 +0,0 @@
package repo
import (
"admin/apps/mockpro/domain/entity"
"admin/apps/mockpro/internal/model"
"admin/internal/errcode"
"gorm.io/gorm"
)
type IWhiteListRepo interface {
List(pageNo, pageLen int) ([]*entity.WhiteList, error)
Create(et *entity.WhiteList) error
Edit(et *entity.WhiteList) error
Delete(id int) error
}
func NewWhiteListRepo(db *gorm.DB) IWhiteListRepo {
return newWhiteListRepoImpl(db)
}
type WhiteListRepoImpl struct {
db *gorm.DB
}
func newWhiteListRepoImpl(db *gorm.DB) *WhiteListRepoImpl {
return &WhiteListRepoImpl{db: db}
}
func (repo *WhiteListRepoImpl) List(pageNo, pageLen int) ([]*entity.WhiteList, error) {
list := make([]*model.WhiteList, 0)
err := repo.db.Find(&list).Error
if err != nil {
return nil, errcode.New(errcode.DBError, "find WhiteList error:%v", err)
}
entityList := make([]*entity.WhiteList, 0, len(list))
for _, WhiteList := range list {
entityList = append(entityList, entity.FromWhiteListPo(WhiteList))
}
return entityList, nil
}
func (repo *WhiteListRepoImpl) Create(et *entity.WhiteList) error {
po := et.ToPo()
err := repo.db.Create(po).Error
if err != nil {
return errcode.New(errcode.DBError, "create obj:%+v error:%v", et, err)
}
et.Id = po.ID
return nil
}
func (repo *WhiteListRepoImpl) Edit(et *entity.WhiteList) error {
po := et.ToPo()
err := repo.db.Where("id=?", et.Id).Updates(po).Error
if err != nil {
return errcode.New(errcode.DBError, "edit obj:%+v error:%v", et, err)
}
return nil
}
func (repo *WhiteListRepoImpl) Delete(id int) error {
err := repo.db.Where("id=?", id).Unscoped().Delete(&model.WhiteList{}).Error
if err != nil {
return errcode.New(errcode.DBError, "delete obj:%+v error:%v", id, err)
}
return nil
}

View File

@ -1,48 +0,0 @@
package domain
import (
"admin/apps/mockpro/domain/entity"
"admin/apps/mockpro/domain/repo"
"admin/apps/mockpro/internal/model/dto"
"gorm.io/gorm"
)
type WhiteListSvc struct {
proRepo repo.IWhiteListRepo
}
func NewWhiteListSvc(db *gorm.DB) *WhiteListSvc {
svc := &WhiteListSvc{
proRepo: repo.NewWhiteListRepo(db),
}
registerRestfulSvc("whitelist", svc)
return svc
}
func (svc *WhiteListSvc) List(pageNo, pageLen int) ([]*dto.CommonDtoFieldDesc, []IRestfulEntity, error) {
entityList, err := svc.proRepo.List(pageNo, pageLen)
if err != nil {
return nil, nil, err
}
iList := make([]IRestfulEntity, 0, len(entityList))
for _, v := range entityList {
iList = append(iList, v)
}
return entity.WhiteListDtoFieldsDescInfo, iList, nil
}
func (svc *WhiteListSvc) Post(obj dto.CommonDtoValues) (IRestfulEntity, error) {
et := entity.FromWhiteListDto(obj)
err := svc.proRepo.Create(et)
return et, err
}
func (svc *WhiteListSvc) Put(obj dto.CommonDtoValues) (IRestfulEntity, error) {
et := entity.FromWhiteListDto(obj)
err := svc.proRepo.Edit(et)
return et, err
}
func (svc *WhiteListSvc) Delete(id int) error {
return svc.proRepo.Delete(id)
}

View File

@ -1,5 +0,0 @@
package config
type MockBootFlags struct {
ApiPort string `env:"mock_api_port" default:"8654" desc:"api端口客户端请求的地址端口"`
}

View File

@ -1,11 +0,0 @@
package global
import (
"admin/apps/mockpro/internal/config"
"gorm.io/gorm"
)
var (
GLOB_BOOT_FLAGS = &config.MockBootFlags{}
GLOB_DB *gorm.DB
)

View File

@ -1,24 +0,0 @@
package model
import (
"admin/internal/db"
"gorm.io/gorm"
"time"
)
func init() {
db.RegisterTableModels(Account{})
}
type Account struct {
ID int `gorm:"primarykey"`
Account string `gorm:"primarykey"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
func (lm *Account) TableName() string {
return "mock_account"
}

View File

@ -1,26 +0,0 @@
package model
import (
"admin/internal/db"
"gorm.io/gorm"
"time"
)
func init() {
db.RegisterTableModels(Ban{})
}
type Ban struct {
ID int `gorm:"primarykey"`
BanType string
Value string
ExpireSeconds int
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
func (lm *Ban) TableName() string {
return "mock_ban"
}

View File

@ -1,26 +0,0 @@
package model
import (
"admin/internal/db"
"gorm.io/gorm"
"time"
)
func init() {
db.RegisterTableModels(DevicePush{})
}
type DevicePush struct {
ID int `gorm:"primarykey"`
Account string
Title string
Content string
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
func (lm *DevicePush) TableName() string {
return "mock_devicepush"
}

View File

@ -1,33 +0,0 @@
package dto
type CommonDtoFieldChoice struct {
Desc string `json:"desc"`
Value any `json:"value"`
// 描述选项的类型,例如添加物品时,可以添加道具、翅膀、宠物等,他们可能不一定都设计为道具
Type int `json:"type"`
}
type CommonDtoFieldDesc struct {
Name string `json:"name"`
Key string `json:"key"`
// 字段类型基础类型支持int float string bool []<基础类行>
// 支持自定义类型和自定义类型的数组
Type string `json:"type"`
HelpText string `json:"help_text"`
Editable bool `json:"editable"` // 是否可编辑例如id就不可编辑新增时也不需要填写
Require bool `json:"require"` // 是否必填,不能为空
Choices []*CommonDtoFieldChoice `json:"choices"` // 可选项,用于字段做下拉框
MultiChoice bool `json:"multi_choice"` // 是否多选
}
//type CommonDtoValue struct {
// FieldName string `json:"field_name"`
// Value any `json:"value"`
//}
type CommonDtoValues map[string]any
type CommonDtoList struct {
FieldsDesc []*CommonDtoFieldDesc `json:"fields_desc"` // 数据字段描述信息
Rows []CommonDtoValues `json:"rows"` // 数据行
}

View File

@ -1,38 +0,0 @@
package dto
type NilReq struct {
}
type NilRsp struct {
}
type CommonListReq struct {
PageNo int `json:"page_no"`
PageLen int `json:"page_len"`
}
type CommonPostReq struct {
Dto *CommonDtoValues `json:"dto"`
}
type CommonPutReq struct {
Dto *CommonDtoValues `json:"dto"`
}
type CommonDeleteReq struct {
Id int `json:"id"`
}
type CommonListRsp = CommonDtoList
type CommonPostRsp struct {
Dto *CommonDtoValues `json:"dto"`
}
type CommonPutRsp struct {
Dto *CommonDtoValues `json:"dto"`
}
type CommonDeleteRsp struct {
Id int `json:"id"`
}

View File

@ -1,27 +0,0 @@
package model
import (
"admin/internal/db"
"gorm.io/gorm"
"time"
)
func init() {
db.RegisterTableModels(GlobalMail{})
}
type GlobalMail struct {
ID int `gorm:"primarykey"`
ServerIDs []int `gorm:"type:json;serializer:json"`
Title string
Content string
Attach []*MailAttachItem `gorm:"type:json;serializer:json"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
func (lm *GlobalMail) TableName() string {
return "mock_mailglobal"
}

View File

@ -1,27 +0,0 @@
package model
import (
"admin/internal/db"
"gorm.io/gorm"
"time"
)
func init() {
db.RegisterTableModels(Notice{})
}
type Notice struct {
ID int `gorm:"primarykey"`
ServerIDs []int `gorm:"type:json;serializer:json"`
Content string
StartAt int64
EndAt int64
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
func (lm *Notice) TableName() string {
return "mock_notice"
}

View File

@ -1,28 +0,0 @@
package model
import (
"admin/internal/db"
"gorm.io/gorm"
"time"
)
func init() {
db.RegisterTableModels(Order{})
}
type Order struct {
ID int `gorm:"primarykey"`
RoleID string
Account string
Price int
Currency int
GoodID int
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
func (lm *Order) TableName() string {
return "mock_order"
}

View File

@ -1,25 +0,0 @@
package model
import (
"admin/internal/db"
"gorm.io/gorm"
"time"
)
func init() {
db.RegisterTableModels(RewardCode{})
}
type RewardCode struct {
ID int `gorm:"primarykey"`
Group int
Code int
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
func (lm *RewardCode) TableName() string {
return "mock_rewardcode"
}

View File

@ -1,26 +0,0 @@
package model
import (
"admin/internal/db"
"gorm.io/gorm"
"time"
)
func init() {
db.RegisterTableModels(Role{})
}
type Role struct {
ID int `gorm:"primarykey"`
RoleID string
Name string
Account string `gorm:"primarykey"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
func (lm *Role) TableName() string {
return "mock_role"
}

View File

@ -1,34 +0,0 @@
package model
import (
"admin/internal/db"
"gorm.io/gorm"
"time"
)
func init() {
db.RegisterTableModels(RoleMail{})
}
type MailAttachItem struct {
ID int32
Num int64
ItemType int
}
type RoleMail struct {
ID int `gorm:"primarykey"`
RoleIDs string
ServerID int
Title string
Content string
Attach []*MailAttachItem `gorm:"type:json;serializer:json"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
func (lm *RoleMail) TableName() string {
return "mock_mailrole"
}

View File

@ -1,26 +0,0 @@
package model
import (
"admin/internal/db"
"gorm.io/gorm"
"time"
)
func init() {
db.RegisterTableModels(WhiteList{})
}
type WhiteList struct {
ID int `gorm:"primarykey"`
Account string `gorm:"primarykey"`
AccountType int
Desc string
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
func (lm *WhiteList) TableName() string {
return "mock_whitelist"
}

View File

@ -1,11 +0,0 @@
package server
import "admin/apps/mockpro/service"
type controller struct {
svc *service.Service
}
func newController(svc *service.Service) *controller {
return &controller{svc: svc}
}

View File

@ -1,40 +0,0 @@
package server
import (
dto2 "admin/apps/mockpro/internal/model/dto"
)
func (ctl *controller) CommonList(ctx *WebContext, restfulResourceName string, params *dto2.CommonListReq, rsp *dto2.CommonListRsp) error {
list, err := ctl.svc.CommonList(ctx, restfulResourceName, params)
if err != nil {
return err
}
*rsp = *list
return nil
}
func (ctl *controller) CommonPost(ctx *WebContext, restfulResourceName string, params *dto2.CommonPostReq, rsp *dto2.CommonPostRsp) error {
newObj, err := ctl.svc.CommonPost(ctx, restfulResourceName, *params.Dto)
if err != nil {
return err
}
rsp.Dto = &newObj
return nil
}
func (ctl *controller) CommonPut(ctx *WebContext, restfulResourceName string, params *dto2.CommonPutReq, rsp *dto2.CommonPutRsp) error {
newObj, err := ctl.svc.CommonPut(ctx, restfulResourceName, *params.Dto)
if err != nil {
return err
}
rsp.Dto = &newObj
return nil
}
func (ctl *controller) CommonDelete(ctx *WebContext, restfulResourceName string, params *dto2.CommonDeleteReq, rsp *dto2.CommonDeleteRsp) error {
err := ctl.svc.CommonDelete(ctx, restfulResourceName, params.Id)
if err != nil {
return err
}
return nil
}

View File

@ -1,44 +0,0 @@
package server
import (
"admin/internal/errcode"
"admin/lib/web"
"context"
"github.com/gin-gonic/gin"
)
type WebContext struct {
context.Context
rawCtx *gin.Context
}
func NewWebContext(rawCtx *gin.Context) web.IContext {
return &WebContext{rawCtx: rawCtx}
}
func (ctx *WebContext) Ok(data any) {
ctx.rawCtx.JSON(200, map[string]any{
"code": 200,
"msg": "",
"data": data,
})
}
func (ctx *WebContext) Fail(err error) {
code, codeContent, stack, msg := errcode.ParseError(err)
ctx.rawCtx.JSON(200, map[string]any{
"code": code,
"stack": stack,
"msg": codeContent,
"detail_msg": msg,
"data": "",
})
}
func (ctx *WebContext) HandleError(path string, err error) {
ctx.Fail(err)
}
func (ctx *WebContext) HandleSuccess(rspData any) {
ctx.Ok(rspData)
}

View File

@ -1,105 +0,0 @@
package server
import (
"admin/apps/mockpro/internal/model/dto"
"admin/internal/consts"
"admin/lib/web"
)
func (srv *Server) Route(engine *web.Engine) {
apiGroup := engine.Group("/api", "")
{
srv.whitelist(apiGroup)
srv.ban(apiGroup)
srv.rolemail(apiGroup)
srv.globalmail(apiGroup)
srv.account(apiGroup)
srv.role(apiGroup)
srv.order(apiGroup)
srv.notice(apiGroup)
srv.rewardcode(apiGroup)
srv.devicepush(apiGroup)
}
apiGroup.Get("/commandlist", "获取项目所有gm指令描述", consts.WebPathPermit_Read, srv.commandlist)
}
func (srv *Server) whitelist(engine *web.RoutesGroup) {
resourceName := "whitelist"
srv.registerResourceRouter(resourceName, engine.Group("/"+resourceName, "白名单管理"))
}
func (srv *Server) ban(engine *web.RoutesGroup) {
resourceName := "ban"
srv.registerResourceRouter(resourceName, engine.Group("/"+resourceName, "封禁管理"))
}
func (srv *Server) rolemail(engine *web.RoutesGroup) {
resourceName := "rolemail"
srv.registerResourceRouter(resourceName, engine.Group("/"+resourceName, "个人邮件"))
}
func (srv *Server) globalmail(engine *web.RoutesGroup) {
resourceName := "globalmail"
srv.registerResourceRouter(resourceName, engine.Group("/"+resourceName, "全服邮件"))
}
func (srv *Server) account(engine *web.RoutesGroup) {
resourceName := "account"
srv.registerResourceRouter(resourceName, engine.Group("/"+resourceName, "账号管理"))
}
func (srv *Server) role(engine *web.RoutesGroup) {
resourceName := "role"
srv.registerResourceRouter(resourceName, engine.Group("/"+resourceName, "角色管理"))
}
func (srv *Server) order(engine *web.RoutesGroup) {
resourceName := "order"
srv.registerResourceRouter(resourceName, engine.Group("/"+resourceName, "订单管理"))
}
func (srv *Server) notice(engine *web.RoutesGroup) {
resourceName := "notice"
srv.registerResourceRouter(resourceName, engine.Group("/"+resourceName, "公告管理"))
}
func (srv *Server) rewardcode(engine *web.RoutesGroup) {
resourceName := "rewardcode"
srv.registerResourceRouter(resourceName, engine.Group("/"+resourceName, "奖励码"))
}
func (srv *Server) devicepush(engine *web.RoutesGroup) {
resourceName := "devicepush"
srv.registerResourceRouter(resourceName, engine.Group("/"+resourceName, "设备推送"))
}
func (srv *Server) registerResourceRouter(resourceName string, group *web.RoutesGroup) {
group.Get("", "获取列表", consts.WebPathPermit_Read, commonHandlerList(srv.ctl, resourceName))
group.Post("", "新增", consts.WebPathPermit_Read, commonHandlerPost(srv.ctl, resourceName))
group.Put("", "修改", consts.WebPathPermit_Read, commonHandlerPut(srv.ctl, resourceName))
group.Delete("", "删除", consts.WebPathPermit_Read, commonHandlerDelete(srv.ctl, resourceName))
}
func commonHandlerList(ctl *controller, resourceName string) func(ctx *WebContext, params *dto.CommonListReq, rsp *dto.CommonListRsp) error {
return func(ctx *WebContext, params *dto.CommonListReq, rsp *dto.CommonListRsp) error {
return ctl.CommonList(ctx, resourceName, params, rsp)
}
}
func commonHandlerPost(ctl *controller, resourceName string) func(ctx *WebContext, params *dto.CommonPostReq, rsp *dto.CommonPostRsp) error {
return func(ctx *WebContext, params *dto.CommonPostReq, rsp *dto.CommonPostRsp) error {
return ctl.CommonPost(ctx, resourceName, params, rsp)
}
}
func commonHandlerPut(ctl *controller, resourceName string) func(ctx *WebContext, params *dto.CommonPutReq, rsp *dto.CommonPutRsp) error {
return func(ctx *WebContext, params *dto.CommonPutReq, rsp *dto.CommonPutRsp) error {
return ctl.CommonPut(ctx, resourceName, params, rsp)
}
}
func commonHandlerDelete(ctl *controller, resourceName string) func(ctx *WebContext, params *dto.CommonDeleteReq, rsp *dto.CommonDeleteRsp) error {
return func(ctx *WebContext, params *dto.CommonDeleteReq, rsp *dto.CommonDeleteRsp) error {
return ctl.CommonDelete(ctx, resourceName, params, rsp)
}
}

View File

@ -1,51 +0,0 @@
package server
import (
"admin/apps/mockpro/internal/model/dto"
"admin/lib/web"
"path/filepath"
)
type PathInfo struct {
Path string `json:"path"`
Method string `json:"method"`
}
type ResourceInfo struct {
Path string `json:"path"`
Desc string `json:"desc"`
Paths []*PathInfo `json:"paths"`
}
type CmdListRsp struct {
List []*ResourceInfo `json:"list"`
}
func (srv *Server) commandlist(ctx *WebContext, req *dto.NilReq, rsp *CmdListRsp) error {
paths := make([]*ResourceInfo, 0)
srv.engine.TravelPaths(func(parentPath, parentDesc string, path string, method string, handlers ...web.HandlerFunc) {
find := false
for _, v := range paths {
if v.Desc == parentDesc {
v.Paths = append(v.Paths, &PathInfo{
Path: path,
Method: method,
})
find = true
break
}
}
if !find {
paths = append(paths, &ResourceInfo{
Path: filepath.Base(parentPath),
Desc: parentDesc,
Paths: []*PathInfo{
&PathInfo{
Path: path,
Method: method,
},
},
})
}
})
rsp.List = paths
return nil
}

View File

@ -1,29 +0,0 @@
package server
import (
"admin/apps/mockpro/internal/global"
"admin/apps/mockpro/service"
"admin/lib/web"
)
type Server struct {
engine *web.Engine
svc *service.Service
ctl *controller
}
func New(svc *service.Service) *Server {
engine := web.New(NewWebContext)
srv := &Server{
engine: engine,
ctl: newController(svc),
}
srv.Route(engine)
go func() {
err := engine.Run(":" + global.GLOB_BOOT_FLAGS.ApiPort)
if err != nil {
panic(err)
}
}()
return srv
}

View File

@ -1,68 +0,0 @@
package service
import (
"admin/apps/mockpro/domain"
dto2 "admin/apps/mockpro/internal/model/dto"
"context"
"gorm.io/gorm"
)
type Service struct {
db *gorm.DB
whitelistSvc *domain.WhiteListSvc
banSvc *domain.BanSvc
}
func New(db *gorm.DB) *Service {
return &Service{
db: db,
whitelistSvc: domain.NewWhiteListSvc(db),
banSvc: domain.NewBanSvc(db),
}
}
func (svc *Service) CommonList(ctx context.Context, resourceName string, params *dto2.CommonListReq) (*dto2.CommonDtoList, error) {
restfulDomainSvc, err := domain.FindRestfulResourceSvc(resourceName)
if err != nil {
return nil, err
}
dtoFieldsDescInfo, list, err := restfulDomainSvc.List(params.PageNo, params.PageLen)
if err != nil {
return nil, err
}
retList := make([]dto2.CommonDtoValues, 0, len(list))
for _, v := range list {
retList = append(retList, v.ToCommonDto())
}
return &dto2.CommonDtoList{FieldsDesc: dtoFieldsDescInfo, Rows: retList}, nil
}
func (svc *Service) CommonPost(ctx context.Context, resourceName string, params dto2.CommonDtoValues) (dto2.CommonDtoValues, error) {
restfulDomainSvc, err := domain.FindRestfulResourceSvc(resourceName)
if err != nil {
return nil, err
}
et, err := restfulDomainSvc.Post(params)
if err != nil {
return nil, err
}
return et.ToCommonDto(), nil
}
func (svc *Service) CommonPut(ctx context.Context, resourceName string, params dto2.CommonDtoValues) (dto2.CommonDtoValues, error) {
restfulDomainSvc, err := domain.FindRestfulResourceSvc(resourceName)
if err != nil {
return nil, err
}
et, err := restfulDomainSvc.Put(params)
if err != nil {
return nil, err
}
return et.ToCommonDto(), nil
}
func (svc *Service) CommonDelete(ctx context.Context, resourceName string, id int) error {
restfulDomainSvc, err := domain.FindRestfulResourceSvc(resourceName)
if err != nil {
return err
}
return restfulDomainSvc.Delete(id)
}

View File

@ -4,8 +4,8 @@ import (
"admin/apps/user/domain/entity"
"admin/apps/user/domain/repo"
"admin/apps/user/model"
"admin/apps/user/model/dto"
"admin/internal/consts"
"admin/internal/model/dto"
"fmt"
"gorm.io/gorm"
)
@ -29,10 +29,10 @@ func NewCommonResourceService(db *gorm.DB) *CommonResourceService {
return svc
}
func (svc *CommonResourceService) List(resource string, pageNo, pageLen int, extraQuery string, args ...any) ([]*dto.CommonDtoFieldDesc, []dto.CommonDtoValues, error) {
fieldsDescInfo, etList, err := findCommResourceRepo(resource).List(pageNo, pageLen, extraQuery, args...)
func (svc *CommonResourceService) List(resource string, listParams *dto.CommonListReq) (int, []*dto.CommonDtoFieldDesc, []dto.CommonDtoValues, error) {
totalCount, fieldsDescInfo, etList, err := findCommResourceRepo(resource).List(listParams)
if err != nil {
return nil, nil, err
return 0, nil, nil, err
}
retList := make([]dto.CommonDtoValues, 0, len(etList))
for _, v := range etList {
@ -52,7 +52,7 @@ func (svc *CommonResourceService) List(resource string, pageNo, pageLen int, ext
retList = append(retList, v.ToCommonDto())
}
return fieldsDescInfo, retList, nil
return totalCount, fieldsDescInfo, retList, nil
}
func (svc *CommonResourceService) GetById(resource string, id int) ([]*dto.CommonDtoFieldDesc, dto.CommonDtoValues, *entity.CommonResource, bool, error) {

View File

@ -2,7 +2,7 @@ package entity
import (
"admin/apps/user/model"
"admin/apps/user/model/dto"
"admin/internal/model/dto"
"reflect"
)

View File

@ -2,7 +2,7 @@ package entity
import (
"admin/apps/user/model"
"admin/apps/user/model/dto"
"admin/internal/model/dto"
)
type User struct {

View File

@ -1,7 +1,7 @@
package entity
import (
"admin/apps/user/model/dto"
"admin/internal/model/dto"
"admin/lib/xlog"
"fmt"
"gorm.io/gorm"

View File

@ -1,7 +1,7 @@
package domain
import (
"admin/apps/game/model/dto"
"admin/internal/model/dto"
)
type IRestfulEntity interface {

View File

@ -3,17 +3,21 @@ package repo
import (
"admin/apps/user/domain/entity"
"admin/apps/user/model"
"admin/apps/user/model/dto"
"admin/internal/errcode"
"admin/internal/model/dto"
"admin/lib/passlib"
"admin/lib/xlog"
"errors"
"fmt"
"gorm.io/gorm"
"gorm.io/gorm/schema"
"reflect"
"strings"
"time"
)
type ICommonResourceRepo interface {
List(pageNo, pageLen int, extraQuery string, args ...any) ([]*dto.CommonDtoFieldDesc, []*entity.CommonResource, error)
List(params *dto.CommonListReq) (int, []*dto.CommonDtoFieldDesc, []*entity.CommonResource, error)
GetById(id int) ([]*dto.CommonDtoFieldDesc, *entity.CommonResource, bool, error)
Create(et dto.CommonDtoValues) (*entity.CommonResource, error)
Edit(et dto.CommonDtoValues) error
@ -35,18 +39,43 @@ func newCommonResourceRepoImpl(db *gorm.DB, poTemplate model.IModel) *commonReso
return &commonResourceRepoImpl{db: db, poTemplate: poTemplate, fieldsDescInfoFun: fieldsInfo}
}
func (repo *commonResourceRepoImpl) List(pageNo, pageLen int,
extraQuery string, args ...any) ([]*dto.CommonDtoFieldDesc, []*entity.CommonResource, error) {
func (repo *commonResourceRepoImpl) List(params *dto.CommonListReq) (int, []*dto.CommonDtoFieldDesc, []*entity.CommonResource, error) {
pageNo := params.PageNo
pageLen := params.PageLen
whereConditions := params.ParsedWhereConditions.Conditions
if pageNo <= 0 || pageLen <= 0 {
return 0, nil, nil, errcode.New(errcode.ParamsInvalid, "page no or page len invalid:%v,%v", pageNo, pageLen)
}
limitStart := (pageNo - 1) * pageLen
limitLen := pageLen
listType := reflect.New(reflect.SliceOf(reflect.TypeOf(repo.poTemplate)))
var totalCount int64
var txCount, txFind *gorm.DB
var err error
if extraQuery == "" {
err = repo.db.Find(listType.Interface()).Error
if len(whereConditions) <= 0 {
txCount = repo.db.Model(repo.poTemplate)
txFind = repo.db.Offset(limitStart).Limit(limitLen).Order("created_at desc")
} else {
err = repo.db.Where(extraQuery, args...).Find(listType.Interface()).Error
whereSql, whereArgs := repo.parseWhereConditions2Sql(whereConditions)
xlog.Debugf("list resource %v where sql:%v, args:%+v",
repo.poTemplate.TableName(), whereSql, whereArgs)
txCount = repo.db.Model(repo.poTemplate).Where(whereSql, whereArgs...)
txFind = repo.db.Where(whereSql, whereArgs...).Offset(limitStart).Limit(limitLen).Order("created_at desc")
}
err = txCount.Count(&totalCount).Error
if err != nil {
return nil, nil, errcode.New(errcode.DBError, "list resource %v error:%v", repo.poTemplate.TableName(), err)
return 0, nil, nil, errcode.New(errcode.DBError, "count resource %v error:%v", repo.poTemplate.TableName(), err)
}
err = txFind.Find(listType.Interface()).Error
if err != nil {
return 0, nil, nil, errcode.New(errcode.DBError, "list resource %v error:%v", repo.poTemplate.TableName(), err)
}
listType1 := listType.Elem()
@ -60,7 +89,7 @@ func (repo *commonResourceRepoImpl) List(pageNo, pageLen int,
entityList = append(entityList, et)
}
return repo.fieldsDescInfoFun(), entityList, nil
return int(totalCount), repo.fieldsDescInfoFun(), entityList, nil
}
func (repo *commonResourceRepoImpl) GetById(id int) ([]*dto.CommonDtoFieldDesc, *entity.CommonResource, bool, error) {
@ -125,3 +154,82 @@ func (repo *commonResourceRepoImpl) Delete(id int) (*entity.CommonResource, bool
func (repo *commonResourceRepoImpl) newEmptyPo() model.IModel {
return reflect.New(reflect.TypeOf(repo.poTemplate).Elem()).Interface().(model.IModel)
}
func (repo *commonResourceRepoImpl) parseWhereConditions2Sql(conditions []*dto.GetWhereCondition) (whereSql string, args []any) {
namer := new(schema.NamingStrategy)
to := reflect.TypeOf(repo.poTemplate).Elem()
whereClause := make([]string, 0, len(conditions))
whereArgs := make([]interface{}, 0, len(conditions))
for _, cond := range conditions {
for i := 0; i < to.NumField(); i++ {
field := to.Field(i)
if field.Name != cond.Key {
continue
}
dbFieldName := namer.ColumnName("", field.Name)
if field.Type.Name() == "Time" {
if cond.Value1 == nil {
cond.Value1 = time.Time{}
} else {
cond.Value1, _ = time.ParseInLocation("2006/01/02 15:04:05", cond.Value1.(string), time.Local)
}
if cond.Value2 == nil {
cond.Value2 = time.Time{}
} else {
cond.Value2, _ = time.ParseInLocation("2006/01/02 15:04:05", cond.Value2.(string), time.Local)
}
}
switch field.Tag.Get("where") {
case "eq":
if field.Tag.Get("type") == "[]string" && field.Tag.Get("multi_choice") == "true" {
// eq也要查出来为空的
whereClause = append(whereClause, fmt.Sprintf("JSON_CONTAINS( `%v`, '\"%v\"', '$' ) or `%v` IS NULL",
dbFieldName, cond.Value1, dbFieldName))
} else {
whereClause = append(whereClause, fmt.Sprintf("`%v` = ?", dbFieldName))
whereArgs = append(whereArgs, cond.Value1)
}
case "gt":
whereClause = append(whereClause, fmt.Sprintf("`%v` > ?", dbFieldName))
whereArgs = append(whereArgs, cond.Value1)
case "lt":
whereClause = append(whereClause, fmt.Sprintf("`%v` < ?", dbFieldName))
whereArgs = append(whereArgs, cond.Value1)
case "le":
whereClause = append(whereClause, fmt.Sprintf("`%v` <= ?", dbFieldName))
whereArgs = append(whereArgs, cond.Value1)
case "ge":
whereClause = append(whereClause, fmt.Sprintf("`%v` >= ?", dbFieldName))
whereArgs = append(whereArgs, cond.Value1)
case "like":
whereClause = append(whereClause, fmt.Sprintf("`%v` like ?", dbFieldName))
whereArgs = append(whereArgs, cond.Value1)
case "range":
t1, ok1 := cond.Value1.(time.Time)
t2, ok2 := cond.Value2.(time.Time)
if ok1 || ok2 {
if !t1.IsZero() && !t2.IsZero() {
whereClause = append(whereClause, fmt.Sprintf("`%v` >= ? and `%v` <= ?", dbFieldName, dbFieldName))
whereArgs = append(whereArgs, cond.Value1, cond.Value2)
} else if !t1.IsZero() {
whereClause = append(whereClause, fmt.Sprintf("`%v` >= ? ", dbFieldName))
whereArgs = append(whereArgs, cond.Value1)
} else {
whereClause = append(whereClause, fmt.Sprintf("`%v` <= ? ", dbFieldName))
whereArgs = append(whereArgs, cond.Value2)
}
} else {
whereClause = append(whereClause, fmt.Sprintf("`%v` >= ? and `%v` <= ?", dbFieldName, dbFieldName))
whereArgs = append(whereArgs, cond.Value1, cond.Value2)
}
case "":
default:
panic(fmt.Errorf("unsupport where tag %v", field.Tag))
}
}
}
whereSql = strings.Join(whereClause, " AND ")
return whereSql, whereArgs
}

View File

@ -1,64 +0,0 @@
package dto
type WebRspData struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data any `json:"data"`
}
type ResourceInitInfo struct {
Resource string `json:"resource"`
Desc string `json:"desc"`
ShowMethods []string `json:"show_methods"`
}
type CommonDtoFieldChoice struct {
Desc string `json:"desc"`
Value any `json:"value"`
// 描述选项的类型,例如添加物品时,可以添加道具、翅膀、宠物等,他们可能不一定都设计为道具
Type int `json:"type"`
}
type CommonDtoFieldDesc struct {
Name string `json:"name"`
Key string `json:"key"`
// 字段类型基础类型支持int float string bool []<基础类行>
// 支持自定义类型和自定义类型的数组
Type string `json:"type"`
HelpText string `json:"help_text"`
Readonly bool `json:"readonly"` // 是否只读,就只展示在表格中
Required bool `json:"required"` // 是否必填,不能为空
Choices []*CommonDtoFieldChoice `json:"choices"` // 可选项,用于字段做下拉框
MultiChoice bool `json:"multi_choice"` // 是否多选
Uneditable bool `json:"uneditable"` // 不可编辑某些数据一旦新增之后不能修改例如封禁的值、服务器的id等
}
//type CommonDtoValue struct {
// FieldName string `json:"field_name"`
// Value any `json:"value"`
//}
type CommonDtoValues map[string]any
type CommonDtoList struct {
FieldsDesc []*CommonDtoFieldDesc `json:"fields_desc"` // 数据字段描述信息
Rows []CommonDtoValues `json:"rows"` // 数据行
}
type PathInfo struct {
Path string `json:"path"`
Method string `json:"method"`
}
type UserInfo struct {
UserId int `json:"user_id"`
NickName string `json:"nick_name"`
Icon string `json:"icon"`
Character string `json:"character"`
Permissions []string `json:"permissions"`
}
type TokenInfo struct {
Token string `json:"token"`
ExpireAt int64 `json:"expire_at"`
}

View File

@ -1,67 +0,0 @@
package dto
import "admin/apps/game/api"
type NilReq struct {
}
type NilRsp = NilReq
type CommonListReq struct {
PageNo int `json:"page_no"`
PageLen int `json:"page_len"`
WhereValue1 string `json:"where_value1"`
WhereValue2 string `json:"where_value2"`
WhereValue3 string `json:"where_value3"`
}
type CommonPostReq struct {
Dto *CommonDtoValues `json:"dto"`
}
type CommonPutReq struct {
Dto *CommonDtoValues `json:"dto"`
}
type CommonDeleteReq struct {
Id int `json:"id"`
}
type CommonListRsp = CommonDtoList
type CommonPostRsp struct {
Dto *CommonDtoValues `json:"dto"`
}
type CommonPutRsp struct {
Dto *CommonDtoValues `json:"dto"`
}
type CommonDeleteRsp struct {
Id int `json:"id"`
}
type CommandListReq struct {
Addr string `json:"addr"`
}
type CommandListRsp struct {
List []*PathInfo `json:"list"`
}
type ResourceListRsp struct {
List []*api.ResourceInitInfo `json:"list"`
}
type LoginReq struct {
User string `json:"user"`
Password string `json:"password"`
}
type LoginRsp struct {
User *UserInfo `json:"user_info"`
Token *TokenInfo `json:"token_info"`
ProjectsRoutes []*api.ProjectInitInfo `json:"projects"` // 项目路由
}
type GetUserInfoRsp = LoginRsp

View File

@ -1,8 +1,8 @@
package model
import (
"admin/apps/user/model/dto"
"admin/internal/db"
"admin/internal/model/dto"
"time"
)

View File

@ -1,8 +1,8 @@
package server
import (
"admin/apps/user/model/dto"
"admin/internal/context"
"admin/internal/model/dto"
)
func (ctl *controller) CommonList(ctx *context.WebContext, params *dto.CommonListReq, rsp *dto.CommonListRsp) error {

View File

@ -1,8 +1,8 @@
package server
import (
"admin/apps/user/model/dto"
"admin/internal/context"
"admin/internal/model/dto"
)
func (ctl *controller) Login(ctx *context.WebContext, params *dto.LoginReq, rsp *dto.LoginRsp) error {

View File

@ -3,8 +3,10 @@ package service
import (
apiUser "admin/apps/user/api"
"admin/apps/user/domain"
"admin/apps/user/model/dto"
"admin/internal/context"
"admin/internal/errcode"
dto2 "admin/internal/model/dto"
"encoding/json"
"gorm.io/gorm"
)
@ -26,17 +28,20 @@ func New(db *gorm.DB) (*Service, error) {
return svc, nil
}
func (svc *Service) CommonList(ctx *context.WebContext, resourceName string, params *dto.CommonListReq) (*dto.CommonDtoList, error) {
var (
query string
args []any
)
fieldsDescInfo, rows, err := svc.resourceSvc.List(resourceName, params.PageNo, params.PageLen, query, args)
return &dto.CommonDtoList{FieldsDesc: fieldsDescInfo, Rows: rows}, err
func (svc *Service) CommonList(ctx *context.WebContext, resourceName string, params *dto2.CommonListReq) (*dto2.CommonDtoList, error) {
params.ParsedWhereConditions = &dto2.ListWhereConditionInfo{}
if params.WhereConditions != "" {
err := json.Unmarshal([]byte(params.WhereConditions), params.ParsedWhereConditions)
if err != nil {
return nil, errcode.New(errcode.ParamsInvalid, "unmarshal list condition:%v error:%v",
params.WhereConditions, err)
}
}
totalCount, fieldsDescInfo, rows, err := svc.resourceSvc.List(resourceName, params)
return &dto2.CommonDtoList{FieldsDesc: fieldsDescInfo, Rows: rows, TotalCount: totalCount}, err
}
func (svc *Service) CommonPost(ctx *context.WebContext, resourceName string, params dto.CommonDtoValues) (dto.CommonDtoValues, error) {
func (svc *Service) CommonPost(ctx *context.WebContext, resourceName string, params dto2.CommonDtoValues) (dto2.CommonDtoValues, error) {
values, _, err := svc.resourceSvc.Create(resourceName, params)
if err != nil {
return nil, err
@ -44,7 +49,7 @@ func (svc *Service) CommonPost(ctx *context.WebContext, resourceName string, par
return values, err
}
func (svc *Service) CommonPut(ctx *context.WebContext, resourceName string, params dto.CommonDtoValues) error {
func (svc *Service) CommonPut(ctx *context.WebContext, resourceName string, params dto2.CommonDtoValues) error {
return svc.resourceSvc.Edit(resourceName, params)
}
@ -52,6 +57,6 @@ func (svc *Service) CommonDelete(ctx *context.WebContext, resourceName string, i
return svc.resourceSvc.Delete(resourceName, id)
}
func (svc *Service) GetSupportResourcesList() []*dto.ResourceInitInfo {
func (svc *Service) GetSupportResourcesList() []*dto2.ResourceInitInfo {
return svc.resourceSvc.GetSupportResourcesList()
}

View File

@ -5,8 +5,8 @@ import (
apiUser "admin/apps/user/api"
"admin/apps/user/domain/entity"
"admin/apps/user/model"
"admin/apps/user/model/dto"
"admin/internal/errcode"
dto2 "admin/internal/model/dto"
"admin/lib/tokenlib"
"admin/lib/xlog"
"context"
@ -57,7 +57,7 @@ func (svc *Service) Auth(ctx context.Context, req *apiUser.AuthReq) (*apiUser.Au
return rsp, nil
}
func (svc *Service) Login(user, pwd string) (info *dto.LoginRsp, err error) {
func (svc *Service) Login(user, pwd string) (info *dto2.LoginRsp, err error) {
userInfo, err := svc.resourceSvc.Login(user, pwd)
if err != nil {
return nil, err
@ -73,14 +73,14 @@ func (svc *Service) Login(user, pwd string) (info *dto.LoginRsp, err error) {
return nil, err
}
info = &dto.LoginRsp{}
info = &dto2.LoginRsp{}
info.User = userInfo.ToDtoInfo()
info.Token = &dto.TokenInfo{Token: tokenInfo.Token, ExpireAt: tokenInfo.ExpireAt.Unix()}
info.Token = &dto2.TokenInfo{Token: tokenInfo.Token, ExpireAt: tokenInfo.ExpireAt.Unix()}
info.ProjectsRoutes = projectRoutesRsp.Projects
return info, nil
}
func (svc *Service) GetUserInfo(userId int) (*dto.GetUserInfoRsp, error) {
func (svc *Service) GetUserInfo(userId int) (*dto2.GetUserInfoRsp, error) {
user, find, err := svc.GetUserById(userId)
if err != nil {
return nil, err
@ -99,9 +99,9 @@ func (svc *Service) GetUserInfo(userId int) (*dto.GetUserInfoRsp, error) {
return nil, err
}
rsp := &dto.GetUserInfoRsp{
rsp := &dto2.GetUserInfoRsp{
User: user.ToDtoInfo(),
Token: &dto.TokenInfo{Token: tokenInfo.Token, ExpireAt: tokenInfo.ExpireAt.Unix()},
Token: &dto2.TokenInfo{Token: tokenInfo.Token, ExpireAt: tokenInfo.ExpireAt.Unix()},
ProjectsRoutes: projectRoutesRsp.Projects,
}
return rsp, nil

View File

@ -43,6 +43,12 @@ type CommonDtoList struct {
ItemBags []*ItemBagInfo `json:"item_bags"` // 礼包,用来给道具添加功能选择用
}
type ResourceInitInfo struct {
Resource string `json:"resource"`
Desc string `json:"desc"`
ShowMethods []string `json:"show_methods"`
}
type PathInfo struct {
Path string `json:"path"`
Method string `json:"method"`
@ -108,3 +114,16 @@ type AccountDetailInfo struct {
LastLoginTime string `json:"last_login_time"`
RoleList []*AccountDetailRoleInfo `json:"role_list"`
}
type UserInfo struct {
UserId int `json:"user_id"`
NickName string `json:"nick_name"`
Icon string `json:"icon"`
Character string `json:"character"`
Permissions []string `json:"permissions"`
}
type TokenInfo struct {
Token string `json:"token"`
ExpireAt int64 `json:"expire_at"`
}

View File

@ -0,0 +1,22 @@
package dto
import (
"admin/apps/game/api"
)
type ResourceListRsp struct {
List []*api.ResourceInitInfo `json:"list"`
}
type LoginReq struct {
User string `json:"user"`
Password string `json:"password"`
}
type LoginRsp struct {
User *UserInfo `json:"user_info"`
Token *TokenInfo `json:"token_info"`
ProjectsRoutes []*api.ProjectInitInfo `json:"projects"` // 项目路由
}
type GetUserInfoRsp = LoginRsp

View File

@ -28,7 +28,7 @@ func Request(addr string, method string, body interface{}, resData interface{})
bodyReader = strings.NewReader(string(bodyBytes))
}
client := &http.Client{
Timeout: time.Second * 3,
Timeout: time.Second * 10,
}
req, err := http.NewRequest(method, removeUrl, bodyReader)
if err != nil {
@ -70,7 +70,17 @@ func Request(addr string, method string, body interface{}, resData interface{})
removeUrl = removeUrl + "?" + values.Encode()
}
res, err = http.Get(removeUrl)
client := &http.Client{
Timeout: time.Second * 10,
}
req, err := http.NewRequest("get", removeUrl, nil)
if err != nil {
xlog.Warnf(err)
return errcode.New(errcode.ServerError, "数据请求创建失败:%v", err)
}
res, err = client.Do(req)
if err != nil {
xlog.Warnf(err)
return errcode.New(errcode.ServerError, "数据请求失败:%v", err)

View File

@ -1,86 +0,0 @@
/* color palette from <https://github.com/vuejs/theme> */
:root {
--vt-c-white: #ffffff;
--vt-c-white-soft: #f8f8f8;
--vt-c-white-mute: #f2f2f2;
--vt-c-black: #181818;
--vt-c-black-soft: #222222;
--vt-c-black-mute: #282828;
--vt-c-indigo: #2c3e50;
--vt-c-divider-light-1: rgba(60, 60, 60, 0.29);
--vt-c-divider-light-2: rgba(60, 60, 60, 0.12);
--vt-c-divider-dark-1: rgba(84, 84, 84, 0.65);
--vt-c-divider-dark-2: rgba(84, 84, 84, 0.48);
--vt-c-text-light-1: var(--vt-c-indigo);
--vt-c-text-light-2: rgba(60, 60, 60, 0.66);
--vt-c-text-dark-1: var(--vt-c-white);
--vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
}
/* semantic color variables for this project */
:root {
--color-background: var(--vt-c-white);
--color-background-soft: var(--vt-c-white-soft);
--color-background-mute: var(--vt-c-white-mute);
--color-border: var(--vt-c-divider-light-2);
--color-border-hover: var(--vt-c-divider-light-1);
--color-heading: var(--vt-c-text-light-1);
--color-text: var(--vt-c-text-light-1);
--section-gap: 160px;
}
@media (prefers-color-scheme: dark) {
:root {
--color-background: var(--vt-c-black);
--color-background-soft: var(--vt-c-black-soft);
--color-background-mute: var(--vt-c-black-mute);
--color-border: var(--vt-c-divider-dark-2);
--color-border-hover: var(--vt-c-divider-dark-1);
--color-heading: var(--vt-c-text-dark-1);
--color-text: var(--vt-c-text-dark-2);
}
}
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
font-weight: normal;
}
body {
min-height: 100vh;
color: var(--color-text);
background: var(--color-background);
transition:
color 0.5s,
background-color 0.5s;
line-height: 1.6;
font-family:
Inter,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
Oxygen,
Ubuntu,
Cantarell,
'Fira Sans',
'Droid Sans',
'Helvetica Neue',
sans-serif;
font-size: 15px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

View File

@ -1,35 +0,0 @@
@import './base.css';
#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
font-weight: normal;
}
a,
.green {
text-decoration: none;
color: hsla(160, 100%, 37%, 1);
transition: 0.4s;
padding: 3px;
}
@media (hover: hover) {
a:hover {
background-color: hsla(160, 100%, 37%, 0.2);
}
}
@media (min-width: 1024px) {
body {
display: flex;
place-items: center;
}
#app {
display: grid;
grid-template-columns: 1fr 1fr;
padding: 0 2rem;
}
}

View File

@ -1,4 +1,4 @@
/*
body {
min-height: 100vh;
color: var(--color-text);
@ -23,6 +23,44 @@ body {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
*/
body {
height: 100%;
margin: 0;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif;
background: gray;
}
label {
font-weight: 700;
}
html {
height: 100%;
box-sizing: border-box;
/*border: 3px solid;*/
}
#app {
height: 100%;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
/*
.app-container {
padding: 20px;
}
.el-table {
.el-table__header-wrapper, .el-table__fixed-header-wrapper {
@ -42,19 +80,41 @@ body {
}
}
.pagination-container {
margin-top: 30px;
.el-pagination {
right: 20px;
position: absolute;
}
}
.pagination-container {
// position: relative;
height: 25px;
margin-bottom: 10px;
margin-top: 15px;
padding: 10px 20px !important;
}
.pagination-container .el-pagination {
right: 0;
position: absolute;
}
@media (max-width: 768px) {
.pagination-container .el-pagination > .el-pagination__jump {
display: none !important;
}
.pagination-container .el-pagination > .el-pagination__sizes {
display: none !important;
}
}
.el-table .fixed-width .el-button--small {
padding-left: 0;
padding-right: 0;
width: inherit;
}
/** 表格更多操作下拉样式 */
.el-table .el-dropdown-link {
cursor: pointer;
color: #409EFF;
margin-left: 10px;
}
.el-table .el-dropdown, .el-icon-arrow-down {
font-size: 12px;
}
*/

View File

@ -315,7 +315,7 @@ const handleEdit = (index, row) => {
dialogObjectForm.value = row
dialogObjectForm.value.oldData = row
dialogObjectForm.value.oldIndex = index
console.log("edit data:", row)
// console.log("edit data:", row)
dialogEditVisible.value = true
}
@ -455,7 +455,9 @@ const handlePaginationSizeChange = (val) => {
}
if (page_size.value * current_page.value > totalRowCount.value) {
//
return
if (rows.value.length >= totalRowCount.value) {
return
}
}
// console.log(`${page_size.value} `)
listData()
@ -469,299 +471,209 @@ const handlePaginationCurChange = (val) => {
</script>
<template>
<template v-if="!hasListPermit">
<component :is="empty"></component>
</template>
<template v-else>
<el-container v-if="listDataOK">
<el-header style="margin-bottom: 10px">
<el-row :gutter="20" v-if="(whereFieldsDescInfo.length !== 0)">
<template v-for="fieldDescInfo in whereFieldsDescInfo">
<template v-if="(fieldDescInfo.where === 'range')">
<el-col :span="calcElColSpan">
<div class="app-content">
<template v-if="!hasListPermit">
<component :is="empty"></component>
</template>
<template v-else>
<el-container v-if="listDataOK">
<el-header style="margin-bottom: 10px">
<el-row v-if="(whereFieldsDescInfo.length !== 0)">
<template v-for="fieldDescInfo in whereFieldsDescInfo">
<template v-if="(fieldDescInfo.where === 'range')">
<!-- <el-col :span="calcElColSpan">-->
<el-date-picker v-model="fieldDescInfo.value1" type="datetime"
:placeholder="(fieldDescInfo.name + '起始')" format="YYYY/MM/DD HH:mm:ss"
value-format="YYYY/MM/DD HH:mm:ss"></el-date-picker>
</el-col>
<el-col :span="calcElColSpan">
value-format="YYYY/MM/DD HH:mm:ss" style="margin-left: 10px"></el-date-picker>
<!-- </el-col>-->
<!-- <el-col :span="calcElColSpan">-->
<el-date-picker v-model="fieldDescInfo.value2" type="datetime"
:placeholder="(fieldDescInfo.name + '结束')" format="YYYY/MM/DD HH:mm:ss"
value-format="YYYY/MM/DD HH:mm:ss"></el-date-picker>
</el-col>
</template>
<template v-else>
<el-col :span="calcElColSpan">
<!-- </el-col>-->
</template>
<template v-else>
<!-- <el-col :span="calcElColSpan">-->
<el-select v-model="fieldDescInfo.value1"
:placeholder="(fieldDescInfo.multi_choice === true ? '--' + fieldDescInfo.name + '--' : '--' + fieldDescInfo.name + '--')"
style="width: 150px"
style="width: 150px;margin-left: 10px"
filterable v-if="(fieldDescInfo.choices.length > 0)">
<el-option v-for="choice in fieldDescInfo.choices" :key="choice.value" :label="choice.desc"
:value="choice.value"></el-option>
</el-select>
<el-input v-model="fieldDescInfo.value1"
:placeholder="(fieldDescInfo.name + fieldDescInfo.whereDesc)"
style="width: 150px" v-else></el-input>
</el-col>
style="width: 150px;margin-left: 10px" v-else></el-input>
<!-- </el-col>-->
</template>
</template>
</template>
<el-col :span="calcElColSpan">
<el-button @click="listData" type="primary">条件搜索</el-button>
</el-col>
<el-col :span="calcElColSpan">
<!-- <el-col :span="calcElColSpan">-->
<el-button @click="listData" type="primary" style="margin-left: 10px">条件搜索</el-button>
<!-- </el-col>-->
<!-- <el-col :span="calcElColSpan">-->
<el-button @click="resetConditionSearch">清空条件</el-button>
</el-col>
</el-row>
<!-- </el-col>-->
</el-row>
<el-row style="margin-top: 10px">
<el-button @click="dialogAddVisible = true" size="default" type="primary"
v-if="(resource_raw_node.meta.methods.post === true)">
添加
</el-button>
<el-row style="margin-top: 10px">
<el-button @click="dialogAddVisible = true" size="default" type="primary"
v-if="(resource_raw_node.meta.methods.post === true)">
添加
</el-button>
<el-button v-for="btn in globalClickBtns" size="default" :type="btn.btn_color_type"
@click="tableSelectRows1(btn)">
{{ btn.name }}
</el-button>
</el-row>
<el-button v-for="btn in globalClickBtns" size="default" :type="btn.btn_color_type"
@click="tableSelectRows1(btn)">
{{ btn.name }}
</el-button>
</el-row>
</el-header>
<el-main>
<el-table :data="rows" style="width: 100%" table-layout="auto" stripe
@selection-change="handleTableSelectChange">
<el-table-column type="selection" v-if="globalClickBtns.length > 0">
</el-header>
<el-main>
<div class="table-content">
<div class="table">
<el-table :data="rows" style="width: 100%" table-layout="auto" stripe
@selection-change="handleTableSelectChange">
<el-table-column type="selection" v-if="globalClickBtns.length > 0">
</el-table-column>
<template v-for="fieldDescInfo in fieldsDescInfo">
<!-- 道具列表 -->
<el-table-column prop="jsonValue" :label="fieldDescInfo.name" show-overflow-tooltip
v-if="(fieldDescInfo.type === 'items')"></el-table-column>
<!-- 角色状态 -->
<el-table-column prop="jsonValue" :label="fieldDescInfo.name"
v-else-if="(fieldDescInfo.key === 'Status' && cachedResource.meta.resource === 'role' )">
<template #default="scope">
<el-tag type="info" v-if="scope.row.Status === '离线'">离线</el-tag>
<el-tag type="success" v-else-if="scope.row.Status === '在线'">在线</el-tag>
</template>
</el-table-column>
<!-- 其它普通字段 -->
<el-table-column :prop="fieldDescInfo.key" :label="fieldDescInfo.name"
:show-overflow-tooltip="(fieldDescInfo.key === 'Title' || fieldDescInfo.key === 'Content')"
v-else></el-table-column>
</el-table-column>
<template v-for="fieldDescInfo in fieldsDescInfo">
<!-- 道具列表 -->
<el-table-column prop="jsonValue" :label="fieldDescInfo.name" show-overflow-tooltip
v-if="(fieldDescInfo.type === 'items')"></el-table-column>
<!-- 角色状态 -->
<el-table-column prop="jsonValue" :label="fieldDescInfo.name"
v-else-if="(fieldDescInfo.key === 'Status' && cachedResource.meta.resource === 'role' )">
<template #default="scope">
<el-tag type="info" v-if="scope.row.Status === '离线'">离线</el-tag>
<el-tag type="success" v-else-if="scope.row.Status === '在线'">在线</el-tag>
</template>
</el-table-column>
<!-- 其它普通字段 -->
<el-table-column :prop="fieldDescInfo.key" :label="fieldDescInfo.name"
:show-overflow-tooltip="(fieldDescInfo.key === 'Title' || fieldDescInfo.key === 'Content')"
v-else></el-table-column>
</template>
<el-table-column prop="func" label="功 能">
<template #default="scope">
<el-button size="default" type="success" @click="handleEdit( scope.$index, scope.row)"
v-if="(resource_raw_node.meta.methods.put === true)">
<!-- <el-icon style="vertical-align: middle">-->
<!-- <Edit/>-->
<!-- </el-icon>-->
<span>编辑</span>
</el-button>
<el-button size="default" type="danger" @click="handleDelete( scope.$index, scope.row)"
v-if="(resource_raw_node.meta.methods.delete === true)">
<!-- <el-icon style="vertical-align: middle">-->
<!-- <Delete/>-->
<!-- </el-icon>-->
<span>删除</span>
</el-button>
<template v-for="(btn, index) in rowClickBtns">
<template v-if="btn.btn_type === 0">
<el-button size="default" :type="btn.btn_color_type"
@click="tableSelectRows2(btn, scope.$index, scope.row)">
{{ btn.name }}
</el-button>
</template>
<template v-else-if="btn.btn_type === 1">
<el-button size="default" :type="btn.btn_color_type"
@click="tableSelectRow3(index, scope.row)">
{{ btn.name }}
</el-button>
</template>
<template v-else-if="btn.btn_type === 2">
<el-button size="default" :type="btn.btn_color_type"
@click="tableSelectRow4(btn, scope.row)">
{{ btn.name }}
</el-button>
</template>
</template>
</template>
</el-table-column>
</el-table>
</div>
<!-- 表格数据分页 -->
<div class="pagination-container">
<el-pagination
v-model:current-page="current_page"
v-model:page-size="page_size"
:page-sizes="pageSizes"
layout="total, sizes, prev, pager, next, jumper"
:total="totalRowCount"
@size-change="handlePaginationSizeChange"
@current-change="handlePaginationCurChange"
/>
</div>
</div>
<template v-for="(btn, index) in rowClickBtns">
<el-dialog v-model="rowClickBtnVisibleList[index]" :title="btn.name"
@close="rowClickBtnVisibleList[index]=false"
destroy-on-close>
<component :is="btn.btn_callback_component" :rowInfo="rowClickBtnSelectRow"/>
</el-dialog>
</template>
<el-table-column prop="func" label="功 能">
<template #default="scope">
<el-button size="default" type="success" @click="handleEdit( scope.$index, scope.row)"
v-if="(resource_raw_node.meta.methods.put === true)">
<!-- <el-icon style="vertical-align: middle">-->
<!-- <Edit/>-->
<!-- </el-icon>-->
<span>编辑</span>
</el-button>
<el-button size="default" type="danger" @click="handleDelete( scope.$index, scope.row)"
v-if="(resource_raw_node.meta.methods.delete === true)">
<!-- <el-icon style="vertical-align: middle">-->
<!-- <Delete/>-->
<!-- </el-icon>-->
<span>删除</span>
</el-button>
<template v-for="(btn, index) in rowClickBtns">
<template v-if="btn.btn_type === 0">
<el-button size="default" :type="btn.btn_color_type"
@click="tableSelectRows2(btn, scope.$index, scope.row)">
{{ btn.name }}
</el-button>
</template>
<template v-else-if="btn.btn_type === 1">
<el-button size="default" :type="btn.btn_color_type"
@click="tableSelectRow3(index, scope.row)">
{{ btn.name }}
</el-button>
</template>
<template v-else-if="btn.btn_type === 2">
<el-button size="default" :type="btn.btn_color_type"
@click="tableSelectRow4(btn, scope.row)">
{{ btn.name }}
</el-button>
</template>
</template>
</template>
</el-table-column>
</el-table>
<!-- 表格数据分页 -->
<div class="demo-pagination-block">
<div class="demonstration"></div>
<el-pagination
v-model:current-page="current_page"
v-model:page-size="page_size"
:page-sizes="pageSizes"
layout="total, sizes, prev, pager, next, jumper"
:total="totalRowCount"
@size-change="handlePaginationSizeChange"
@current-change="handlePaginationCurChange"
/>
</div>
<template v-for="(btn, index) in rowClickBtns">
<el-dialog v-model="rowClickBtnVisibleList[index]" :title="btn.name"
@close="rowClickBtnVisibleList[index]=false"
<el-dialog v-model="dialogAddVisible" :mask="true" title="添加" :modal="true"
:before-close="handleCloseDialog"
destroy-on-close>
<component :is="btn.btn_callback_component" :rowInfo="rowClickBtnSelectRow"/>
</el-dialog>
</template>
<el-dialog v-model="dialogAddVisible" :mask="true" title="添加" :modal="true" :before-close="handleCloseDialog"
destroy-on-close>
<el-form ref="dialogAddFormRef" :model="dialogObjectForm" :rules="rules" label-position="right"
label-width="130px">
<template v-for="fieldDescInfo in fieldsDescInfo">
<!--如何是items类型就是物品下拉框+道具组合-->
<template v-if="(fieldDescInfo.type === 'items')">
<el-form :inline="true" :model="selectedItem" label-position="right">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key" label-width="130px">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select v-model="selectedItem" placeholder="--搜索道具--" style="width: 150px"
filterable remote clearable
:remote-method="handleQueryItem"
:loading="loadingRemoteItems"
value-key="value"
>
<el-option v-for="info in itemChoices" :key="info.value" :label="info.desc"
:value="info"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
<el-form-item label="数量" prop="num">
<el-input type="number" v-model="selectedItemNum" placeholder="请输入数量" style="width: 150px"/>
</el-form-item>
<!-- 选择礼包 -->
<el-form-item v-if="cachedResource.meta.resource !== 'item_bag'">
<el-tooltip effect="light" content="选择礼包,点击添加到奖励列表">
<el-select placeholder="--礼包--" v-model="selectedItemBag" clearable style="width: 150px"
value-key="name">
<el-option v-for="bag in itemBags" :key="bag.name" :label="bag.name" :value="bag"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="addItem(fieldDescInfo)">添加</el-button>
</el-form-item>
</el-form>
<el-form-item label="奖励列表" prop="Attach">
<el-table :data="dialogObjectForm.Attach" border>
<el-table-column label="道具id" prop="id"/>
<el-table-column label="数量" prop="num"/>
<el-table-column label="道具名" prop="desc"/>
<el-table-column label="操作">
<template #default="scope">
<el-button type="danger" size="small" @click="deleteItem(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form-item>
</template>
<template v-else-if="(fieldDescInfo.readonly !== true)">
<!-- 有可选项的字段走下拉框或者多选框 -->
<template v-if="(fieldDescInfo.choices !== undefined && fieldDescInfo.choices.length > 0)">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select :placeholder="(fieldDescInfo.multi_choice === true ? '--多选--' : '--单选--')"
v-model="dialogObjectForm[fieldDescInfo.key]" style="width: 150px"
:multiple="(fieldDescInfo.multi_choice === true)">
<el-option v-for="info in fieldDescInfo.choices" :key="info.desc" :label="info.desc"
:value="info.value"></el-option>
</el-select>
</el-tooltip>
<el-form ref="dialogAddFormRef" :model="dialogObjectForm" :rules="rules" label-position="right"
label-width="130px">
<template v-for="fieldDescInfo in fieldsDescInfo">
<!--如何是items类型就是物品下拉框+道具组合-->
<template v-if="(fieldDescInfo.type === 'items')">
<el-form :inline="true" :model="selectedItem" label-position="right">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key" label-width="130px">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select v-model="selectedItem" placeholder="--搜索道具--" style="width: 150px"
filterable remote clearable
:remote-method="handleQueryItem"
:loading="loadingRemoteItems"
value-key="value"
>
<el-option v-for="info in itemChoices" :key="info.value" :label="info.desc"
:value="info"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
<el-form-item label="数量" prop="num">
<el-input type="number" v-model="selectedItemNum" placeholder="请输入数量" style="width: 150px"/>
</el-form-item>
<!-- 选择礼包 -->
<el-form-item v-if="cachedResource.meta.resource !== 'item_bag'">
<el-tooltip effect="light" content="选择礼包,点击添加到奖励列表">
<el-select placeholder="--礼包--" v-model="selectedItemBag" clearable style="width: 150px"
value-key="name">
<el-option v-for="bag in itemBags" :key="bag.name" :label="bag.name" :value="bag"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="addItem(fieldDescInfo)">添加</el-button>
</el-form-item>
</el-form>
<el-form-item label="奖励列表" prop="Attach">
<el-table :data="dialogObjectForm.Attach" border>
<el-table-column label="道具id" prop="id"/>
<el-table-column label="数量" prop="num"/>
<el-table-column label="道具名" prop="desc"/>
<el-table-column label="操作">
<template #default="scope">
<el-button type="danger" size="small" @click="deleteItem(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form-item>
</template>
<!-- 时间戳字段展示时间选择器 -->
<template v-else-if="(fieldDescInfo.type === 'Time')">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-date-picker v-model="dialogObjectForm[fieldDescInfo.key]" type="datetime"
placeholder="选个时间" format="YYYY/MM/DD HH:mm:ss"
value-format="YYYY/MM/DD HH:mm:ss"></el-date-picker>
</el-form-item>
</template>
<!-- 否则就是普通字段 -->
<template v-else>
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-input v-model="dialogObjectForm[fieldDescInfo.key]"
:placeholder="fieldDescInfo.help_text"></el-input>
</el-form-item>
</template>
</template>
</template>
<el-form-item>
<el-button @click="submitAdd(dialogAddFormRef)" size="large" type="primary">提交</el-button>
</el-form-item>
</el-form>
</el-dialog>
<el-dialog v-model="dialogEditVisible" :mask="true" title="编辑" :modal="true" :before-close="handleCloseDialog"
destroy-on-close>
<el-form ref="dialogEditFormRef" :model="dialogObjectForm" :rules="rules" class="operation_form"
label-width="130px">
<template v-for="fieldDescInfo in fieldsDescInfo">
<!--如果是items类型就是物品下拉框+道具组合-->
<template v-if="(fieldDescInfo.type === 'items')">
<el-form :inline="true" :model="selectedItem" label-position="right"
label-width="130px">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select placeholder="--搜索道具--" v-model="selectedItem" style="width: 150px"
filterable remote :remote-method="handleQueryItem"
:loading="loadingRemoteItems"
value-key="value"
>
<el-option v-for="info in itemChoices" :key="info.value" :label="info.desc"
:value="info"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
<el-form-item label="数量" prop="number">
<el-input type="number" v-model="selectedItemNum" placeholder="请输入数量" style="width: 150px"/>
</el-form-item>
<!-- 选择礼包 -->
<el-form-item v-if="cachedResource.meta.resource !== 'item_bag'">
<el-tooltip effect="light" content="选择礼包,点击添加到奖励列表">
<el-select placeholder="--礼包--" v-model="selectedItemBag" clearable style="width: 150px"
value-key="name">
<el-option v-for="bag in itemBags" :key="bag.name" :label="bag.name" :value="bag"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="addItem(fieldDescInfo)">添加</el-button>
</el-form-item>
</el-form>
<el-form-item label="奖励列表" prop="Attach">
<el-table :data="dialogObjectForm.Attach" border>
<el-table-column label="道具id" prop="id"/>
<el-table-column label="数量" prop="num"/>
<el-table-column label="道具名" prop="desc"/>
<el-table-column label="操作">
<template #default="scope">
<el-button type="danger" size="small" @click="deleteItem(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form-item>
</template>
<template v-else-if="(fieldDescInfo.readonly !== true)">
<template v-if="(fieldDescInfo.uneditable !== true)">
<template v-else-if="(fieldDescInfo.readonly !== true)">
<!-- 有可选项的字段走下拉框或者多选框 -->
<template v-if="(fieldDescInfo.choices !== undefined && fieldDescInfo.choices.length > 0)">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
@ -794,38 +706,173 @@ const handlePaginationCurChange = (val) => {
</template>
</template>
<template v-else>
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-input v-model="dialogObjectForm[fieldDescInfo.key]"
:placeholder="fieldDescInfo.help_text" disabled></el-input>
</template>
<el-form-item>
<el-button @click="submitAdd(dialogAddFormRef)" size="large" type="primary">提交</el-button>
</el-form-item>
</el-form>
</el-dialog>
<el-dialog v-model="dialogEditVisible" :mask="true" title="编辑" :modal="true"
:before-close="handleCloseDialog"
destroy-on-close>
<el-form ref="dialogEditFormRef" :model="dialogObjectForm" :rules="rules" class="operation_form"
label-width="130px">
<template v-for="fieldDescInfo in fieldsDescInfo">
<!--如果是items类型就是物品下拉框+道具组合-->
<template v-if="(fieldDescInfo.type === 'items')">
<el-form :inline="true" :model="selectedItem" label-position="right"
label-width="130px">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select placeholder="--搜索道具--" v-model="selectedItem" style="width: 150px"
filterable remote :remote-method="handleQueryItem"
:loading="loadingRemoteItems"
value-key="value"
>
<el-option v-for="info in itemChoices" :key="info.value" :label="info.desc"
:value="info"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
<el-form-item label="数量" prop="number">
<el-input type="number" v-model="selectedItemNum" placeholder="请输入数量" style="width: 150px"/>
</el-form-item>
<!-- 选择礼包 -->
<el-form-item v-if="cachedResource.meta.resource !== 'item_bag'">
<el-tooltip effect="light" content="选择礼包,点击添加到奖励列表">
<el-select placeholder="--礼包--" v-model="selectedItemBag" clearable style="width: 150px"
value-key="name">
<el-option v-for="bag in itemBags" :key="bag.name" :label="bag.name" :value="bag"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="addItem(fieldDescInfo)">添加</el-button>
</el-form-item>
</el-form>
<el-form-item label="奖励列表" prop="Attach">
<el-table :data="dialogObjectForm.Attach" border>
<el-table-column label="道具id" prop="id"/>
<el-table-column label="数量" prop="num"/>
<el-table-column label="道具名" prop="desc"/>
<el-table-column label="操作">
<template #default="scope">
<el-button type="danger" size="small" @click="deleteItem(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form-item>
</template>
<template v-else-if="(fieldDescInfo.readonly !== true)">
<template v-if="(fieldDescInfo.uneditable !== true)">
<!-- 有可选项的字段走下拉框或者多选框 -->
<template v-if="(fieldDescInfo.choices !== undefined && fieldDescInfo.choices.length > 0)">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select :placeholder="(fieldDescInfo.multi_choice === true ? '--多选--' : '--单选--')"
v-model="dialogObjectForm[fieldDescInfo.key]" style="width: 150px"
:multiple="(fieldDescInfo.multi_choice === true)">
<el-option v-for="info in fieldDescInfo.choices" :key="info.desc" :label="info.desc"
:value="info.value"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
</template>
<!-- 时间戳字段展示时间选择器 -->
<template v-else-if="(fieldDescInfo.type === 'Time')">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-date-picker v-model="dialogObjectForm[fieldDescInfo.key]" type="datetime"
placeholder="选个时间" format="YYYY/MM/DD HH:mm:ss"
value-format="YYYY/MM/DD HH:mm:ss"></el-date-picker>
</el-form-item>
</template>
<!-- 否则就是普通字段 -->
<template v-else>
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-input v-model="dialogObjectForm[fieldDescInfo.key]"
:placeholder="fieldDescInfo.help_text"></el-input>
</el-form-item>
</template>
</template>
<template v-else>
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-input v-model="dialogObjectForm[fieldDescInfo.key]"
:placeholder="fieldDescInfo.help_text" disabled></el-input>
</el-form-item>
</template>
</template>
<!-- <el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">-->
<!-- <el-input v-model="dialogEditForm[fieldDescInfo.key]"></el-input>-->
<!-- </el-form-item>-->
</template>
<!-- <el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">-->
<!-- <el-input v-model="dialogEditForm[fieldDescInfo.key]"></el-input>-->
<!-- </el-form-item>-->
</template>
<el-form-item>
<el-button @click="submitEdit(dialogEditFormRef)" size="large" type="primary">提交</el-button>
</el-form-item>
</el-form>
</el-dialog>
<el-form-item>
<el-button @click="submitEdit(dialogEditFormRef)" size="large" type="primary">提交</el-button>
</el-form-item>
</el-form>
</el-dialog>
</el-main>
</el-container>
</template>
</el-main>
</el-container>
</template>
</div>
</template>
<style scoped lang="scss">
.demo-pagination-block {
margin-top: 10px;
.el-pagination {
right: 40px;
position: absolute;
.app-content {
height: calc(100vh - 100px);
display: flex;
.table-content {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100%;
overflow: auto;
.table {
flex: 1;
position: relative;
:deep(.el-table) {
flex: 1;
position: absolute;
}
}
}
}
.pagination-container .el-pagination {
right: 0;
position: absolute;
height: 25px;
margin-bottom: 50px;
margin-top: 0px;
padding: 10px 30px !important;
z-index: 2;
}
.pagination-container.hidden {
display: none;
}
@media (max-width: 768px) {
.pagination-container .el-pagination > .el-pagination__jump {
display: none !important;
}
.pagination-container .el-pagination > .el-pagination__sizes {
display: none !important;
}
}

View File

@ -447,15 +447,17 @@ const handleGetUsedHistory = (index, row) => {
}
const handlePaginationSizeChange = (val) => {
// console.log(`${val} `)
console.log(`${val} 大小改变`)
if (totalRowCount.value <= 0) {
return
}
if (page_size.value * current_page.value > totalRowCount.value) {
//
return
if (rows.value.length >= totalRowCount.value) {
return
}
}
// console.log(`${page_size.value} `)
console.log(`${page_size.value} 大小改变`)
listData()
}
@ -468,342 +470,189 @@ const handlePaginationCurChange = (val) => {
</script>
<template>
<template v-if="!hasListPermit">
<component :is="empty"></component>
</template>
<template v-else>
<el-container v-if="listDataOK">
<el-header>
<el-row :gutter="20" v-if="(whereFieldsDescInfo.length !== 0)">
<template v-for="fieldDescInfo in whereFieldsDescInfo">
<template v-if="(fieldDescInfo.where === 'range')">
<el-col :span="calcElColSpan">
<el-date-picker v-model="fieldDescInfo.value1" type="datetime"
:placeholder="(fieldDescInfo.name + '起始')" format="YYYY/MM/DD HH:mm:ss"
value-format="YYYY/MM/DD HH:mm:ss"></el-date-picker>
</el-col>
<el-col :span="calcElColSpan">
<el-date-picker v-model="fieldDescInfo.value2" type="datetime"
:placeholder="(fieldDescInfo.name + '结束')" format="YYYY/MM/DD HH:mm:ss"
value-format="YYYY/MM/DD HH:mm:ss"></el-date-picker>
</el-col>
</template>
<template v-else>
<el-col :span="calcElColSpan">
<el-select v-model="fieldDescInfo.value1"
:placeholder="(fieldDescInfo.multi_choice === true ? '--' + fieldDescInfo.name + '--' : '--' + fieldDescInfo.name + '--')"
style="width: 150px"
filterable v-if="(fieldDescInfo.choices.length > 0)">
<el-option v-for="choice in fieldDescInfo.choices" :key="choice.value" :label="choice.desc"
:value="choice.value"></el-option>
</el-select>
<el-input v-model="fieldDescInfo.value1"
:placeholder="(fieldDescInfo.name + fieldDescInfo.whereDesc)"
style="width: 150px" v-else></el-input>
</el-col>
</template>
</template>
<el-col :span="calcElColSpan">
<el-button @click="listData" type="primary">条件搜索</el-button>
</el-col>
<el-col :span="calcElColSpan">
<el-button @click="resetConditionSearch">清空条件</el-button>
</el-col>
</el-row>
<el-row style="margin-top: 10px">
<el-button @click="dialogAddVisible = true" size="large" type="primary"
v-if="(resource_raw_node.meta.methods.post === true)">
添加
</el-button>
</el-row>
</el-header>
<el-main>
<el-table :data="rows" style="width: 100%" table-layout="auto" stripe>
<template v-for="fieldDescInfo in fieldsDescInfo">
<el-table-column prop="jsonValue" :label="fieldDescInfo.name" show-overflow-tooltip
v-if="(fieldDescInfo.type === 'items')"></el-table-column>
<el-table-column :prop="fieldDescInfo.key" :label="fieldDescInfo.name"
v-else></el-table-column>
</template>
<el-table-column prop="func" label="功 能">
<template #default="scope">
<el-button size="default" type="success" @click="handleLook(scope.$index, scope.row)"
v-if="(resource_raw_node.meta.methods.put === true)">
<span>查看</span>
</el-button>
<el-button size="default" type="primary" @click="handleExport( scope.$index, scope.row)"
v-if="(resource_raw_node.meta.methods.put === true)">
<span>导出</span>
</el-button>
<el-button size="default" type="info" @click="handleEdit( scope.$index, scope.row)"
v-if="(resource_raw_node.meta.methods.put === true)">
<span>修改</span>
</el-button>
<el-button size="default" type="warning" @click="handleGetUsedHistory(scope.$index, scope.row)"
v-if="(resource_raw_node.meta.methods.put === true)">
<span>礼包使用</span>
</el-button>
<el-button size="default" type="danger" @click="handleDelete( scope.$index, scope.row)"
style="margin-top: 5px"
v-if="(resource_raw_node.meta.methods.delete === true)">
<span>删除</span>
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 表格数据分页 -->
<div class="demo-pagination-block">
<div class="demonstration"></div>
<el-pagination
v-model:current-page="current_page"
v-model:page-size="page_size"
:page-sizes="pageSizes"
layout="total, sizes, prev, pager, next, jumper"
:total="totalRowCount"
@size-change="handlePaginationSizeChange"
@current-change="handlePaginationCurChange"
/>
</div>
<el-dialog v-model="dialogAddVisible" :mask="true" title="添加" :modal="true" :before-close="handleCloseDialog"
destroy-on-close>
<el-form ref="dialogAddFormRef" :model="dialogObjectForm" :rules="rules" label-position="right"
label-width="130px">
<template v-for="fieldDescInfo in fieldsDescInfo">
<!--如何是items类型就是物品下拉框+道具组合-->
<template v-if="(fieldDescInfo.type === 'items')">
<el-form :inline="true" :model="selectedItem" label-position="right">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key" label-width="130px">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select v-model="selectedItem" placeholder="--搜索道具--" style="width: 150px"
filterable remote clearable
:remote-method="handleQueryItem"
:loading="loadingRemoteItems"
value-key="value"
>
<el-option v-for="info in itemChoices" :key="info.value" :label="info.desc"
:value="info"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
<el-form-item label="数量" prop="num">
<el-input type="number" v-model="selectedItemNum" placeholder="请输入大于0的道具数量"
style="width: 150px"/>
</el-form-item>
<!-- 选择礼包 -->
<el-form-item>
<el-tooltip effect="light" content="选择礼包,点击添加到奖励列表">
<el-select placeholder="--礼包--" v-model="selectedItemBag" clearable style="width: 150px"
value-key="name">
<el-option v-for="bag in itemBags" :key="bag.name" :label="bag.name" :value="bag"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="addItem()">添加</el-button>
</el-form-item>
</el-form>
<el-form-item label="奖励列表" prop="Attach">
<el-table :data="dialogObjectForm.Attach" border>
<el-table-column label="道具id" prop="id"/>
<el-table-column label="数量" prop="num"/>
<el-table-column label="道具名" prop="desc"/>
<el-table-column label="操作">
<template #default="scope">
<el-button type="danger" size="small" @click="deleteItem(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form-item>
<div class="app-content">
<template v-if="!hasListPermit">
<component :is="empty"></component>
</template>
<template v-else>
<el-container v-if="listDataOK">
<el-header>
<el-row :gutter="20" v-if="(whereFieldsDescInfo.length !== 0)">
<template v-for="fieldDescInfo in whereFieldsDescInfo">
<template v-if="(fieldDescInfo.where === 'range')">
<el-col :span="calcElColSpan">
<el-date-picker v-model="fieldDescInfo.value1" type="datetime"
:placeholder="(fieldDescInfo.name + '起始')" format="YYYY/MM/DD HH:mm:ss"
value-format="YYYY/MM/DD HH:mm:ss"></el-date-picker>
</el-col>
<el-col :span="calcElColSpan">
<el-date-picker v-model="fieldDescInfo.value2" type="datetime"
:placeholder="(fieldDescInfo.name + '结束')" format="YYYY/MM/DD HH:mm:ss"
value-format="YYYY/MM/DD HH:mm:ss"></el-date-picker>
</el-col>
</template>
<template v-else-if="(fieldDescInfo.readonly !== true)">
<!-- 有可选项的字段走下拉框或者多选框 -->
<template v-if="(fieldDescInfo.choices !== undefined && fieldDescInfo.choices.length > 0)">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select :placeholder="(fieldDescInfo.multi_choice === true ? '--多选--' : '--单选--')"
v-model="dialogObjectForm[fieldDescInfo.key]" style="width: 150px"
:multiple="(fieldDescInfo.multi_choice === true)"
v-if="fieldDescInfo.key === 'CodeType'"
@change="handleCodeTypeOnSelect"
>
<el-option v-for="info in fieldDescInfo.choices" :key="info.desc" :label="info.desc"
:value="info.value"></el-option>
</el-select>
<el-select :placeholder="(fieldDescInfo.multi_choice === true ? '--多选--' : '--单选--')"
v-model="dialogObjectForm[fieldDescInfo.key]" style="width: 150px"
:multiple="(fieldDescInfo.multi_choice === true)"
v-else
>
<el-option v-for="info in fieldDescInfo.choices" :key="info.desc" :label="info.desc"
:value="info.value"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
</template>
<!-- 时间戳字段展示时间选择器 -->
<template v-else-if="(fieldDescInfo.type === 'Time')">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-date-picker v-model="dialogObjectForm[fieldDescInfo.key]" type="datetime"
placeholder="选个时间" format="YYYY/MM/DD HH:mm:ss"
value-format="YYYY/MM/DD HH:mm:ss"></el-date-picker>
</el-form-item>
</template>
<!-- 否则就是普通字段 -->
<template v-else>
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-input v-model="dialogObjectForm[fieldDescInfo.key]" :disabled="cdkeyCodeInputDisabled"
:placeholder="fieldDescInfo.help_text" v-if="fieldDescInfo.key === 'Code'"></el-input>
<el-input v-model="dialogObjectForm[fieldDescInfo.key]"
:placeholder="fieldDescInfo.help_text" :disabled="cdkeyCodeNumInputDisabled"
v-else-if="fieldDescInfo.key === 'CodeNum'" type="number"></el-input>
<el-input v-model="dialogObjectForm[fieldDescInfo.key]"
:placeholder="fieldDescInfo.help_text" v-else></el-input>
</el-form-item>
</template>
</template>
</template>
<el-form-item>
<el-button @click="submitAdd(dialogAddFormRef)" size="large" type="primary">提交</el-button>
</el-form-item>
</el-form>
</el-dialog>
<el-dialog v-model="dialogLookVisible" :mask="true" title="查看" :modal="true" :before-close="handleCloseDialog"
destroy-on-close>
<el-form ref="dialogLookFormRef" :model="dialogObjectForm" :rules="rules" class="operation_form"
label-width="130px">
<template v-for="fieldDescInfo in fieldsDescInfo">
<!--如果是items类型就是物品下拉框+道具组合-->
<template v-if="(fieldDescInfo.type === 'items')">
<el-form-item label="奖励列表" prop="Attach">
<el-table :data="dialogObjectForm.Attach" border>
<el-table-column label="道具id" prop="id"/>
<el-table-column label="数量" prop="num"/>
<el-table-column label="道具名" prop="desc"/>
</el-table>
</el-form-item>
</template>
<template v-else>
<!-- 有可选项的字段走下拉框或者多选框 -->
<template v-if="(fieldDescInfo.choices !== undefined && fieldDescInfo.choices.length > 0)">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select :placeholder="(fieldDescInfo.multi_choice === true ? '--多选--' : '--单选--')"
disabled
v-model="dialogObjectForm[fieldDescInfo.key]" style="width: 150px"
:multiple="(fieldDescInfo.multi_choice === true)">
<el-option v-for="info in fieldDescInfo.choices" :key="info.desc" :label="info.desc"
:value="info.value"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
</template>
<!-- 时间戳字段展示时间选择器 -->
<template v-else-if="(fieldDescInfo.type === 'Time')">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-date-picker v-model="dialogObjectForm[fieldDescInfo.key]" type="datetime"
disabled
placeholder="空时间" format="YYYY/MM/DD HH:mm:ss"
value-format="YYYY/MM/DD HH:mm:ss"></el-date-picker>
</el-form-item>
</template>
<!-- 否则就是普通字段 -->
<template v-else>
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-input v-model="dialogObjectForm[fieldDescInfo.key]"
disabled></el-input>
</el-form-item>
</template>
<el-col :span="calcElColSpan">
<el-select v-model="fieldDescInfo.value1"
:placeholder="(fieldDescInfo.multi_choice === true ? '--' + fieldDescInfo.name + '--' : '--' + fieldDescInfo.name + '--')"
style="width: 150px"
filterable v-if="(fieldDescInfo.choices.length > 0)">
<el-option v-for="choice in fieldDescInfo.choices" :key="choice.value" :label="choice.desc"
:value="choice.value"></el-option>
</el-select>
<el-input v-model="fieldDescInfo.value1"
:placeholder="(fieldDescInfo.name + fieldDescInfo.whereDesc)"
style="width: 150px" v-else></el-input>
</el-col>
</template>
<!-- <el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">-->
<!-- <el-input v-model="dialogEditForm[fieldDescInfo.key]"></el-input>-->
<!-- </el-form-item>-->
</template>
</el-form>
</el-dialog>
<el-col :span="calcElColSpan">
<el-button @click="listData" type="primary">条件搜索</el-button>
</el-col>
<el-col :span="calcElColSpan">
<el-button @click="resetConditionSearch">清空条件</el-button>
</el-col>
</el-row>
<el-dialog v-model="dialogEditVisible" :mask="true" title="编辑" :modal="true" :before-close="handleCloseDialog"
destroy-on-close>
<el-form ref="dialogEditFormRef" :model="dialogObjectForm" :rules="rules" class="operation_form"
label-width="130px">
<template v-for="fieldDescInfo in fieldsDescInfo">
<el-row style="margin-top: 10px">
<el-button @click="dialogAddVisible = true" size="large" type="primary"
v-if="(resource_raw_node.meta.methods.post === true)">
添加
</el-button>
</el-row>
</el-header>
<el-main>
<div class="table-content">
<div class="table">
<el-table :data="rows" style="width: 100%" table-layout="auto" stripe>
<template v-for="fieldDescInfo in fieldsDescInfo">
<el-table-column prop="jsonValue" :label="fieldDescInfo.name" show-overflow-tooltip
v-if="(fieldDescInfo.type === 'items')"></el-table-column>
<el-table-column :prop="fieldDescInfo.key" :label="fieldDescInfo.name" show-overflow-tooltip
v-else-if="(fieldDescInfo.key === 'CreatedAt')"></el-table-column>
<el-table-column :prop="fieldDescInfo.key" :label="fieldDescInfo.name" show-overflow-tooltip
v-else-if="(fieldDescInfo.key === 'UpdatedAt')"></el-table-column>
<el-table-column :prop="fieldDescInfo.key" :label="fieldDescInfo.name"
v-else></el-table-column>
</template>
<el-table-column prop="func" label="功 能">
<template #default="scope">
<el-button size="small" type="success" @click="handleLook(scope.$index, scope.row)"
v-if="(resource_raw_node.meta.methods.put === true)">
<span>查看</span>
</el-button>
<el-button size="small" type="primary" @click="handleExport( scope.$index, scope.row)"
v-if="(resource_raw_node.meta.methods.put === true)">
<span>导出</span>
</el-button>
<el-button size="small" type="info" @click="handleEdit( scope.$index, scope.row)"
v-if="(resource_raw_node.meta.methods.put === true)">
<span>修改</span>
</el-button>
<el-button size="small" type="warning" @click="handleGetUsedHistory(scope.$index, scope.row)"
v-if="(resource_raw_node.meta.methods.put === true)">
<span>礼包使用</span>
</el-button>
<el-button size="small" type="danger" @click="handleDelete( scope.$index, scope.row)"
v-if="(resource_raw_node.meta.methods.delete === true)">
<span>删除</span>
</el-button>
</template>
</el-table-column>
</el-table>
</div>
</div>
<!-- 表格数据分页 -->
<div class="pagination-container">
<el-pagination
v-model:current-page="current_page"
v-model:page-size="page_size"
:page-sizes="pageSizes"
layout="total, sizes, prev, pager, next, jumper"
:total="totalRowCount"
@size-change="handlePaginationSizeChange"
@current-change="handlePaginationCurChange"
/>
</div>
<!--如果是items类型就是物品下拉框+道具组合-->
<template v-if="(fieldDescInfo.type === 'items')">
<el-form :inline="true" :model="selectedItem" label-position="right"
label-width="130px">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select placeholder="--搜索道具--" v-model="selectedItem" style="width: 150px"
filterable remote clearable
:remote-method="handleQueryItem"
:loading="loadingRemoteItems"
value-key="value"
>
<el-option v-for="info in itemChoices" :key="info.value" :label="info.desc"
:value="info"></el-option>
</el-select>
</el-tooltip>
<el-dialog v-model="dialogAddVisible" :mask="true" title="添加" :modal="true"
:before-close="handleCloseDialog"
destroy-on-close>
<el-form ref="dialogAddFormRef" :model="dialogObjectForm" :rules="rules" label-position="right"
label-width="130px">
<template v-for="fieldDescInfo in fieldsDescInfo">
<!--如何是items类型就是物品下拉框+道具组合-->
<template v-if="(fieldDescInfo.type === 'items')">
<el-form :inline="true" :model="selectedItem" label-position="right">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key" label-width="130px">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select v-model="selectedItem" placeholder="--搜索道具--" style="width: 150px"
filterable remote clearable
:remote-method="handleQueryItem"
:loading="loadingRemoteItems"
value-key="value"
>
<el-option v-for="info in itemChoices" :key="info.value" :label="info.desc"
:value="info"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
<el-form-item label="数量" prop="num">
<el-input type="number" v-model="selectedItemNum" placeholder="请输入大于0的道具数量"
style="width: 150px"/>
</el-form-item>
<!-- 选择礼包 -->
<el-form-item>
<el-tooltip effect="light" content="选择礼包,点击添加到奖励列表">
<el-select placeholder="--礼包--" v-model="selectedItemBag" clearable style="width: 150px"
value-key="name">
<el-option v-for="bag in itemBags" :key="bag.name" :label="bag.name" :value="bag"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="addItem()">添加</el-button>
</el-form-item>
</el-form>
<el-form-item label="奖励列表" prop="Attach">
<el-table :data="dialogObjectForm.Attach" border>
<el-table-column label="道具id" prop="id"/>
<el-table-column label="数量" prop="num"/>
<el-table-column label="道具名" prop="desc"/>
<el-table-column label="操作">
<template #default="scope">
<el-button type="danger" size="small" @click="deleteItem(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form-item>
<el-form-item label="数量" prop="num" label-width="40px">
<el-input type="number" v-model="selectedItemNum" placeholder="请输入数量" style="width: 150px"/>
</el-form-item>
<!-- 选择礼包 -->
<el-form-item>
<el-tooltip effect="light" content="选择礼包,点击添加到奖励列表">
<el-select placeholder="--礼包--" v-model="selectedItemBag" clearable style="width: 150px"
value-key="name">
<el-option v-for="bag in itemBags" :key="bag.name" :label="bag.name" :value="bag"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="addItem(fieldDescInfo)">添加</el-button>
</el-form-item>
</el-form>
<el-form-item label="奖励列表" prop="Attach">
<el-table :data="dialogObjectForm.Attach" border>
<el-table-column label="道具id" prop="id"/>
<el-table-column label="数量" prop="num"/>
<el-table-column label="道具名" prop="desc"/>
<el-table-column label="操作">
<template #default="scope">
<el-button type="danger" size="small" @click="deleteItem(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form-item>
</template>
</template>
<template v-else-if="(fieldDescInfo.readonly !== true)">
<template v-if="(fieldDescInfo.uneditable !== true)">
<template v-else-if="(fieldDescInfo.readonly !== true)">
<!-- 有可选项的字段走下拉框或者多选框 -->
<template v-if="(fieldDescInfo.choices !== undefined && fieldDescInfo.choices.length > 0)">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select :placeholder="(fieldDescInfo.multi_choice === true ? '--多选--' : '--单选--')"
v-model="dialogObjectForm[fieldDescInfo.key]" style="width: 150px"
:multiple="(fieldDescInfo.multi_choice === true)">
:multiple="(fieldDescInfo.multi_choice === true)"
v-if="fieldDescInfo.key === 'CodeType'"
@change="handleCodeTypeOnSelect"
>
<el-option v-for="info in fieldDescInfo.choices" :key="info.desc" :label="info.desc"
:value="info.value"></el-option>
</el-select>
<el-select :placeholder="(fieldDescInfo.multi_choice === true ? '--多选--' : '--单选--')"
v-model="dialogObjectForm[fieldDescInfo.key]" style="width: 150px"
:multiple="(fieldDescInfo.multi_choice === true)"
v-else
>
<el-option v-for="info in fieldDescInfo.choices" :key="info.desc" :label="info.desc"
:value="info.value"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
</template>
@ -830,65 +679,267 @@ const handlePaginationCurChange = (val) => {
</template>
</template>
<template v-else>
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-input v-model="dialogObjectForm[fieldDescInfo.key]"
:placeholder="fieldDescInfo.help_text" disabled></el-input>
</template>
<el-form-item>
<el-button @click="submitAdd(dialogAddFormRef)" size="large" type="primary">提交</el-button>
</el-form-item>
</el-form>
</el-dialog>
<el-dialog v-model="dialogLookVisible" :mask="true" title="查看" :modal="true"
:before-close="handleCloseDialog"
destroy-on-close>
<el-form ref="dialogLookFormRef" :model="dialogObjectForm" :rules="rules" class="operation_form"
label-width="130px">
<template v-for="fieldDescInfo in fieldsDescInfo">
<!--如果是items类型就是物品下拉框+道具组合-->
<template v-if="(fieldDescInfo.type === 'items')">
<el-form-item label="奖励列表" prop="Attach">
<el-table :data="dialogObjectForm.Attach" border>
<el-table-column label="道具id" prop="id"/>
<el-table-column label="数量" prop="num"/>
<el-table-column label="道具名" prop="desc"/>
</el-table>
</el-form-item>
</template>
<template v-else>
<!-- 有可选项的字段走下拉框或者多选框 -->
<template v-if="(fieldDescInfo.choices !== undefined && fieldDescInfo.choices.length > 0)">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select :placeholder="(fieldDescInfo.multi_choice === true ? '--多选--' : '--单选--')"
disabled
v-model="dialogObjectForm[fieldDescInfo.key]" style="width: 150px"
:multiple="(fieldDescInfo.multi_choice === true)">
<el-option v-for="info in fieldDescInfo.choices" :key="info.desc" :label="info.desc"
:value="info.value"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
</template>
<!-- 时间戳字段展示时间选择器 -->
<template v-else-if="(fieldDescInfo.type === 'Time')">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-date-picker v-model="dialogObjectForm[fieldDescInfo.key]" type="datetime"
disabled
placeholder="空时间" format="YYYY/MM/DD HH:mm:ss"
value-format="YYYY/MM/DD HH:mm:ss"></el-date-picker>
</el-form-item>
</template>
<!-- 否则就是普通字段 -->
<template v-else>
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-input v-model="dialogObjectForm[fieldDescInfo.key]"
disabled></el-input>
</el-form-item>
</template>
</template>
<!-- <el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">-->
<!-- <el-input v-model="dialogEditForm[fieldDescInfo.key]"></el-input>-->
<!-- </el-form-item>-->
</template>
</el-form>
</el-dialog>
<el-dialog v-model="dialogEditVisible" :mask="true" title="编辑" :modal="true"
:before-close="handleCloseDialog"
destroy-on-close>
<el-form ref="dialogEditFormRef" :model="dialogObjectForm" :rules="rules" class="operation_form"
label-width="130px">
<template v-for="fieldDescInfo in fieldsDescInfo">
<!--如果是items类型就是物品下拉框+道具组合-->
<template v-if="(fieldDescInfo.type === 'items')">
<el-form :inline="true" :model="selectedItem" label-position="right"
label-width="130px">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select placeholder="--搜索道具--" v-model="selectedItem" style="width: 150px"
filterable remote clearable
:remote-method="handleQueryItem"
:loading="loadingRemoteItems"
value-key="value"
>
<el-option v-for="info in itemChoices" :key="info.value" :label="info.desc"
:value="info"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
<el-form-item label="数量" prop="num" label-width="40px">
<el-input type="number" v-model="selectedItemNum" placeholder="请输入数量" style="width: 150px"/>
</el-form-item>
<!-- 选择礼包 -->
<el-form-item>
<el-tooltip effect="light" content="选择礼包,点击添加到奖励列表">
<el-select placeholder="--礼包--" v-model="selectedItemBag" clearable style="width: 150px"
value-key="name">
<el-option v-for="bag in itemBags" :key="bag.name" :label="bag.name" :value="bag"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="addItem(fieldDescInfo)">添加</el-button>
</el-form-item>
</el-form>
<el-form-item label="奖励列表" prop="Attach">
<el-table :data="dialogObjectForm.Attach" border>
<el-table-column label="道具id" prop="id"/>
<el-table-column label="数量" prop="num"/>
<el-table-column label="道具名" prop="desc"/>
<el-table-column label="操作">
<template #default="scope">
<el-button type="danger" size="small" @click="deleteItem(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form-item>
</template>
<template v-else-if="(fieldDescInfo.readonly !== true)">
<template v-if="(fieldDescInfo.uneditable !== true)">
<!-- 有可选项的字段走下拉框或者多选框 -->
<template v-if="(fieldDescInfo.choices !== undefined && fieldDescInfo.choices.length > 0)">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select :placeholder="(fieldDescInfo.multi_choice === true ? '--多选--' : '--单选--')"
v-model="dialogObjectForm[fieldDescInfo.key]" style="width: 150px"
:multiple="(fieldDescInfo.multi_choice === true)">
<el-option v-for="info in fieldDescInfo.choices" :key="info.desc" :label="info.desc"
:value="info.value"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
</template>
<!-- 时间戳字段展示时间选择器 -->
<template v-else-if="(fieldDescInfo.type === 'Time')">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-date-picker v-model="dialogObjectForm[fieldDescInfo.key]" type="datetime"
placeholder="选个时间" format="YYYY/MM/DD HH:mm:ss"
value-format="YYYY/MM/DD HH:mm:ss"></el-date-picker>
</el-form-item>
</template>
<!-- 否则就是普通字段 -->
<template v-else>
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-input v-model="dialogObjectForm[fieldDescInfo.key]" :disabled="cdkeyCodeInputDisabled"
:placeholder="fieldDescInfo.help_text" v-if="fieldDescInfo.key === 'Code'"></el-input>
<el-input v-model="dialogObjectForm[fieldDescInfo.key]"
:placeholder="fieldDescInfo.help_text" :disabled="cdkeyCodeNumInputDisabled"
v-else-if="fieldDescInfo.key === 'CodeNum'" type="number"></el-input>
<el-input v-model="dialogObjectForm[fieldDescInfo.key]"
:placeholder="fieldDescInfo.help_text" v-else></el-input>
</el-form-item>
</template>
</template>
<template v-else>
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-input v-model="dialogObjectForm[fieldDescInfo.key]"
:placeholder="fieldDescInfo.help_text" disabled></el-input>
</el-form-item>
</template>
</template>
<!-- <el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">-->
<!-- <el-input v-model="dialogEditForm[fieldDescInfo.key]"></el-input>-->
<!-- </el-form-item>-->
</template>
<!-- <el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">-->
<!-- <el-input v-model="dialogEditForm[fieldDescInfo.key]"></el-input>-->
<!-- </el-form-item>-->
</template>
<el-form-item>
<el-button @click="submitEdit(dialogEditFormRef)" size="large" type="primary">提交</el-button>
</el-form-item>
</el-form>
</el-dialog>
<el-form-item>
<el-button @click="submitEdit(dialogEditFormRef)" size="large" type="primary">提交</el-button>
</el-form-item>
</el-form>
</el-dialog>
<el-dialog v-model="dialogUsedHistoryVisible" :mask="true"
:modal="true"
:before-close="handleCloseDialog"
destroy-on-close>
<template #header>
<el-dialog v-model="dialogUsedHistoryVisible" :mask="true"
:modal="true"
:before-close="handleCloseDialog"
destroy-on-close>
<template #header>
<span style="font-size: 30px" v-if="dialogObjectForm.CodeType === 0">
{{ dialogObjectForm.Name }}-{{ dialogObjectForm.Code }}使用{{ cdkeyUsedHistoryList.length }}
</span>
<span style="font-size: 30px" v-if="dialogObjectForm.CodeType === 1">
<span style="font-size: 30px" v-if="dialogObjectForm.CodeType === 1">
{{ dialogObjectForm.Name }}-{{ dialogObjectForm.CodeNum }}使用{{
cdkeyUsedHistoryList.length
}}
cdkeyUsedHistoryList.length
}}
</span>
</template>
<el-table :data="cdkeyUsedHistoryList" style="width: 100%" height="300" max-height="300" table-layout="auto"
stripe>
<el-table-column prop="server_id" label="区服"></el-table-column>
<el-table-column prop="account" label="账号名"></el-table-column>
<el-table-column prop="role_id" label="角色id"></el-table-column>
<el-table-column prop="role_name" label="角色名"></el-table-column>
<el-table-column prop="key" label="码"></el-table-column>
<el-table-column prop="ip" label="ip"></el-table-column>
<el-table-column prop="device_id" label="设备号"></el-table-column>
<el-table-column prop="created_at" label="使用时间"></el-table-column>
</el-table>
</el-dialog>
</template>
<el-table :data="cdkeyUsedHistoryList" style="width: 100%" height="300" max-height="300" table-layout="auto"
stripe>
<el-table-column prop="server_id" label="区服"></el-table-column>
<el-table-column prop="account" label="账号名"></el-table-column>
<el-table-column prop="role_id" label="角色id"></el-table-column>
<el-table-column prop="role_name" label="角色名"></el-table-column>
<el-table-column prop="key" label="码"></el-table-column>
<el-table-column prop="ip" label="ip"></el-table-column>
<el-table-column prop="device_id" label="设备号"></el-table-column>
<el-table-column prop="created_at" label="使用时间"></el-table-column>
</el-table>
</el-dialog>
</el-main>
</el-container>
</template>
</el-main>
</el-container>
</template>
</div>
</template>
<style scoped lang="scss">
.demo-pagination-block {
margin-top: 10px;
.el-pagination {
right: 40px;
position: absolute;
.app-content {
height: 100%;
display: flex;
.table-content {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100%;
overflow: auto;
.table {
flex: 1;
position: relative;
:deep(.el-table) {
flex: 1;
position: absolute;
}
}
}
}
.pagination-container .el-pagination {
right: 0;
position: absolute;
height: 25px;
margin-bottom: 50px;
margin-top: 0px;
padding: 10px 30px !important;
z-index: 2;
}
.pagination-container.hidden {
display: none;
}
@media (max-width: 768px) {
.pagination-container .el-pagination > .el-pagination__jump {
display: none !important;
}
.pagination-container .el-pagination > .el-pagination__sizes {
display: none !important;
}
}

View File

@ -18,11 +18,14 @@ const hasListPermit = resource_raw_node.meta.methods.get !== undefined && resour
const resource_url = cachedResource.meta.resource_url;
const fieldsDescInfo = ref([])
const whereFieldsDescInfo = ref([])
const rows = ref([])
const rules = ref({})
const current_page = ref(0)
const page_size = ref(0)
const current_page = ref(1)
const page_size = ref(10)
const pageSizes = [10, 20, 50, 100]
const totalRowCount = ref(0)
const item = ref({
id: 0,
@ -39,17 +42,34 @@ const selectedPermitList = ref([])
const listData = async () => {
try {
let listParams = {
page_no: 0,
page_len: 100,
page_no: current_page.value,
page_len: page_size.value,
where_conditions: "",
}
// console.log("list params:", listParams)
// console.log(`${listParams.page_no}${listParams.page_len}`)
let whereReqConditions = {
conditions: []
}
whereFieldsDescInfo.value.forEach((field) => {
if (field.value1 || field.value2) {
whereReqConditions.conditions.push({
key: field.key,
op: field.where,
value1: field.value1,
value2: field.value2,
})
}
})
listParams.where_conditions = JSON.stringify(whereReqConditions)
const rspData = await resourceList(resource_url, listParams);
listRsp.value = rspData;
if (listRsp.value.code !== 200) throw new Error("请求失败,错误码:", listRsp.code);
fieldsDescInfo.value = listRsp.value.data.fields_desc
totalRowCount.value = listRsp.value.data.total_count
rows.value = listRsp.value.data.rows
for (let i = 0; i < fieldsDescInfo.value.length; i++) {
var field = fieldsDescInfo.value[i]
dialogAddForm.value[field.key] = ''
@ -277,203 +297,137 @@ const handleCloseDialog = () => {
selectedPermitList.value = []
}
const handlePaginationSizeChange = (val) => {
// console.log(`${val} `)
if (totalRowCount.value <= 0) {
return
}
if (page_size.value * current_page.value > totalRowCount.value) {
//
if (rows.value.length >= totalRowCount.value) {
return
}
}
// console.log(`${page_size.value} `)
listData()
}
const handlePaginationCurChange = (val) => {
// console.log(`${val} `)
listData()
}
</script>
<template>
<template v-if="!hasListPermit">
<component :is="empty"></component>
</template>
<template v-else>
<el-container v-if="listDataOK">
<el-header>
<el-button @click="dialogAddVisible = true" size="large" type="primary"
v-if="(resource_raw_node.meta.methods.post === true)">
添加
</el-button>
</el-header>
<el-main>
<el-table :data="rows" style="width: 100%" table-layout="auto" stripe>
<template v-for="fieldDescInfo in fieldsDescInfo">
<el-table-column prop="jsonValue" :label="fieldDescInfo.name"
v-if="(fieldDescInfo.type === 'items')"></el-table-column>
<el-table-column prop="jsonValue" :label="fieldDescInfo.name"
v-else-if="(fieldDescInfo.key === 'UserPass')"></el-table-column>
<el-table-column :prop="fieldDescInfo.key" :label="fieldDescInfo.name"
v-else-if="(fieldDescInfo.key === 'Permissions')" show-overflow-tooltip></el-table-column>
<el-table-column :prop="fieldDescInfo.key" :label="fieldDescInfo.name"
v-else></el-table-column>
</template>
<el-table-column prop="func" label="功 能">
<template #default="scope">
<div class="app-content">
<template v-if="!hasListPermit">
<component :is="empty"></component>
</template>
<template v-else>
<el-container v-if="listDataOK">
<el-header>
<el-button @click="dialogAddVisible = true" size="large" type="primary"
v-if="(resource_raw_node.meta.methods.post === true)">
添加
</el-button>
</el-header>
<el-main>
<div class="table-content">
<div class="table">
<el-table :data="rows" style="width: 100%" table-layout="auto" stripe>
<template v-for="fieldDescInfo in fieldsDescInfo">
<el-table-column prop="jsonValue" :label="fieldDescInfo.name"
v-if="(fieldDescInfo.type === 'items')"></el-table-column>
<el-table-column prop="jsonValue" :label="fieldDescInfo.name"
v-else-if="(fieldDescInfo.key === 'UserPass')"></el-table-column>
<el-table-column :prop="fieldDescInfo.key" :label="fieldDescInfo.name"
v-else-if="(fieldDescInfo.key === 'Permissions')"
show-overflow-tooltip></el-table-column>
<el-table-column :prop="fieldDescInfo.key" :label="fieldDescInfo.name"
v-else></el-table-column>
</template>
<el-table-column prop="func" label="功 能">
<template #default="scope">
<el-button size="default" type="success" @click="handleEdit( scope.$index, scope.row)"
v-if="(resource_raw_node.meta.methods.put === true)">
<el-icon style="vertical-align: middle">
<Edit/>
</el-icon>
<span>编辑</span>
</el-button>
<el-button size="default" type="danger" @click="handleDelete( scope.$index, scope.row)"
v-if="(resource_raw_node.meta.methods.delete === true)">
<el-icon style="vertical-align: middle">
<Delete/>
</el-icon>
<span>删除</span>
</el-button>
</template>
</el-table-column>
</el-table>
<el-button size="default" type="success" @click="handleEdit( scope.$index, scope.row)"
v-if="(resource_raw_node.meta.methods.put === true)">
<el-icon style="vertical-align: middle">
<Edit/>
</el-icon>
<span>编辑</span>
</el-button>
<el-button size="default" type="danger" @click="handleDelete( scope.$index, scope.row)"
v-if="(resource_raw_node.meta.methods.delete === true)">
<el-icon style="vertical-align: middle">
<Delete/>
</el-icon>
<span>删除</span>
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<!-- 表格数据分页 -->
<div class="pagination-container">
<el-pagination
v-model:current-page="current_page"
v-model:page-size="page_size"
:page-sizes="pageSizes"
layout="total, sizes, prev, pager, next, jumper"
:total="totalRowCount"
@size-change="handlePaginationSizeChange"
@current-change="handlePaginationCurChange"
/>
</div>
</div>
<!-- 表格数据分页 -->
<div class="demo-pagination-block">
<div class="demonstration"></div>
<el-pagination
v-model:current-page="current_page"
v-model:page-size="page_size"
:page-sizes="[20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper"
:total="400"
/>
</div>
<el-dialog v-model="dialogAddVisible" :mask="true" title="添加" :modal="true" :before-close="handleCloseDialog"
destroy-on-close>
<el-form ref="dialogAddFormRef" :model="dialogAddForm" :rules="rules" label-position="right"
label-width="130px">
<template v-for="fieldDescInfo in fieldsDescInfo">
<!--如何是items类型就是物品下拉框+道具组合-->
<template v-if="(fieldDescInfo.type === 'items')">
<el-form :inline="true" :model="item" label-position="right">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key" label-width="130px">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select placeholder="--选择道具后填数量点击添加--" v-model="item.id" style="width: 150px"
filterable>
<el-option v-for="info in fieldDescInfo.choices" :key="info.desc" :label="info.desc"
:value="info.value"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
<el-form-item label="数量" prop="num">
<el-input type="number" v-model="item.num" placeholder="请输入数量" style="width: 150px"/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="addItem(fieldDescInfo)">添加</el-button>
</el-form-item>
</el-form>
<el-form-item label="奖励列表" prop="Attach">
<el-table :data="dialogAddForm.Attach" border>
<el-table-column label="道具id" prop="id"/>
<el-table-column label="数量" prop="num"/>
<el-table-column label="操作">
<template #default="scope">
<el-button type="danger" size="small" @click="deleteItem(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form-item>
</template>
<template v-else-if="(fieldDescInfo.readonly !== true)">
<!-- 有可选项的字段走下拉框或者多选框 -->
<template v-if="(fieldDescInfo.choices !== undefined && fieldDescInfo.choices.length > 0)">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select :placeholder="(fieldDescInfo.multi_choice === true ? '--多选--' : '--单选--')"
v-model="dialogAddForm[fieldDescInfo.key]" style="width: 150px"
:multiple="(fieldDescInfo.multi_choice === true)">
<el-option v-for="info in fieldDescInfo.choices" :key="info.desc" :label="info.desc"
:value="info.value"></el-option>
</el-select>
</el-tooltip>
<el-dialog v-model="dialogAddVisible" :mask="true" title="添加" :modal="true"
:before-close="handleCloseDialog"
destroy-on-close>
<el-form ref="dialogAddFormRef" :model="dialogAddForm" :rules="rules" label-position="right"
label-width="130px">
<template v-for="fieldDescInfo in fieldsDescInfo">
<!--如何是items类型就是物品下拉框+道具组合-->
<template v-if="(fieldDescInfo.type === 'items')">
<el-form :inline="true" :model="item" label-position="right">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key" label-width="130px">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select placeholder="--选择道具后填数量点击添加--" v-model="item.id" style="width: 150px"
filterable>
<el-option v-for="info in fieldDescInfo.choices" :key="info.desc" :label="info.desc"
:value="info.value"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
<el-form-item label="数量" prop="num">
<el-input type="number" v-model="item.num" placeholder="请输入数量" style="width: 150px"/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="addItem(fieldDescInfo)">添加</el-button>
</el-form-item>
</el-form>
<el-form-item label="奖励列表" prop="Attach">
<el-table :data="dialogAddForm.Attach" border>
<el-table-column label="道具id" prop="id"/>
<el-table-column label="数量" prop="num"/>
<el-table-column label="操作">
<template #default="scope">
<el-button type="danger" size="small" @click="deleteItem(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form-item>
</template>
<!-- 时间戳字段展示时间选择器 -->
<template v-else-if="(fieldDescInfo.type === 'Time')">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-date-picker v-model="dialogAddForm[fieldDescInfo.key]" type="datetime"
placeholder="选个时间" format="YYYY/MM/DD HH:mm:ss"
value-format="YYYY/MM/DD HH:mm:ss"></el-date-picker>
</el-form-item>
</template>
<template v-else-if="(fieldDescInfo.key === 'Permissions')">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-tree ref="treeRef" :data="permitTree" show-checkbox node-key="id"
:props="permitTreeDefaultProps" @check-change="handlePermitCheckChange">
</el-tree>
</el-form-item>
</template>
<!-- 否则就是普通字段 -->
<template v-else>
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-input v-model="dialogAddForm[fieldDescInfo.key]"
:placeholder="fieldDescInfo.help_text" show-password
v-if="(fieldDescInfo.key === 'UserPass')"></el-input>
<el-input v-model="dialogAddForm[fieldDescInfo.key]"
:placeholder="fieldDescInfo.help_text"
v-else></el-input>
</el-form-item>
</template>
</template>
</template>
<el-form-item>
<el-button @click="submitAdd(dialogAddFormRef)" size="large" type="primary">提交</el-button>
</el-form-item>
</el-form>
</el-dialog>
<el-dialog v-model="dialogEditVisible" :mask="true" title="编辑" :modal="true" :before-close="handleCloseDialog"
destroy-on-close>
<el-form ref="dialogEditFormRef" :model="dialogEditForm" :rules="rules" class="operation_form"
label-width="130px">
<template v-for="fieldDescInfo in fieldsDescInfo">
<!--如果是items类型就是物品下拉框+道具组合-->
<template v-if="(fieldDescInfo.type === 'items')">
<el-form :inline="true" :model="item" label-position="right"
label-width="130px">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select placeholder="--选择道具后填数量点击添加--" v-model="item.id" style="width: 150px"
filterable>
<el-option v-for="info in fieldDescInfo.choices" :key="info.desc" :label="info.desc"
:value="info.value"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
<el-form-item label="数量" prop="number">
<el-input type="number" v-model="item.num" placeholder="请输入数量" style="width: 150px"/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="addItem(fieldDescInfo)">添加</el-button>
</el-form-item>
</el-form>
<el-form-item label="奖励列表" prop="attachmentsList">
<el-table :data="dialogEditForm.Attach" border>
<el-table-column label="道具id" prop="id"/>
<el-table-column label="数量" prop="num"/>
<el-table-column label="操作">
<template #default="scope">
<el-button type="danger" size="small" @click="deleteItem(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form-item>
</template>
<template v-else-if="(fieldDescInfo.readonly !== true)">
<template v-if="(fieldDescInfo.uneditable !== true)">
<template v-else-if="(fieldDescInfo.readonly !== true)">
<!-- 有可选项的字段走下拉框或者多选框 -->
<template v-if="(fieldDescInfo.choices !== undefined && fieldDescInfo.choices.length > 0)">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select :placeholder="(fieldDescInfo.multi_choice === true ? '--多选--' : '--单选--')"
v-model="dialogEditForm[fieldDescInfo.key]" style="width: 150px"
v-model="dialogAddForm[fieldDescInfo.key]" style="width: 150px"
:multiple="(fieldDescInfo.multi_choice === true)">
<el-option v-for="info in fieldDescInfo.choices" :key="info.desc" :label="info.desc"
:value="info.value"></el-option>
@ -485,7 +439,7 @@ const handleCloseDialog = () => {
<!-- 时间戳字段展示时间选择器 -->
<template v-else-if="(fieldDescInfo.type === 'Time')">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-date-picker v-model="dialogEditForm[fieldDescInfo.key]" type="datetime"
<el-date-picker v-model="dialogAddForm[fieldDescInfo.key]" type="datetime"
placeholder="选个时间" format="YYYY/MM/DD HH:mm:ss"
value-format="YYYY/MM/DD HH:mm:ss"></el-date-picker>
</el-form-item>
@ -494,7 +448,6 @@ const handleCloseDialog = () => {
<template v-else-if="(fieldDescInfo.key === 'Permissions')">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-tree ref="treeRef" :data="permitTree" show-checkbox node-key="id"
:default-checked-keys="selectedPermitList"
:props="permitTreeDefaultProps" @check-change="handlePermitCheckChange">
</el-tree>
</el-form-item>
@ -503,48 +456,186 @@ const handleCloseDialog = () => {
<!-- 否则就是普通字段 -->
<template v-else>
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-input v-model="dialogEditForm[fieldDescInfo.key]"
<el-input v-model="dialogAddForm[fieldDescInfo.key]"
:placeholder="fieldDescInfo.help_text" show-password
v-if="(fieldDescInfo.key === 'UserPass')"></el-input>
<el-input v-model="dialogEditForm[fieldDescInfo.key]"
<el-input v-model="dialogAddForm[fieldDescInfo.key]"
:placeholder="fieldDescInfo.help_text"
v-else></el-input>
</el-form-item>
</template>
</template>
<template v-else>
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-input v-model="dialogEditForm[fieldDescInfo.key]"
:placeholder="fieldDescInfo.help_text" disabled></el-input>
</template>
<el-form-item>
<el-button @click="submitAdd(dialogAddFormRef)" size="large" type="primary">提交</el-button>
</el-form-item>
</el-form>
</el-dialog>
<el-dialog v-model="dialogEditVisible" :mask="true" title="编辑" :modal="true"
:before-close="handleCloseDialog"
destroy-on-close>
<el-form ref="dialogEditFormRef" :model="dialogEditForm" :rules="rules" class="operation_form"
label-width="130px">
<template v-for="fieldDescInfo in fieldsDescInfo">
<!--如果是items类型就是物品下拉框+道具组合-->
<template v-if="(fieldDescInfo.type === 'items')">
<el-form :inline="true" :model="item" label-position="right"
label-width="130px">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select placeholder="--选择道具后填数量点击添加--" v-model="item.id" style="width: 150px"
filterable>
<el-option v-for="info in fieldDescInfo.choices" :key="info.desc" :label="info.desc"
:value="info.value"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
<el-form-item label="数量" prop="number">
<el-input type="number" v-model="item.num" placeholder="请输入数量" style="width: 150px"/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="addItem(fieldDescInfo)">添加</el-button>
</el-form-item>
</el-form>
<el-form-item label="奖励列表" prop="attachmentsList">
<el-table :data="dialogEditForm.Attach" border>
<el-table-column label="道具id" prop="id"/>
<el-table-column label="数量" prop="num"/>
<el-table-column label="操作">
<template #default="scope">
<el-button type="danger" size="small" @click="deleteItem(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form-item>
</template>
<template v-else-if="(fieldDescInfo.readonly !== true)">
<template v-if="(fieldDescInfo.uneditable !== true)">
<!-- 有可选项的字段走下拉框或者多选框 -->
<template v-if="(fieldDescInfo.choices !== undefined && fieldDescInfo.choices.length > 0)">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-tooltip effect="light" :content="fieldDescInfo.help_text" placement="bottom-start">
<el-select :placeholder="(fieldDescInfo.multi_choice === true ? '--多选--' : '--单选--')"
v-model="dialogEditForm[fieldDescInfo.key]" style="width: 150px"
:multiple="(fieldDescInfo.multi_choice === true)">
<el-option v-for="info in fieldDescInfo.choices" :key="info.desc" :label="info.desc"
:value="info.value"></el-option>
</el-select>
</el-tooltip>
</el-form-item>
</template>
<!-- 时间戳字段展示时间选择器 -->
<template v-else-if="(fieldDescInfo.type === 'Time')">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-date-picker v-model="dialogEditForm[fieldDescInfo.key]" type="datetime"
placeholder="选个时间" format="YYYY/MM/DD HH:mm:ss"
value-format="YYYY/MM/DD HH:mm:ss"></el-date-picker>
</el-form-item>
</template>
<template v-else-if="(fieldDescInfo.key === 'Permissions')">
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-tree ref="treeRef" :data="permitTree" show-checkbox node-key="id"
:default-checked-keys="selectedPermitList"
:props="permitTreeDefaultProps" @check-change="handlePermitCheckChange">
</el-tree>
</el-form-item>
</template>
<!-- 否则就是普通字段 -->
<template v-else>
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-input v-model="dialogEditForm[fieldDescInfo.key]"
:placeholder="fieldDescInfo.help_text" show-password
v-if="(fieldDescInfo.key === 'UserPass')"></el-input>
<el-input v-model="dialogEditForm[fieldDescInfo.key]"
:placeholder="fieldDescInfo.help_text"
v-else></el-input>
</el-form-item>
</template>
</template>
<template v-else>
<el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">
<el-input v-model="dialogEditForm[fieldDescInfo.key]"
:placeholder="fieldDescInfo.help_text" disabled></el-input>
</el-form-item>
</template>
</template>
<!-- <el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">-->
<!-- <el-input v-model="dialogEditForm[fieldDescInfo.key]"></el-input>-->
<!-- </el-form-item>-->
</template>
<!-- <el-form-item :label="fieldDescInfo.name" :prop="fieldDescInfo.key">-->
<!-- <el-input v-model="dialogEditForm[fieldDescInfo.key]"></el-input>-->
<!-- </el-form-item>-->
</template>
<el-form-item>
<el-button @click="submitEdit(dialogEditFormRef)" size="large" type="primary">提交</el-button>
</el-form-item>
</el-form>
</el-dialog>
<el-form-item>
<el-button @click="submitEdit(dialogEditFormRef)" size="large" type="primary">提交</el-button>
</el-form-item>
</el-form>
</el-dialog>
</el-main>
</el-container>
</template>
</el-main>
</el-container>
</template>
</div>
</template>
<style scoped lang="scss">
.demo-pagination-block {
margin-top: 10px;
.el-pagination {
right: 40px;
position: absolute;
.app-content {
height: 100%;
display: flex;
}
.table-content {
display: flex;
flex-direction: column;
justify-content: space-between;
height: calc(100vh - 200px);
overflow: auto;
.table {
flex: 1;
position: relative;
:deep(.el-table) {
flex: 1;
position: absolute;
}
}
}
.pagination-container .el-pagination {
right: 0;
position: absolute;
height: 25px;
margin-bottom: 50px;
margin-top: 0px;
padding: 10px 30px !important;
z-index: 2;
}
.pagination-container.hidden {
display: none;
}
@media (max-width: 768px) {
.pagination-container .el-pagination > .el-pagination__jump {
display: none !important;
}
.pagination-container .el-pagination > .el-pagination__sizes {
display: none !important;
}
}

View File

@ -11,7 +11,7 @@ import userStore from "@/stores/user.js";
// 创建axios实例
const service = axios.create({
baseURL: import.meta.env.VITE_APP_BASE_API,
timeout: 10000,
timeout: 15000,
headers: {
"Content-type": "application/json;charset=utf-8",
"Cache-Control": 'no-cache',

View File

@ -62,8 +62,8 @@ function logout() {
<template>
<main>
<div>
<el-container class="layout-container">
<el-aside class="el-aside-demo">
<el-container class="app-container">
<el-aside class="app-sidebar">
<div class="sidebar-content">
<!-- <el-avatar shape="square" :size="100" :src="avatarUrl"></el-avatar>-->
<div class="sidebar-logo" @click="handleEnterIndex">
@ -116,8 +116,8 @@ function logout() {
</div>
</el-aside>
<el-container class="el-container-right">
<el-header class="el-header-demo">
<el-container class="app-container-right">
<el-header class="app-header">
<div class="header-content">
<div class="avatar-container">
<el-dropdown class="right-menu-item hover-effect" trigger="click" @command="handleCommand">
@ -143,7 +143,7 @@ function logout() {
</div>
<!-- <el-avatar shape="square" :size="100" :src="avatarUrl"></el-avatar>-->
</el-header>
<el-main class="el-main-demo">
<el-main class="app-main">
<router-view :key="$route.fullPath"></router-view>
</el-main>
</el-container>
@ -160,11 +160,11 @@ h1 {
margin-bottom: 20px;
}
.layout-container {
.app-container {
height: 100vh;
overflow: hidden;
.el-aside-demo {
.app-sidebar {
position: fixed;
left: 0;
top: 0;
@ -180,19 +180,20 @@ h1 {
}
}
.el-container-right {
.app-container-right {
min-height: 100vh;
margin-left: 200px;
flex-direction: column;
.el-header-demo {
.app-header {
height: 60px;
background: #fff;
border-bottom: 1px solid #e6e6e6;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}
.el-main-demo {
.app-main {
height: calc(100vh - 70px);
flex: 1;
padding: 20px;
background: #f0f2f5;