package code import "net/http" // Code 错误输出数据结构 type Code struct { Status int `json:"status"` // HTTP 状态 Message string `json:"msg"` // 描述信息 } // 实现 error 接口的 Error 方法 func (c *Code) Error() string { return c.Message } var ( Success = &Code{http.StatusOK, "请求处理成功"} UpdateSuccess = &Code{http.StatusOK, "更新成功"} DeleteSuccess = &Code{http.StatusOK, "删除成功"} SaveFail = &Code{3001, "新增失败"} RequestParamError = &Code{3002, "请求参数有误"} DeleteUsingError = &Code{3003, "删除失败"} NameExistedError = &Code{3004, "名称已存在"} SelectError = &Code{3013, "查询失败"} SilkRankStandardNotSetError = &Code{4101, "生丝标注未设定"} )