Skip to content

Commit 82fdfc7

Browse files
LinkinStarsshuashuaikelvinkuohgaolsy-records
authored
Release/1.2.1 (#678)
Co-authored-by: shuai <[email protected]> Co-authored-by: kelvinkuo <[email protected]> Co-authored-by: hgaol <[email protected]> Co-authored-by: sy-records <[email protected]>
1 parent a00f660 commit 82fdfc7

File tree

83 files changed

+2248
-1022
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+2248
-1022
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: build clean ui
22

3-
VERSION=1.2.0
3+
VERSION=1.2.1
44
BIN=answer
55
DIR_SRC=./cmd/answer
66
DOCKER_CMD=docker

cmd/command.go

+37-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ var (
4545
// This config is used to upgrade the database from a specific version manually.
4646
// If you want to upgrade the database to version 1.1.0, you can use `answer upgrade -f v1.1.0`.
4747
upgradeVersion string
48+
// The fields that need to be set to the default value
49+
configFields []string
4850
)
4951

5052
func init() {
@@ -60,7 +62,9 @@ func init() {
6062

6163
upgradeCmd.Flags().StringVarP(&upgradeVersion, "from", "f", "", "upgrade from specific version, eg: -f v1.1.0")
6264

63-
for _, cmd := range []*cobra.Command{initCmd, checkCmd, runCmd, dumpCmd, upgradeCmd, buildCmd, pluginCmd} {
65+
configCmd.Flags().StringSliceVarP(&configFields, "with", "w", []string{}, "the fields that need to be set to the default value, eg: -w allow_password_login")
66+
67+
for _, cmd := range []*cobra.Command{initCmd, checkCmd, runCmd, dumpCmd, upgradeCmd, buildCmd, pluginCmd, configCmd} {
6468
rootCmd.AddCommand(cmd)
6569
}
6670
}
@@ -231,6 +235,38 @@ To run answer, use:
231235
})
232236
},
233237
}
238+
239+
// configCmd set some config to default value
240+
configCmd = &cobra.Command{
241+
Use: "config",
242+
Short: "set some config to default value",
243+
Long: `set some config to default value`,
244+
Run: func(_ *cobra.Command, _ []string) {
245+
cli.FormatAllPath(dataDirPath)
246+
247+
c, err := conf.ReadConfig(cli.GetConfigFilePath())
248+
if err != nil {
249+
fmt.Println("read config failed: ", err.Error())
250+
return
251+
}
252+
253+
field := &cli.ConfigField{}
254+
for _, f := range configFields {
255+
switch f {
256+
case "allow_password_login":
257+
field.AllowPasswordLogin = true
258+
default:
259+
fmt.Printf("field %s not support\n", f)
260+
}
261+
}
262+
err = cli.SetDefaultConfig(c.Data.Database, c.Data.Cache, field)
263+
if err != nil {
264+
fmt.Println("set default config failed: ", err.Error())
265+
} else {
266+
fmt.Println("set default config successfully")
267+
}
268+
},
269+
}
234270
)
235271

236272
// Execute adds all child commands to the root command and sets flags appropriately.

