Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add custom service dialogue pages with im. #156

Merged
merged 4 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server/config.docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ openim:
ip: 127.0.0.1
api_port: 10002
platform_id: 5 # web
admin_id: openkf_admin # OpenIMServer admin userID

slack:
bot_token:
Expand Down
1 change: 1 addition & 0 deletions server/config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ openim:
ip: 127.0.0.1
api_port: 10002
platform_id: 5 # web
admin_id: openkf_admin # OpenIMServer admin userID

slack:
bot_token:
Expand Down
3 changes: 2 additions & 1 deletion server/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ email:
pool_size: 4

openim:
secret: openkf
secret: openIM123
ip: 127.0.0.1
api_port: 10002
platform_id: 5 # web
admin_id: openIMAdmin

slack:
bot_token:
Expand Down
4 changes: 2 additions & 2 deletions server/internal/api/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
func CreateStaff(c *gin.Context) {
uuid, err := utils.GetCommunityUUID(c)
if err != nil {
response.FailWithCode(common.ERROR, c)
response.FailWithAll(common.ERROR, err.Error(), c)

return
}
Expand All @@ -53,7 +53,7 @@ func CreateStaff(c *gin.Context) {
svc := service.NewUserService(c)
_, _, err = svc.CreateStaff(uuid, &params)
if err != nil {
response.FailWithCode(common.ERROR, c)
response.FailWithAll(common.ERROR, err.Error(), c)

return
}
Expand Down
2 changes: 2 additions & 0 deletions server/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func ConfigInit(configPath string) {
Ip: GetStringOrDefault("openim.ip", "127.0.0.1"),
ApiPort: GetIntOrDefault("openim.api_port", 10002),
PlatformID: GetIntOrDefault("openim.platform_id", 5),
AdminID: GetStringOrDefault("openim.admin_id", "openkf_admin"),
},
Slack: Slack{
BotToken: GetString("slack.bot_token"),
Expand Down Expand Up @@ -170,6 +171,7 @@ type OpenIM struct {
Ip string `mapstructure:"ip"`
ApiPort int `mapstructure:"api_port"`
PlatformID int `mapstructure:"platform_id"`
AdminID string `mapstructure:"admin_id"`
}

// Slack Bot config.
Expand Down
6 changes: 2 additions & 4 deletions server/internal/dal/dao/gen_sys_bot_dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
"context"
"time"

"github.com/gofrs/uuid"

"github.com/OpenIMSDK/OpenKF/server/internal/conn/db"
"github.com/OpenIMSDK/OpenKF/server/internal/dal/cache"
"github.com/OpenIMSDK/OpenKF/server/internal/dal/gen"
Expand Down Expand Up @@ -125,14 +123,14 @@ func (d *SysBotDao) FindByDeletedAtPage(deletedat time.Time, offset int, limit i
}

// FindFirstByUUID get first matched result by uuid.
func (d *SysBotDao) FindFirstByUUID(uuid uuid.UUID) (*systemroles.SysBot, error) {
func (d *SysBotDao) FindFirstByUUID(uuid string) (*systemroles.SysBot, error) {
m := d.query.SysBot

return m.WithContext(d.ctx).Where(m.UUID.Eq(uuid)).First()
}

// FindByUUIDPage get page by UUID.
func (d *SysBotDao) FindByUUIDPage(uuid uuid.UUID, offset int, limit int) ([]*systemroles.SysBot, int64, error) {
func (d *SysBotDao) FindByUUIDPage(uuid string, offset int, limit int) ([]*systemroles.SysBot, int64, error) {
m := d.query.SysBot

result, count, err := m.WithContext(d.ctx).Where(m.UUID.Eq(uuid)).FindByPage(offset, limit)
Expand Down
6 changes: 2 additions & 4 deletions server/internal/dal/dao/gen_sys_community_dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
"context"
"time"

"github.com/gofrs/uuid"

"github.com/OpenIMSDK/OpenKF/server/internal/conn/db"
"github.com/OpenIMSDK/OpenKF/server/internal/dal/cache"
"github.com/OpenIMSDK/OpenKF/server/internal/dal/gen"
Expand Down Expand Up @@ -125,14 +123,14 @@ func (d *SysCommunityDao) FindByDeletedAtPage(deletedat time.Time, offset int, l
}

// FindFirstByUUID get first matched result by uuid.
func (d *SysCommunityDao) FindFirstByUUID(uuid uuid.UUID) (*systemroles.SysCommunity, error) {
func (d *SysCommunityDao) FindFirstByUUID(uuid string) (*systemroles.SysCommunity, error) {
m := d.query.SysCommunity

return m.WithContext(d.ctx).Where(m.UUID.Eq(uuid)).First()
}

// FindByUUIDPage get page by UUID.
func (d *SysCommunityDao) FindByUUIDPage(uuid uuid.UUID, offset int, limit int) ([]*systemroles.SysCommunity, int64, error) {
func (d *SysCommunityDao) FindByUUIDPage(uuid string, offset int, limit int) ([]*systemroles.SysCommunity, int64, error) {
m := d.query.SysCommunity

result, count, err := m.WithContext(d.ctx).Where(m.UUID.Eq(uuid)).FindByPage(offset, limit)
Expand Down
6 changes: 2 additions & 4 deletions server/internal/dal/dao/gen_sys_customer_dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
"context"
"time"

"github.com/gofrs/uuid"

"github.com/OpenIMSDK/OpenKF/server/internal/conn/db"
"github.com/OpenIMSDK/OpenKF/server/internal/dal/cache"
"github.com/OpenIMSDK/OpenKF/server/internal/dal/gen"
Expand Down Expand Up @@ -125,14 +123,14 @@ func (d *SysCustomerDao) FindByDeletedAtPage(deletedat time.Time, offset int, li
}

// FindFirstByUUID get first matched result by uuid.
func (d *SysCustomerDao) FindFirstByUUID(uuid uuid.UUID) (*systemroles.SysCustomer, error) {
func (d *SysCustomerDao) FindFirstByUUID(uuid string) (*systemroles.SysCustomer, error) {
m := d.query.SysCustomer

return m.WithContext(d.ctx).Where(m.UUID.Eq(uuid)).First()
}

// FindByUUIDPage get page by UUID.
func (d *SysCustomerDao) FindByUUIDPage(uuid uuid.UUID, offset int, limit int) ([]*systemroles.SysCustomer, int64, error) {
func (d *SysCustomerDao) FindByUUIDPage(uuid string, offset int, limit int) ([]*systemroles.SysCustomer, int64, error) {
m := d.query.SysCustomer

result, count, err := m.WithContext(d.ctx).Where(m.UUID.Eq(uuid)).FindByPage(offset, limit)
Expand Down
6 changes: 2 additions & 4 deletions server/internal/dal/dao/gen_sys_user_dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
"context"
"time"

"github.com/gofrs/uuid"

"github.com/OpenIMSDK/OpenKF/server/internal/conn/db"
"github.com/OpenIMSDK/OpenKF/server/internal/dal/cache"
"github.com/OpenIMSDK/OpenKF/server/internal/dal/gen"
Expand Down Expand Up @@ -125,14 +123,14 @@ func (d *SysUserDao) FindByDeletedAtPage(deletedat time.Time, offset int, limit
}

// FindFirstByUUID get first matched result by uuid.
func (d *SysUserDao) FindFirstByUUID(uuid uuid.UUID) (*systemroles.SysUser, error) {
func (d *SysUserDao) FindFirstByUUID(uuid string) (*systemroles.SysUser, error) {
m := d.query.SysUser

return m.WithContext(d.ctx).Where(m.UUID.Eq(uuid)).First()
}

// FindByUUIDPage get page by UUID.
func (d *SysUserDao) FindByUUIDPage(uuid uuid.UUID, offset int, limit int) ([]*systemroles.SysUser, int64, error) {
func (d *SysUserDao) FindByUUIDPage(uuid string, offset int, limit int) ([]*systemroles.SysUser, int64, error) {
m := d.query.SysUser

result, count, err := m.WithContext(d.ctx).Where(m.UUID.Eq(uuid)).FindByPage(offset, limit)
Expand Down
6 changes: 3 additions & 3 deletions server/internal/dal/gen/sys_bot.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions server/internal/dal/gen/sys_community.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions server/internal/dal/gen/sys_customer.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions server/internal/dal/gen/sys_user.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions server/internal/models/base/user_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@

package base

import "github.com/gofrs/uuid"

// UserBase user base model.
type UserBase struct {
Model

UUID uuid.UUID `json:"uuid" gorm:"index;type:varchar(36);not null;comment:UUID"`
Email string `json:"email" gorm:"type:varchar(255);not null;unique;comment:Email"`
Nickname string `json:"nickname" gorm:"type:varchar(20);not null;comment:Nickname"`
Avatar string `json:"avatar" gorm:"type:varchar(255);not null;comment:Avatar"`
Description string `json:"description" gorm:"type:varchar(255);not null;comment:Description"`
IsEnable bool `json:"is_enable" gorm:"type:tinyint(1);not null;default:1;comment:IsEnable,1:enable,0:disable"`
UUID string `json:"uuid" gorm:"index;type:varchar(36);not null;comment:UUID"`
Email string `json:"email" gorm:"type:varchar(255);not null;unique;comment:Email"`
Nickname string `json:"nickname" gorm:"type:varchar(20);not null;comment:Nickname"`
Avatar string `json:"avatar" gorm:"type:varchar(255);not null;comment:Avatar"`
Description string `json:"description" gorm:"type:varchar(255);not null;comment:Description"`
IsEnable bool `json:"is_enable" gorm:"type:tinyint(1);not null;default:1;comment:IsEnable,1:enable,0:disable"`
}
4 changes: 1 addition & 3 deletions server/internal/models/system_roles/sys_bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@
package systemroles

import (
"github.com/gofrs/uuid"

"github.com/OpenIMSDK/OpenKF/server/internal/models/base"
)

// SysBot system bot model.
type SysBot struct {
base.Model

UUID uuid.UUID `json:"uuid" gorm:"index;type:varchar(36);not null;comment:UUID"`
UUID string `json:"uuid" gorm:"index;type:varchar(36);not null;comment:UUID"`
BotAddr string `gorm:"column:bot_addr;type:varchar(255);not null;comment:'AI bot address'"`
BotPort int `gorm:"column:bot_port;type:int(11);not null;comment:'AI bot port'"`
BotToken string `gorm:"column:bot_token;type:varchar(255);not null;comment:'AI bot token'"`
Expand Down
12 changes: 5 additions & 7 deletions server/internal/models/system_roles/sys_community.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,18 @@
package systemroles

import (
"github.com/gofrs/uuid"

"github.com/OpenIMSDK/OpenKF/server/internal/models/base"
)

// SysCommunity system community model.
type SysCommunity struct {
base.Model

UUID uuid.UUID `gorm:"index;column:uuid;column:uuid;not null;unique;comment:'community uuid'"`
Name string `gorm:"column:name;type:varchar(64);not null;comment:'community name'"`
Email string `gorm:"column:email;type:varchar(64);not null;comment:'community email'"`
Avatar string `gorm:"column:avatar;type:varchar(255);not null;comment:'community avatar'"`
Description string `gorm:"column:description;type:varchar(255);not null;comment:'community description'"`
UUID string `gorm:"index;column:uuid;column:uuid;not null;unique;comment:'community uuid'"`
Name string `gorm:"column:name;type:varchar(64);not null;comment:'community name'"`
Email string `gorm:"column:email;type:varchar(64);not null;comment:'community email'"`
Avatar string `gorm:"column:avatar;type:varchar(255);comment:'community avatar'"`
Description string `gorm:"column:description;type:varchar(255);comment:'community description'"`
}

// TableName table name.
Expand Down
4 changes: 2 additions & 2 deletions server/internal/params/request/community.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package requestparams
type CommunityParams struct {
Name string `json:"name" binding:"required"`
Email string `json:"email" binding:"required"`
Description *string `json:"description"` // Description is optional.
Avatar *string `json:"avatar" binding:"required"` // Avatar is optional.
Description *string `json:"description"` // Description is optional.
Avatar *string `json:"avatar"` // Avatar is optional.
}

// GetCommunityInfoParams community info params.
Expand Down
Loading
Loading