fix:mapping expert
This commit is contained in:
parent
c7f334bd00
commit
e72b014fd5
|
|
@ -34,12 +34,27 @@ func NewAgentController(agentService service.AgentService) AgentController {
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param name query string false "Agent name"
|
// @Param name query string false "Agent name"
|
||||||
// @Param type query string false "Agent type"
|
// @Param type query string false "Agent type"
|
||||||
|
// @Param status query string false "Agent status"
|
||||||
// @Success 200 {object} utilRes.Response
|
// @Success 200 {object} utilRes.Response
|
||||||
// @Router /agent [get]
|
// @Router /agent [get]
|
||||||
func (_i *agentController) All(c *fiber.Ctx) error {
|
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{
|
req := request.AgentQueryRequest{
|
||||||
Name: c.Query("name"),
|
Name: c.Query("name"),
|
||||||
Type: c.Query("type"),
|
Type: c.Query("type"),
|
||||||
|
Status: status,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := _i.agentService.All(req)
|
data, err := _i.agentService.All(req)
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ func (_i *agentRepository) GetAll(req request.AgentQueryRequest) (agents []*enti
|
||||||
query = query.Where("name ILIKE ?", "%"+req.Name+"%")
|
query = query.Where("name ILIKE ?", "%"+req.Name+"%")
|
||||||
}
|
}
|
||||||
if req.Type != "" {
|
if req.Type != "" {
|
||||||
query = query.Where("type = ?", req.Type)
|
query = query.Where("type ILIKE ?", "%"+req.Type+"%")
|
||||||
}
|
}
|
||||||
if req.Status != nil {
|
if req.Status != nil {
|
||||||
query = query.Where("status = ?", *req.Status)
|
query = query.Where("status = ?", *req.Status)
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ func (r *userExpertRepository) GetExperts(
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Type != nil {
|
if req.Type != nil {
|
||||||
query = query.Where("work_type = ?", *req.Type)
|
query = query.Where("type ILIKE ?", "%"+*req.Type+"%")
|
||||||
}
|
}
|
||||||
|
|
||||||
err := query.Find(&res).Error
|
err := query.Find(&res).Error
|
||||||
|
|
|
||||||
|
|
@ -77,23 +77,37 @@ if s.UserRepo == nil {
|
||||||
var results []*response.UserExpertResponse
|
var results []*response.UserExpertResponse
|
||||||
|
|
||||||
workReq := workReq.WorkHistoryQueryRequest{
|
workReq := workReq.WorkHistoryQueryRequest{
|
||||||
Pagination: &paginator.Pagination{},
|
Pagination: &paginator.Pagination{
|
||||||
|
Page: 1,
|
||||||
|
Limit: 100,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
eduReq := eduReq.EducationHistoryQueryRequest{
|
eduReq := eduReq.EducationHistoryQueryRequest{
|
||||||
Pagination: &paginator.Pagination{},
|
Pagination: &paginator.Pagination{Page: 1,
|
||||||
|
Limit: 100, },
|
||||||
}
|
}
|
||||||
|
|
||||||
researchReq := researchReq.ResearchJournalsQueryRequest{
|
researchReq := researchReq.ResearchJournalsQueryRequest{
|
||||||
Pagination: &paginator.Pagination{},
|
Pagination: &paginator.Pagination{Page: 1,
|
||||||
|
Limit: 100, },
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
|
|
||||||
|
s.Log.Info().
|
||||||
|
Uint("user_id", user.ID).
|
||||||
|
Msg("Fetching relations for user")
|
||||||
works, _, _ := s.WorkRepo.GetAll(user.ID, workReq)
|
works, _, _ := s.WorkRepo.GetAll(user.ID, workReq)
|
||||||
educations, _, _ := s.EduRepo.GetAll(user.ID, eduReq)
|
educations, _, _ := s.EduRepo.GetAll(user.ID, eduReq)
|
||||||
researches, _, _ := s.ResearchRepo.GetAll(user.ID, researchReq)
|
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{
|
res := &response.UserExpertResponse{
|
||||||
ID: user.ID,
|
ID: user.ID,
|
||||||
Username: user.Username,
|
Username: user.Username,
|
||||||
|
|
|
||||||
|
|
@ -939,6 +939,12 @@ const docTemplate = `{
|
||||||
"description": "Agent type",
|
"description": "Agent type",
|
||||||
"name": "type",
|
"name": "type",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Agent status",
|
||||||
|
"name": "status",
|
||||||
|
"in": "query"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
|
|
||||||
|
|
@ -928,6 +928,12 @@
|
||||||
"description": "Agent type",
|
"description": "Agent type",
|
||||||
"name": "type",
|
"name": "type",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Agent status",
|
||||||
|
"name": "status",
|
||||||
|
"in": "query"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
|
|
||||||
|
|
@ -2064,6 +2064,10 @@ paths:
|
||||||
in: query
|
in: query
|
||||||
name: type
|
name: type
|
||||||
type: string
|
type: string
|
||||||
|
- description: Agent status
|
||||||
|
in: query
|
||||||
|
name: status
|
||||||
|
type: string
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue