refactor: base.repo与base.app精简优化

This commit is contained in:
meilin.huang
2024-04-29 12:29:56 +08:00
parent f2c7ef78c0
commit a5cd7caf19
14 changed files with 108 additions and 105 deletions

View File

@@ -7,8 +7,8 @@ import (
"mayfly-go/internal/sys/domain/repository"
"mayfly-go/pkg/base"
"mayfly-go/pkg/errorx"
"mayfly-go/pkg/gormx"
"mayfly-go/pkg/model"
"mayfly-go/pkg/utils/collx"
"mayfly-go/pkg/utils/stringx"
"strings"
"time"
@@ -138,14 +138,14 @@ func (r *resourceAppImpl) Sort(ctx context.Context, sortResource *entity.Resourc
}
// 更新零值使用map因为pid=0表示根节点
updateMap := map[string]interface{}{
updateMap := collx.M{
"pid": sortResource.Pid,
"weight": sortResource.Weight,
"ui_path": newParentResourceUiPath + resourceUi,
}
condition := new(entity.Resource)
condition.Id = sortResource.Id
return gormx.Updates(condition, condition, updateMap)
return r.UpdateByCond(ctx, updateMap, condition)
}
func (r *resourceAppImpl) checkCode(code string) error {

View File

@@ -4,7 +4,6 @@ import (
"mayfly-go/internal/sys/domain/entity"
"mayfly-go/internal/sys/domain/repository"
"mayfly-go/pkg/base"
"mayfly-go/pkg/gormx"
)
type resourceRepoImpl struct {
@@ -26,7 +25,7 @@ func (r *resourceRepoImpl) GetChildren(uiPath string) []entity.Resource {
func (r *resourceRepoImpl) UpdateByUiPathLike(resource *entity.Resource) error {
sql := "UPDATE t_sys_resource SET status=? WHERE (ui_path LIKE ?)"
return gormx.ExecSql(sql, resource.Status, resource.UiPath+"%")
return r.ExecBySql(sql, resource.Status, resource.UiPath+"%")
}
func (r *resourceRepoImpl) GetAccountResources(accountId uint64, toEntity any) error {