Skip to content

Commit 8678e57

Browse files
authored
Feat/v0.15.0 (#63)
1 parent aa37fe9 commit 8678e57

File tree

40 files changed

+1887
-250
lines changed

40 files changed

+1887
-250
lines changed

backend/docs/docs.go

Lines changed: 231 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2966,6 +2966,11 @@ const docTemplate = `{
29662966
],
29672967
"summary": "list user",
29682968
"parameters": [
2969+
{
2970+
"type": "string",
2971+
"name": "email",
2972+
"in": "query"
2973+
},
29692974
{
29702975
"type": "string",
29712976
"name": "name",
@@ -4316,6 +4321,11 @@ const docTemplate = `{
43164321
],
43174322
"summary": "get user third login url",
43184323
"parameters": [
4324+
{
4325+
"type": "boolean",
4326+
"name": "app",
4327+
"in": "query"
4328+
},
43194329
{
43204330
"type": "string",
43214331
"name": "redirect",
@@ -4400,6 +4410,135 @@ const docTemplate = `{
44004410
}
44014411
}
44024412
},
4413+
"/user/notify/list": {
4414+
"get": {
4415+
"produces": [
4416+
"application/json"
4417+
],
4418+
"tags": [
4419+
"user"
4420+
],
4421+
"summary": "list notify message",
4422+
"parameters": [
4423+
{
4424+
"minimum": 1,
4425+
"type": "integer",
4426+
"name": "page",
4427+
"in": "query"
4428+
},
4429+
{
4430+
"type": "boolean",
4431+
"name": "read",
4432+
"in": "query"
4433+
},
4434+
{
4435+
"minimum": 1,
4436+
"type": "integer",
4437+
"name": "size",
4438+
"in": "query"
4439+
}
4440+
],
4441+
"responses": {
4442+
"200": {
4443+
"description": "OK",
4444+
"schema": {
4445+
"allOf": [
4446+
{
4447+
"$ref": "#/definitions/context.Response"
4448+
},
4449+
{
4450+
"type": "object",
4451+
"properties": {
4452+
"data": {
4453+
"allOf": [
4454+
{
4455+
"$ref": "#/definitions/model.ListRes"
4456+
},
4457+
{
4458+
"type": "object",
4459+
"properties": {
4460+
"items": {
4461+
"type": "array",
4462+
"items": {
4463+
"$ref": "#/definitions/model.MessageNotify"
4464+
}
4465+
}
4466+
}
4467+
}
4468+
]
4469+
}
4470+
}
4471+
}
4472+
]
4473+
}
4474+
}
4475+
}
4476+
}
4477+
},
4478+
"/user/notify/read": {
4479+
"post": {
4480+
"consumes": [
4481+
"application/json"
4482+
],
4483+
"produces": [
4484+
"application/json"
4485+
],
4486+
"tags": [
4487+
"user"
4488+
],
4489+
"summary": "read notify message",
4490+
"parameters": [
4491+
{
4492+
"description": "req params",
4493+
"name": "req",
4494+
"in": "body",
4495+
"required": true,
4496+
"schema": {
4497+
"$ref": "#/definitions/svc.NotifyReadReq"
4498+
}
4499+
}
4500+
],
4501+
"responses": {
4502+
"200": {
4503+
"description": "OK",
4504+
"schema": {
4505+
"$ref": "#/definitions/context.Response"
4506+
}
4507+
}
4508+
}
4509+
}
4510+
},
4511+
"/user/notify/unread": {
4512+
"get": {
4513+
"produces": [
4514+
"application/json"
4515+
],
4516+
"tags": [
4517+
"user"
4518+
],
4519+
"summary": "get notify message unread num",
4520+
"responses": {
4521+
"200": {
4522+
"description": "OK",
4523+
"schema": {
4524+
"allOf": [
4525+
{
4526+
"$ref": "#/definitions/context.Response"
4527+
},
4528+
{
4529+
"type": "object",
4530+
"properties": {
4531+
"data": {
4532+
"type": "integer"
4533+
}
4534+
}
4535+
}
4536+
]
4537+
}
4538+
}
4539+
}
4540+
}
4541+
},
44034542
"/user/register": {
44044543
"post": {
44054544
"consumes": [
@@ -4521,6 +4660,9 @@ const docTemplate = `{
45214660
"client_secret": {
45224661
"type": "string"
45234662
},
4663+
"corp_id": {
4664+
"type": "string"
4665+
},
45244666
"url": {
45254667
"type": "string"
45264668
}
@@ -4537,7 +4679,7 @@ const docTemplate = `{
45374679
},
45384680
"type": {
45394681
"type": "integer",
4540-
"maximum": 2,
4682+
"maximum": 3,
45414683
"minimum": 1
45424684
}
45434685
}
@@ -5189,6 +5331,86 @@ const docTemplate = `{
51895331
}
51905332
}
51915333
},
5334+
"model.MessageNotify": {
5335+
"type": "object",
5336+
"properties": {
5337+
"created_at": {
5338+
"type": "integer"
5339+
},
5340+
"discuss_id": {
5341+
"type": "integer"
5342+
},
5343+
"discuss_title": {
5344+
"type": "string"
5345+
},
5346+
"discuss_uuid": {
5347+
"type": "string"
5348+
},
5349+
"discussion_type": {
5350+
"$ref": "#/definitions/model.DiscussionType"
5351+
},
5352+
"forum_id": {
5353+
"type": "integer"
5354+
},
5355+
"from_bot": {
5356+
"type": "boolean"
5357+
},
5358+
"from_id": {
5359+
"type": "integer"
5360+
},
5361+
"from_name": {
5362+
"type": "string"
5363+
},
5364+
"id": {
5365+
"type": "integer"
5366+
},
5367+
"read": {
5368+
"type": "boolean"
5369+
},
5370+
"to_bot": {
5371+
"type": "boolean"
5372+
},
5373+
"to_id": {
5374+
"type": "integer"
5375+
},
5376+
"to_name": {
5377+
"type": "string"
5378+
},
5379+
"type": {
5380+
"$ref": "#/definitions/model.MsgNotifyType"
5381+
},
5382+
"updated_at": {
5383+
"type": "integer"
5384+
},
5385+
"user_id": {
5386+
"description": "通知到谁,除了发给机器人的信息,user_id 与 to_id 相同",
5387+
"type": "integer"
5388+
}
5389+
}
5390+
},
5391+
"model.MsgNotifyType": {
5392+
"type": "integer",
5393+
"enum": [
5394+
0,
5395+
1,
5396+
2,
5397+
3,
5398+
4,
5399+
5,
5400+
6,
5401+
7
5402+
],
5403+
"x-enum-varnames": [
5404+
"MsgNotifyTypeUnknown",
5405+
"MsgNotifyTypeReplyDiscuss",
5406+
"MsgNotifyTypeReplyComment",
5407+
"MsgNotifyTypeApplyComment",
5408+
"MsgNotifyTypeLikeComment",
5409+
"MsgNotifyTypeDislikeComment",
5410+
"MsgNotifyTypeBotUnknown",
5411+
"MsgNotifyTypeLikeDiscussion"
5412+
]
5413+
},
51925414
"model.PlatformOpt": {
51935415
"type": "object",
51945416
"properties": {
@@ -6167,6 +6389,14 @@ const docTemplate = `{
61676389
}
61686390
}
61696391
},
6392+
"svc.NotifyReadReq": {
6393+
"type": "object",
6394+
"properties": {
6395+
"id": {
6396+
"type": "integer"
6397+
}
6398+
}
6399+
},
61706400
"svc.OrgListItem": {
61716401
"type": "object",
61726402
"properties": {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package migration
2+
3+
import (
4+
"gorm.io/gorm"
5+
6+
"github.com/chaitin/koalaqa/migration/migrator"
7+
)
8+
9+
type fixNotifyToName struct{}
10+
11+
func (m *fixNotifyToName) Version() int64 {
12+
return 20251104182916
13+
}
14+
15+
func (m *fixNotifyToName) Migrate(tx *gorm.DB) error {
16+
return tx.Exec(`UPDATE message_notifies SET to_name = u.name
17+
FROM (SELECT id, name FROM users) AS u
18+
WHERE message_notifies.to_id = u.id`).Error
19+
}
20+
21+
func newFixNotifyToName() migrator.Migrator {
22+
return &fixNotifyToName{}
23+
}
24+
25+
func init() {
26+
registerDBMigrator(newFixNotifyToName)
27+
}

backend/model/message_notify.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ const (
1616
type MessageNotify struct {
1717
Base
1818

19-
UserID uint `gorm:"column:user_id"` // 通知到谁,除了发给机器人的信息,user_id 与 to_id 相同
19+
UserID uint `gorm:"column:user_id" json:"user_id"` // 通知到谁,除了发给机器人的信息,user_id 与 to_id 相同
2020

2121
MessageNotifyCommon
22-
Read bool `gorm:"column:read;default:false"`
22+
Read bool `gorm:"column:read;default:false" json:"read"`
2323
}
2424

2525
func init() {

backend/model/system.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ type AuthType uint
4545
const (
4646
AuthTypePassword = iota + 1
4747
AuthTypeOIDC
48+
AuthTypeWeCom
4849
)
4950

5051
type AuthInfo struct {
51-
Type AuthType `json:"type" binding:"min=1,max=2"`
52+
Type AuthType `json:"type" binding:"min=1,max=3"`
5253
Config AuthConfig `json:"config"`
5354
ButtonDesc string `json:"button_desc"`
5455
}
@@ -77,6 +78,7 @@ type AuthConfigOauth struct {
7778
URL string `json:"url,omitempty"`
7879
ClientID string `json:"client_id,omitempty"`
7980
ClientSecret string `json:"client_secret,omitempty"`
81+
CorpID string `json:"corp_id,omitempty"`
8082
}
8183

8284
type SystemBrand struct {

backend/pkg/third_auth/manager.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ func (m *Manager) Update(t model.AuthType, cfg Config, checkCfg bool) error {
3131
switch t {
3232
case model.AuthTypeOIDC:
3333
author = newOIDC(cfg)
34+
case model.AuthTypeWeCom:
35+
author = newWeCom(cfg)
3436
default:
3537
return errors.ErrUnsupported
3638
}
@@ -47,22 +49,22 @@ func (m *Manager) Update(t model.AuthType, cfg Config, checkCfg bool) error {
4749
return nil
4850
}
4951

50-
func (m *Manager) AuthURL(ctx context.Context, t model.AuthType, state string) (string, error) {
52+
func (m *Manager) AuthURL(ctx context.Context, t model.AuthType, state string, optFuncs ...authURLOptFunc) (string, error) {
5153
author, ok := m.author(t)
5254
if !ok {
5355
return "", errors.ErrUnsupported
5456
}
5557

56-
return author.AuthURL(ctx, state)
58+
return author.AuthURL(ctx, state, optFuncs...)
5759
}
5860

59-
func (o *Manager) User(ctx context.Context, t model.AuthType, code string, optFuncs ...userOptFunc) (*User, error) {
61+
func (o *Manager) User(ctx context.Context, t model.AuthType, code string) (*User, error) {
6062
author, ok := o.author(t)
6163
if !ok {
6264
return nil, errors.ErrUnsupported
6365
}
6466

65-
return author.User(ctx, code, optFuncs...)
67+
return author.User(ctx, code)
6668
}
6769

6870
func newManager() *Manager {

0 commit comments

Comments
 (0)