初步实现device_controller
This commit is contained in:
@@ -60,10 +60,8 @@ type LoginResponse struct {
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param user body CreateUserRequest true "用户信息"
|
||||
// @Success 200 {object} controller.Response{data=CreateUserResponse} "用户创建成功"
|
||||
// @Failure 400 {object} controller.Response "请求参数错误"
|
||||
// @Failure 409 {object} controller.Response "用户名已存在"
|
||||
// @Failure 500 {object} controller.Response "服务器内部错误"
|
||||
// @Success 200 {object} controller.Response{data=CreateUserResponse} "业务码为201代表创建成功"
|
||||
// @Failure 200 {object} controller.Response "业务失败,具体错误码和信息见响应体(例如400, 409, 500)"
|
||||
// @Router /users [post]
|
||||
func (c *Controller) CreateUser(ctx *gin.Context) {
|
||||
var req CreateUserRequest
|
||||
@@ -93,7 +91,7 @@ func (c *Controller) CreateUser(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
controller.SendResponse(ctx, http.StatusOK, "用户创建成功", CreateUserResponse{
|
||||
controller.SendResponse(ctx, http.StatusCreated, "用户创建成功", CreateUserResponse{
|
||||
Username: user.Username,
|
||||
ID: user.ID,
|
||||
})
|
||||
@@ -106,10 +104,8 @@ func (c *Controller) CreateUser(ctx *gin.Context) {
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param credentials body LoginRequest true "登录凭证"
|
||||
// @Success 200 {object} controller.Response{data=LoginResponse} "登录成功"
|
||||
// @Failure 400 {object} controller.Response "请求参数错误"
|
||||
// @Failure 401 {object} controller.Response "用户名或密码不正确"
|
||||
// @Failure 500 {object} controller.Response "服务器内部错误"
|
||||
// @Success 200 {object} controller.Response{data=LoginResponse} "业务码为200代表登录成功"
|
||||
// @Failure 200 {object} controller.Response "业务失败,具体错误码和信息见响应体(例如400, 401, 500)"
|
||||
// @Router /users/login [post]
|
||||
func (c *Controller) Login(ctx *gin.Context) {
|
||||
var req LoginRequest
|
||||
|
||||
Reference in New Issue
Block a user