v1
This commit is contained in:
@@ -5,8 +5,8 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"management/internal/erpserver/model/dto"
|
||||
"management/internal/erpserver/model/system"
|
||||
"management/internal/erpserver/model/system/request"
|
||||
"management/internal/erpserver/repository"
|
||||
"management/internal/pkg/sqldb"
|
||||
|
||||
@@ -55,7 +55,7 @@ func (s *store) BatchCreate(ctx context.Context, objs []*system.AuditLog) error
|
||||
return sqldb.NamedExecContext(ctx, s.log, s.db.DB(ctx), q, objs)
|
||||
}
|
||||
|
||||
func (s *store) Count(ctx context.Context, filter dto.SearchDto) (int64, error) {
|
||||
func (s *store) Count(ctx context.Context, filter request.ListAudit) (int64, error) {
|
||||
//goland:noinspection ALL
|
||||
const q = `
|
||||
SELECT
|
||||
@@ -80,7 +80,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.AuditLog, error) {
|
||||
func (s *store) List(ctx context.Context, filter request.ListAudit) ([]*system.AuditLog, error) {
|
||||
//goland:noinspection ALL
|
||||
const q = `
|
||||
SELECT
|
||||
@@ -90,8 +90,8 @@ func (s *store) List(ctx context.Context, filter dto.SearchDto) ([]*system.Audit
|
||||
sys_audit_log`
|
||||
|
||||
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)
|
||||
|
||||
@@ -4,20 +4,20 @@ 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.ListAudit, 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
|
||||
if filter.Email != "" {
|
||||
data["email"] = filter.Email
|
||||
wc = append(wc, "email LIKE :email")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user