Kaynağa Gözat

Merge branch 'yhg_240730'

jimmyyem 5 ay önce
ebeveyn
işleme
5f5203467e

+ 7 - 1
internal/logic/employee/get_api_employee_list_logic.go

@@ -4,6 +4,8 @@ import (
 	"context"
 	"github.com/suyuan32/simple-admin-common/msg/errormsg"
 	"github.com/suyuan32/simple-admin-common/utils/pointy"
+	"wechat-api/ent/employee"
+	"wechat-api/ent/predicate"
 	"wechat-api/internal/utils/dberrorhandler"
 
 	"wechat-api/internal/svc"
@@ -26,7 +28,11 @@ func NewGetApiEmployeeListLogic(ctx context.Context, svcCtx *svc.ServiceContext)
 }
 
 func (l *GetApiEmployeeListLogic) GetApiEmployeeList(req *types.EmployeeListReq) (*types.EmployeeListResp, error) {
-	data, err := l.svcCtx.DB.Employee.Query().Page(l.ctx, req.Page, req.PageSize)
+	var predicates []predicate.Employee
+	if req.CategoryId != nil && *req.CategoryId > 0 {
+		predicates = append(predicates, employee.CategoryID(*req.CategoryId))
+	}
+	data, err := l.svcCtx.DB.Employee.Query().Where(predicates...).Page(l.ctx, req.Page, req.PageSize)
 
 	if err != nil {
 		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)