cmd/main.go

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ var (
4747
Revision = "-"
4848
// Time is the build time of the project
4949
Time = "-"
50+
// GoVersion is the go version of the project
51+
GoVersion = "1.19"
5052
// log level
5153
logLevel = os.Getenv("LOG_LEVEL")
5254
// log path
@@ -75,6 +77,7 @@ func runApp() {
7577
}
7678
constant.Version = Version
7779
constant.Revision = Revision
80+
constant.GoVersion = GoVersion
7881
schema.AppStartTime = time.Now()
7982
fmt.Println("answer Version:", constant.Version, " Revision:", constant.Revision)
8083

cmd/wire_gen.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/docs.go

+19-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/swagger.json

+19-9
Original file line numberDiff line numberDiff line change
@@ -6871,12 +6871,13 @@
68716871
"object_id"
68726872
],
68736873
"properties": {
6874+
"bookmark": {
6875+
"type": "boolean"
6876+
},
68746877
"group_id": {
6875-
"description": "user collection group TagID",
68766878
"type": "string"
68776879
},
68786880
"object_id": {
6879-
"description": "object TagID",
68806881
"type": "string"
68816882
}
68826883
}
@@ -6885,13 +6886,7 @@
68856886
"type": "object",
68866887
"properties": {
68876888
"object_collection_count": {
6888-
"type": "string"
6889-
},
6890-
"object_id": {
6891-
"type": "string"
6892-
},
6893-
"switch": {
6894-
"type": "boolean"
6889+
"type": "integer"
68956890
}
68966891
}
68976892
},
@@ -8755,6 +8750,9 @@
87558750
"site_users": {
87568751
"$ref": "#/definitions/schema.SiteUsersResp"
87578752
},
8753+
"site_write": {
8754+
"$ref": "#/definitions/schema.SiteWriteResp"
8755+
},
87588756
"theme": {
87598757
"$ref": "#/definitions/schema.SiteThemeResp"
87608758
},
@@ -8846,6 +8844,9 @@
88468844
"allow_new_registrations": {
88478845
"type": "boolean"
88488846
},
8847+
"allow_password_login": {
8848+
"type": "boolean"
8849+
},
88498850
"login_required": {
88508851
"type": "boolean"
88518852
}
@@ -8866,6 +8867,9 @@
88668867
"allow_new_registrations": {
88678868
"type": "boolean"
88688869
},
8870+
"allow_password_login": {
8871+
"type": "boolean"
8872+
},
88698873
"login_required": {
88708874
"type": "boolean"
88718875
}
@@ -9028,6 +9032,9 @@
90289032
"items": {
90299033
"type": "string"
90309034
}
9035+
},
9036+
"restrict_answer": {
9037+
"type": "boolean"
90319038
}
90329039
}
90339040
},
@@ -9048,6 +9055,9 @@
90489055
"items": {
90499056
"type": "string"
90509057
}
9058+
},
9059+
"restrict_answer": {
9060+
"type": "boolean"
90519061
}
90529062
}
90539063
},

docs/swagger.yaml

+13-7
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,11 @@ definitions:
357357
type: object
358358
schema.CollectionSwitchReq:
359359
properties:
360+
bookmark:
361+
type: boolean
360362
group_id:
361-
description: user collection group TagID
362363
type: string
363364
object_id:
364-
description: object TagID
365365
type: string
366366
required:
367367
- group_id
@@ -370,11 +370,7 @@ definitions:
370370
schema.CollectionSwitchResp:
371371
properties:
372372
object_collection_count:
373-
type: string
374-
object_id:
375-
type: string
376-
switch:
377-
type: boolean
373+
type: integer
378374
type: object
379375
schema.ConfigField:
380376
properties:
@@ -1677,6 +1673,8 @@ definitions:
16771673
$ref: '#/definitions/schema.SiteSeoResp'
16781674
site_users:
16791675
$ref: '#/definitions/schema.SiteUsersResp'
1676+
site_write:
1677+
$ref: '#/definitions/schema.SiteWriteResp'
16801678
theme:
16811679
$ref: '#/definitions/schema.SiteThemeResp'
16821680
version:
@@ -1738,6 +1736,8 @@ definitions:
17381736
type: boolean
17391737
allow_new_registrations:
17401738
type: boolean
1739+
allow_password_login:
1740+
type: boolean
17411741
login_required:
17421742
type: boolean
17431743
type: object
@@ -1751,6 +1751,8 @@ definitions:
17511751
type: boolean
17521752
allow_new_registrations:
17531753
type: boolean
1754+
allow_password_login:
1755+
type: boolean
17541756
login_required:
17551757
type: boolean
17561758
type: object
@@ -1861,6 +1863,8 @@ definitions:
18611863
items:
18621864
type: string
18631865
type: array
1866+
restrict_answer:
1867+
type: boolean
18641868
type: object
18651869
schema.SiteWriteResp:
18661870
properties:
@@ -1874,6 +1878,8 @@ definitions:
18741878
items:
18751879
type: string
18761880
type: array
1881+
restrict_answer:
1882+
type: boolean
18771883
type: object
18781884
schema.TagItem:
18791885
properties:

0 commit comments

Comments
 (0)