Commit 7c8e65bf by keith

UPDATE

parent babaca33
Showing with 304 additions and 48 deletions
......@@ -59,7 +59,7 @@ func (c *BaseController) GetUserInfo() *models.User {
var userRepository = services.GetUserRepositoryInstance()
user := userRepository.GetUserWithToken(token)
if user == nil {
logs.Warn("GetAdminAuthInfo fun error------------登录已失效!")
logs.Warn("GetUserInfo get current user info error------------登录已失效!")
}
return user
}
......@@ -30,7 +30,7 @@ func (c *CompanyController) Finish() {}
// Get get conpany info
func (c *CompanyController) Get() {
company := c.CompanyRepository.GetCompany(1)
company := c.CompanyRepository.GetCompany()
if company == nil {
c.JSON(configs.ResponseFail, "fail", nil)
}
......@@ -62,7 +62,7 @@ func (c *CompanyController) Put() {
}
// orm
row, err := c.CompanyRepository.Update(1, orm.Params{
row, err := c.CompanyRepository.Update(orm.Params{
"Title": company.Title,
"Address": company.Address,
"Email": company.Email,
......
......@@ -5,14 +5,12 @@ import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/toolbox"
_ "github.com/go-sql-driver/mysql"
"kefu_server/controllers"
"kefu_server/db"
"kefu_server/grpcs"
_ "kefu_server/routers"
"kefu_server/task"
)
// Initialization log
......@@ -39,9 +37,9 @@ func main() {
initLog()
// init task
task.Run()
toolbox.StartTask()
defer toolbox.StopTask()
// task.Run()
// toolbox.StartTask()
// defer toolbox.StopTask()
/// Static file configuration
beego.SetStaticPath("/", "public/client")
......
......@@ -5,13 +5,16 @@ type WorkOrder struct {
ID int64 `orm:"auto;pk;type(bigint);column(id)" json:"id"` // ID
UID int64 `orm:"type(bigint);column(uid)" json:"uid"` // 用户ID
TID int64 `orm:"type(bigint);column(tid))" json:"tid"` // 工单类型ID
Title string `orm:"column(title)" json:"title"` // 工单标题
Content string `orm:"type(text);column(content)" json:"content"` // 内容
Phone string `orm:"type(char);null;column(phone)" json:"phone"` // 用户联系电话
Email string `orm:"type(varchar);null;column(email)" json:"email"` // 邮箱(可用于客服回复后发提醒邮件给客户)
Status int `orm:"default(0);column(status)" json:"status"` // 当前状态 ( 0=待处理 | 1=客服已回复 | 2=客户已回复 | 3=已结单 )
LastReply int64 `orm:"type(bigint);column(last_reply))" json:"last_reply"` // 最后回复的客服ID
CID int64 `orm:"type(bigint);column(cid))" json:"cid"` // 结单客服ID
CloseAt int64 `orm:"type(bigint);column(close_at)" json:"close_at"` // 结单时间
Comment string `orm:"type(text);column(comment)" json:"comment"` // 结单原因
Content string // 内容(不实际存储)
Remark string `orm:"column(remark)" json:"remark"` // 结单原因
UpdateAt int64 `orm:"type(bigint);column(update_at)" json:"update_at"` // 更新时间
Delete int `orm:"default(0);column(delete)" json:"delete"` // 是否已删除 0 未删除, 1已删除 (未结单状态不能删除)
CreateAt int64 `orm:"type(bigint);column(create_at)" json:"create_at"` // 提交时间
}
File mode changed
No preview for this file type
No preview for this file type
No preview for this file type

4.35 KB | W: | H:

4.35 KB | W: | H:

public/admin/img/kefu_logo.9c308a55.png
public/admin/img/kefu_logo.9c308a55.png
public/admin/img/kefu_logo.9c308a55.png
public/admin/img/kefu_logo.9c308a55.png
  • 2-up
  • Swipe
  • Onion skin

237 KB | W: | H:

237 KB | W: | H:

public/admin/img/login_bg.8ba760be.jpg
public/admin/img/login_bg.8ba760be.jpg
public/admin/img/login_bg.8ba760be.jpg
public/admin/img/login_bg.8ba760be.jpg
  • 2-up
  • Swipe
  • Onion skin

23.4 KB | W: | H:

23.4 KB | W: | H:

public/admin/img/login_bg1.531e0c1c.jpg
public/admin/img/login_bg1.531e0c1c.jpg
public/admin/img/login_bg1.531e0c1c.jpg
public/admin/img/login_bg1.531e0c1c.jpg
  • 2-up
  • Swipe
  • Onion skin
File mode changed
File mode changed
File mode changed
File mode changed
No preview for this file type

8.64 KB | W: | H:

8.64 KB | W: | H:

public/client/img/expression.73c98a16.png
public/client/img/expression.73c98a16.png
public/client/img/expression.73c98a16.png
public/client/img/expression.73c98a16.png
  • 2-up
  • Swipe
  • Onion skin

5.59 KB | W: | H:

5.59 KB | W: | H:

public/client/img/photo_btn.c337b681.png
public/client/img/photo_btn.c337b681.png
public/client/img/photo_btn.c337b681.png
public/client/img/photo_btn.c337b681.png
  • 2-up
  • Swipe
  • Onion skin
File mode changed
File mode changed
......@@ -50,6 +50,10 @@ func init() {
beego.NSRouter("/message/cancel", &controllers.PublicController{}, "post:CancelMessage"),
beego.NSRouter("/workorder/create", &controllers.PublicController{}, "post:CreateWorkOrder"),
beego.NSRouter("/workorder/reply", &controllers.PublicController{}, "post:ReplyWorkOrder"),
beego.NSRouter("/workorders", &controllers.PublicController{}, "get:GetWorkOrders"),
beego.NSRouter("/workorder/comments/:wid", &controllers.PublicController{}, "get:GetWorkOrderComments"),
beego.NSRouter("/workorder/:wid", &controllers.PublicController{}, "get:GetWorkOrder"),
beego.NSRouter("/workorder/:wid", &controllers.PublicController{}, "delete:DeleteWorkOrder"),
),
// knowledge_base
......
......@@ -9,7 +9,7 @@ import (
// CompanyRepositoryInterface interface
type CompanyRepositoryInterface interface {
GetCompany(id int64) *models.Company
GetCompany() *models.Company
Update(id int64, params *orm.Params) (int64, error)
}
......@@ -26,9 +26,9 @@ func GetCompanyRepositoryInstance() *CompanyRepository {
}
// GetCompany get one company
func (r *CompanyRepository) GetCompany(id int64) *models.Company {
func (r *CompanyRepository) GetCompany() *models.Company {
var company models.Company
if err := r.q.Filter("id", id).One(&company); err != nil {
if err := r.q.Filter("id", 1).One(&company); err != nil {
logs.Warn("GetCompany get one company------------", err)
return nil
}
......@@ -36,8 +36,8 @@ func (r *CompanyRepository) GetCompany(id int64) *models.Company {
}
// Update company
func (r *CompanyRepository) Update(id int64, params orm.Params) (int64, error) {
index, err := r.q.Filter("id", id).Update(params)
func (r *CompanyRepository) Update(params orm.Params) (int64, error) {
index, err := r.q.Filter("id", 1).Update(params)
if err != nil {
logs.Warn("Update company------------", err)
}
......
......@@ -2,14 +2,14 @@ package services
import (
"kefu_server/models"
"time"
"github.com/astaxie/beego/logs"
)
// WorkOrderCommentRepositoryInterface interface
type WorkOrderCommentRepositoryInterface interface {
GetWorkOrder() *models.WorkOrderComment
DeleteAll(wid int64) (int64, error)
GetWorkOrderComments(wid int64) ([]models.WorkOrderComment, error)
Add(workOrderComment models.WorkOrderComment) (int64, error)
}
......@@ -25,20 +25,22 @@ func GetWorkOrderCommentRepositoryInstance() *WorkOrderCommentRepository {
return instance
}
// Add add WorkOrderComment
func (r *WorkOrderCommentRepository) Add(workOrderComment models.WorkOrderComment) (int64, error) {
index, err := r.o.Insert(workOrderComment)
// GetWorkOrderComments get WorkOrderComments
func (r *WorkOrderCommentRepository) GetWorkOrderComments(wid int64) ([]models.WorkOrderComment, error) {
var workOrderComments []models.WorkOrderComment
_, err := r.q.Filter("wid", wid).OrderBy("id").All(&workOrderComments)
if err != nil {
logs.Warn(" Add add WorkOrderComment------------", err)
logs.Warn("GetWorkOrderComments get WorkOrderComments-----------", err)
}
return index, err
return workOrderComments, err
}
// DeleteAll delete all WorkOrderComment
func (r *WorkOrderCommentRepository) DeleteAll(wid int64) (int64, error) {
index, err := r.q.Filter("wid", wid).Delete()
// Add add WorkOrderComment
func (r *WorkOrderCommentRepository) Add(workOrderComment models.WorkOrderComment) (int64, error) {
workOrderComment.CreateAt = time.Now().Unix()
index, err := r.o.Insert(&workOrderComment)
if err != nil {
logs.Warn(" DeleteAll delete all WorkOrderComment------------", err)
logs.Warn(" Add add WorkOrderComment------------", err)
}
return index, err
}
......@@ -10,10 +10,12 @@ import (
// WorkOrderRepositoryInterface interface
type WorkOrderRepositoryInterface interface {
GetWorkOrder() models.WorkOrder
GetWorkOrder(id int64) (models.WorkOrder, error)
GetUserWorkOrders(uid int64) ([]models.WorkOrder, error)
Update(id int64, params *orm.Params) (int64, error)
Add(workOrder models.WorkOrder) (int64, error)
Delete(id int64) (int64, error)
Close(id int64) (int64, error)
}
// WorkOrderRepository struct
......@@ -30,26 +32,53 @@ func GetWorkOrderRepositoryInstance() *WorkOrderRepository {
return instance
}
// Delete delete WorkOrder
func (r *WorkOrderRepository) Delete(id int64) (int64, error) {
index, err := r.q.Filter("id", id).Delete()
// Close close WorkOrder
func (r *WorkOrderRepository) Close(id int64) (int64, error) {
row, err := r.q.Filter("id", id).Update(orm.Params{
"Status": 3,
})
if err != nil {
logs.Warn("Close close WorkOrder-----------", err)
}
return row, err
}
// GetUserWorkOrders get user WorkOrders
func (r *WorkOrderRepository) GetUserWorkOrders(uid int64) ([]models.WorkOrder, error) {
var workOrders []models.WorkOrder
_, err := r.q.Filter("uid", uid).Filter("delete", 0).OrderBy("-id").All(&workOrders)
if err != nil {
logs.Warn("Delete delete WorkOrder------------", err)
logs.Warn("GetUserWorkOrders get user WorkOrders------------", err)
}
if index > 0 {
_, err := r.WorkOrderCommentRepository.DeleteAll(id)
return workOrders, err
}
// GetWorkOrder get WorkOrder
func (r *WorkOrderRepository) GetWorkOrder(id int64) (models.WorkOrder, error) {
var workOrder models.WorkOrder
err := r.q.Filter("id", id).One(&workOrder)
if err != nil {
logs.Warn("Delete delete WorkOrder child------------", err)
logs.Warn("GetWorkOrder get WorkOrder------------", err)
}
return workOrder, err
}
// Delete delete WorkOrder
func (r *WorkOrderRepository) Delete(id int64) (int64, error) {
row, err := r.q.Filter("id", id).Update(orm.Params{
"Delete": 1,
})
if err != nil {
logs.Warn("Delete delete WorkOrder-----------", err)
}
return index, err
return row, err
}
// Add add WorkOrder
func (r *WorkOrderRepository) Add(workOrder models.WorkOrder) (int64, error) {
createAt := time.Now().Unix()
workOrder.CreateAt = createAt
wid, err := r.o.Insert(workOrder)
wid, err := r.o.Insert(&workOrder)
if err != nil {
logs.Warn("Add add WorkOrder------------", err)
}
......@@ -65,6 +94,7 @@ func (r *WorkOrderRepository) Add(workOrder models.WorkOrder) (int64, error) {
// Update WorkOrder Info
func (r *WorkOrderRepository) Update(id int64, params orm.Params) (int64, error) {
params["UpdateAt"] = time.Now().Unix()
index, err := r.q.Filter("id", id).Update(params)
if err != nil {
logs.Warn("Update WorkOrder Info------------", err)
......
No preview for this file type
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