Commit ad0a0917 by keith

join

parent c6bb2418
......@@ -131,12 +131,12 @@ GO 》》》》》 [小米开放平台][6]
mimc_appKey = ""
mimc_appSecret = ""
# IM数据库信息
im_alias_name = "default"
im_driver_name= "mysql"
im_mysql_host = "localhost"
im_mysql_user = "root"
im_mysql_db = "kefu_server"
im_mysql_pwd = "keith"
kf_alias_name = "default"
kf_driver_name= "mysql"
kf_mysql_host = "localhost"
kf_mysql_user = "root"
kf_mysql_db = "kefu_server"
kf_mysql_pwd = "keith"
```
> **Note:** 根据beego的配置文件配置,填写从小米开放平台获得的appId,appKey, appSecret, 以及您的数据库连接,账号,密码
......
......@@ -27,13 +27,15 @@ httpaddr = "localhost"
mimc_appId = 2882303761517669588
mimc_appKey = "5111766983588"
mimc_appSecret = "b0L3IOz/9Ob809v8H2FbVg=="
# IM数据库信息
im_alias_name = "default"
im_driver_name= "mysql"
im_mysql_host = "192.168.31.72"
im_mysql_user = "root"
im_mysql_db = "kefu_server"
im_mysql_pwd = "chenxianqi"
kf_alias_name = "default"
kf_driver_name= "mysql"
kf_mysql_host = "aissz.com"
kf_mysql_port = "3636"
kf_mysql_user = "root"
kf_mysql_db = "kefu_server"
kf_mysql_pwd = "chenxianqi"
[prod]
......@@ -43,9 +45,10 @@ mimc_appId =
mimc_appKey = ""
mimc_appSecret = ""
# IM数据库信息
im_alias_name = "default"
im_driver_name= "mysql"
im_mysql_host = "host"
im_mysql_user = "user"
im_mysql_db = "kefu_server"
im_mysql_pwd = "pwd"
kf_alias_name = "default"
kf_driver_name= "mysql"
kf_mysql_host = "host"
kf_mysql_port = "3306"
kf_mysql_user = "user"
kf_mysql_db = "kefu_server"
kf_mysql_pwd = "pwd"
......@@ -174,7 +174,7 @@ func (c *PublicController) Register() {
resData = successData{Token: &imTokenDto, User: &admin}
}
c.JSON(configs.ResponseSucess, "获取成功!", &resData)
c.JSON(configs.ResponseSucess, "注册成功!", &resData)
}
......@@ -186,7 +186,7 @@ func (c *PublicController) Read() {
if err == nil {
readCount = 0
}
c.JSON(configs.ResponseSucess, "获取成功!", readCount)
c.JSON(configs.ResponseSucess, "查询成功!", readCount)
}
......@@ -217,7 +217,7 @@ func (c *PublicController) Window() {
c.JSON(configs.ResponseFail, "更新失败!", nil)
}
c.JSON(configs.ResponseSucess, "更新更新成功!", nil)
c.JSON(configs.ResponseSucess, "更新成功!", nil)
}
// CleanRead clean user read
......@@ -381,6 +381,7 @@ func (c *PublicController) PushMessage() {
utils.MessageInto(getMessage, false)
c.JSON(configs.ResponseSucess, "push success", nil)
}
// Upload upload image
......
package controllers
import (
"kefu_server/configs"
"kefu_server/services"
)
// WorkOrderController struct
type WorkOrderController struct {
BaseController
WorkOrderRepository *services.WorkOrderRepository
WorkOrderTypeRepository *services.WorkOrderTypeRepository
WorkOrderCommentRepository *services.WorkOrderCommentRepository
}
// Prepare More like construction method
func (c *WorkOrderController) Prepare() {
// WorkOrderRepository instance
c.WorkOrderRepository = services.GetWorkOrderRepositoryInstance()
// WorkOrderTypeRepository instance
c.WorkOrderTypeRepository = services.GetWorkOrderTypeRepositoryInstance()
// WorkOrderCommentRepository instance
c.WorkOrderCommentRepository = services.GetWorkOrderCommentRepositoryInstance()
}
// Finish Comparison like destructor
func (c *WorkOrderController) Finish() {}
// Get get one WorkOrder
func (c *WorkOrderController) Get() {
}
// Post create WorkOrder
func (c *WorkOrderController) Post() {
}
// Put update WorkOrder
func (c *WorkOrderController) Put() {
}
// Delete delete WorkOrder
func (c *WorkOrderController) Delete() {
}
// Comment send comment
func (c *WorkOrderController) Comment() {
}
// PostType add work order type
func (c *WorkOrderController) PostType() {
c.JSON(configs.ResponseSucess, "success", nil)
}
// GetType get work order type
func (c *WorkOrderController) GetType() {
}
// GetTypes get work order types
func (c *WorkOrderController) GetTypes() {
}
// PutType update work order type
func (c *WorkOrderController) PutType() {
}
// DeleteType delete work order type
func (c *WorkOrderController) DeleteType() {
}
......@@ -11,13 +11,14 @@ import (
func Run() {
// 链接IM数据库
imAliasName := beego.AppConfig.String("im_alias_name")
imDriverName := beego.AppConfig.String("im_driver_name")
imAliasName := beego.AppConfig.String("kf_alias_name")
imDriverName := beego.AppConfig.String("kf_driver_name")
var imDataSource string
imDataSource = beego.AppConfig.String("im_mysql_user") + ":"
imDataSource += beego.AppConfig.String("im_mysql_pwd")
imDataSource += "@tcp(" + beego.AppConfig.String("im_mysql_host") + ":3306" + ")/"
imDataSource += beego.AppConfig.String("im_mysql_db") + "?charset=utf8"
imDataSource = beego.AppConfig.String("kf_mysql_user") + ":"
imDataSource += beego.AppConfig.String("kf_mysql_pwd")
imDataSource += "@tcp(" + beego.AppConfig.String("kf_mysql_host")
imDataSource += ":" + beego.AppConfig.String("kf_mysql_port") + ")/"
imDataSource += beego.AppConfig.String("kf_mysql_db") + "?charset=utf8"
_ = orm.RegisterDataBase(imAliasName, imDriverName, imDataSource, 30)
// 注册模型
......@@ -36,6 +37,9 @@ func Run() {
orm.RegisterModel(new(models.ServicesStatistical))
orm.RegisterModel(new(models.AuthTypes))
orm.RegisterModel(new(models.Auths))
orm.RegisterModel(new(models.WorkOrder))
orm.RegisterModel(new(models.WorkOrderType))
orm.RegisterModel(new(models.WorkOrderComment))
// 创建表
_ = orm.RunSyncdb("default", false, true)
......
......@@ -10,9 +10,7 @@ import (
"kefu_server/controllers"
"kefu_server/db"
"kefu_server/im"
_ "kefu_server/routers"
"kefu_server/task"
)
// Initialization log
......@@ -41,18 +39,18 @@ func main() {
initLog()
// init task
task.Run()
// task.Run()
/// Static file configuration
beego.SetStaticPath("/", "public/client")
beego.SetStaticPath("/admin", "public/admin")
beego.SetStaticPath("/static", "static")
// Error handling
// Handling Error
beego.ErrorController(&controllers.ErrorController{})
// init robot
im.RobotInit()
// im.RobotInit()
// run application
beego.Run()
......
package models
// WorkOrderComment model
type WorkOrderComment struct {
ID int64 `orm:"auto;pk;type(bigint);column(id)" json:"id"` // ID
WID int64 `orm:"type(bigint);column(wid)" json:"wid"` // 关联(WorkOrder ID)
Content string `orm:"type(text);null;column(content)" json:"content"` // 内容
}
package models
// WorkOrderType model
type WorkOrderType struct {
ID int64 `orm:"auto;pk;type(bigint);column(id)" json:"id"` // ID
WID int64 `orm:"type(bigint);column(wid)" json:"wid"` // 关联(WorkOrder ID)
Title string `orm:"type(varchar);null;column(title)" json:"title"` // 类型名称
}
......@@ -7,8 +7,10 @@ type WorkOrder struct {
AID int64 `orm:"type(bigint);column(aid))" json:"aid"` // 客服ID
TID int64 `orm:"type(bigint);column(tid))" json:"tid"` // 工单类型ID
Phone string `orm:"type(char);null;column(phone)" json:"phone"` // 用户联系电话
Email string `orm:"type(varchar);null;column(email)" json:"email"` // 邮箱(可用于回复后发提醒邮件给客户)
CreateAt int64 `orm:"type(bigint);column(create_at)" json:"create_at"` // 提交时间
Email string `orm:"type(varchar);null;column(email)" json:"email"` // 邮箱(可用于客服回复后发提醒邮件给客户)
Status int `orm:"default(0);column(status)" json:"status"` // 当前状态 ( 0=待处理 | 1=客服已回复 | 2=客户已回复 | 3=已结单 )
CID int64 `orm:"type(bigint);column(cid))" json:"cid"` // 结单客服ID
CloseAt int64 `orm:"type(bigint);column(close_at)" json:"close_at"` // 结单时间
Comment int64 `orm:"type(bigint);column(comment)" json:"comment"` // 结单原因
CreateAt int64 `orm:"type(bigint);column(create_at)" json:"create_at"` // 提交时间
}
package models
// WorkOrderComment model
type WorkOrderComment struct {
ID int64 `orm:"auto;pk;type(bigint);column(id)" json:"id"` // ID
WID int64 `orm:"type(bigint);column(wid)" json:"wid"` // 关联(WorkOrder ID)
Content string `orm:"type(text);null;column(content)" json:"content"` // 内容
CreateAt int64 `orm:"type(bigint);column(create_at)" json:"create_at"` // 提交时间
}
package models
// WorkOrderType model
type WorkOrderType struct {
ID int64 `orm:"auto;pk;type(bigint);column(id)" json:"id"` // ID
Title string `orm:"type(varchar);null;column(title)" json:"title"` // 类型名称
CreateAt int64 `orm:"type(bigint);column(create_at)" json:"create_at"` // 提交时间
}
......@@ -147,6 +147,12 @@ func init() {
beego.NSBefore(filters.FilterToken),
beego.NSRouter("/list", &controllers.ServicesStatisticalController{}, "post:List"),
),
// Work Order
beego.NSNamespace("/workorder",
beego.NSBefore(filters.FilterToken),
beego.NSRouter("/type", &controllers.WorkOrderController{}, "post:PostType"),
),
)
beego.AddNamespace(ns)
......
package services
import (
"kefu_server/models"
)
// WorkOrderCommentRepositoryInterface interface
type WorkOrderCommentRepositoryInterface interface {
GetWorkOrder() *models.WorkOrderComment
}
// WorkOrderCommentRepository struct
type WorkOrderCommentRepository struct {
BaseRepository
}
// GetWorkOrderCommentRepositoryInstance get instance
func GetWorkOrderCommentRepositoryInstance() *WorkOrderCommentRepository {
instance := new(WorkOrderCommentRepository)
instance.Init(new(models.WorkOrderComment))
return instance
}
package services
import (
"kefu_server/models"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/orm"
)
// WorkOrderRepositoryInterface interface
type WorkOrderRepositoryInterface interface {
GetWorkOrder() *models.WorkOrder
Update(id int64,params *orm.Params) (int64, error)
}
// WorkOrderRepository struct
type WorkOrderRepository struct {
BaseRepository
}
// GetWorkOrderRepositoryInstance get instance
func GetWorkOrderRepositoryInstance() *WorkOrderRepository {
instance := new(WorkOrderRepository)
instance.Init(new(models.WorkOrder))
return instance
}
// Update WorkOrder Info
func (r *WorkOrderRepository) Update(id int64,params orm.Params) (int64, error) {
index, err := r.q.Filter("id", id).Update(params)
if err != nil {
logs.Warn("Update WorkOrder Info------------", err)
}
return index, err
}
package services
import (
"kefu_server/models"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/orm"
)
// WorkOrderTypeRepositoryInterface interface
type WorkOrderTypeRepositoryInterface interface {
GetWorkOrder() *models.WorkOrderType
Update(id int64,params *orm.Params) (int64, error)
}
// WorkOrderTypeRepository struct
type WorkOrderTypeRepository struct {
BaseRepository
}
// GetWorkOrderTypeRepositoryInstance get instance
func GetWorkOrderTypeRepositoryInstance() *WorkOrderTypeRepository {
instance := new(WorkOrderTypeRepository)
instance.Init(new(models.WorkOrderType))
return instance
}
// Update WorkOrderType Info
func (r *WorkOrderTypeRepository) Update(id int64,params orm.Params) (int64, error) {
index, err := r.q.Filter("id", id).Update(params)
if err != nil {
logs.Warn("Update WorkOrderType Info------------", err)
}
return index, err
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment