This commit is contained in:
2025-06-30 16:44:06 +08:00
parent 4186cd0caf
commit c8a81d0f49
840 changed files with 1389 additions and 403165 deletions

View File

@@ -4,40 +4,35 @@ import (
"bytes"
"strings"
"management/internal/erpserver/model/dto"
"management/internal/erpserver/model/system/request"
)
func applyFilter(filter dto.SearchDto, data map[string]any, buf *bytes.Buffer) {
func applyFilter(filter request.ListRole, data map[string]any, buf *bytes.Buffer) {
var wc []string
if filter.SearchTimeBegin != "" && filter.SearchTimeEnd == "" {
data["start_at"] = filter.SearchTimeBegin
data["end_at"] = filter.SearchTimeEnd
if filter.StartTime != "" && filter.EndTime != "" {
data["start_at"] = filter.StartTime
data["end_at"] = filter.EndTime
wc = append(wc, "created_at BETWEEN :start_at AND :end_at")
}
if filter.SearchEmail != "" {
data["email"] = filter.SearchEmail
wc = append(wc, "email LIKE :email")
}
if filter.SearchID != 0 {
data["id"] = filter.SearchID
if filter.ID != 0 {
data["id"] = filter.ID
wc = append(wc, "id = :id")
}
if filter.SearchParentID != 0 && filter.SearchParentID != 1 {
data["parent_id"] = filter.SearchParentID
if filter.ParentID != 0 && filter.ParentID != 1 {
data["parent_id"] = filter.ParentID
wc = append(wc, "parent_id = :parent_id")
}
if filter.SearchName != "" {
data["name"] = filter.SearchName
if filter.Name != "" {
data["name"] = filter.Name
wc = append(wc, "name LIKE :name")
}
if filter.SearchStatus != 9999 {
data["status"] = filter.SearchStatus
if filter.Status != 9999 {
data["status"] = filter.Status
wc = append(wc, "status = :status")
}

View File

@@ -6,8 +6,8 @@ import (
"fmt"
"time"
"management/internal/erpserver/model/dto"
"management/internal/erpserver/model/system"
"management/internal/erpserver/model/system/request"
"management/internal/erpserver/repository"
"management/internal/pkg/sqldb"
@@ -27,7 +27,7 @@ func NewStore(db *repository.Store, log *logger.Logger) system.RoleRepository {
}
func (s *store) Initialize(ctx context.Context) (*system.Role, error) {
count, err := s.Count(ctx, dto.SearchDto{})
count, err := s.Count(ctx, request.ListRole{})
if err != nil {
return nil, err
}
@@ -157,7 +157,7 @@ func (s *store) All(ctx context.Context) ([]*system.Role, error) {
return toPointer(roles), nil
}
func (s *store) Count(ctx context.Context, filter dto.SearchDto) (int64, error) {
func (s *store) Count(ctx context.Context, filter request.ListRole) (int64, error) {
//goland:noinspection ALL
const q = `
SELECT
@@ -182,7 +182,7 @@ func (s *store) Count(ctx context.Context, filter dto.SearchDto) (int64, error)
return count.Count, nil
}
func (s *store) List(ctx context.Context, filter dto.SearchDto) ([]*system.Role, error) {
func (s *store) List(ctx context.Context, filter request.ListRole) ([]*system.Role, error) {
//goland:noinspection ALL
const q = `
SELECT
@@ -191,8 +191,8 @@ func (s *store) List(ctx context.Context, filter dto.SearchDto) ([]*system.Role,
sys_role`
data := map[string]any{
"offset": (filter.Page - 1) * filter.Rows,
"rows_per_page": filter.Rows,
"offset": (filter.PageID - 1) * filter.PageSize,
"rows_per_page": filter.PageSize,
}
buf := bytes.NewBufferString(q)