Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

remove: useless controller

LinkinStarc5df2f95a9c8
diff --git a/internal/controller/useless/collection_group_controller.go b/internal/controller/useless/collection_group_controller.go
deleted file mode 100644
index 7da94ff7..00000000
--- a/internal/controller/useless/collection_group_controller.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package useless
-
-import (
- "github.com/gin-gonic/gin"
- "github.com/segmentfault/answer/internal/base/handler"
- "github.com/segmentfault/answer/internal/schema"
- "github.com/segmentfault/answer/internal/service"
- "github.com/segmentfault/pacman/log"
-)
-
-// CollectionGroupController collectionGroup controller
-type CollectionGroupController struct {
- log log.log
- collectionGroupService *service.CollectionGroupService
-}
-
-// NewCollectionGroupController new controller
-func NewCollectionGroupController(collectionGroupService *service.CollectionGroupService) *CollectionGroupController {
- return &CollectionGroupController{collectionGroupService: collectionGroupService}
-}
-
-// AddCollectionGroup add collection group
-// @Summary add collection group
-// @Description add collection group
-// @Tags CollectionGroup
-// @Accept json
-// @Produce json
-// @Param data body schema.AddCollectionGroupReq true "collection group"
-// @Success 200 {object} handler.RespBody
-// Router /collection-group [post]
-func (cc *CollectionGroupController) AddCollectionGroup(ctx *gin.Context) {
- req := &schema.AddCollectionGroupReq{}
- if handler.BindAndCheck(ctx, req) {
- return
- }
-
- err := cc.collectionGroupService.AddCollectionGroup(ctx, req)
- handler.HandleResponse(ctx, err, nil)
-}
-
-// UpdateCollectionGroup update collection group
-// @Summary update collection group
-// @Description update collection group
-// @Tags CollectionGroup
-// @Accept json
-// @Produce json
-// @Param data body schema.UpdateCollectionGroupReq true "collection group"
-// @Success 200 {object} handler.RespBody
-// Router /collection-group [put]
-func (cc *CollectionGroupController) UpdateCollectionGroup(ctx *gin.Context) {
- req := &schema.UpdateCollectionGroupReq{}
- if handler.BindAndCheck(ctx, req) {
- return
- }
-
- err := cc.collectionGroupService.UpdateCollectionGroup(ctx, req, []string{})
- handler.HandleResponse(ctx, err, nil)
-}
diff --git a/internal/controller/useless/notification_read_controller.go b/internal/controller/useless/notification_read_controller.go
deleted file mode 100644
index 22136383..00000000
--- a/internal/controller/useless/notification_read_controller.go
+++ /dev/null
@@ -1,143 +0,0 @@
-package useless
-
-import (
- "strconv"
-
- "github.com/gin-gonic/gin"
- "github.com/segmentfault/answer/internal/base/handler"
- "github.com/segmentfault/answer/internal/base/reason"
- "github.com/segmentfault/answer/internal/schema"
- "github.com/segmentfault/answer/internal/service/notification"
- "github.com/segmentfault/pacman/errors"
- "github.com/segmentfault/pacman/log"
-)
-
-// NotificationReadController notificationRead controller
-type NotificationReadController struct {
- log log.log
- notificationReadService *notification.NotificationReadService
-}
-
-// NewNotificationReadController new controller
-func NewNotificationReadController(notificationReadService *notification.NotificationReadService) *NotificationReadController {
- return &NotificationReadController{notificationReadService: notificationReadService}
-}
-
-// AddNotificationRead add notification read record
-// @Summary add notification read record
-// @Description add notification read record
-// @Tags NotificationRead
-// @Accept json
-// @Produce json
-// @Param data body schema.AddNotificationReadReq true "notification read record"
-// @Success 200 {object} handler.RespBody
-// Router /notification-read [post]
-func (nc *NotificationReadController) AddNotificationRead(ctx *gin.Context) {
- req := &schema.AddNotificationReadReq{}
- if handler.BindAndCheck(ctx, req) {
- return
- }
-
- err := nc.notificationReadService.AddNotificationRead(ctx, req)
- handler.HandleResponse(ctx, err, nil)
-}
-
-// RemoveNotificationRead delete notification read record
-// @Summary delete notification read record
-// @Description delete notification read record
-// @Tags NotificationRead
-// @Accept json
-// @Produce json
-// @Param data body schema.RemoveNotificationReadReq true "notification read record"
-// @Success 200 {object} handler.RespBody
-// Router /notification-read [delete]
-func (nc *NotificationReadController) RemoveNotificationRead(ctx *gin.Context) {
- req := &schema.RemoveNotificationReadReq{}
- if handler.BindAndCheck(ctx, req) {
- return
- }
-
- err := nc.notificationReadService.RemoveNotificationRead(ctx, req.ID)
- handler.HandleResponse(ctx, err, nil)
-}
-
-// UpdateNotificationRead update notification read record
-// @Summary update notification read record
-// @Description update notification read record
-// @Tags NotificationRead
-// @Accept json
-// @Produce json
-// @Param data body schema.UpdateNotificationReadReq true "notification read record"
-// @Success 200 {object} handler.RespBody
-// Router /notification-read [put]
-func (nc *NotificationReadController) UpdateNotificationRead(ctx *gin.Context) {
- req := &schema.UpdateNotificationReadReq{}
- if handler.BindAndCheck(ctx, req) {
- return
- }
-
- err := nc.notificationReadService.UpdateNotificationRead(ctx, req)
- handler.HandleResponse(ctx, err, nil)
-}
-
-// GetNotificationRead get notification read record one
-// @Summary get notification read record one
-// @Description get notification read record one
-// @Tags NotificationRead
-// @Accept json
-// @Produce json
-// @Param id path int true "notification read recordid"
-// @Success 200 {object} handler.RespBody{data=schema.GetNotificationReadResp}
-// Router /notification-read/{id} [get]
-func (nc *NotificationReadController) GetNotificationRead(ctx *gin.Context) {
- id, _ := strconv.Atoi(ctx.Param("id"))
- if id == 0 {
- handler.HandleResponse(ctx, errors.BadRequest(reason.RequestFormatError), nil)
- return
- }
-
- resp, err := nc.notificationReadService.GetNotificationRead(ctx, id)
- handler.HandleResponse(ctx, err, resp)
-}
-
-// GetNotificationReadList get notification read record list
-// @Summary get notification read record list
-// @Description get notification read record list
-// @Tags NotificationRead
-// @Produce json
-// @Param user_id query string false "user id"
-// @Param message_id query string false "message id"
-// @Param is_read query string false "read status(unread: 1; read 2)"
-// @Success 200 {object} handler.RespBody{data=[]schema.GetNotificationReadResp}
-// Router /notification-reads [get]
-func (nc *NotificationReadController) GetNotificationReadList(ctx *gin.Context) {
- req := &schema.GetNotificationReadListReq{}
- if handler.BindAndCheck(ctx, req) {
- return
- }
-
- resp, err := nc.notificationReadService.GetNotificationReadList(ctx, req)
- handler.HandleResponse(ctx, err, resp)
-}
-
-// GetNotificationReadWithPage get notification read record page
-// @Summary get notification read record page
-// @Description get notification read record page
-// @Tags NotificationRead
-// @Produce json
-// @Param page query int false "page size"
-// @Param page_size query int false "page size"
-// @Param user_id query string false "user id"
-// @Param message_id query string false "message id"
-// @Param is_read query string false "read status(unread: 1; read 2)"
-// @Success 200 {object} handler.RespBody{data=pager.PageModel{list=[]schema.GetNotificationReadResp}}
-// Router /notification-reads/page [get]
-func (nc *NotificationReadController) GetNotificationReadWithPage(ctx *gin.Context) {
- req := &schema.GetNotificationReadWithPageReq{}
- if handler.BindAndCheck(ctx, req) {
- return
- }
-
- resp, err := nc.notificationReadService.GetNotificationReadWithPage(ctx, req)
- handler.HandleResponse(ctx, err, resp)
-}
diff --git a/internal/controller/useless/user_group_controller.go b/internal/controller/useless/user_group_controller.go
deleted file mode 100644
index 6f6a000e..00000000
--- a/internal/controller/useless/user_group_controller.go
+++ /dev/null
@@ -1,137 +0,0 @@
-package useless
-
-import (
- "strconv"
-
- "github.com/gin-gonic/gin"
- "github.com/segmentfault/answer/internal/base/handler"
- "github.com/segmentfault/answer/internal/base/reason"
- "github.com/segmentfault/answer/internal/schema"
- "github.com/segmentfault/answer/internal/service"
- "github.com/segmentfault/pacman/errors"
- "github.com/segmentfault/pacman/log"
-)
-
-// UserGroupController userGroup controller
-type UserGroupController struct {
- log log.log
- userGroupService *service.UserGroupService
-}
-
-// NewUserGroupController new controller
-func NewUserGroupController(userGroupService *service.UserGroupService) *UserGroupController {
- return &UserGroupController{userGroupService: userGroupService}
-}
-
-// AddUserGroup add user group
-// @Summary add user group
-// @Description add user group
-// @Tags UserGroup
-// @Accept json
-// @Produce json
-// @Param data body schema.AddUserGroupReq true "user group"
-// @Success 200 {object} handler.RespBody
-// Router /user-group [post]
-func (uc *UserGroupController) AddUserGroup(ctx *gin.Context) {
- req := &schema.AddUserGroupReq{}
- if handler.BindAndCheck(ctx, req) {
- return
- }
-
- err := uc.userGroupService.AddUserGroup(ctx, req)
- handler.HandleResponse(ctx, err, nil)
-}
-
-// RemoveUserGroup delete user group
-// @Summary delete user group
-// @Description delete user group
-// @Tags UserGroup
-// @Accept json
-// @Produce json
-// @Param data body schema.RemoveUserGroupReq true "user group"
-// @Success 200 {object} handler.RespBody
-// Router /user-group [delete]
-func (uc *UserGroupController) RemoveUserGroup(ctx *gin.Context) {
- req := &schema.RemoveUserGroupReq{}
- if handler.BindAndCheck(ctx, req) {
- return
- }
-
- err := uc.userGroupService.RemoveUserGroup(ctx, int(req.ID))
- handler.HandleResponse(ctx, err, nil)
-}
-
-// UpdateUserGroup update user group
-// @Summary update user group
-// @Description update user group
-// @Tags UserGroup
-// @Accept json
-// @Produce json
-// @Param data body schema.UpdateUserGroupReq true "user group"
-// @Success 200 {object} handler.RespBody
-// Router /user-group [put]
-func (uc *UserGroupController) UpdateUserGroup(ctx *gin.Context) {
- req := &schema.UpdateUserGroupReq{}
- if handler.BindAndCheck(ctx, req) {
- return
- }
-
- err := uc.userGroupService.UpdateUserGroup(ctx, req)
- handler.HandleResponse(ctx, err, nil)
-}
-
-// GetUserGroup get user group one
-// @Summary get user group one
-// @Description get user group one
-// @Tags UserGroup
-// @Accept json
-// @Produce json
-// @Param id path int true "user groupid"
-// @Success 200 {object} handler.RespBody{data=schema.GetUserGroupResp}
-// Router /user-group/{id} [get]
-func (uc *UserGroupController) GetUserGroup(ctx *gin.Context) {
- id, _ := strconv.Atoi(ctx.Param("id"))
- if id == 0 {
- handler.HandleResponse(ctx, errors.BadRequest(reason.RequestFormatError), nil)
- return
- }
-
- resp, err := uc.userGroupService.GetUserGroup(ctx, id)
- handler.HandleResponse(ctx, err, resp)
-}
-
-// GetUserGroupList get user group list
-// @Summary get user group list
-// @Description get user group list
-// @Tags UserGroup
-// @Produce json
-// @Success 200 {object} handler.RespBody{data=[]schema.GetUserGroupResp}
-// Router /user-groups [get]
-func (uc *UserGroupController) GetUserGroupList(ctx *gin.Context) {
- req := &schema.GetUserGroupListReq{}
- if handler.BindAndCheck(ctx, req) {
- return
- }
-
- resp, err := uc.userGroupService.GetUserGroupList(ctx, req)
- handler.HandleResponse(ctx, err, resp)
-}
-
-// GetUserGroupWithPage get user group page
-// @Summary get user group page
-// @Description get user group page
-// @Tags UserGroup
-// @Produce json
-// @Param page query int false "page size"
-// @Param page_size query int false "page size"
-// @Success 200 {object} handler.RespBody{data=pager.PageModel{list=[]schema.GetUserGroupResp}}
-// Router /user-groups/page [get]
-func (uc *UserGroupController) GetUserGroupWithPage(ctx *gin.Context) {
- req := &schema.GetUserGroupWithPageReq{}
- if handler.BindAndCheck(ctx, req) {
- return
- }
-
- resp, err := uc.userGroupService.GetUserGroupWithPage(ctx, req)
- handler.HandleResponse(ctx, err, resp)
-}