mirror of https://gitee.com/answerdev/answer.git
Merge branch 'feat/clean-code' into 'main'
style: remove unnecessary functions See merge request opensource/answer!97
This commit is contained in:
commit
80c69175a5
|
@ -1,8 +0,0 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="Go" enabled="true" />
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/charts.iml" filepath="$PROJECT_DIR$/.idea/charts.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -1,3 +0,0 @@
|
|||
# /deployments
|
||||
|
||||
IaaS, PaaS, system and container orchestration deployment configurations and templates (docker-compose, kubernetes/helm, mesos, terraform, bosh).
|
185
docs/docs.go
185
docs/docs.go
|
@ -3962,36 +3962,6 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.AddCollectionGroupReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"create_time",
|
||||
"default_group",
|
||||
"name",
|
||||
"update_time",
|
||||
"user_id"
|
||||
],
|
||||
"properties": {
|
||||
"create_time": {
|
||||
"type": "string"
|
||||
},
|
||||
"default_group": {
|
||||
"description": "mark this group is default, default 1",
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"description": "the collection group name",
|
||||
"type": "string",
|
||||
"maxLength": 50
|
||||
},
|
||||
"update_time": {
|
||||
"type": "string"
|
||||
},
|
||||
"user_id": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.AddCommentReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -4025,28 +3995,6 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.AddNotificationReadReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"is_read",
|
||||
"message_id",
|
||||
"user_id"
|
||||
],
|
||||
"properties": {
|
||||
"is_read": {
|
||||
"description": "read status(unread: 1; read 2)",
|
||||
"type": "integer"
|
||||
},
|
||||
"message_id": {
|
||||
"description": "message id",
|
||||
"type": "integer"
|
||||
},
|
||||
"user_id": {
|
||||
"description": "user id",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.AddReportReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -4070,9 +4018,6 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.AddUserGroupReq": {
|
||||
"type": "object"
|
||||
},
|
||||
"schema.AdminSetQuestionStatusRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -4386,35 +4331,6 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.GetNotificationReadResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"created_at": {
|
||||
"description": "create time",
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"description": "id",
|
||||
"type": "integer"
|
||||
},
|
||||
"is_read": {
|
||||
"description": "read status(unread: 1; read 2)",
|
||||
"type": "integer"
|
||||
},
|
||||
"message_id": {
|
||||
"description": "message id",
|
||||
"type": "integer"
|
||||
},
|
||||
"updated_at": {
|
||||
"description": "update time",
|
||||
"type": "string"
|
||||
},
|
||||
"user_id": {
|
||||
"description": "user id",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.GetOtherUserInfoByUsernameResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -4778,18 +4694,6 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.GetUserGroupResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"description": "user group id",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.GetUserInfoResp": {
|
||||
"type": "object"
|
||||
},
|
||||
"schema.GetUserPageResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -5139,18 +5043,6 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.RemoveNotificationReadReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"description": "id",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.RemoveQuestionReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -5175,18 +5067,6 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.RemoveUserGroupReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"description": "user group id",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.ReportHandleReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -5401,35 +5281,6 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.UpdateCollectionGroupReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"create_time": {
|
||||
"type": "string"
|
||||
},
|
||||
"default_group": {
|
||||
"description": "mark this group is default, default 1",
|
||||
"type": "integer"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"description": "the collection group name",
|
||||
"type": "string",
|
||||
"maxLength": 50
|
||||
},
|
||||
"update_time": {
|
||||
"type": "string"
|
||||
},
|
||||
"user_id": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.UpdateCommentReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -5505,30 +5356,6 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.UpdateNotificationReadReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"description": "id",
|
||||
"type": "integer"
|
||||
},
|
||||
"is_read": {
|
||||
"description": "read status(unread: 1; read 2)",
|
||||
"type": "integer"
|
||||
},
|
||||
"message_id": {
|
||||
"description": "message id",
|
||||
"type": "integer"
|
||||
},
|
||||
"user_id": {
|
||||
"description": "user id",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.UpdateSMTPConfigReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -5626,18 +5453,6 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.UpdateUserGroupReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"description": "user group id",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.UpdateUserStatusReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
|
@ -3950,36 +3950,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.AddCollectionGroupReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"create_time",
|
||||
"default_group",
|
||||
"name",
|
||||
"update_time",
|
||||
"user_id"
|
||||
],
|
||||
"properties": {
|
||||
"create_time": {
|
||||
"type": "string"
|
||||
},
|
||||
"default_group": {
|
||||
"description": "mark this group is default, default 1",
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"description": "the collection group name",
|
||||
"type": "string",
|
||||
"maxLength": 50
|
||||
},
|
||||
"update_time": {
|
||||
"type": "string"
|
||||
},
|
||||
"user_id": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.AddCommentReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -4013,28 +3983,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.AddNotificationReadReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"is_read",
|
||||
"message_id",
|
||||
"user_id"
|
||||
],
|
||||
"properties": {
|
||||
"is_read": {
|
||||
"description": "read status(unread: 1; read 2)",
|
||||
"type": "integer"
|
||||
},
|
||||
"message_id": {
|
||||
"description": "message id",
|
||||
"type": "integer"
|
||||
},
|
||||
"user_id": {
|
||||
"description": "user id",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.AddReportReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -4058,9 +4006,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.AddUserGroupReq": {
|
||||
"type": "object"
|
||||
},
|
||||
"schema.AdminSetQuestionStatusRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -4374,35 +4319,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.GetNotificationReadResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"created_at": {
|
||||
"description": "create time",
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"description": "id",
|
||||
"type": "integer"
|
||||
},
|
||||
"is_read": {
|
||||
"description": "read status(unread: 1; read 2)",
|
||||
"type": "integer"
|
||||
},
|
||||
"message_id": {
|
||||
"description": "message id",
|
||||
"type": "integer"
|
||||
},
|
||||
"updated_at": {
|
||||
"description": "update time",
|
||||
"type": "string"
|
||||
},
|
||||
"user_id": {
|
||||
"description": "user id",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.GetOtherUserInfoByUsernameResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -4766,18 +4682,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.GetUserGroupResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"description": "user group id",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.GetUserInfoResp": {
|
||||
"type": "object"
|
||||
},
|
||||
"schema.GetUserPageResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -5127,18 +5031,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.RemoveNotificationReadReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"description": "id",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.RemoveQuestionReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -5163,18 +5055,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.RemoveUserGroupReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"description": "user group id",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.ReportHandleReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -5389,35 +5269,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.UpdateCollectionGroupReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"create_time": {
|
||||
"type": "string"
|
||||
},
|
||||
"default_group": {
|
||||
"description": "mark this group is default, default 1",
|
||||
"type": "integer"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"description": "the collection group name",
|
||||
"type": "string",
|
||||
"maxLength": 50
|
||||
},
|
||||
"update_time": {
|
||||
"type": "string"
|
||||
},
|
||||
"user_id": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.UpdateCommentReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -5493,30 +5344,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.UpdateNotificationReadReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"description": "id",
|
||||
"type": "integer"
|
||||
},
|
||||
"is_read": {
|
||||
"description": "read status(unread: 1; read 2)",
|
||||
"type": "integer"
|
||||
},
|
||||
"message_id": {
|
||||
"description": "message id",
|
||||
"type": "integer"
|
||||
},
|
||||
"user_id": {
|
||||
"description": "user id",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.UpdateSMTPConfigReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -5614,18 +5441,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"schema.UpdateUserGroupReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"description": "user group id",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.UpdateUserStatusReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
|
@ -35,28 +35,6 @@ definitions:
|
|||
verify:
|
||||
type: boolean
|
||||
type: object
|
||||
schema.AddCollectionGroupReq:
|
||||
properties:
|
||||
create_time:
|
||||
type: string
|
||||
default_group:
|
||||
description: mark this group is default, default 1
|
||||
type: integer
|
||||
name:
|
||||
description: the collection group name
|
||||
maxLength: 50
|
||||
type: string
|
||||
update_time:
|
||||
type: string
|
||||
user_id:
|
||||
type: integer
|
||||
required:
|
||||
- create_time
|
||||
- default_group
|
||||
- name
|
||||
- update_time
|
||||
- user_id
|
||||
type: object
|
||||
schema.AddCommentReq:
|
||||
properties:
|
||||
mention_username_list:
|
||||
|
@ -81,22 +59,6 @@ definitions:
|
|||
- original_text
|
||||
- parsed_text
|
||||
type: object
|
||||
schema.AddNotificationReadReq:
|
||||
properties:
|
||||
is_read:
|
||||
description: 'read status(unread: 1; read 2)'
|
||||
type: integer
|
||||
message_id:
|
||||
description: message id
|
||||
type: integer
|
||||
user_id:
|
||||
description: user id
|
||||
type: integer
|
||||
required:
|
||||
- is_read
|
||||
- message_id
|
||||
- user_id
|
||||
type: object
|
||||
schema.AddReportReq:
|
||||
properties:
|
||||
content:
|
||||
|
@ -114,8 +76,6 @@ definitions:
|
|||
- object_id
|
||||
- report_type
|
||||
type: object
|
||||
schema.AddUserGroupReq:
|
||||
type: object
|
||||
schema.AdminSetQuestionStatusRequest:
|
||||
properties:
|
||||
question_id:
|
||||
|
@ -340,27 +300,6 @@ definitions:
|
|||
description: tag id
|
||||
type: string
|
||||
type: object
|
||||
schema.GetNotificationReadResp:
|
||||
properties:
|
||||
created_at:
|
||||
description: create time
|
||||
type: string
|
||||
id:
|
||||
description: id
|
||||
type: integer
|
||||
is_read:
|
||||
description: 'read status(unread: 1; read 2)'
|
||||
type: integer
|
||||
message_id:
|
||||
description: message id
|
||||
type: integer
|
||||
updated_at:
|
||||
description: update time
|
||||
type: string
|
||||
user_id:
|
||||
description: user id
|
||||
type: integer
|
||||
type: object
|
||||
schema.GetOtherUserInfoByUsernameResp:
|
||||
properties:
|
||||
answer_count:
|
||||
|
@ -627,14 +566,6 @@ definitions:
|
|||
description: tag id
|
||||
type: string
|
||||
type: object
|
||||
schema.GetUserGroupResp:
|
||||
properties:
|
||||
id:
|
||||
description: user group id
|
||||
type: integer
|
||||
type: object
|
||||
schema.GetUserInfoResp:
|
||||
type: object
|
||||
schema.GetUserPageResp:
|
||||
properties:
|
||||
avatar:
|
||||
|
@ -891,14 +822,6 @@ definitions:
|
|||
required:
|
||||
- comment_id
|
||||
type: object
|
||||
schema.RemoveNotificationReadReq:
|
||||
properties:
|
||||
id:
|
||||
description: id
|
||||
type: integer
|
||||
required:
|
||||
- id
|
||||
type: object
|
||||
schema.RemoveQuestionReq:
|
||||
properties:
|
||||
id:
|
||||
|
@ -915,14 +838,6 @@ definitions:
|
|||
required:
|
||||
- tag_id
|
||||
type: object
|
||||
schema.RemoveUserGroupReq:
|
||||
properties:
|
||||
id:
|
||||
description: user group id
|
||||
type: integer
|
||||
required:
|
||||
- id
|
||||
type: object
|
||||
schema.ReportHandleReq:
|
||||
properties:
|
||||
flagged_content:
|
||||
|
@ -1074,26 +989,6 @@ definitions:
|
|||
slug_name:
|
||||
type: string
|
||||
type: object
|
||||
schema.UpdateCollectionGroupReq:
|
||||
properties:
|
||||
create_time:
|
||||
type: string
|
||||
default_group:
|
||||
description: mark this group is default, default 1
|
||||
type: integer
|
||||
id:
|
||||
type: integer
|
||||
name:
|
||||
description: the collection group name
|
||||
maxLength: 50
|
||||
type: string
|
||||
update_time:
|
||||
type: string
|
||||
user_id:
|
||||
type: integer
|
||||
required:
|
||||
- id
|
||||
type: object
|
||||
schema.UpdateCommentReq:
|
||||
properties:
|
||||
comment_id:
|
||||
|
@ -1149,23 +1044,6 @@ definitions:
|
|||
required:
|
||||
- display_name
|
||||
type: object
|
||||
schema.UpdateNotificationReadReq:
|
||||
properties:
|
||||
id:
|
||||
description: id
|
||||
type: integer
|
||||
is_read:
|
||||
description: 'read status(unread: 1; read 2)'
|
||||
type: integer
|
||||
message_id:
|
||||
description: message id
|
||||
type: integer
|
||||
user_id:
|
||||
description: user id
|
||||
type: integer
|
||||
required:
|
||||
- id
|
||||
type: object
|
||||
schema.UpdateSMTPConfigReq:
|
||||
properties:
|
||||
encryption:
|
||||
|
@ -1236,14 +1114,6 @@ definitions:
|
|||
- synonym_tag_list
|
||||
- tag_id
|
||||
type: object
|
||||
schema.UpdateUserGroupReq:
|
||||
properties:
|
||||
id:
|
||||
description: user group id
|
||||
type: integer
|
||||
required:
|
||||
- id
|
||||
type: object
|
||||
schema.UpdateUserStatusReq:
|
||||
properties:
|
||||
status:
|
||||
|
|
|
@ -3,10 +3,7 @@ package constant
|
|||
import "time"
|
||||
|
||||
const (
|
||||
Default_PageSize = 20 //Default number of pages
|
||||
Key_UserID = "_UserID" //session userid
|
||||
LoginUserID = "login_user_id"
|
||||
LoginUserVerify = "login_user_verify"
|
||||
Default_PageSize = 20 //Default number of pages
|
||||
UserStatusChangedCacheKey = "answer:user:status:"
|
||||
UserStatusChangedCacheTime = 7 * 24 * time.Hour
|
||||
UserTokenCacheKey = "answer:user:token:"
|
||||
|
|
|
@ -19,26 +19,6 @@ func NewRevisionController(revisionListService *service.RevisionService) *Revisi
|
|||
return &RevisionController{revisionListService: revisionListService}
|
||||
}
|
||||
|
||||
// GetRevision get revision one
|
||||
// @Summary get revision one
|
||||
// @Description get revision one
|
||||
// @Tags Revision
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "revisionid"
|
||||
// @Success 200 {object} handler.RespBody{data=schema.GetRevisionResp}
|
||||
// Router /revision/{id} [get]
|
||||
func (rc *RevisionController) GetRevision(ctx *gin.Context) {
|
||||
id := ctx.Param("id")
|
||||
if id == "0" {
|
||||
handler.HandleResponse(ctx, errors.BadRequest(reason.RequestFormatError), nil)
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := rc.revisionListService.GetRevision(ctx, id)
|
||||
handler.HandleResponse(ctx, err, resp)
|
||||
}
|
||||
|
||||
// GetRevisionList godoc
|
||||
// @Summary get revision list
|
||||
// @Description get revision list
|
||||
|
|
|
@ -3,10 +3,8 @@ package controller_backyard
|
|||
import (
|
||||
"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/user_backyard"
|
||||
"github.com/segmentfault/pacman/errors"
|
||||
)
|
||||
|
||||
// UserBackyardController user controller
|
||||
|
@ -39,27 +37,6 @@ func (uc *UserBackyardController) UpdateUserStatus(ctx *gin.Context) {
|
|||
handler.HandleResponse(ctx, err, nil)
|
||||
}
|
||||
|
||||
// GetUserInfo get user one
|
||||
// @Summary get user one
|
||||
// @Description get user one
|
||||
// @Security ApiKeyAuth
|
||||
// @Tags admin
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "userid"
|
||||
// @Success 200 {object} handler.RespBody{data=schema.GetUserInfoResp}
|
||||
// Router /user/{id} [get]
|
||||
func (uc *UserBackyardController) GetUserInfo(ctx *gin.Context) {
|
||||
userID := ctx.Query("user_id")
|
||||
if len(userID) == 0 {
|
||||
handler.HandleResponse(ctx, errors.BadRequest(reason.RequestFormatError), nil)
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := uc.userService.GetUserInfo(ctx, userID)
|
||||
handler.HandleResponse(ctx, err, resp)
|
||||
}
|
||||
|
||||
// GetUserPage get user page
|
||||
// @Summary get user page
|
||||
// @Description get user page
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
package schema
|
||||
|
||||
import "time"
|
||||
|
||||
// AddNotificationReadReq add notification read record request
|
||||
type AddNotificationReadReq struct {
|
||||
// user id
|
||||
UserID int64 `validate:"required" comment:"user id" json:"user_id"`
|
||||
// message id
|
||||
MessageID int64 `validate:"required" comment:"message id" json:"message_id"`
|
||||
// read status(unread: 1; read 2)
|
||||
IsRead int `validate:"required" comment:"read status(unread: 1; read 2)" json:"is_read"`
|
||||
}
|
||||
|
||||
// RemoveNotificationReadReq delete notification read record request
|
||||
type RemoveNotificationReadReq struct {
|
||||
// id
|
||||
ID int `validate:"required" comment:"id" json:"id"`
|
||||
}
|
||||
|
||||
// UpdateNotificationReadReq update notification read record request
|
||||
type UpdateNotificationReadReq struct {
|
||||
// id
|
||||
ID int `validate:"required" comment:"id" json:"id"`
|
||||
// user id
|
||||
UserID int64 `validate:"omitempty" comment:"user id" json:"user_id"`
|
||||
// message id
|
||||
MessageID int64 `validate:"omitempty" comment:"message id" json:"message_id"`
|
||||
// read status(unread: 1; read 2)
|
||||
IsRead int `validate:"omitempty" comment:"read status(unread: 1; read 2)" json:"is_read"`
|
||||
}
|
||||
|
||||
// GetNotificationReadListReq get notification read record list all request
|
||||
type GetNotificationReadListReq struct {
|
||||
// user id
|
||||
UserID int64 `validate:"omitempty" comment:"user id" form:"user_id"`
|
||||
// message id
|
||||
MessageID int64 `validate:"omitempty" comment:"message id" form:"message_id"`
|
||||
// read status(unread: 1; read 2)
|
||||
IsRead int `validate:"omitempty" comment:"read status(unread: 1; read 2)" form:"is_read"`
|
||||
}
|
||||
|
||||
// GetNotificationReadWithPageReq get notification read record list page request
|
||||
type GetNotificationReadWithPageReq struct {
|
||||
// page
|
||||
Page int `validate:"omitempty,min=1" form:"page"`
|
||||
// page size
|
||||
PageSize int `validate:"omitempty,min=1" form:"page_size"`
|
||||
// user id
|
||||
UserID int64 `validate:"omitempty" comment:"user id" form:"user_id"`
|
||||
// message id
|
||||
MessageID int64 `validate:"omitempty" comment:"message id" form:"message_id"`
|
||||
// read status(unread: 1; read 2)
|
||||
IsRead int `validate:"omitempty" comment:"read status(unread: 1; read 2)" form:"is_read"`
|
||||
}
|
||||
|
||||
// GetNotificationReadResp get notification read record response
|
||||
type GetNotificationReadResp struct {
|
||||
// id
|
||||
ID int `json:"id"`
|
||||
// create time
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
// update time
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
// user id
|
||||
UserID int64 `json:"user_id"`
|
||||
// message id
|
||||
MessageID int64 `json:"message_id"`
|
||||
// read status(unread: 1; read 2)
|
||||
IsRead int `json:"is_read"`
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package schema
|
||||
|
||||
// AddUserGroupReq add user group request
|
||||
type AddUserGroupReq struct {
|
||||
}
|
||||
|
||||
// RemoveUserGroupReq delete user group request
|
||||
type RemoveUserGroupReq struct {
|
||||
// user group id
|
||||
ID int64 `validate:"required" comment:"user group id" json:"id"`
|
||||
}
|
||||
|
||||
// UpdateUserGroupReq update user group request
|
||||
type UpdateUserGroupReq struct {
|
||||
// user group id
|
||||
ID int64 `validate:"required" comment:"user group id" json:"id"`
|
||||
}
|
||||
|
||||
// GetUserGroupListReq get user group list all request
|
||||
type GetUserGroupListReq struct {
|
||||
}
|
||||
|
||||
// GetUserGroupWithPageReq get user group list page request
|
||||
type GetUserGroupWithPageReq struct {
|
||||
// page
|
||||
Page int `validate:"omitempty,min=1" form:"page"`
|
||||
// page size
|
||||
PageSize int `validate:"omitempty,min=1" form:"page_size"`
|
||||
}
|
||||
|
||||
// GetUserGroupResp get user group response
|
||||
type GetUserGroupResp struct {
|
||||
// user group id
|
||||
ID int64 `json:"id"`
|
||||
}
|
|
@ -195,7 +195,7 @@ type UserRegisterReq struct {
|
|||
|
||||
func (u *UserRegisterReq) Check() (errField *validator.ErrorField, err error) {
|
||||
// TODO i18n
|
||||
err = checker.PassWordCheck(8, 32, 0, u.Pass)
|
||||
err = checker.CheckPassword(8, 32, 0, u.Pass)
|
||||
if err != nil {
|
||||
return &validator.ErrorField{
|
||||
Key: "pass",
|
||||
|
@ -214,7 +214,7 @@ type UserModifyPassWordRequest struct {
|
|||
|
||||
func (u *UserModifyPassWordRequest) Check() (errField *validator.ErrorField, err error) {
|
||||
// TODO i18n
|
||||
err = checker.PassWordCheck(8, 32, 0, u.Pass)
|
||||
err = checker.CheckPassword(8, 32, 0, u.Pass)
|
||||
if err != nil {
|
||||
return &validator.ErrorField{
|
||||
Key: "pass",
|
||||
|
@ -272,7 +272,7 @@ type UserRePassWordRequest struct {
|
|||
|
||||
func (u *UserRePassWordRequest) Check() (errField *validator.ErrorField, err error) {
|
||||
// TODO i18n
|
||||
err = checker.PassWordCheck(8, 32, 0, u.Pass)
|
||||
err = checker.CheckPassword(8, 32, 0, u.Pass)
|
||||
if err != nil {
|
||||
return &validator.ErrorField{
|
||||
Key: "pass",
|
||||
|
|
|
@ -21,7 +21,7 @@ type CollectionRepo interface {
|
|||
SearchList(ctx context.Context, search *entity.CollectionSearch) ([]*entity.Collection, int64, error)
|
||||
}
|
||||
|
||||
// CollectionService user service
|
||||
// CollectionCommon user service
|
||||
type CollectionCommon struct {
|
||||
collectionRepo CollectionRepo
|
||||
}
|
||||
|
|
|
@ -13,13 +13,12 @@ const (
|
|||
LevelS
|
||||
)
|
||||
|
||||
/*
|
||||
* minLength: Specifies the minimum length of a password
|
||||
* maxLength:Specifies the maximum length of a password
|
||||
* minLevel:Specifies the minimum strength level required for passwords
|
||||
* pwd:Text passwords
|
||||
*/
|
||||
func PassWordCheck(minLength, maxLength, minLevel int, pwd string) error {
|
||||
// CheckPassword
|
||||
// minLength: Specifies the minimum length of a password
|
||||
// maxLength:Specifies the maximum length of a password
|
||||
// minLevel:Specifies the minimum strength level required for passwords
|
||||
// pwd:Text passwords
|
||||
func CheckPassword(minLength, maxLength, minLevel int, pwd string) error {
|
||||
// First check whether the password length is within the range
|
||||
if len(pwd) < minLength {
|
||||
return fmt.Errorf("BAD PASSWORD: The password is shorter than %d characters", minLength)
|
||||
|
|
|
@ -2,6 +2,7 @@ package dir
|
|||
|
||||
import "os"
|
||||
|
||||
// CreatePathIsNotExist create path is not exists
|
||||
func CreatePathIsNotExist(path string) (bool, error) {
|
||||
_, err := os.Stat(path)
|
||||
if err == nil {
|
||||
|
@ -18,6 +19,7 @@ func CreatePathIsNotExist(path string) (bool, error) {
|
|||
return false, err
|
||||
}
|
||||
|
||||
// CheckPathExist path if exist
|
||||
func CheckPathExist(path string) bool {
|
||||
_, err := os.Stat(path)
|
||||
if err == nil {
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
package encrypt
|
||||
|
||||
import (
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// StringEncrypt
|
||||
func StringEncrypt(message, key string) (encoded string, err error) {
|
||||
//Create byte array from the input string
|
||||
plainText := []byte(message)
|
||||
|
||||
//Create a new AES cipher using the key
|
||||
block, err := aes.NewCipher([]byte(key))
|
||||
|
||||
//IF NewCipher failed, exit:
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
//Make the cipher text a byte array of size BlockSize + the length of the message
|
||||
cipherText := make([]byte, aes.BlockSize+len(plainText))
|
||||
|
||||
//iv is the ciphertext up to the blocksize (16)
|
||||
iv := cipherText[:aes.BlockSize]
|
||||
if _, err = io.ReadFull(rand.Reader, iv); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
//Encrypt the data:
|
||||
stream := cipher.NewCFBEncrypter(block, iv)
|
||||
stream.XORKeyStream(cipherText[aes.BlockSize:], plainText)
|
||||
|
||||
//Return string encoded in base64
|
||||
return base64.RawStdEncoding.EncodeToString(cipherText), err
|
||||
}
|
||||
|
||||
// StringDecrypt
|
||||
func StringDecrypt(secure, key string) (decoded string, err error) {
|
||||
//Remove base64 encoding:
|
||||
cipherText, err := base64.RawStdEncoding.DecodeString(secure)
|
||||
|
||||
//IF DecodeString failed, exit:
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
//Create a new AES cipher with the key and encrypted message
|
||||
block, err := aes.NewCipher([]byte(key))
|
||||
|
||||
//IF NewCipher failed, exit:
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
//IF the length of the cipherText is less than 16 Bytes:
|
||||
if len(cipherText) < aes.BlockSize {
|
||||
err = fmt.Errorf("ciphertext block size is too short")
|
||||
return
|
||||
}
|
||||
|
||||
iv := cipherText[:aes.BlockSize]
|
||||
cipherText = cipherText[aes.BlockSize:]
|
||||
|
||||
//Decrypt the message
|
||||
stream := cipher.NewCFBDecrypter(block, iv)
|
||||
stream.XORKeyStream(cipherText, cipherText)
|
||||
|
||||
return string(cipherText), err
|
||||
}
|
||||
|
||||
func StringUrlEnCode(str string) string {
|
||||
return url.QueryEscape(str)
|
||||
}
|
||||
func StringUrlDeCode(str string) (string, error) {
|
||||
return url.QueryUnescape(str)
|
||||
}
|
Loading…
Reference in New Issue