feat:get agent by agent id, get agent for user
This commit is contained in:
parent
e72b014fd5
commit
fb4fd0f4a8
|
|
@ -1,6 +1,9 @@
|
||||||
package entity
|
package entity
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
userAgent "narasi-ahli-be/app/database/entity/user_agent"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
type Agent struct {
|
type Agent struct {
|
||||||
ID uint `gorm:"primaryKey" json:"id"`
|
ID uint `gorm:"primaryKey" json:"id"`
|
||||||
|
|
@ -13,4 +16,6 @@ type Agent struct {
|
||||||
IsActive bool `gorm:"default:true" json:"is_active"`
|
IsActive bool `gorm:"default:true" json:"is_active"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
UserAgents []*userAgent.UserAgent `gorm:"foreignKey:AgentID"`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package user_agent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserAgent struct {
|
||||||
|
UserID uint `gorm:"primaryKey;column:user_id"`
|
||||||
|
AgentID uint `gorm:"primaryKey;column:agent_id"`
|
||||||
|
CreatedAt time.Time `gorm:"autoCreateTime"`
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package users
|
package users
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
userAgent "narasi-ahli-be/app/database/entity/user_agent"
|
||||||
userLevels "narasi-ahli-be/app/database/entity/user_levels"
|
userLevels "narasi-ahli-be/app/database/entity/user_levels"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
@ -35,4 +36,6 @@ type Users struct {
|
||||||
IsActive *bool `json:"is_active" gorm:"type:bool;default:true"`
|
IsActive *bool `json:"is_active" gorm:"type:bool;default:true"`
|
||||||
CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
|
CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
|
||||||
UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"`
|
UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"`
|
||||||
|
UserAgents []userAgent.UserAgent `gorm:"foreignKey:UserID"`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ func (_i *AgentRouter) RegisterAgentRoutes() {
|
||||||
_i.App.Route("/agent", func(router fiber.Router) {
|
_i.App.Route("/agent", func(router fiber.Router) {
|
||||||
router.Get("/", agentController.All)
|
router.Get("/", agentController.All)
|
||||||
router.Get("/:id", agentController.Show)
|
router.Get("/:id", agentController.Show)
|
||||||
|
router.Get("/agent_id/:agentId", agentController.FindByAgentId)
|
||||||
|
|
||||||
router.Post("/", agentController.Save)
|
router.Post("/", agentController.Save)
|
||||||
router.Delete("/:id", agentController.Delete)
|
router.Delete("/:id", agentController.Delete)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ type AgentController interface {
|
||||||
Save(c *fiber.Ctx) error
|
Save(c *fiber.Ctx) error
|
||||||
Update(c *fiber.Ctx) error
|
Update(c *fiber.Ctx) error
|
||||||
Delete(c *fiber.Ctx) error
|
Delete(c *fiber.Ctx) error
|
||||||
|
FindByAgentId(c *fiber.Ctx) error
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAgentController(agentService service.AgentService) AgentController {
|
func NewAgentController(agentService service.AgentService) AgentController {
|
||||||
|
|
@ -151,3 +153,21 @@ func (_i *agentController) Delete(c *fiber.Ctx) error {
|
||||||
}
|
}
|
||||||
return utilRes.Resp(c, utilRes.Response{Success: true})
|
return utilRes.Resp(c, utilRes.Response{Success: true})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show godoc
|
||||||
|
// @Summary Get agent by AgentID
|
||||||
|
// @Tags Agent
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param agentId path string true "Agent ID"
|
||||||
|
// @Success 200 {object} utilRes.Response
|
||||||
|
// @Router /agent/agent_id/{agentId} [get]
|
||||||
|
func (_i *agentController) FindByAgentId(c *fiber.Ctx) error {
|
||||||
|
id:= c.Params("agentId")
|
||||||
|
data, err := _i.agentService.FindByAgentId(id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return utilRes.Resp(c, utilRes.Response{Success: true, Data: data})
|
||||||
|
}
|
||||||
|
|
@ -16,6 +16,9 @@ type AgentRepository interface {
|
||||||
Create(agent *entity.Agent) (*entity.Agent, error)
|
Create(agent *entity.Agent) (*entity.Agent, error)
|
||||||
Update(id uint, data map[string]interface{}) error
|
Update(id uint, data map[string]interface{}) error
|
||||||
Delete(id uint) error
|
Delete(id uint) error
|
||||||
|
|
||||||
|
FindByAgentId(agentId string) (*entity.Agent, error)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAgentRepository(db *database.Database) AgentRepository {
|
func NewAgentRepository(db *database.Database) AgentRepository {
|
||||||
|
|
@ -50,6 +53,16 @@ func (_i *agentRepository) FindById(id uint) (*entity.Agent, error) {
|
||||||
return &agent, nil
|
return &agent, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (_i *agentRepository) FindByAgentId(agentId string) (*entity.Agent, error) {
|
||||||
|
var agent entity.Agent
|
||||||
|
err := _i.DB.DB.Where("agent_id = ? ", agentId).
|
||||||
|
First(&agent).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &agent, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (_i *agentRepository) Create(agent *entity.Agent) (*entity.Agent, error) {
|
func (_i *agentRepository) Create(agent *entity.Agent) (*entity.Agent, error) {
|
||||||
if err := _i.DB.DB.Create(agent).Error; err != nil {
|
if err := _i.DB.DB.Create(agent).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ type AgentService interface {
|
||||||
Save(req request.AgentCreateRequest) (*response.AgentResponse, error)
|
Save(req request.AgentCreateRequest) (*response.AgentResponse, error)
|
||||||
Update(id uint, req request.AgentUpdateRequest) error
|
Update(id uint, req request.AgentUpdateRequest) error
|
||||||
Delete(id uint) error
|
Delete(id uint) error
|
||||||
|
FindByAgentId(id string) (*response.AgentResponse, error)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAgentService(repo repository.AgentRepository, log zerolog.Logger) AgentService {
|
func NewAgentService(repo repository.AgentRepository, log zerolog.Logger) AgentService {
|
||||||
|
|
@ -47,6 +49,14 @@ func (_i *agentService) Show(id uint) (*response.AgentResponse, error) {
|
||||||
return mapper.AgentResponseMapper(result), nil
|
return mapper.AgentResponseMapper(result), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (_i *agentService) FindByAgentId(agentId string) (*response.AgentResponse, error) {
|
||||||
|
result, err := _i.Repo.FindByAgentId(agentId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.New("agent not found")
|
||||||
|
}
|
||||||
|
return mapper.AgentResponseMapper(result), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (_i *agentService) Save(req request.AgentCreateRequest) (*response.AgentResponse, error) {
|
func (_i *agentService) Save(req request.AgentCreateRequest) (*response.AgentResponse, error) {
|
||||||
entity := req.ToEntity()
|
entity := req.ToEntity()
|
||||||
result, err := _i.Repo.Create(entity)
|
result, err := _i.Repo.Create(entity)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
package controller
|
||||||
|
|
||||||
|
import (
|
||||||
|
userAgentService "narasi-ahli-be/app/module/user_agent/service"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Controller struct {
|
||||||
|
UserAgent UserAgentController
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewController(service userAgentService.UserAgentService) *Controller {
|
||||||
|
return &Controller{
|
||||||
|
UserAgent: NewUserAgentController(service),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,120 @@
|
||||||
|
package controller
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"narasi-ahli-be/app/module/user_agent/request"
|
||||||
|
"narasi-ahli-be/app/module/user_agent/response"
|
||||||
|
"narasi-ahli-be/app/module/user_agent/service"
|
||||||
|
utilRes "narasi-ahli-be/utils/response"
|
||||||
|
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
type userAgentController struct {
|
||||||
|
userAgentService service.UserAgentService
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserAgentController interface {
|
||||||
|
UpdateUserAgents(c *fiber.Ctx) error
|
||||||
|
GetAgentsByUser(c *fiber.Ctx) error
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func NewUserAgentController(userAgentService service.UserAgentService) UserAgentController {
|
||||||
|
return &userAgentController{userAgentService: userAgentService}
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateUserAgentRequest struct {
|
||||||
|
UserID uint `json:"userId"`
|
||||||
|
AgentIDs []uint `json:"agentIds"`
|
||||||
|
}
|
||||||
|
// UpdateUserAgents godoc
|
||||||
|
// @Summary Update agents assigned to user
|
||||||
|
// @Description Replace all agent mapping for a user
|
||||||
|
// @Tags User Agent
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param request body request.UpdateUserAgentRequest true "User Agent Mapping"
|
||||||
|
// @Success 200 {object} response.UpdateUserAgentResponse
|
||||||
|
// @Failure 400 {object} response.ErrorResponse
|
||||||
|
// @Failure 500 {object} response.ErrorResponse
|
||||||
|
// @Router /user-agent [put]
|
||||||
|
func (c *userAgentController) UpdateUserAgents(ctx *fiber.Ctx) error {
|
||||||
|
var req request.UpdateUserAgentRequest
|
||||||
|
|
||||||
|
if err := ctx.BodyParser(&req); err != nil {
|
||||||
|
return ctx.Status(fiber.StatusBadRequest).JSON(response.ErrorResponse{
|
||||||
|
Message: "invalid request",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
err := c.userAgentService.UpdateUserAgents(req.UserID, req.AgentID)
|
||||||
|
if err != nil {
|
||||||
|
return ctx.Status(fiber.StatusInternalServerError).JSON(response.ErrorResponse{
|
||||||
|
Message: err.Error(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.JSON(response.UpdateUserAgentResponse{
|
||||||
|
Message: "user agents updated",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAgentsByUser godoc
|
||||||
|
// @Summary Get agents by user
|
||||||
|
// @Description Get all agent IDs assigned to a user
|
||||||
|
// @Tags User Agent
|
||||||
|
// @Produce json
|
||||||
|
// @Param user_id query int true "User ID"
|
||||||
|
// @Success 200 {object} response.GetUserAgentResponse
|
||||||
|
// @Failure 400 {object} response.ErrorResponse
|
||||||
|
// @Failure 500 {object} response.ErrorResponse
|
||||||
|
// @Router /user-agent [get]
|
||||||
|
func (c *userAgentController) GetAgentsByUser(ctx *fiber.Ctx) error {
|
||||||
|
|
||||||
|
userIDStr := ctx.Query("user_id")
|
||||||
|
userID, err := strconv.Atoi(userIDStr)
|
||||||
|
if err != nil || userID == 0 {
|
||||||
|
return ctx.Status(fiber.StatusBadRequest).JSON(response.ErrorResponse{
|
||||||
|
Message: "user_id required",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
agents, err := c.userAgentService.GetAgentsByUser(uint(userID))
|
||||||
|
if err != nil {
|
||||||
|
return ctx.Status(fiber.StatusInternalServerError).JSON(response.ErrorResponse{
|
||||||
|
Message: err.Error(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
var agentResponses []response.AgentDetail
|
||||||
|
|
||||||
|
for _, a := range agents {
|
||||||
|
agentResponses = append(agentResponses, response.AgentDetail{
|
||||||
|
ID: a.ID,
|
||||||
|
AgentID: a.AgentID,
|
||||||
|
Name: a.Name,
|
||||||
|
Description: a.Description,
|
||||||
|
Instructions: a.Instructions,
|
||||||
|
Type: a.Type,
|
||||||
|
Status: a.Status,
|
||||||
|
IsActive: a.IsActive,
|
||||||
|
CreatedAt: a.CreatedAt,
|
||||||
|
UpdatedAt: a.UpdatedAt,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// return ctx.JSON(response.GetUserAgentResponse{
|
||||||
|
// UserID: uint(userID),
|
||||||
|
// Agents: agentResponses,
|
||||||
|
// })
|
||||||
|
return utilRes.Resp(ctx, utilRes.Response{
|
||||||
|
Success: true,
|
||||||
|
Data: response.GetUserAgentResponse{
|
||||||
|
UserID: uint(userID),
|
||||||
|
Agents: agentResponses,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
package repository
|
||||||
|
|
||||||
|
import (
|
||||||
|
"narasi-ahli-be/app/database"
|
||||||
|
"narasi-ahli-be/app/database/entity"
|
||||||
|
"narasi-ahli-be/app/database/entity/user_agent"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserAgentRepository interface {
|
||||||
|
ReplaceUserAgents(userID uint, agentIDs []uint) error
|
||||||
|
GetAgentsByUser(userID uint) ([]entity.Agent, error)
|
||||||
|
ValidateAgents(agentIDs []uint) ([]uint, error)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type userAgentRepository struct {
|
||||||
|
DB *database.Database
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUserAgentRepository(db *database.Database) UserAgentRepository {
|
||||||
|
return &userAgentRepository{DB: db}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *userAgentRepository) ReplaceUserAgents(userID uint, agentIDs []uint) error {
|
||||||
|
|
||||||
|
tx := r.DB.DB.Begin()
|
||||||
|
|
||||||
|
if err := tx.Where("user_id = ?", userID).
|
||||||
|
Delete(&user_agent.UserAgent{}).Error; err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(agentIDs) == 0 {
|
||||||
|
return tx.Commit().Error
|
||||||
|
}
|
||||||
|
|
||||||
|
var mappings []user_agent.UserAgent
|
||||||
|
for _, aid := range agentIDs {
|
||||||
|
mappings = append(mappings, user_agent.UserAgent{
|
||||||
|
UserID: userID,
|
||||||
|
AgentID: aid,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := tx.Create(&mappings).Error; err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return tx.Commit().Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *userAgentRepository) GetAgentsByUser(userID uint) ([]entity.Agent, error) {
|
||||||
|
var agents []entity.Agent
|
||||||
|
|
||||||
|
err := r.DB.DB.
|
||||||
|
Table("user_agents ua").
|
||||||
|
Select("a.*").
|
||||||
|
Joins("JOIN agents a ON a.id = ua.agent_id").
|
||||||
|
Where("ua.user_id = ?", userID).
|
||||||
|
Scan(&agents).Error
|
||||||
|
|
||||||
|
return agents, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *userAgentRepository) ValidateAgents(agentIDs []uint) ([]uint, error) {
|
||||||
|
var validIDs []uint
|
||||||
|
|
||||||
|
err := r.DB.DB.
|
||||||
|
Table("agents").
|
||||||
|
Where("id IN ?", agentIDs).
|
||||||
|
Pluck("id", &validIDs).Error
|
||||||
|
|
||||||
|
return validIDs, err
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
package request
|
||||||
|
|
||||||
|
type UpdateUserAgentRequest struct {
|
||||||
|
UserID uint `json:"user_id" validate:"required"`
|
||||||
|
AgentID []uint `json:"agent_id"` // boleh kosong
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetUserAgentRequest struct {
|
||||||
|
UserID uint `query:"user_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package response
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type UpdateUserAgentResponse struct {
|
||||||
|
Message string `json:"message"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AgentDetail struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
AgentID string `json:"agentId"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
Instructions string `json:"instructions"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Status bool `json:"status"`
|
||||||
|
IsActive bool `json:"isActive"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetUserAgentResponse struct {
|
||||||
|
UserID uint `json:"userId"`
|
||||||
|
Agents []AgentDetail `json:"agentId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ErrorResponse struct {
|
||||||
|
Message string `json:"message"`
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"narasi-ahli-be/app/database/entity"
|
||||||
|
"narasi-ahli-be/app/module/user_agent/repository"
|
||||||
|
|
||||||
|
"github.com/rs/zerolog"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserAgentService interface {
|
||||||
|
UpdateUserAgents(userID uint, agentIDs []uint) error
|
||||||
|
GetAgentsByUser(userID uint) ([]entity.Agent, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type userAgentService struct {
|
||||||
|
Repo repository.UserAgentRepository
|
||||||
|
Log zerolog.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func NewUserAgentService(repo repository.UserAgentRepository, log zerolog.Logger) UserAgentService {
|
||||||
|
return &userAgentService{Repo: repo, Log: log}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *userAgentService) UpdateUserAgents(userID uint, agentIDs []uint) error {
|
||||||
|
|
||||||
|
// kosong → valid (lepas semua agent)
|
||||||
|
if len(agentIDs) == 0 {
|
||||||
|
return s.Repo.ReplaceUserAgents(userID, agentIDs)
|
||||||
|
}
|
||||||
|
|
||||||
|
validIDs, err := s.Repo.ValidateAgents(agentIDs)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// cek apakah ada agent yang tidak exist
|
||||||
|
if len(validIDs) != len(agentIDs) {
|
||||||
|
return errors.New("one or more agent_id not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.Repo.ReplaceUserAgents(userID, agentIDs)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *userAgentService) GetAgentsByUser(userID uint) ([]entity.Agent, error) {
|
||||||
|
return s.Repo.GetAgentsByUser(userID)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
package user_agent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"narasi-ahli-be/app/module/user_agent/controller"
|
||||||
|
"narasi-ahli-be/app/module/user_agent/repository"
|
||||||
|
"narasi-ahli-be/app/module/user_agent/service"
|
||||||
|
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"go.uber.org/fx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserAgentRouter struct {
|
||||||
|
App fiber.Router
|
||||||
|
Controller *controller.Controller
|
||||||
|
}
|
||||||
|
|
||||||
|
var NewUserAgentModule = fx.Options(
|
||||||
|
|
||||||
|
// repository
|
||||||
|
fx.Provide(repository.NewUserAgentRepository),
|
||||||
|
|
||||||
|
// service
|
||||||
|
fx.Provide(service.NewUserAgentService),
|
||||||
|
|
||||||
|
// controller
|
||||||
|
fx.Provide(controller.NewController),
|
||||||
|
|
||||||
|
// router
|
||||||
|
fx.Provide(NewUserAgentRouter),
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewUserAgentRouter(app *fiber.App, controller *controller.Controller) *UserAgentRouter {
|
||||||
|
return &UserAgentRouter{
|
||||||
|
App: app,
|
||||||
|
Controller: controller,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *UserAgentRouter) RegisterUserAgentRoutes() {
|
||||||
|
userAgentController := r.Controller.UserAgent
|
||||||
|
|
||||||
|
r.App.Route("/user-agent", func(router fiber.Router) {
|
||||||
|
|
||||||
|
// GET mapping agents by user
|
||||||
|
router.Get("/", userAgentController.GetAgentsByUser)
|
||||||
|
|
||||||
|
// UPDATE mapping (replace)
|
||||||
|
router.Put("/", userAgentController.UpdateUserAgents)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -28,6 +28,7 @@ import (
|
||||||
"narasi-ahli-be/app/module/provinces"
|
"narasi-ahli-be/app/module/provinces"
|
||||||
"narasi-ahli-be/app/module/research_journals"
|
"narasi-ahli-be/app/module/research_journals"
|
||||||
"narasi-ahli-be/app/module/subscription"
|
"narasi-ahli-be/app/module/subscription"
|
||||||
|
"narasi-ahli-be/app/module/user_agent"
|
||||||
"narasi-ahli-be/app/module/user_levels"
|
"narasi-ahli-be/app/module/user_levels"
|
||||||
"narasi-ahli-be/app/module/user_role_accesses"
|
"narasi-ahli-be/app/module/user_role_accesses"
|
||||||
"narasi-ahli-be/app/module/user_roles"
|
"narasi-ahli-be/app/module/user_roles"
|
||||||
|
|
@ -75,7 +76,9 @@ type Router struct {
|
||||||
ResearchJournalsRouter *research_journals.ResearchJournalsRouter
|
ResearchJournalsRouter *research_journals.ResearchJournalsRouter
|
||||||
AIChatFilesRouter *ai_chat_files.AiChatFilesRouter
|
AIChatFilesRouter *ai_chat_files.AiChatFilesRouter
|
||||||
NotificationRouter *notifications.NotificationRouter
|
NotificationRouter *notifications.NotificationRouter
|
||||||
AgentRouter *agent.AgentRouter
|
AgentRouter *agent.AgentRouter
|
||||||
|
UserAgentRouter *user_agent.UserAgentRouter
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRouter(
|
func NewRouter(
|
||||||
|
|
@ -114,6 +117,8 @@ func NewRouter(
|
||||||
aiChatFilesRouter *ai_chat_files.AiChatFilesRouter,
|
aiChatFilesRouter *ai_chat_files.AiChatFilesRouter,
|
||||||
notificationRouter *notifications.NotificationRouter,
|
notificationRouter *notifications.NotificationRouter,
|
||||||
agentRouter *agent.AgentRouter,
|
agentRouter *agent.AgentRouter,
|
||||||
|
userAgentRouter *user_agent.UserAgentRouter,
|
||||||
|
|
||||||
|
|
||||||
) *Router {
|
) *Router {
|
||||||
return &Router{
|
return &Router{
|
||||||
|
|
@ -151,6 +156,8 @@ func NewRouter(
|
||||||
AIChatFilesRouter: aiChatFilesRouter,
|
AIChatFilesRouter: aiChatFilesRouter,
|
||||||
NotificationRouter: notificationRouter,
|
NotificationRouter: notificationRouter,
|
||||||
AgentRouter: agentRouter,
|
AgentRouter: agentRouter,
|
||||||
|
UserAgentRouter: userAgentRouter,
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -198,6 +205,7 @@ func (r *Router) Register() {
|
||||||
r.AIChatFilesRouter.RegisterAiChatFilesRoutes()
|
r.AIChatFilesRouter.RegisterAiChatFilesRoutes()
|
||||||
r.NotificationRouter.RegisterNotificationRoutes()
|
r.NotificationRouter.RegisterNotificationRoutes()
|
||||||
r.AgentRouter.RegisterAgentRoutes()
|
r.AgentRouter.RegisterAgentRoutes()
|
||||||
|
r.UserAgentRouter.RegisterUserAgentRoutes()
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -988,6 +988,37 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/agent/agent_id/{agentId}": {
|
||||||
|
"get": {
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Agent"
|
||||||
|
],
|
||||||
|
"summary": "Get agent by AgentID",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Agent ID",
|
||||||
|
"name": "agentId",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.Response"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/agent/{id}": {
|
"/agent/{id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"consumes": [
|
"consumes": [
|
||||||
|
|
@ -13666,6 +13697,91 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/user-agent": {
|
||||||
|
"get": {
|
||||||
|
"description": "Get all agent IDs assigned to a user",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"User Agent"
|
||||||
|
],
|
||||||
|
"summary": "Get agents by user",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "User ID",
|
||||||
|
"name": "user_id",
|
||||||
|
"in": "query",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.GetUserAgentResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.ErrorResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.ErrorResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"put": {
|
||||||
|
"description": "Replace all agent mapping for a user",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"User Agent"
|
||||||
|
],
|
||||||
|
"summary": "Update agents assigned to user",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "User Agent Mapping",
|
||||||
|
"name": "request",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/request.UpdateUserAgentRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.UpdateUserAgentResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.ErrorResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.ErrorResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/user-levels": {
|
"/user-levels": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
|
|
@ -17921,6 +18037,24 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"request.UpdateUserAgentRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"user_id"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"agent_id": {
|
||||||
|
"description": "boleh kosong",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"user_id": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"request.UserEmailValidationRequest": {
|
"request.UserEmailValidationRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
@ -18436,6 +18570,41 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"response.AgentDetail": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"agentId": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"createdAt": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"instructions": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"isActive": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"updatedAt": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"response.BadRequestError": {
|
"response.BadRequestError": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
@ -18453,6 +18622,28 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"response.ErrorResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"message": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response.GetUserAgentResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"agentId": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/response.AgentDetail"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userId": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"response.InternalServerError": {
|
"response.InternalServerError": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
@ -18505,6 +18696,14 @@ const docTemplate = `{
|
||||||
"example": false
|
"example": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"response.UpdateUserAgentResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"message": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
|
|
|
||||||
|
|
@ -977,6 +977,37 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/agent/agent_id/{agentId}": {
|
||||||
|
"get": {
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Agent"
|
||||||
|
],
|
||||||
|
"summary": "Get agent by AgentID",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Agent ID",
|
||||||
|
"name": "agentId",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.Response"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/agent/{id}": {
|
"/agent/{id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"consumes": [
|
"consumes": [
|
||||||
|
|
@ -13655,6 +13686,91 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/user-agent": {
|
||||||
|
"get": {
|
||||||
|
"description": "Get all agent IDs assigned to a user",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"User Agent"
|
||||||
|
],
|
||||||
|
"summary": "Get agents by user",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "User ID",
|
||||||
|
"name": "user_id",
|
||||||
|
"in": "query",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.GetUserAgentResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.ErrorResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.ErrorResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"put": {
|
||||||
|
"description": "Replace all agent mapping for a user",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"User Agent"
|
||||||
|
],
|
||||||
|
"summary": "Update agents assigned to user",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "User Agent Mapping",
|
||||||
|
"name": "request",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/request.UpdateUserAgentRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.UpdateUserAgentResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.ErrorResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.ErrorResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/user-levels": {
|
"/user-levels": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
|
|
@ -17910,6 +18026,24 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"request.UpdateUserAgentRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"user_id"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"agent_id": {
|
||||||
|
"description": "boleh kosong",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"user_id": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"request.UserEmailValidationRequest": {
|
"request.UserEmailValidationRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
@ -18425,6 +18559,41 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"response.AgentDetail": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"agentId": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"createdAt": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"instructions": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"isActive": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"updatedAt": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"response.BadRequestError": {
|
"response.BadRequestError": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
@ -18442,6 +18611,28 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"response.ErrorResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"message": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response.GetUserAgentResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"agentId": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/response.AgentDetail"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userId": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"response.InternalServerError": {
|
"response.InternalServerError": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
@ -18494,6 +18685,14 @@
|
||||||
"example": false
|
"example": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"response.UpdateUserAgentResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"message": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1071,6 +1071,18 @@ definitions:
|
||||||
- email
|
- email
|
||||||
- id
|
- id
|
||||||
type: object
|
type: object
|
||||||
|
request.UpdateUserAgentRequest:
|
||||||
|
properties:
|
||||||
|
agent_id:
|
||||||
|
description: boleh kosong
|
||||||
|
items:
|
||||||
|
type: integer
|
||||||
|
type: array
|
||||||
|
user_id:
|
||||||
|
type: integer
|
||||||
|
required:
|
||||||
|
- user_id
|
||||||
|
type: object
|
||||||
request.UserEmailValidationRequest:
|
request.UserEmailValidationRequest:
|
||||||
properties:
|
properties:
|
||||||
newEmail:
|
newEmail:
|
||||||
|
|
@ -1425,6 +1437,29 @@ definitions:
|
||||||
- jobTitle
|
- jobTitle
|
||||||
- startDate
|
- startDate
|
||||||
type: object
|
type: object
|
||||||
|
response.AgentDetail:
|
||||||
|
properties:
|
||||||
|
agentId:
|
||||||
|
type: string
|
||||||
|
createdAt:
|
||||||
|
type: string
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
instructions:
|
||||||
|
type: string
|
||||||
|
isActive:
|
||||||
|
type: boolean
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
status:
|
||||||
|
type: boolean
|
||||||
|
type:
|
||||||
|
type: string
|
||||||
|
updatedAt:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
response.BadRequestError:
|
response.BadRequestError:
|
||||||
properties:
|
properties:
|
||||||
code:
|
code:
|
||||||
|
|
@ -1437,6 +1472,20 @@ definitions:
|
||||||
example: false
|
example: false
|
||||||
type: boolean
|
type: boolean
|
||||||
type: object
|
type: object
|
||||||
|
response.ErrorResponse:
|
||||||
|
properties:
|
||||||
|
message:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
response.GetUserAgentResponse:
|
||||||
|
properties:
|
||||||
|
agentId:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/response.AgentDetail'
|
||||||
|
type: array
|
||||||
|
userId:
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
response.InternalServerError:
|
response.InternalServerError:
|
||||||
properties:
|
properties:
|
||||||
code:
|
code:
|
||||||
|
|
@ -1475,6 +1524,11 @@ definitions:
|
||||||
example: false
|
example: false
|
||||||
type: boolean
|
type: boolean
|
||||||
type: object
|
type: object
|
||||||
|
response.UpdateUserAgentResponse:
|
||||||
|
properties:
|
||||||
|
message:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
info:
|
info:
|
||||||
contact: {}
|
contact: {}
|
||||||
paths:
|
paths:
|
||||||
|
|
@ -2162,6 +2216,26 @@ paths:
|
||||||
summary: Update agent
|
summary: Update agent
|
||||||
tags:
|
tags:
|
||||||
- Agent
|
- Agent
|
||||||
|
/agent/agent_id/{agentId}:
|
||||||
|
get:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: Agent ID
|
||||||
|
in: path
|
||||||
|
name: agentId
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.Response'
|
||||||
|
summary: Get agent by AgentID
|
||||||
|
tags:
|
||||||
|
- Agent
|
||||||
/ai-chat-files:
|
/ai-chat-files:
|
||||||
get:
|
get:
|
||||||
description: API for getting all AiChatFiles
|
description: API for getting all AiChatFiles
|
||||||
|
|
@ -10198,6 +10272,62 @@ paths:
|
||||||
summary: update Subscription
|
summary: update Subscription
|
||||||
tags:
|
tags:
|
||||||
- Subscription
|
- Subscription
|
||||||
|
/user-agent:
|
||||||
|
get:
|
||||||
|
description: Get all agent IDs assigned to a user
|
||||||
|
parameters:
|
||||||
|
- description: User ID
|
||||||
|
in: query
|
||||||
|
name: user_id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.GetUserAgentResponse'
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.ErrorResponse'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.ErrorResponse'
|
||||||
|
summary: Get agents by user
|
||||||
|
tags:
|
||||||
|
- User Agent
|
||||||
|
put:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Replace all agent mapping for a user
|
||||||
|
parameters:
|
||||||
|
- description: User Agent Mapping
|
||||||
|
in: body
|
||||||
|
name: request
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/request.UpdateUserAgentRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.UpdateUserAgentResponse'
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.ErrorResponse'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.ErrorResponse'
|
||||||
|
summary: Update agents assigned to user
|
||||||
|
tags:
|
||||||
|
- User Agent
|
||||||
/user-levels:
|
/user-levels:
|
||||||
get:
|
get:
|
||||||
description: API for getting all UserLevels
|
description: API for getting all UserLevels
|
||||||
|
|
|
||||||
2
main.go
2
main.go
|
|
@ -30,6 +30,7 @@ import (
|
||||||
"narasi-ahli-be/app/module/provinces"
|
"narasi-ahli-be/app/module/provinces"
|
||||||
"narasi-ahli-be/app/module/research_journals"
|
"narasi-ahli-be/app/module/research_journals"
|
||||||
"narasi-ahli-be/app/module/subscription"
|
"narasi-ahli-be/app/module/subscription"
|
||||||
|
"narasi-ahli-be/app/module/user_agent"
|
||||||
"narasi-ahli-be/app/module/user_levels"
|
"narasi-ahli-be/app/module/user_levels"
|
||||||
"narasi-ahli-be/app/module/user_role_accesses"
|
"narasi-ahli-be/app/module/user_role_accesses"
|
||||||
"narasi-ahli-be/app/module/user_role_level_details"
|
"narasi-ahli-be/app/module/user_role_level_details"
|
||||||
|
|
@ -103,6 +104,7 @@ func main() {
|
||||||
ai_chat_files.NewAiChatFilesModule,
|
ai_chat_files.NewAiChatFilesModule,
|
||||||
notifications.NewNotificationsModule,
|
notifications.NewNotificationsModule,
|
||||||
agent.NewAgentModule,
|
agent.NewAgentModule,
|
||||||
|
user_agent.NewUserAgentModule,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue