fix:mapping expert

This commit is contained in:
Rama Priyanto 2026-02-02 01:14:12 +07:00
parent c7f334bd00
commit e72b014fd5
7 changed files with 50 additions and 5 deletions

View File

@ -34,12 +34,27 @@ func NewAgentController(agentService service.AgentService) AgentController {
// @Produce json
// @Param name query string false "Agent name"
// @Param type query string false "Agent type"
// @Param status query string false "Agent status"
// @Success 200 {object} utilRes.Response
// @Router /agent [get]
func (_i *agentController) All(c *fiber.Ctx) error {
statusStr := c.Query("status")
var status *bool
if statusStr != "" {
val, err := strconv.ParseBool(statusStr)
if err != nil {
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
"message": "status must be true or false",
})
}
status = &val
}
req := request.AgentQueryRequest{
Name: c.Query("name"),
Type: c.Query("type"),
Status: status,
}
data, err := _i.agentService.All(req)

View File

@ -30,7 +30,7 @@ func (_i *agentRepository) GetAll(req request.AgentQueryRequest) (agents []*enti
query = query.Where("name ILIKE ?", "%"+req.Name+"%")
}
if req.Type != "" {
query = query.Where("type = ?", req.Type)
query = query.Where("type ILIKE ?", "%"+req.Type+"%")
}
if req.Status != nil {
query = query.Where("status = ?", *req.Status)

View File

@ -49,7 +49,7 @@ func (r *userExpertRepository) GetExperts(
}
if req.Type != nil {
query = query.Where("work_type = ?", *req.Type)
query = query.Where("type ILIKE ?", "%"+*req.Type+"%")
}
err := query.Find(&res).Error

View File

@ -77,23 +77,37 @@ if s.UserRepo == nil {
var results []*response.UserExpertResponse
workReq := workReq.WorkHistoryQueryRequest{
Pagination: &paginator.Pagination{},
Pagination: &paginator.Pagination{
Page: 1,
Limit: 100,
},
}
eduReq := eduReq.EducationHistoryQueryRequest{
Pagination: &paginator.Pagination{},
Pagination: &paginator.Pagination{Page: 1,
Limit: 100, },
}
researchReq := researchReq.ResearchJournalsQueryRequest{
Pagination: &paginator.Pagination{},
Pagination: &paginator.Pagination{Page: 1,
Limit: 100, },
}
for _, user := range users {
s.Log.Info().
Uint("user_id", user.ID).
Msg("Fetching relations for user")
works, _, _ := s.WorkRepo.GetAll(user.ID, workReq)
educations, _, _ := s.EduRepo.GetAll(user.ID, eduReq)
researches, _, _ := s.ResearchRepo.GetAll(user.ID, researchReq)
s.Log.Info().
Int("work_count", len(works)).
Int("edu_count", len(educations)).
Int("research_count", len(researches)).
Msg("Relation result count")
res := &response.UserExpertResponse{
ID: user.ID,
Username: user.Username,

View File

@ -939,6 +939,12 @@ const docTemplate = `{
"description": "Agent type",
"name": "type",
"in": "query"
},
{
"type": "string",
"description": "Agent status",
"name": "status",
"in": "query"
}
],
"responses": {

View File

@ -928,6 +928,12 @@
"description": "Agent type",
"name": "type",
"in": "query"
},
{
"type": "string",
"description": "Agent status",
"name": "status",
"in": "query"
}
],
"responses": {

View File

@ -2064,6 +2064,10 @@ paths:
in: query
name: type
type: string
- description: Agent status
in: query
name: status
type: string
produces:
- application/json
responses: