修改
This commit is contained in:
commit
f41697bcf0
File diff suppressed because it is too large
Load Diff
@ -18,9 +18,9 @@
|
||||
syntax = "proto3";
|
||||
package accountFiee;
|
||||
import "github.com/mwitkow/go-proto-validators@v0.3.2/validator.proto";
|
||||
|
||||
option go_package = "./;accountFiee";
|
||||
|
||||
//protoc -I . -I C:\Users\lenovo\go\src --go_out=. --go-triple_out=. ./accountFiee.proto
|
||||
service AccountFiee {
|
||||
rpc Login (LoginRequest) returns (TokenInfo) {}
|
||||
rpc RefreshToken (RefreshTokenRequest) returns (TokenInfo) {} //刷新token
|
||||
@ -65,6 +65,34 @@ service AccountFiee {
|
||||
|
||||
// submit info
|
||||
rpc SaveSubmitInfo(SubmitInfoRequest) returns (CommonResponse);
|
||||
|
||||
//-----------------------------客服聊天系统--------------------------------
|
||||
rpc CreateChatUser ( ChatUserData )returns( CreateChatUserResp ){} //创建聊天用户
|
||||
rpc UpdateChatUser ( ChatUserData )returns( CommonMsg ){} //更新聊天用户
|
||||
rpc SaveChatUser ( ChatUserData )returns( CommonMsg ){} //覆盖聊天用户
|
||||
rpc DeleteChatUser ( DeleteChatUserRequest )returns( CommonMsg ){} //删除聊天用户
|
||||
rpc GetChatUserDetail ( GetChatUserByIdRequest )returns( ChatUserData ){} //查询聊天用户详情
|
||||
rpc GetChatUserList ( GetChatUserListRequest )returns( GetChatUserListResp ){} //查询聊天用户列表
|
||||
rpc GetChatUserList2 ( GetChatUserListRequest2 )returns( GetChatUserListResp2 ){} //查询聊天用户列表2
|
||||
rpc RegisterWaiter ( RegisterWaiterRequest )returns( RegisterWaiterResp ){} //注册客服账号
|
||||
rpc CreateChatRecord ( ChatRecordData )returns( CreateChatRecordResp ){} //创建ChatRecord
|
||||
rpc UpdateChatRecord ( ChatRecordData )returns( CommonMsg ){} //更新ChatRecord
|
||||
rpc SaveChatRecord ( ChatRecordData )returns( CommonMsg ){} //覆盖ChatRecord
|
||||
rpc DeleteChatRecord ( DeleteChatRecordRequest )returns( CommonMsg ){} //删除ChatRecord
|
||||
rpc GetChatRecordDetail ( GetChatRecordByIdRequest )returns( ChatRecordData ){} //查询ChatRecord详情
|
||||
rpc GetChatRecordList ( GetChatRecordListRequest )returns( GetChatRecordListResp ){} //查询ChatRecord列表
|
||||
rpc CreateChatMedia ( ChatMediaData )returns( CreateChatMediaResp ){} //创建ChatMedia
|
||||
rpc UpdateChatMedia ( ChatMediaData )returns( CommonMsg ){} //更新ChatMedia
|
||||
rpc SaveChatMedia ( ChatMediaData )returns( CommonMsg ){} //覆盖ChatMedia
|
||||
rpc DeleteChatMedia ( DeleteChatMediaRequest )returns( CommonMsg ){} //删除ChatMedia
|
||||
rpc GetChatMediaDetail ( GetChatMediaByIdRequest )returns( ChatMediaData ){} //查询ChatMedia详情
|
||||
rpc GetChatMediaList ( GetChatMediaListRequest )returns( GetChatMediaListResp ){} //查询ChatMedia列表
|
||||
rpc CreateChatAutoReplyRuler ( ChatAutoReplyRulerData )returns( CreateChatAutoReplyRulerResp ){} //创建自动回复规则
|
||||
rpc UpdateChatAutoReplyRuler ( ChatAutoReplyRulerData )returns( CommonMsg ){} //更新自动回复规则
|
||||
rpc SaveChatAutoReplyRuler ( ChatAutoReplyRulerData )returns( CommonMsg ){} //覆盖自动回复规则
|
||||
rpc DeleteChatAutoReplyRuler ( DeleteChatAutoReplyRulerRequest )returns( CommonMsg ){} //删除自动回复规则
|
||||
rpc GetChatAutoReplyRulerDetail ( GetChatAutoReplyRulerByIdRequest )returns( ChatAutoReplyRulerData ){} //查询自动回复规则详情
|
||||
rpc GetChatAutoReplyRulerList ( GetChatAutoReplyRulerListRequest )returns( GetChatAutoReplyRulerListResp ){} //查询自动回复规则列表
|
||||
}
|
||||
|
||||
message VerifySliderStatusRequest {
|
||||
@ -829,4 +857,200 @@ message SubmitInfoRequest{
|
||||
string email = 3;
|
||||
string company = 4;
|
||||
string phone = 5;
|
||||
}
|
||||
|
||||
message CommonMsg{
|
||||
string msg = 1;
|
||||
}
|
||||
enum MsgType{
|
||||
UnknownMsgType = 0 ;//未知类型
|
||||
TextMsgType = 1 ;//文本
|
||||
ImageMsgType = 2 ;//图片
|
||||
AudioMsgType = 3 ;//音频
|
||||
VideoMsgType = 4 ;//视频
|
||||
FileType = 5 ;//文件
|
||||
}
|
||||
message ChatRecordData{
|
||||
int64 ID=1;
|
||||
string createdAt=2;
|
||||
string updatedAt=3;
|
||||
int64 deletedAt=4;
|
||||
string sessionId = 5; //会话UID
|
||||
int64 userId = 6; //用户ID
|
||||
string name = 7; //名称
|
||||
string avatar = 8; //头像
|
||||
MsgType msgType = 9; //消息类型
|
||||
string content = 10; //消息内容
|
||||
repeated ChatMediaData medias = 11; //媒体
|
||||
int32 waiterRead=12;//客服是否已读 1=已读 2=未读 (被任意客服读取过均为已读)
|
||||
int64 localStamp = 13; //本地时间戳 用户端的消息唯一值,用于用户本地的一些逻辑处理
|
||||
string domain =14;//域
|
||||
}
|
||||
message CreateChatRecordResp{
|
||||
ChatRecordData data=1;
|
||||
string msg=2;
|
||||
}
|
||||
message DeleteChatRecordRequest{
|
||||
int64 id=1; //二选一,数据id
|
||||
repeated int64 ids=2;//二选一,数据id列表
|
||||
}
|
||||
message GetChatRecordByIdRequest{
|
||||
int64 id=1; //数据id
|
||||
}
|
||||
message GetChatRecordListRequest{
|
||||
ChatRecordData query =1;
|
||||
int64 page=2;
|
||||
int64 pageSize=3;
|
||||
string where=4;
|
||||
string order=5;
|
||||
}
|
||||
message GetChatRecordListResp{
|
||||
repeated ChatRecordData list=1;
|
||||
int64 page=2;
|
||||
int64 pageSize=3;
|
||||
int64 Total=4;
|
||||
}
|
||||
|
||||
message RegisterWaiterRequest{
|
||||
string origin=1; //来源
|
||||
int64 originId=2; //来源对应的用户ID
|
||||
string nickName=3; //名称
|
||||
string avatar=4; //头像
|
||||
string telNum=5; //电话
|
||||
string invitationCode=6; //邀请码
|
||||
string account=7;
|
||||
}
|
||||
message RegisterWaiterResp{
|
||||
int64 userId=1;
|
||||
}
|
||||
|
||||
message ChatMediaData{
|
||||
int64 ID=1;
|
||||
string createdAt=2;
|
||||
string updatedAt=3;
|
||||
int64 deletedAt=4;
|
||||
string url = 5; //url
|
||||
string md5 = 6; //md5值
|
||||
string size = 7; //尺寸
|
||||
string ext = 8; //后缀格式
|
||||
string convText=9; //语音转文字内容
|
||||
int64 duration=10;//时长
|
||||
}
|
||||
message CreateChatMediaResp{
|
||||
ChatMediaData data=1;
|
||||
string msg=2;
|
||||
}
|
||||
message DeleteChatMediaRequest{
|
||||
int64 id=1; //二选一,数据id
|
||||
repeated int64 ids=2;//二选一,数据id列表
|
||||
}
|
||||
message GetChatMediaByIdRequest{
|
||||
int64 id=1; //数据id
|
||||
}
|
||||
message GetChatMediaListRequest{
|
||||
ChatMediaData query =1;
|
||||
int64 page=2;
|
||||
int64 pageSize=3;
|
||||
string where=4;
|
||||
string order=5;
|
||||
}
|
||||
message GetChatMediaListResp{
|
||||
repeated ChatMediaData list=1;
|
||||
int64 page=2;
|
||||
int64 pageSize=3;
|
||||
int64 Total=4;
|
||||
}
|
||||
message GetChatUserListRequest2{
|
||||
int64 page=1;
|
||||
int64 pageSize=2;
|
||||
string where=3;
|
||||
string name=4;
|
||||
repeated int64 userIdIn=5;
|
||||
}
|
||||
message ChatUser2{
|
||||
int64 userId=1;
|
||||
string name=2;
|
||||
string avatar=3;
|
||||
string origin=4;
|
||||
string originId=5;
|
||||
}
|
||||
message GetChatUserListResp2{
|
||||
repeated ChatUser2 list=1;
|
||||
int64 page=2;
|
||||
int64 pageSize=3;
|
||||
int64 Total=4;
|
||||
string where=5;
|
||||
}
|
||||
message ChatAutoReplyRulerData{
|
||||
int64 ID = 1; //
|
||||
string createdAt = 2; //
|
||||
string updatedAt = 3; //
|
||||
int64 deletedAt = 4; //
|
||||
string title = 5; //标题
|
||||
string ruler = 6; //规则内容
|
||||
int32 rulerStatus = 7; //规则状态: 1=启用 2=禁用
|
||||
|
||||
}
|
||||
|
||||
message CreateChatAutoReplyRulerResp{
|
||||
ChatAutoReplyRulerData data=1;
|
||||
string msg=2;
|
||||
}
|
||||
message DeleteChatAutoReplyRulerRequest{
|
||||
int64 id=1; //二选一,数据id
|
||||
repeated int64 ids=2;//二选一,数据id列表
|
||||
}
|
||||
message GetChatAutoReplyRulerByIdRequest{
|
||||
int64 id=1; //数据id
|
||||
}
|
||||
message GetChatAutoReplyRulerListRequest{
|
||||
ChatAutoReplyRulerData query =1;
|
||||
int64 page=2;
|
||||
int64 pageSize=3;
|
||||
string where=4;
|
||||
string order=5;
|
||||
}
|
||||
message GetChatAutoReplyRulerListResp{
|
||||
repeated ChatAutoReplyRulerData list=1;
|
||||
int64 page=2;
|
||||
int64 pageSize=3;
|
||||
int64 Total=4;
|
||||
}
|
||||
message ChatUserData{
|
||||
int64 ID = 1; //
|
||||
string createdAt = 2; //
|
||||
string updatedAt = 3; //
|
||||
int64 deletedAt = 4; //
|
||||
string nickName = 5; //昵称
|
||||
string account = 6; //账号
|
||||
int32 role = 7; //聊天角色 1=用户 2=客服
|
||||
string origin = 8; //数据来源
|
||||
int64 originId = 9; //数据来源对应的用户ID
|
||||
string avatar = 10; //头像
|
||||
|
||||
}
|
||||
|
||||
message CreateChatUserResp{
|
||||
ChatUserData data=1;
|
||||
string msg=2;
|
||||
}
|
||||
message DeleteChatUserRequest{
|
||||
int64 id=1; //二选一,数据id
|
||||
repeated int64 ids=2;//二选一,数据id列表
|
||||
}
|
||||
message GetChatUserByIdRequest{
|
||||
int64 id=1; //数据id
|
||||
}
|
||||
message GetChatUserListRequest{
|
||||
ChatUserData query =1;
|
||||
int64 page=2;
|
||||
int64 pageSize=3;
|
||||
string where=4;
|
||||
string order=5;
|
||||
}
|
||||
message GetChatUserListResp{
|
||||
repeated ChatUserData list=1;
|
||||
int64 page=2;
|
||||
int64 pageSize=3;
|
||||
int64 Total=4;
|
||||
}
|
@ -525,3 +525,175 @@ func (this *ClockLogListResponse) Validate() error {
|
||||
func (this *SubmitInfoRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *CommonMsg) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *ChatRecordData) Validate() error {
|
||||
for _, item := range this.Medias {
|
||||
if item != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("Medias", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *CreateChatRecordResp) Validate() error {
|
||||
if this.Data != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Data); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *DeleteChatRecordRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *GetChatRecordByIdRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *GetChatRecordListRequest) Validate() error {
|
||||
if this.Query != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Query); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("Query", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *GetChatRecordListResp) Validate() error {
|
||||
for _, item := range this.List {
|
||||
if item != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("List", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *RegisterWaiterRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *RegisterWaiterResp) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *ChatMediaData) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *CreateChatMediaResp) Validate() error {
|
||||
if this.Data != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Data); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *DeleteChatMediaRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *GetChatMediaByIdRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *GetChatMediaListRequest) Validate() error {
|
||||
if this.Query != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Query); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("Query", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *GetChatMediaListResp) Validate() error {
|
||||
for _, item := range this.List {
|
||||
if item != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("List", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *GetChatUserListRequest2) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *ChatUser2) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *GetChatUserListResp2) Validate() error {
|
||||
for _, item := range this.List {
|
||||
if item != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("List", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *ChatAutoReplyRulerData) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *CreateChatAutoReplyRulerResp) Validate() error {
|
||||
if this.Data != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Data); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *DeleteChatAutoReplyRulerRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *GetChatAutoReplyRulerByIdRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *GetChatAutoReplyRulerListRequest) Validate() error {
|
||||
if this.Query != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Query); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("Query", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *GetChatAutoReplyRulerListResp) Validate() error {
|
||||
for _, item := range this.List {
|
||||
if item != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("List", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *ChatUserData) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *CreateChatUserResp) Validate() error {
|
||||
if this.Data != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Data); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *DeleteChatUserRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *GetChatUserByIdRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *GetChatUserListRequest) Validate() error {
|
||||
if this.Query != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Query); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("Query", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *GetChatUserListResp) Validate() error {
|
||||
for _, item := range this.List {
|
||||
if item != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("List", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
19
pkg/common/db/dto.go
Normal file
19
pkg/common/db/dto.go
Normal file
@ -0,0 +1,19 @@
|
||||
// Package model -----------------------------
|
||||
// @file : videoDto.go
|
||||
// @author : JJXu
|
||||
// @contact : wavingbear@163.com
|
||||
// @time : 2023/2/27 11:54
|
||||
// -------------------------------------------
|
||||
package db
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
func Pagination[T int | int32 | int64](page T, pageSize T) func(db *gorm.DB) *gorm.DB {
|
||||
if page == 0 || pageSize == 0 {
|
||||
page = 1
|
||||
pageSize = 15
|
||||
}
|
||||
return func(db *gorm.DB) *gorm.DB {
|
||||
return db.Limit(int(pageSize)).Offset(int((page - 1) * pageSize))
|
||||
}
|
||||
}
|
55
pkg/common/utils/copierOptions.go
Normal file
55
pkg/common/utils/copierOptions.go
Normal file
@ -0,0 +1,55 @@
|
||||
// Package util -----------------------------
|
||||
// @file : copierOptions.go
|
||||
// @author : JJXu
|
||||
// @contact : wavingbear@163.com
|
||||
// @time : 2023/8/18 12:00
|
||||
// -------------------------------------------
|
||||
package utils
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/jinzhu/copier"
|
||||
"time"
|
||||
)
|
||||
|
||||
var CopierProtoOptions = copier.Option{
|
||||
IgnoreEmpty: true,
|
||||
DeepCopy: true,
|
||||
Converters: []copier.TypeConverter{
|
||||
{
|
||||
SrcType: time.Time{},
|
||||
DstType: copier.String,
|
||||
Fn: func(src interface{}) (interface{}, error) {
|
||||
s, ok := src.(time.Time)
|
||||
if !ok {
|
||||
return nil, errors.New("src type :time.Time not matching")
|
||||
}
|
||||
return s.Format("2006-01-02 15:04:05"), nil
|
||||
},
|
||||
},
|
||||
{
|
||||
SrcType: copier.String,
|
||||
DstType: time.Time{},
|
||||
Fn: func(src interface{}) (interface{}, error) {
|
||||
s, ok := src.(string)
|
||||
if !ok {
|
||||
return nil, errors.New("src type :time.Time not matching")
|
||||
}
|
||||
tt, err := StringToTime(s, "2006-01-02 15:04:05")
|
||||
return *tt, err
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func StringToTime(strTime string, timeFormat string) (*time.Time, error) {
|
||||
timeObj, err := time.ParseInLocation(timeFormat, strTime, LocShanghai())
|
||||
return &timeObj, err
|
||||
}
|
||||
func LocShanghai() *time.Location {
|
||||
var shanghai, err = time.LoadLocation("Asia/Shanghai")
|
||||
if err != nil {
|
||||
shanghai = time.FixedZone("CST", 8*3600)
|
||||
}
|
||||
return shanghai
|
||||
}
|
90
pkg/common/utils/stime/common.go
Normal file
90
pkg/common/utils/stime/common.go
Normal file
@ -0,0 +1,90 @@
|
||||
// Package stime -----------------------------
|
||||
// @file : common.go
|
||||
// @author : JJXu
|
||||
// @contact : wavingbear@163.com
|
||||
// @time : 2022/10/21 00:19:04
|
||||
// -------------------------------------------
|
||||
package stime
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
var Loc loc
|
||||
|
||||
type loc time.Location
|
||||
|
||||
func (l loc) Shanghai() *time.Location {
|
||||
var shanghai, err = time.LoadLocation("Asia/Shanghai")
|
||||
if err != nil {
|
||||
shanghai = time.FixedZone("CST", 8*3600)
|
||||
}
|
||||
return shanghai
|
||||
}
|
||||
|
||||
const (
|
||||
//常规时间格式(日期带横杠)
|
||||
Format_Normal_YMDhms = "2006-01-02 15:04:05"
|
||||
Format_Normal_YMD = "2006-01-02"
|
||||
Format_Normal_hms = "15:04:05"
|
||||
Format_Normal_hm = "15:04"
|
||||
Format_Normal_YM = "2006-01"
|
||||
//带斜杠的时间格式
|
||||
Format_Slash_YMDhms = "2006/01/02 15:04:05"
|
||||
Format_Slash_YMD = "2006/01/02"
|
||||
//无间隔符
|
||||
Format_NoSpacer_YMDhms = "20060102150405"
|
||||
Format_NoSpacer_YMD = "20060102"
|
||||
Format_ChinaChar_YMD = "2006年01月02日"
|
||||
Format_ChinaChar_YMDhm = "2006年01月02日 15时04分"
|
||||
Format_DB_YMDhms = "2006-01-02T15:04:05+08:00"
|
||||
)
|
||||
|
||||
var MonthStrMap = map[string]string{
|
||||
"January": "01",
|
||||
"February": "02",
|
||||
"March": "03",
|
||||
"April": "04",
|
||||
"May": "05",
|
||||
"June": "06",
|
||||
"July": "07",
|
||||
"August": "08",
|
||||
"September": "09",
|
||||
"October": "10",
|
||||
"November": "11",
|
||||
"December": "12",
|
||||
}
|
||||
var MonthIntMap = map[string]int{
|
||||
"January": 1,
|
||||
"February": 2,
|
||||
"March": 3,
|
||||
"April": 4,
|
||||
"May": 5,
|
||||
"June": 6,
|
||||
"July": 7,
|
||||
"August": 8,
|
||||
"September": 9,
|
||||
"October": 10,
|
||||
"November": 11,
|
||||
"December": 12,
|
||||
}
|
||||
|
||||
var WeekIntMap = map[string]int{
|
||||
"Monday": 1,
|
||||
"Tuesday": 2,
|
||||
"Wednesday": 3,
|
||||
"Thursday": 4,
|
||||
"Friday": 5,
|
||||
"Saturday": 6,
|
||||
"Sunday": 7,
|
||||
}
|
||||
|
||||
var WeekStrMap = map[string]string{
|
||||
"Monday": "一",
|
||||
"Tuesday": "二",
|
||||
"Wednesday": "三",
|
||||
"Thursday": "四",
|
||||
"Friday": "五",
|
||||
"Saturday": "六",
|
||||
"Sunday": "日",
|
||||
}
|
157
pkg/common/utils/stime/getTime.go
Normal file
157
pkg/common/utils/stime/getTime.go
Normal file
@ -0,0 +1,157 @@
|
||||
/*
|
||||
* @FileName: getTime.go
|
||||
* @Author: JJXu
|
||||
* @CreateTime: 2022/3/1 下午6:35
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
package stime
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func StrNowDate() string {
|
||||
return TimeToString(time.Now(), Format_Normal_YMD)
|
||||
}
|
||||
|
||||
func StrNowYearMonth() string {
|
||||
return TimeToString(time.Now(), Format_Normal_YM)
|
||||
}
|
||||
|
||||
// ThisMorming 今天凌晨
|
||||
func ThisMorming(format string) (strTime string) {
|
||||
thisTime := time.Now()
|
||||
year := thisTime.Year()
|
||||
month := MonthStrMap[thisTime.Month().String()]
|
||||
day := fmt.Sprintf("%02d", thisTime.Day())
|
||||
strTime = fmt.Sprintf("%v-%v-%v 00:00:00", year, month, day)
|
||||
if format != Format_Normal_YMDhms {
|
||||
t1, _ := time.ParseInLocation(Format_Normal_YMDhms, strTime, Loc.Shanghai())
|
||||
strTime = t1.Format(format)
|
||||
}
|
||||
return strTime
|
||||
}
|
||||
|
||||
// ThisMorningUnix 获取当日凌晨的时间戳
|
||||
func ThisMorningToUnix() int64 {
|
||||
thist := time.Now()
|
||||
zero_tm := time.Date(thist.Year(), thist.Month(), thist.Day(), 0, 0, 0, 0, thist.Location()).Unix()
|
||||
return zero_tm
|
||||
}
|
||||
|
||||
// TomorrowMorning 第二天凌晨
|
||||
func TomorrowMorning(baseTime time.Time) *time.Time {
|
||||
year := baseTime.Year()
|
||||
month := MonthStrMap[baseTime.Month().String()]
|
||||
day := fmt.Sprintf("%02d", baseTime.Day()+1)
|
||||
strTime := fmt.Sprintf("%v-%v-%v 00:00:00", year, month, day)
|
||||
res, _ := StringToTime(strTime)
|
||||
return res
|
||||
}
|
||||
|
||||
// ThisTimeUnix 获取当前时间的时间戳
|
||||
func CurrentimeToUnix() int64 {
|
||||
return time.Now().Unix()
|
||||
}
|
||||
|
||||
// Currentime 获取当前时间
|
||||
func Currentime(format string) (strTime string) {
|
||||
strTime = time.Now().Format(format)
|
||||
return
|
||||
}
|
||||
|
||||
// HoursAgo 若干小时之前的时间
|
||||
func HoursAgo(hours time.Duration, format string) (lastTimeStr string) {
|
||||
lastStamp := time.Now().Unix() - int64((time.Hour * hours).Seconds())
|
||||
lastTime := time.Unix(lastStamp, 0).In(Loc.Shanghai())
|
||||
lastTimeStr = lastTime.Format(format)
|
||||
return
|
||||
}
|
||||
|
||||
// TimeToString 时间转字符串
|
||||
func TimeToString(t time.Time, format string) string {
|
||||
return t.Format(format)
|
||||
}
|
||||
|
||||
// 计算指定月份的天数
|
||||
func YearMonthToDayNumber(year int, month int) int {
|
||||
// 有31天的月份
|
||||
day31 := map[int]bool{
|
||||
1: true,
|
||||
3: true,
|
||||
5: true,
|
||||
7: true,
|
||||
8: true,
|
||||
10: true,
|
||||
12: true,
|
||||
}
|
||||
if day31[month] == true {
|
||||
return 31
|
||||
}
|
||||
// 有30天的月份
|
||||
day30 := map[int]bool{
|
||||
4: true,
|
||||
6: true,
|
||||
9: true,
|
||||
11: true,
|
||||
}
|
||||
if day30[month] == true {
|
||||
return 30
|
||||
}
|
||||
// 计算是平年还是闰年
|
||||
if (year%4 == 0 && year%100 != 0) || year%400 == 0 {
|
||||
// 得出2月的天数
|
||||
return 29
|
||||
}
|
||||
// 得出2月的天数
|
||||
return 28
|
||||
}
|
||||
|
||||
// 求时间差(返回一个数字,该数字单位由传过来的unit决定。若unit为60,则单位是分钟。)
|
||||
func GetDiffTime(start_time string, end_time string, unit int64) int64 {
|
||||
// 转成时间戳
|
||||
if len(start_time) == 10 {
|
||||
start_time = fmt.Sprintf("%v 00:00:00", start_time)
|
||||
}
|
||||
if len(end_time) == 10 {
|
||||
end_time = fmt.Sprintf("%v 00:00:00", end_time)
|
||||
}
|
||||
startUnix, _ := time.ParseInLocation("2006-01-02 15:04:05", start_time, Loc.Shanghai())
|
||||
endUnix, _ := time.ParseInLocation("2006-01-02 15:04:05", end_time, Loc.Shanghai())
|
||||
startTime := startUnix.Unix()
|
||||
endTime := endUnix.Unix()
|
||||
// 求相差天数
|
||||
date := (endTime - startTime) / unit
|
||||
return date
|
||||
}
|
||||
|
||||
func TimeSince(pastTime string, format string) string {
|
||||
|
||||
t, err := time.Parse(format, pastTime)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
diff := time.Since(t)
|
||||
if diff.Minutes() < 15 {
|
||||
return "刚刚"
|
||||
} else if diff.Minutes() >= 15 && diff.Minutes() < 30 {
|
||||
return "15分钟前"
|
||||
} else if diff.Minutes() >= 30 && diff.Minutes() < 60 {
|
||||
return "半小时前"
|
||||
} else if diff.Hours() >= 1 && diff.Hours() < 24 {
|
||||
return fmt.Sprintf("%d小时前", int(diff.Hours()))
|
||||
} else if diff.Hours() >= 24 && diff.Hours() < 24*15 {
|
||||
return fmt.Sprintf("%d天前", int(diff.Hours()/24))
|
||||
} else if diff.Hours() < 24*30 {
|
||||
return "半月前"
|
||||
} else if diff.Hours() < 24*30*6 { //小于半年
|
||||
return fmt.Sprintf("%d月前", int(diff.Hours()/24/30))
|
||||
} else if diff.Hours() < 24*365 { //小于1年
|
||||
return "半年前"
|
||||
} else {
|
||||
return t.Format("2006-01-02 15:04:05")
|
||||
}
|
||||
}
|
101
pkg/common/utils/stime/getTimeExt.go
Normal file
101
pkg/common/utils/stime/getTimeExt.go
Normal file
@ -0,0 +1,101 @@
|
||||
package stime
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 根据指定时间获取后面的若干天工作日列表
|
||||
// param baseOn 指定基准时间
|
||||
// param daysNum 获取工作日的数量
|
||||
func GetWorkDayList(baseOn *time.Time, daysNum int) []time.Time {
|
||||
var timeList []time.Time
|
||||
var basCount = 1
|
||||
var workDay time.Time
|
||||
for {
|
||||
if len(timeList) == daysNum {
|
||||
break
|
||||
}
|
||||
workDay = baseOn.AddDate(0, 0, basCount)
|
||||
switch workDay.Weekday() {
|
||||
case time.Saturday:
|
||||
basCount += 2
|
||||
continue
|
||||
case time.Sunday:
|
||||
basCount++
|
||||
continue
|
||||
default:
|
||||
timeList = append(timeList, workDay)
|
||||
basCount++
|
||||
}
|
||||
}
|
||||
return timeList
|
||||
}
|
||||
|
||||
// 根据指定时间获取后面的若干天工作日列表
|
||||
// param baseOn 指定基准时间
|
||||
// param daysNum 获取工作日的数量
|
||||
func GetWorkDayStrList(baseOn *time.Time, daysNum int) []string {
|
||||
var timeList []string
|
||||
var basCount = 1
|
||||
var workDay time.Time
|
||||
for {
|
||||
if len(timeList) == daysNum {
|
||||
break
|
||||
}
|
||||
workDay = baseOn.AddDate(0, 0, basCount)
|
||||
switch workDay.Weekday() {
|
||||
case time.Saturday:
|
||||
basCount += 2
|
||||
continue
|
||||
case time.Sunday:
|
||||
basCount++
|
||||
continue
|
||||
default:
|
||||
timeList = append(timeList, TimeToString(workDay, Format_Normal_YMD))
|
||||
basCount++
|
||||
}
|
||||
}
|
||||
return timeList
|
||||
}
|
||||
|
||||
// 获取时间差文字描述
|
||||
func GetTimeDifferenceDesc(now *time.Time, before *time.Time) string {
|
||||
if before == nil {
|
||||
return ""
|
||||
}
|
||||
if now.After(*before) {
|
||||
subTimestamp := now.Unix() - before.Unix()
|
||||
day := subTimestamp / (3600 * 24)
|
||||
hour := (subTimestamp - day*3600*24) / 3600
|
||||
minute := (subTimestamp - day*3600*24 - hour*3600) / 60
|
||||
second := subTimestamp - day*3600*24 - hour*3600 - minute*60
|
||||
|
||||
switch {
|
||||
case day > 0:
|
||||
if hour > 0 {
|
||||
return fmt.Sprintf("%d天%d小时", day, hour)
|
||||
} else {
|
||||
return fmt.Sprintf("%d天", day)
|
||||
}
|
||||
case hour > 0:
|
||||
if minute < 10 {
|
||||
return fmt.Sprintf("%d小时", hour)
|
||||
} else {
|
||||
return fmt.Sprintf("%d小时%d", hour, minute)
|
||||
}
|
||||
case hour == 0 && minute > 0:
|
||||
return fmt.Sprintf("%d分钟", minute)
|
||||
case hour == 0 && minute == 0:
|
||||
return fmt.Sprintf("%d秒", second)
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// TimeStampToBytes 时间戳转字节
|
||||
func TimeStampToBytes(stamp int64) []byte {
|
||||
timeStr := strconv.FormatInt(stamp, 2)
|
||||
return []byte(timeStr)
|
||||
}
|
12
pkg/common/utils/stime/getTimeExt_test.go
Normal file
12
pkg/common/utils/stime/getTimeExt_test.go
Normal file
@ -0,0 +1,12 @@
|
||||
package stime
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestGetWorkDayStrList(t *testing.T) {
|
||||
now := time.Now()
|
||||
result := GetWorkDayStrList(&now, 5)
|
||||
t.Log(result)
|
||||
}
|
77
pkg/common/utils/stime/timeTranslate.go
Normal file
77
pkg/common/utils/stime/timeTranslate.go
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* @Author: immortal
|
||||
* @Date: 2022-03-11 20:55:38
|
||||
* @LastEditors: immortal
|
||||
* @LastEditTime: 2022-03-12 14:26:42
|
||||
* @Description:
|
||||
* @FilePath: \monitor_env\utils\simpletime\timeTranslate.go
|
||||
*/
|
||||
/**
|
||||
* @Author Puzzle
|
||||
* @Date 2021/11/18 1:36 下午
|
||||
**/
|
||||
|
||||
package stime
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func GetTimestampMillisecond() int64 {
|
||||
now := time.Now()
|
||||
return now.UnixNano() / 1e6
|
||||
}
|
||||
|
||||
func StringToTime(strTime string) (*time.Time, error) {
|
||||
const TIME_LAYOUT = "2006-01-02 15:04:05" //此时间不可更改
|
||||
timeobj, err := time.ParseInLocation(TIME_LAYOUT, strTime, Loc.Shanghai())
|
||||
return &timeobj, err
|
||||
}
|
||||
|
||||
func StringToTimeWithFormat(strTime string, timeFormat string) (*time.Time, error) {
|
||||
timeobj, err := time.ParseInLocation(timeFormat, strTime, Loc.Shanghai())
|
||||
return &timeobj, err
|
||||
}
|
||||
|
||||
// 去除精确时间后面的小数点
|
||||
func NowTimeToTime(layout string) *time.Time {
|
||||
otime := time.Now().Format(layout) //"2006-01-02 15:04:05" and so on
|
||||
tt, _ := StringToTime(otime)
|
||||
return tt
|
||||
}
|
||||
|
||||
// 时间之间的转换
|
||||
func TimeStampToString(value interface{}, after_type string) {
|
||||
switch value.(type) {
|
||||
case string:
|
||||
fmt.Println(value.(string))
|
||||
case int64:
|
||||
fmt.Println(value.(int64))
|
||||
case int32:
|
||||
fmt.Println(value.(int32))
|
||||
}
|
||||
}
|
||||
|
||||
func GetAge(birthday time.Time) int {
|
||||
if birthday.IsZero() {
|
||||
return 0
|
||||
}
|
||||
now := time.Now()
|
||||
year, month, day := now.Date()
|
||||
if year == 0 || month == 0 || day == 0 {
|
||||
return 0
|
||||
}
|
||||
age := year - birthday.Year() - 1
|
||||
//判断年龄
|
||||
if birthday.Month() < month || birthday.Month() == month && birthday.Day() <= day {
|
||||
age++
|
||||
}
|
||||
return age
|
||||
}
|
||||
func ParseTimeStamp(unix int64) (result time.Time) {
|
||||
if unix == 0 {
|
||||
return
|
||||
}
|
||||
return time.Unix(unix, 0)
|
||||
}
|
26
pkg/common/utils/stime/timeTranslate_test.go
Normal file
26
pkg/common/utils/stime/timeTranslate_test.go
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* @FileName: time_test.go
|
||||
* @Author: JJXu
|
||||
* @CreateTime: 2022/2/25 下午2:37
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
package stime
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestTime(t *testing.T) {
|
||||
result := NowTimeToTime(Format_Normal_YMDhms)
|
||||
fmt.Println(result)
|
||||
}
|
||||
func TestGetAge(t *testing.T) {
|
||||
age := GetAge(time.Date(1991, 3, 6, 0, 0, 0, 0, Loc.Shanghai()))
|
||||
fmt.Println(age)
|
||||
if age != 31 {
|
||||
t.Errorf("want 31 but get %v", age)
|
||||
}
|
||||
}
|
52
pkg/common/utils/stime/week.go
Normal file
52
pkg/common/utils/stime/week.go
Normal file
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @Author Puzzle
|
||||
* @Date 2022/5/20 12:54 下午
|
||||
**/
|
||||
|
||||
package stime
|
||||
|
||||
import "time"
|
||||
|
||||
func NowWeekDay() string {
|
||||
var weekday = [7]string{"七", "一", "二", "三", "四", "五", "六"}
|
||||
week := int(time.Now().Weekday())
|
||||
return weekday[week]
|
||||
}
|
||||
|
||||
// 获取按年算的周数
|
||||
func GetYearWeek(t *time.Time) int {
|
||||
yearDay := t.YearDay()
|
||||
yearFirstDay := t.AddDate(0, 0, -yearDay+1)
|
||||
firstDayInWeek := int(yearFirstDay.Weekday())
|
||||
|
||||
//今年第一周有几天
|
||||
firstWeekDays := 1
|
||||
if firstDayInWeek != 0 {
|
||||
firstWeekDays = 7 - firstDayInWeek + 1
|
||||
}
|
||||
var week int
|
||||
if yearDay <= firstWeekDays {
|
||||
week = 1
|
||||
} else {
|
||||
week = (yearDay-firstWeekDays)/7 + 2
|
||||
}
|
||||
return week
|
||||
}
|
||||
|
||||
// GetWeekDate 获取基准时间范围最最近的某个星期时间
|
||||
//
|
||||
// param baseOn: 基准时间
|
||||
// param weekNum: 中国星期数 1~7
|
||||
// return *time.Time
|
||||
func GetWeekDate(baseOn time.Time, weekNum int) *time.Time {
|
||||
if baseOn.IsZero() || (weekNum <= 0 || weekNum > 7) {
|
||||
return nil
|
||||
}
|
||||
baseDate := time.Date(baseOn.Year(), baseOn.Month(), baseOn.Day(), 0, 0, 0, 0, Loc.Shanghai())
|
||||
var (
|
||||
w = int(baseOn.Weekday())
|
||||
weekDate time.Time
|
||||
)
|
||||
weekDate = baseDate.AddDate(0, 0, weekNum-w)
|
||||
return &weekDate
|
||||
}
|
20
pkg/common/utils/stime/week_test.go
Normal file
20
pkg/common/utils/stime/week_test.go
Normal file
@ -0,0 +1,20 @@
|
||||
// Package simpletime -----------------------------
|
||||
// @file : week_test.go
|
||||
// @author : JJXu
|
||||
// @contact : wavingbear@163.com
|
||||
// @time : 2022/8/31 14:57
|
||||
// -------------------------------------------
|
||||
package stime
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestGetYearWeek(t *testing.T) {
|
||||
now := time.Now()
|
||||
t.Log(GetYearWeek(&now))
|
||||
var w = int(now.Weekday())
|
||||
t.Log(now.AddDate(0, 0, -w+1).Weekday())
|
||||
t.Log(now.AddDate(0, 0, 7-w).Weekday())
|
||||
}
|
268
pkg/dao/asChatRecordDao.go
Normal file
268
pkg/dao/asChatRecordDao.go
Normal file
@ -0,0 +1,268 @@
|
||||
// Package dao -----------------------------
|
||||
// @author : JJXu
|
||||
// @contact : wavingbear@163.com
|
||||
// @time : 2024-09-10 15:50:24
|
||||
// -------------------------------------------
|
||||
package dao
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/fonchain_enterprise/micro-account/api/accountFiee"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/common/db"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/m"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/model"
|
||||
)
|
||||
|
||||
type chatDao struct {
|
||||
}
|
||||
|
||||
var AsChatDao = new(chatDao)
|
||||
|
||||
// 创建ChatRecord
|
||||
func (chatDao) CreateChatRecord(data *model.ChatRecord) error {
|
||||
return model.DB.Debug().Create(data).Error
|
||||
}
|
||||
|
||||
// 删除ChatRecord
|
||||
func (chatDao) DeleteChatRecords(id int64, ids []int64) (err error) {
|
||||
if id != 0 {
|
||||
err = model.DB.Delete(&model.ChatRecord{}, id).Error
|
||||
} else if len(ids) > 0 {
|
||||
err = model.DB.Delete(&model.ChatRecord{}, ids).Error
|
||||
}
|
||||
if err != nil {
|
||||
//log.L().Error("CreateChatRecord Err", zap.Error(err))
|
||||
err = errors.New(m.DBError)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 更新ChatRecord
|
||||
func (chatDao) UpdateChatRecord(data *model.ChatRecord) (err error) {
|
||||
var thisData model.ChatRecord
|
||||
if err = model.DB.First(&thisData, "id = ?", data.ID).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if data.SessionId != "" {
|
||||
thisData.SessionId = data.SessionId
|
||||
}
|
||||
if data.UserId != 0 {
|
||||
thisData.UserId = data.UserId
|
||||
}
|
||||
if data.Name != "" {
|
||||
thisData.Name = data.Name
|
||||
}
|
||||
if data.Avatar != "" {
|
||||
thisData.Avatar = data.Avatar
|
||||
}
|
||||
if data.MsgType != 0 {
|
||||
thisData.MsgType = data.MsgType
|
||||
}
|
||||
if data.Content != "" {
|
||||
thisData.Content = data.Content
|
||||
}
|
||||
if data.WaiterRead != 0 {
|
||||
thisData.WaiterRead = data.WaiterRead
|
||||
}
|
||||
if data.LocalStamp != 0 {
|
||||
thisData.LocalStamp = data.LocalStamp
|
||||
}
|
||||
|
||||
if err = model.DB.Updates(&thisData).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
//更新关联关系
|
||||
return
|
||||
}
|
||||
|
||||
// 覆盖ChatRecord
|
||||
func (chatDao) SaveChatRecord(data *model.ChatRecord) (err error) {
|
||||
if err = model.DB.Omit("created_at,deleted_at").Save(&data).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
//更新关联关系
|
||||
return
|
||||
}
|
||||
|
||||
// 使用id查询ChatRecord
|
||||
func (chatDao) GetChatRecordById(id int) (res model.ChatRecord, err error) {
|
||||
err = model.DB.Where("id = ?", id).First(&res).Error
|
||||
if err != nil {
|
||||
//log.L().Error("GetChatRecord Err", zap.Error(err))
|
||||
err = errors.New(m.DBError)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 批量查询ChatRecord
|
||||
func (chatDao) GetChatRecordList(info *accountFiee.GetChatRecordListRequest) (resp []model.ChatRecord, total int64, err error) {
|
||||
var dbQuery = model.DB.Model(&model.ChatRecord{}).Preload("Medias")
|
||||
if info.Query != nil {
|
||||
|
||||
if info.Query.SessionId != "" {
|
||||
dbQuery = dbQuery.Where("session_id =?", info.Query.SessionId)
|
||||
}
|
||||
if info.Query.UserId != 0 {
|
||||
dbQuery = dbQuery.Where("user_id = ?", info.Query.UserId)
|
||||
}
|
||||
if info.Query.Name != "" {
|
||||
dbQuery = dbQuery.Where(fmt.Sprintf("name like '%%%v%%'", info.Query.Name))
|
||||
}
|
||||
if info.Query.Avatar != "" {
|
||||
dbQuery = dbQuery.Where(fmt.Sprintf("avatar like '%%%v%%'", info.Query.Avatar))
|
||||
}
|
||||
if info.Query.MsgType != 0 {
|
||||
dbQuery = dbQuery.Where("msg_type = ?", info.Query.MsgType)
|
||||
}
|
||||
if info.Query.Content != "" {
|
||||
dbQuery = dbQuery.Where(fmt.Sprintf("content like '%%%v%%'", info.Query.Content))
|
||||
}
|
||||
if info.Query.WaiterRead != 0 {
|
||||
dbQuery = dbQuery.Where("waiter_read = ?", info.Query.WaiterRead)
|
||||
}
|
||||
if info.Query.LocalStamp != 0 {
|
||||
dbQuery = dbQuery.Where("local_stamp = ?", info.Query.LocalStamp)
|
||||
}
|
||||
}
|
||||
if info.Where != "" {
|
||||
dbQuery = dbQuery.Where(info.Where)
|
||||
}
|
||||
if info.Order != "" {
|
||||
dbQuery = dbQuery.Order(info.Order)
|
||||
}
|
||||
//数据查询
|
||||
dbQuery.Count(&total)
|
||||
err = dbQuery.Scopes(db.Pagination(info.Page, info.PageSize)).Find(&resp).Error
|
||||
if err != nil {
|
||||
//log.L().Error("GetChatRecordList Err", zap.Error(err))
|
||||
err = errors.New(m.DBError)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 创建ChatMedia
|
||||
func (chatDao) CreateChatMedia(data *model.ChatMedia) error {
|
||||
return model.DB.Create(data).Error
|
||||
}
|
||||
|
||||
// 删除ChatMedia
|
||||
func (chatDao) DeleteChatMedias(id int64, ids []int64) (err error) {
|
||||
if id != 0 {
|
||||
err = model.DB.Delete(&model.ChatMedia{}, id).Error
|
||||
} else if len(ids) > 0 {
|
||||
err = model.DB.Delete(&model.ChatMedia{}, ids).Error
|
||||
}
|
||||
if err != nil {
|
||||
//log.L().Error("CreateChatMedia Err", zap.Error(err))
|
||||
err = errors.New(m.DBError)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 更新ChatMedia
|
||||
func (chatDao) UpdateChatMedia(data *model.ChatMedia) (err error) {
|
||||
var thisData model.ChatMedia
|
||||
if err = model.DB.First(&thisData, "id = ?", data.ID).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if data.Url != "" {
|
||||
thisData.Url = data.Url
|
||||
}
|
||||
if data.Md5 != "" {
|
||||
thisData.Md5 = data.Md5
|
||||
}
|
||||
if data.Size != "" {
|
||||
thisData.Size = data.Size
|
||||
}
|
||||
if data.Ext != "" {
|
||||
thisData.Ext = data.Ext
|
||||
}
|
||||
if data.ConvText != "" {
|
||||
thisData.ConvText = data.ConvText
|
||||
}
|
||||
if err = model.DB.Updates(&thisData).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
//更新关联关系
|
||||
return
|
||||
}
|
||||
|
||||
// 覆盖ChatMedia
|
||||
func (chatDao) SaveChatMedia(data *model.ChatMedia) (err error) {
|
||||
if err = model.DB.Omit("created_at,deleted_at").Save(&data).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
//更新关联关系
|
||||
return
|
||||
}
|
||||
|
||||
// 使用id查询ChatMedia
|
||||
func (chatDao) GetChatMediaById(id int64) (res model.ChatMedia, err error) {
|
||||
err = model.DB.Where("id = ?", id).First(&res).Error
|
||||
if err != nil {
|
||||
//log.L().Error("GetChatMedia Err", zap.Error(err))
|
||||
err = errors.New(m.DBError)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 批量查询ChatMedia
|
||||
func (chatDao) GetChatMediaList(info *accountFiee.GetChatMediaListRequest) (resp []model.ChatMedia, total int64, err error) {
|
||||
var dbQuery = model.DB.Model(&model.ChatMedia{})
|
||||
if info.Query != nil {
|
||||
|
||||
if info.Query.Url != "" {
|
||||
dbQuery = dbQuery.Where(fmt.Sprintf("url like '%%%v%%'", info.Query.Url))
|
||||
}
|
||||
if info.Query.Md5 != "" {
|
||||
dbQuery = dbQuery.Where("md5 =?", info.Query.Md5)
|
||||
}
|
||||
if info.Query.Size != "" {
|
||||
dbQuery = dbQuery.Where(fmt.Sprintf("size like '%%%v%%'", info.Query.Size))
|
||||
}
|
||||
if info.Query.Ext != "" {
|
||||
dbQuery = dbQuery.Where(fmt.Sprintf("ext like '%%%v%%'", info.Query.Ext))
|
||||
}
|
||||
}
|
||||
if info.Where != "" {
|
||||
dbQuery = dbQuery.Where(info.Where)
|
||||
}
|
||||
if info.Order != "" {
|
||||
dbQuery = dbQuery.Order(info.Order)
|
||||
}
|
||||
//数据查询
|
||||
dbQuery.Count(&total)
|
||||
err = dbQuery.Scopes(db.Pagination(info.Page, info.PageSize)).Find(&resp).Error
|
||||
if err != nil {
|
||||
//log.L().Error("GetChatMediaList Err", zap.Error(err))
|
||||
err = errors.New(m.DBError)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 批量查询ChatMedia
|
||||
func (chatDao) GetChatUserList(req *accountFiee.GetChatUserListRequest2) (resp []*accountFiee.ChatUser2, total int64, err error) {
|
||||
var dbQuery = model.DB.Table(`(SELECT su.id user_id,su.mgmt_artist_uid artist_uid,CASE WHEN su.is_real_name=0 THEN icu.name ELSE rn.name END name,icu.head_img avatar
|
||||
FROM sys_user su
|
||||
LEFT JOIN real_name rn ON rn.id = su.real_name_id AND rn.deleted_at =0
|
||||
LEFT JOIN in_circle_user icu ON icu.user_id=su.id AND icu.deleted_at =0
|
||||
WHERE su.deleted_at = 0) as t`)
|
||||
if req.Where != "" {
|
||||
dbQuery = dbQuery.Where(req.Where)
|
||||
}
|
||||
if req.UserIdIn != nil {
|
||||
dbQuery = dbQuery.Where("user_id in (?)", req.UserIdIn)
|
||||
}
|
||||
if req.Name != "" {
|
||||
dbQuery = dbQuery.Where(fmt.Sprintf("name like '%%%v%%'", req.Name))
|
||||
}
|
||||
//数据查询
|
||||
dbQuery.Count(&total)
|
||||
err = dbQuery.Scopes(db.Pagination(req.Page, req.PageSize)).Find(&resp).Error
|
||||
if err != nil {
|
||||
//log.L().Error("GetChatUserList Err", zap.Error(err))
|
||||
err = errors.New(m.DBError)
|
||||
}
|
||||
return
|
||||
}
|
126
pkg/dao/chatAutoReplyRulerDao.go
Normal file
126
pkg/dao/chatAutoReplyRulerDao.go
Normal file
@ -0,0 +1,126 @@
|
||||
// Package dao -----------------------------
|
||||
// @author : JJXu
|
||||
// @contact : wavingbear@163.com
|
||||
// @time : 2025-06-12 09:22:01
|
||||
// -------------------------------------------
|
||||
package dao
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/fonchain_enterprise/micro-account/api/accountFiee"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/common/db"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/m"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/model"
|
||||
)
|
||||
|
||||
type chatAutoReplyRulerDao struct {
|
||||
}
|
||||
|
||||
var ChatAutoReplyRulerDao = new(chatAutoReplyRulerDao)
|
||||
|
||||
// 创建自动回复规则
|
||||
func (chatAutoReplyRulerDao) CreateChatAutoReplyRuler(data *model.ChatAutoReplyRuler) error {
|
||||
return model.DB.Create(data).Error
|
||||
}
|
||||
|
||||
// 删除自动回复规则
|
||||
func (chatAutoReplyRulerDao) DeleteChatAutoReplyRulers(id int64, ids []int64) (err error) {
|
||||
if id != 0 {
|
||||
err = model.DB.Delete(&model.ChatAutoReplyRuler{}, id).Error
|
||||
} else if len(ids) > 0 {
|
||||
err = model.DB.Delete(&model.ChatAutoReplyRuler{}, ids).Error
|
||||
}
|
||||
if err != nil {
|
||||
//log.L().Error("CreateChatAutoReplyRuler Err", zap.Error(err))
|
||||
err = errors.New(m.DBError)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 更新自动回复规则
|
||||
func (chatAutoReplyRulerDao) UpdateChatAutoReplyRuler(data *model.ChatAutoReplyRuler) (err error) {
|
||||
var thisData model.ChatAutoReplyRuler
|
||||
if err = model.DB.First(&thisData, "id = ?", data.ID).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if data.ID != 0 {
|
||||
thisData.ID = data.ID
|
||||
}
|
||||
if data.Title != "" {
|
||||
thisData.Title = data.Title
|
||||
}
|
||||
if data.Ruler != "" {
|
||||
thisData.Ruler = data.Ruler
|
||||
}
|
||||
if data.RulerStatus != 0 {
|
||||
thisData.RulerStatus = data.RulerStatus
|
||||
}
|
||||
|
||||
if err = model.DB.Updates(&thisData).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
//更新关联关系
|
||||
return
|
||||
}
|
||||
|
||||
// 覆盖自动回复规则
|
||||
func (chatAutoReplyRulerDao) SaveChatAutoReplyRuler(data *model.ChatAutoReplyRuler) (err error) {
|
||||
if err = model.DB.Omit("created_at,deleted_at").Save(&data).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
//更新关联关系
|
||||
return
|
||||
}
|
||||
|
||||
// 使用map更新自动回复规则
|
||||
func (chatAutoReplyRulerDao) UpdateUseMap(id string, updateMap map[string]any) (err error) {
|
||||
if err = model.DB.Model(&model.ChatAutoReplyRuler{}).Where("id =?", id).Updates(&updateMap).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 使用id查询自动回复规则
|
||||
func (chatAutoReplyRulerDao) GetChatAutoReplyRulerById(id int) (res model.ChatAutoReplyRuler, err error) {
|
||||
err = model.DB.Where("id = ?", id).First(&res).Error
|
||||
if err != nil {
|
||||
//log.L().Error("GetChatAutoReplyRuler Err", zap.Error(err))
|
||||
err = errors.New(m.DBError)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 批量查询自动回复规则
|
||||
func (chatAutoReplyRulerDao) GetChatAutoReplyRulerList(info *accountFiee.GetChatAutoReplyRulerListRequest) (resp []model.ChatAutoReplyRuler, total int64, err error) {
|
||||
var dbQuery = model.DB.Model(&model.ChatAutoReplyRuler{})
|
||||
if info.Query != nil {
|
||||
|
||||
if info.Query.ID != 0 {
|
||||
dbQuery = dbQuery.Where(" = ?", info.Query.ID)
|
||||
}
|
||||
if info.Query.Title != "" {
|
||||
dbQuery = dbQuery.Where(fmt.Sprintf("title like '%%%v%%'", info.Query.Title))
|
||||
}
|
||||
if info.Query.Ruler != "" {
|
||||
dbQuery = dbQuery.Where("ruler =?", info.Query.Ruler)
|
||||
}
|
||||
if info.Query.RulerStatus != 0 {
|
||||
dbQuery = dbQuery.Where("ruler_status = ?", info.Query.RulerStatus)
|
||||
}
|
||||
}
|
||||
if info.Where != "" {
|
||||
dbQuery = dbQuery.Where(info.Where)
|
||||
}
|
||||
if info.Order != "" {
|
||||
dbQuery = dbQuery.Order(info.Order)
|
||||
}
|
||||
//数据查询
|
||||
dbQuery.Count(&total)
|
||||
err = dbQuery.Scopes(db.Pagination(info.Page, info.PageSize)).Find(&resp).Error
|
||||
if err != nil {
|
||||
//log.L().Error("GetChatAutoReplyRulerList Err", zap.Error(err))
|
||||
err = errors.New(m.DBError)
|
||||
}
|
||||
return
|
||||
}
|
144
pkg/dao/chatUserDao.go
Normal file
144
pkg/dao/chatUserDao.go
Normal file
@ -0,0 +1,144 @@
|
||||
// Package dao -----------------------------
|
||||
// @author : JJXu
|
||||
// @contact : wavingbear@163.com
|
||||
// @time : 2025-06-12 10:06:32
|
||||
// -------------------------------------------
|
||||
package dao
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/fonchain_enterprise/micro-account/api/accountFiee"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/common/db"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/m"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/model"
|
||||
)
|
||||
|
||||
type chatUserDao struct {
|
||||
}
|
||||
|
||||
var ChatUserDao = new(chatUserDao)
|
||||
|
||||
// 创建聊天用户
|
||||
func (chatUserDao) CreateChatUser(data *model.ChatUser) error {
|
||||
return model.DB.Create(data).Error
|
||||
}
|
||||
|
||||
// 删除聊天用户
|
||||
func (chatUserDao) DeleteChatUsers(id int64, ids []int64) (err error) {
|
||||
if id != 0 {
|
||||
err = model.DB.Delete(&model.ChatUser{}, id).Error
|
||||
} else if len(ids) > 0 {
|
||||
err = model.DB.Delete(&model.ChatUser{}, ids).Error
|
||||
}
|
||||
if err != nil {
|
||||
//log.L().Error("CreateChatUser Err", zap.Error(err))
|
||||
err = errors.New(m.DBError)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 更新聊天用户
|
||||
func (chatUserDao) UpdateChatUser(data *model.ChatUser) (err error) {
|
||||
var thisData model.ChatUser
|
||||
if err = model.DB.First(&thisData, "id = ?", data.ID).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if data.ID != 0 {
|
||||
thisData.ID = data.ID
|
||||
}
|
||||
if data.NickName != "" {
|
||||
thisData.NickName = data.NickName
|
||||
}
|
||||
if data.Account != "" {
|
||||
thisData.Account = data.Account
|
||||
}
|
||||
if data.Role != 0 {
|
||||
thisData.Role = data.Role
|
||||
}
|
||||
if data.Origin != "" {
|
||||
thisData.Origin = data.Origin
|
||||
}
|
||||
if data.OriginId != 0 {
|
||||
thisData.OriginId = data.OriginId
|
||||
}
|
||||
if data.Avatar != "" {
|
||||
thisData.Avatar = data.Avatar
|
||||
}
|
||||
|
||||
if err = model.DB.Updates(&thisData).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
//更新关联关系
|
||||
return
|
||||
}
|
||||
|
||||
// 覆盖聊天用户
|
||||
func (chatUserDao) SaveChatUser(data *model.ChatUser) (err error) {
|
||||
if err = model.DB.Omit("created_at,deleted_at").Save(&data).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
//更新关联关系
|
||||
return
|
||||
}
|
||||
|
||||
// 使用map更新聊天用户
|
||||
func (chatUserDao) UpdateUseMap(id string, updateMap map[string]any) (err error) {
|
||||
if err = model.DB.Model(&model.ChatUser{}).Where("id =?", id).Updates(&updateMap).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 使用id查询聊天用户
|
||||
func (chatUserDao) GetChatUserById(id int) (res model.ChatUser, err error) {
|
||||
err = model.DB.Where("id = ?", id).First(&res).Error
|
||||
if err != nil {
|
||||
//log.L().Error("GetChatUser Err", zap.Error(err))
|
||||
err = errors.New(m.DBError)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 批量查询聊天用户
|
||||
func (chatUserDao) GetChatUserList(info *accountFiee.GetChatUserListRequest) (resp []model.ChatUser, total int64, err error) {
|
||||
var dbQuery = model.DB.Model(&model.ChatUser{})
|
||||
if info.Query != nil {
|
||||
|
||||
if info.Query.ID != 0 {
|
||||
dbQuery = dbQuery.Where(" = ?", info.Query.ID)
|
||||
}
|
||||
if info.Query.NickName != "" {
|
||||
dbQuery = dbQuery.Where(fmt.Sprintf("nick_name like '%%%v%%'", info.Query.NickName))
|
||||
}
|
||||
if info.Query.Account != "" {
|
||||
dbQuery = dbQuery.Where(fmt.Sprintf("account like '%%%v%%'", info.Query.Account))
|
||||
}
|
||||
if info.Query.Role != 0 {
|
||||
dbQuery = dbQuery.Where("role = ?", info.Query.Role)
|
||||
}
|
||||
if info.Query.Origin != "" {
|
||||
dbQuery = dbQuery.Where(fmt.Sprintf("origin like '%%%v%%'", info.Query.Origin))
|
||||
}
|
||||
if info.Query.OriginId != 0 {
|
||||
dbQuery = dbQuery.Where("origin_id = ?", info.Query.OriginId)
|
||||
}
|
||||
if info.Query.Avatar != "" {
|
||||
dbQuery = dbQuery.Where(fmt.Sprintf("avatar like '%%%v%%'", info.Query.Avatar))
|
||||
}
|
||||
}
|
||||
if info.Where != "" {
|
||||
dbQuery = dbQuery.Where(info.Where)
|
||||
}
|
||||
if info.Order != "" {
|
||||
dbQuery = dbQuery.Order(info.Order)
|
||||
}
|
||||
//数据查询
|
||||
dbQuery.Count(&total)
|
||||
err = dbQuery.Scopes(db.Pagination(info.Page, info.PageSize)).Find(&resp).Error
|
||||
if err != nil {
|
||||
//log.L().Error("GetChatUserList Err", zap.Error(err))
|
||||
err = errors.New(m.DBError)
|
||||
}
|
||||
return
|
||||
}
|
250
pkg/logic/asChatRecordLogic.go
Normal file
250
pkg/logic/asChatRecordLogic.go
Normal file
@ -0,0 +1,250 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/fonchain_enterprise/micro-account/api/accountFiee"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/common/utils"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/common/utils/stime"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/dao"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/model"
|
||||
"github.com/jinzhu/copier"
|
||||
)
|
||||
|
||||
type AsChatLogic struct{}
|
||||
|
||||
// 创建ChatRecord
|
||||
func (AsChatLogic) CreateChatRecord(data *accountFiee.ChatRecordData) (resp *accountFiee.CreateChatRecordResp, err error) {
|
||||
resp = &accountFiee.CreateChatRecordResp{
|
||||
Data: &accountFiee.ChatRecordData{},
|
||||
Msg: "创建成功",
|
||||
}
|
||||
fmt.Println("原始数据", data)
|
||||
var modelData = model.ChatRecord{}
|
||||
if err = copier.CopyWithOption(&modelData, data, utils.CopierProtoOptions); err != nil {
|
||||
resp.Msg = "数据转换失败"
|
||||
return
|
||||
}
|
||||
fmt.Println("转换后数据", modelData)
|
||||
err = dao.AsChatDao.CreateChatRecord(&modelData)
|
||||
if err != nil {
|
||||
resp.Msg = "创建失败"
|
||||
return
|
||||
}
|
||||
if len(data.Medias) > 0 {
|
||||
model.DB.Preload("Medias").First(&modelData, modelData.ID)
|
||||
}
|
||||
if err = copier.CopyWithOption(resp.Data, &modelData, utils.CopierProtoOptions); err != nil {
|
||||
resp.Msg = "创建失败."
|
||||
return
|
||||
}
|
||||
if len(data.Medias) > 0 {
|
||||
for _, v := range data.Medias {
|
||||
mediaModelData, _ := dao.AsChatDao.GetChatMediaById(v.ID)
|
||||
resp.Data.Medias = append(resp.Data.Medias, &accountFiee.ChatMediaData{
|
||||
ID: mediaModelData.ID,
|
||||
CreatedAt: mediaModelData.CreatedAt.Format(stime.Format_Normal_YMDhms),
|
||||
UpdatedAt: mediaModelData.UpdatedAt.Format(stime.Format_Normal_YMDhms),
|
||||
Url: mediaModelData.Url,
|
||||
Md5: mediaModelData.Md5,
|
||||
Size: mediaModelData.Size,
|
||||
Ext: mediaModelData.Ext,
|
||||
ConvText: mediaModelData.ConvText,
|
||||
Duration: mediaModelData.Duration,
|
||||
})
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 删除ChatRecord
|
||||
func (AsChatLogic) DeleteChatRecords(req *accountFiee.DeleteChatRecordRequest) (resp *accountFiee.CommonMsg, err error) {
|
||||
err = dao.AsChatDao.DeleteChatRecords(req.Id, req.Ids)
|
||||
return
|
||||
}
|
||||
|
||||
// 更新ChatRecord
|
||||
func (AsChatLogic) UpdateChatRecord(data *accountFiee.ChatRecordData) (resp *accountFiee.CommonMsg, err error) {
|
||||
resp = new(accountFiee.CommonMsg)
|
||||
if data.ID == 0 {
|
||||
resp.Msg = "ID不能为空"
|
||||
err = errors.New(resp.Msg)
|
||||
return
|
||||
}
|
||||
var modelData = model.ChatRecord{}
|
||||
if err = copier.CopyWithOption(&modelData, data, utils.CopierProtoOptions); err != nil {
|
||||
return
|
||||
}
|
||||
err = dao.AsChatDao.UpdateChatRecord(&modelData)
|
||||
return
|
||||
}
|
||||
|
||||
// 覆盖ChatRecord
|
||||
func (AsChatLogic) SaveChatRecord(data *accountFiee.ChatRecordData) (resp *accountFiee.CommonMsg, err error) {
|
||||
resp = new(accountFiee.CommonMsg)
|
||||
if data.ID == 0 {
|
||||
resp.Msg = "ID不能为空"
|
||||
err = errors.New(resp.Msg)
|
||||
return
|
||||
}
|
||||
var modelData = model.ChatRecord{}
|
||||
if err = copier.CopyWithOption(&modelData, data, utils.CopierProtoOptions); err != nil {
|
||||
return
|
||||
}
|
||||
err = dao.AsChatDao.SaveChatRecord(&modelData)
|
||||
return
|
||||
}
|
||||
|
||||
// 使用id查询ChatRecord
|
||||
func (AsChatLogic) GetChatRecordById(req *accountFiee.GetChatRecordByIdRequest) (data *accountFiee.ChatRecordData, err error) {
|
||||
data = &accountFiee.ChatRecordData{}
|
||||
modelData, err := dao.AsChatDao.GetChatRecordById(int(req.Id))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = copier.CopyWithOption(&data, &modelData, utils.CopierProtoOptions); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 批量查询ChatRecord
|
||||
func (AsChatLogic) GetChatRecordList(req *accountFiee.GetChatRecordListRequest) (resp *accountFiee.GetChatRecordListResp, err error) {
|
||||
resp = &accountFiee.GetChatRecordListResp{
|
||||
List: []*accountFiee.ChatRecordData{},
|
||||
Page: req.Page,
|
||||
PageSize: req.PageSize,
|
||||
}
|
||||
var data = []model.ChatRecord{}
|
||||
data, resp.Total, err = dao.AsChatDao.GetChatRecordList(req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if err = copier.CopyWithOption(&resp.List, &data, utils.CopierProtoOptions); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
func (AsChatLogic) RegisterWaiter(request *accountFiee.RegisterWaiterRequest) (resp *accountFiee.RegisterWaiterResp, err error) {
|
||||
resp = &accountFiee.RegisterWaiterResp{
|
||||
UserId: 0,
|
||||
}
|
||||
var waiterUserInfo = model.ChatUser{
|
||||
OriginId: request.OriginId,
|
||||
Account: request.Account,
|
||||
Role: 2,
|
||||
NickName: request.NickName,
|
||||
Origin: request.Origin,
|
||||
Avatar: request.Avatar,
|
||||
}
|
||||
err = dao.ChatUserDao.CreateChatUser(&waiterUserInfo)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 创建ChatMedia
|
||||
func (AsChatLogic) CreateChatMedia(data *accountFiee.ChatMediaData) (resp *accountFiee.CreateChatMediaResp, err error) {
|
||||
resp = &accountFiee.CreateChatMediaResp{
|
||||
Data: &accountFiee.ChatMediaData{},
|
||||
Msg: "创建成功",
|
||||
}
|
||||
var modelData = model.ChatMedia{}
|
||||
if err = copier.CopyWithOption(&modelData, data, utils.CopierProtoOptions); err != nil {
|
||||
resp.Msg = "数据转换失败"
|
||||
return
|
||||
}
|
||||
err = dao.AsChatDao.CreateChatMedia(&modelData)
|
||||
if err != nil {
|
||||
resp.Msg = "创建失败"
|
||||
return
|
||||
}
|
||||
if err = copier.CopyWithOption(resp.Data, &modelData, utils.CopierProtoOptions); err != nil {
|
||||
resp.Msg = "创建失败."
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 删除ChatMedia
|
||||
func (AsChatLogic) DeleteChatMedias(req *accountFiee.DeleteChatMediaRequest) (resp *accountFiee.CommonMsg, err error) {
|
||||
err = dao.AsChatDao.DeleteChatMedias(req.Id, req.Ids)
|
||||
return
|
||||
}
|
||||
|
||||
// 更新ChatMedia
|
||||
func (AsChatLogic) UpdateChatMedia(data *accountFiee.ChatMediaData) (resp *accountFiee.CommonMsg, err error) {
|
||||
resp = new(accountFiee.CommonMsg)
|
||||
if data.ID == 0 {
|
||||
resp.Msg = "ID不能为空"
|
||||
err = errors.New(resp.Msg)
|
||||
return
|
||||
}
|
||||
var modelData = model.ChatMedia{}
|
||||
if err = copier.CopyWithOption(&modelData, data, utils.CopierProtoOptions); err != nil {
|
||||
return
|
||||
}
|
||||
err = dao.AsChatDao.UpdateChatMedia(&modelData)
|
||||
return
|
||||
}
|
||||
|
||||
// 覆盖ChatMedia
|
||||
func (AsChatLogic) SaveChatMedia(data *accountFiee.ChatMediaData) (resp *accountFiee.CommonMsg, err error) {
|
||||
resp = new(accountFiee.CommonMsg)
|
||||
if data.ID == 0 {
|
||||
resp.Msg = "ID不能为空"
|
||||
err = errors.New(resp.Msg)
|
||||
return
|
||||
}
|
||||
var modelData = model.ChatMedia{}
|
||||
if err = copier.CopyWithOption(&modelData, data, utils.CopierProtoOptions); err != nil {
|
||||
return
|
||||
}
|
||||
err = dao.AsChatDao.SaveChatMedia(&modelData)
|
||||
return
|
||||
}
|
||||
|
||||
// 使用id查询ChatMedia
|
||||
func (AsChatLogic) GetChatMediaById(req *accountFiee.GetChatMediaByIdRequest) (data *accountFiee.ChatMediaData, err error) {
|
||||
data = &accountFiee.ChatMediaData{}
|
||||
modelData, err := dao.AsChatDao.GetChatMediaById(req.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = copier.CopyWithOption(&data, &modelData, utils.CopierProtoOptions); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 批量查询ChatMedia
|
||||
func (AsChatLogic) GetChatMediaList(req *accountFiee.GetChatMediaListRequest) (resp *accountFiee.GetChatMediaListResp, err error) {
|
||||
resp = &accountFiee.GetChatMediaListResp{
|
||||
List: []*accountFiee.ChatMediaData{},
|
||||
Page: req.Page,
|
||||
PageSize: req.PageSize,
|
||||
}
|
||||
var data = []model.ChatMedia{}
|
||||
data, resp.Total, err = dao.AsChatDao.GetChatMediaList(req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if err = copier.CopyWithOption(&resp.List, &data, utils.CopierProtoOptions); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (AsChatLogic) GetChatUserList2(req *accountFiee.GetChatUserListRequest2) (resp *accountFiee.GetChatUserListResp2, err error) {
|
||||
resp = &accountFiee.GetChatUserListResp2{
|
||||
List: []*accountFiee.ChatUser2{},
|
||||
Page: req.Page,
|
||||
PageSize: req.PageSize,
|
||||
}
|
||||
resp.List, resp.Total, err = dao.AsChatDao.GetChatUserList(req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
104
pkg/logic/chatAutoReplyRulerLogic.go
Normal file
104
pkg/logic/chatAutoReplyRulerLogic.go
Normal file
@ -0,0 +1,104 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/fonchain_enterprise/micro-account/api/accountFiee"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/common/utils"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/dao"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/model"
|
||||
"github.com/jinzhu/copier"
|
||||
)
|
||||
|
||||
type ChatAutoReplyRulerLogic struct{}
|
||||
|
||||
// 创建自动回复规则
|
||||
func (ChatAutoReplyRulerLogic) CreateChatAutoReplyRuler(data *accountFiee.ChatAutoReplyRulerData) (resp *accountFiee.CreateChatAutoReplyRulerResp, err error) {
|
||||
resp = &accountFiee.CreateChatAutoReplyRulerResp{
|
||||
Data: &accountFiee.ChatAutoReplyRulerData{},
|
||||
Msg: "创建成功",
|
||||
}
|
||||
var modelData = model.ChatAutoReplyRuler{}
|
||||
if err = copier.CopyWithOption(&modelData, data, utils.CopierProtoOptions); err != nil {
|
||||
resp.Msg = "数据转换失败"
|
||||
return
|
||||
}
|
||||
err = dao.ChatAutoReplyRulerDao.CreateChatAutoReplyRuler(&modelData)
|
||||
if err != nil {
|
||||
resp.Msg = "创建失败"
|
||||
return
|
||||
}
|
||||
if err = copier.CopyWithOption(resp.Data, &modelData, utils.CopierProtoOptions); err != nil {
|
||||
resp.Msg = "创建失败."
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 删除自动回复规则
|
||||
func (ChatAutoReplyRulerLogic) DeleteChatAutoReplyRulers(req *accountFiee.DeleteChatAutoReplyRulerRequest) (resp *accountFiee.CommonMsg, err error) {
|
||||
err = dao.ChatAutoReplyRulerDao.DeleteChatAutoReplyRulers(req.Id, req.Ids)
|
||||
return
|
||||
}
|
||||
|
||||
// 更新自动回复规则
|
||||
func (ChatAutoReplyRulerLogic) UpdateChatAutoReplyRuler(data *accountFiee.ChatAutoReplyRulerData) (resp *accountFiee.CommonMsg, err error) {
|
||||
resp = new(accountFiee.CommonMsg)
|
||||
if data.ID == 0 {
|
||||
resp.Msg = "ID不能为空"
|
||||
err = errors.New(resp.Msg)
|
||||
return
|
||||
}
|
||||
var modelData = model.ChatAutoReplyRuler{}
|
||||
if err = copier.CopyWithOption(&modelData, data, utils.CopierProtoOptions); err != nil {
|
||||
return
|
||||
}
|
||||
err = dao.ChatAutoReplyRulerDao.UpdateChatAutoReplyRuler(&modelData)
|
||||
return
|
||||
}
|
||||
|
||||
// 覆盖自动回复规则
|
||||
func (ChatAutoReplyRulerLogic) SaveChatAutoReplyRuler(data *accountFiee.ChatAutoReplyRulerData) (resp *accountFiee.CommonMsg, err error) {
|
||||
resp = new(accountFiee.CommonMsg)
|
||||
if data.ID == 0 {
|
||||
resp.Msg = "ID不能为空"
|
||||
err = errors.New(resp.Msg)
|
||||
return
|
||||
}
|
||||
var modelData = model.ChatAutoReplyRuler{}
|
||||
if err = copier.CopyWithOption(&modelData, data, utils.CopierProtoOptions); err != nil {
|
||||
return
|
||||
}
|
||||
err = dao.ChatAutoReplyRulerDao.SaveChatAutoReplyRuler(&modelData)
|
||||
return
|
||||
}
|
||||
|
||||
// 使用id查询自动回复规则
|
||||
func (ChatAutoReplyRulerLogic) GetChatAutoReplyRulerById(req *accountFiee.GetChatAutoReplyRulerByIdRequest) (data *accountFiee.ChatAutoReplyRulerData, err error) {
|
||||
data = &accountFiee.ChatAutoReplyRulerData{}
|
||||
modelData, err := dao.ChatAutoReplyRulerDao.GetChatAutoReplyRulerById(int(req.Id))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = copier.CopyWithOption(&data, &modelData, utils.CopierProtoOptions); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 批量查询自动回复规则
|
||||
func (ChatAutoReplyRulerLogic) GetChatAutoReplyRulerList(req *accountFiee.GetChatAutoReplyRulerListRequest) (resp *accountFiee.GetChatAutoReplyRulerListResp, err error) {
|
||||
resp = &accountFiee.GetChatAutoReplyRulerListResp{
|
||||
List: []*accountFiee.ChatAutoReplyRulerData{},
|
||||
Page: req.Page,
|
||||
PageSize: req.PageSize,
|
||||
}
|
||||
var data = []model.ChatAutoReplyRuler{}
|
||||
data, resp.Total, err = dao.ChatAutoReplyRulerDao.GetChatAutoReplyRulerList(req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if err = copier.CopyWithOption(&resp.List, &data, utils.CopierProtoOptions); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
104
pkg/logic/chatUserLogic.go
Normal file
104
pkg/logic/chatUserLogic.go
Normal file
@ -0,0 +1,104 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/fonchain_enterprise/micro-account/api/accountFiee"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/common/utils"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/dao"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/model"
|
||||
"github.com/jinzhu/copier"
|
||||
)
|
||||
|
||||
type ChatUserLogic struct{}
|
||||
|
||||
// 创建聊天用户
|
||||
func (ChatUserLogic) CreateChatUser(data *accountFiee.ChatUserData) (resp *accountFiee.CreateChatUserResp, err error) {
|
||||
resp = &accountFiee.CreateChatUserResp{
|
||||
Data: &accountFiee.ChatUserData{},
|
||||
Msg: "创建成功",
|
||||
}
|
||||
var modelData = model.ChatUser{}
|
||||
if err = copier.CopyWithOption(&modelData, data, utils.CopierProtoOptions); err != nil {
|
||||
resp.Msg = "数据转换失败"
|
||||
return
|
||||
}
|
||||
err = dao.ChatUserDao.CreateChatUser(&modelData)
|
||||
if err != nil {
|
||||
resp.Msg = "创建失败"
|
||||
return
|
||||
}
|
||||
if err = copier.CopyWithOption(resp.Data, &modelData, utils.CopierProtoOptions); err != nil {
|
||||
resp.Msg = "创建失败."
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 删除聊天用户
|
||||
func (ChatUserLogic) DeleteChatUsers(req *accountFiee.DeleteChatUserRequest) (resp *accountFiee.CommonMsg, err error) {
|
||||
err = dao.ChatUserDao.DeleteChatUsers(req.Id, req.Ids)
|
||||
return
|
||||
}
|
||||
|
||||
// 更新聊天用户
|
||||
func (ChatUserLogic) UpdateChatUser(data *accountFiee.ChatUserData) (resp *accountFiee.CommonMsg, err error) {
|
||||
resp = new(accountFiee.CommonMsg)
|
||||
if data.ID == 0 {
|
||||
resp.Msg = "ID不能为空"
|
||||
err = errors.New(resp.Msg)
|
||||
return
|
||||
}
|
||||
var modelData = model.ChatUser{}
|
||||
if err = copier.CopyWithOption(&modelData, data, utils.CopierProtoOptions); err != nil {
|
||||
return
|
||||
}
|
||||
err = dao.ChatUserDao.UpdateChatUser(&modelData)
|
||||
return
|
||||
}
|
||||
|
||||
// 覆盖聊天用户
|
||||
func (ChatUserLogic) SaveChatUser(data *accountFiee.ChatUserData) (resp *accountFiee.CommonMsg, err error) {
|
||||
resp = new(accountFiee.CommonMsg)
|
||||
if data.ID == 0 {
|
||||
resp.Msg = "ID不能为空"
|
||||
err = errors.New(resp.Msg)
|
||||
return
|
||||
}
|
||||
var modelData = model.ChatUser{}
|
||||
if err = copier.CopyWithOption(&modelData, data, utils.CopierProtoOptions); err != nil {
|
||||
return
|
||||
}
|
||||
err = dao.ChatUserDao.SaveChatUser(&modelData)
|
||||
return
|
||||
}
|
||||
|
||||
// 使用id查询聊天用户
|
||||
func (ChatUserLogic) GetChatUserById(req *accountFiee.GetChatUserByIdRequest) (data *accountFiee.ChatUserData, err error) {
|
||||
data = &accountFiee.ChatUserData{}
|
||||
modelData, err := dao.ChatUserDao.GetChatUserById(int(req.Id))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = copier.CopyWithOption(&data, &modelData, utils.CopierProtoOptions); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 批量查询聊天用户
|
||||
func (ChatUserLogic) GetChatUserList(req *accountFiee.GetChatUserListRequest) (resp *accountFiee.GetChatUserListResp, err error) {
|
||||
resp = &accountFiee.GetChatUserListResp{
|
||||
List: []*accountFiee.ChatUserData{},
|
||||
Page: req.Page,
|
||||
PageSize: req.PageSize,
|
||||
}
|
||||
var data = []model.ChatUser{}
|
||||
data, resp.Total, err = dao.ChatUserDao.GetChatUserList(req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if err = copier.CopyWithOption(&resp.List, &data, utils.CopierProtoOptions); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
@ -28,6 +28,7 @@ const (
|
||||
Pass = 4
|
||||
)
|
||||
const (
|
||||
DBError = "数据库错误"
|
||||
ERRORPWD = "账号或密码错误"
|
||||
ERRORCODE = "账号或验证码错误"
|
||||
ERRORCONFIG = "配置文件读取错误,请检查文件路径:"
|
||||
|
76
pkg/model/chatRecord.go
Normal file
76
pkg/model/chatRecord.go
Normal file
@ -0,0 +1,76 @@
|
||||
// Package model -----------------------------
|
||||
// @file : chatRecord.go
|
||||
// @author : JJXu
|
||||
// @contact : wavingbear@163.com
|
||||
// @time : 2024/9/10 下午3:23
|
||||
// -------------------------------------------
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/plugin/soft_delete"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
ID int64 `gorm:"primarykey;" json:"id" form:"id"`
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"`
|
||||
DeletedAt soft_delete.DeletedAt `gorm:"column:deleted_at;type:bigint;default:0" json:"deletedAt"`
|
||||
}
|
||||
type ChatRecord struct {
|
||||
Model
|
||||
SessionId string `gorm:"column:session_id;comment:会话ID"`
|
||||
Domain string `gorm:"column:domain;comment:域"`
|
||||
UserId int64 `gorm:"column:user_id;comment:账号ID"`
|
||||
Name string `gorm:"column:name;comment:名称"`
|
||||
Avatar string `gorm:"column:avatar;comment:头像"`
|
||||
MsgType int32 `gorm:"column:msg_type;comment:消息类型"`
|
||||
Content string `gorm:"column:content;type:varchar(2000);comment:消息内容"`
|
||||
Medias []*ChatMedia `gorm:"many2many:chat_record_media;"`
|
||||
WaiterRead int32 `gorm:"column:waiter_read;default:2;comment:客服是否已读 1=已读 2=未读"` // (被任意客服读取过均为已读)
|
||||
LocalStamp int64 `gorm:"column:local_stamp;comment:用户端的消息唯一值,用于用户端的消息校验"`
|
||||
}
|
||||
|
||||
func (c ChatRecord) TableName() string {
|
||||
return "chat_record"
|
||||
}
|
||||
|
||||
type ChatMedia struct {
|
||||
Model
|
||||
//MediaType int32 `gorm:"column:media_type;comment:媒体类型"`
|
||||
Url string `gorm:"column:url;comment:url"`
|
||||
Md5 string `gorm:"column:md5;comment:md5值"`
|
||||
Size string `gorm:"column:size;comment:尺寸"`
|
||||
Ext string `gorm:"column:ext;comment:后缀格式"`
|
||||
ConvText string `gorm:"column:conv_text;type:varchar(2000);comment:语音转文字内容"`
|
||||
Duration int64 `gorm:"column:duration;comment:时长 单位为ms"`
|
||||
}
|
||||
|
||||
func (c ChatRecord) ChatMedia() string {
|
||||
return "chat_media"
|
||||
}
|
||||
|
||||
type ChatAutoReplyRuler struct {
|
||||
Model
|
||||
Title string `gorm:"column:title;comment:标题"`
|
||||
Ruler string `gorm:"column:ruler;type:varchar(2000);comment:规则内容"`
|
||||
RulerStatus int32 `gorm:"column:ruler_status;comment:规则状态: 1=启用 2=禁用"`
|
||||
}
|
||||
|
||||
func (c ChatRecord) AutoChatRuler() string {
|
||||
return "chat_auto_reply_ruler"
|
||||
}
|
||||
|
||||
type ChatUser struct {
|
||||
Model
|
||||
NickName string `gorm:"column:nick_name;comment:昵称"`
|
||||
Account string `gorm:"column:account;comment:账号"`
|
||||
Role int32 `gorm:"column:role;default:1;comment:聊天角色 1=用户 2=客服"`
|
||||
Origin string `gorm:"column:origin;default:'fiee';comment:数据来源"`
|
||||
OriginId int64 `gorm:"column:origin_id;comment:数据来源对应的用户ID"`
|
||||
Avatar string `gorm:"column:avatar;comment:头像"`
|
||||
}
|
||||
|
||||
func (c ChatUser) TableName() string {
|
||||
return "chat_user"
|
||||
}
|
@ -7,10 +7,11 @@ import (
|
||||
// 类型迁移
|
||||
func migration() {
|
||||
|
||||
err := DB.AutoMigrate()
|
||||
//err = DBOrder.AutoMigrate(
|
||||
// &model.Pay{},
|
||||
//)
|
||||
err := DB.AutoMigrate(
|
||||
&ChatMedia{},
|
||||
&ChatRecord{},
|
||||
&ChatUser{},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("register table fail")
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/common/utils"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/common/verifica"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/domain"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/logic"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/m"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/model"
|
||||
"github.com/fonchain_enterprise/micro-account/pkg/serializer"
|
||||
@ -34,6 +35,9 @@ import (
|
||||
|
||||
type AccountFieeProvider struct {
|
||||
account.UnimplementedAccountFieeServer
|
||||
chatAutoReplyRulerLogic logic.ChatAutoReplyRulerLogic
|
||||
asChatLogic logic.AsChatLogic
|
||||
chatUserLogic logic.ChatUserLogic
|
||||
}
|
||||
|
||||
// OffLine 踢出
|
||||
|
79
pkg/service/asChatRecordProvider.go
Normal file
79
pkg/service/asChatRecordProvider.go
Normal file
@ -0,0 +1,79 @@
|
||||
// Package controller -----------------------------
|
||||
// @author : JJXu
|
||||
// @contact : wavingbear@163.com
|
||||
// @time : 2024-09-10 15:50:24
|
||||
// -------------------------------------------
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/fonchain_enterprise/micro-account/api/accountFiee"
|
||||
)
|
||||
|
||||
func (a *AccountFieeProvider) GetChatUserList2(ctx context.Context, request *accountFiee.GetChatUserListRequest2) (*accountFiee.GetChatUserListResp2, error) {
|
||||
return a.asChatLogic.GetChatUserList2(request)
|
||||
}
|
||||
|
||||
func (a *AccountFieeProvider) RegisterWaiter(ctx context.Context, request *accountFiee.RegisterWaiterRequest) (*accountFiee.RegisterWaiterResp, error) {
|
||||
return a.asChatLogic.RegisterWaiter(request)
|
||||
}
|
||||
|
||||
// 创建ChatRecord
|
||||
func (a *AccountFieeProvider) CreateChatRecord(ctx context.Context, req *accountFiee.ChatRecordData) (*accountFiee.CreateChatRecordResp, error) {
|
||||
return a.asChatLogic.CreateChatRecord(req)
|
||||
}
|
||||
|
||||
// 删除ChatRecord
|
||||
func (a *AccountFieeProvider) DeleteChatRecord(ctx context.Context, req *accountFiee.DeleteChatRecordRequest) (*accountFiee.CommonMsg, error) {
|
||||
return a.asChatLogic.DeleteChatRecords(req)
|
||||
}
|
||||
|
||||
// 更新ChatRecord
|
||||
func (a *AccountFieeProvider) UpdateChatRecord(ctx context.Context, data *accountFiee.ChatRecordData) (*accountFiee.CommonMsg, error) {
|
||||
return a.asChatLogic.UpdateChatRecord(data)
|
||||
}
|
||||
|
||||
// 覆盖ChatRecord
|
||||
func (a *AccountFieeProvider) SaveChatRecord(ctx context.Context, data *accountFiee.ChatRecordData) (*accountFiee.CommonMsg, error) {
|
||||
return a.asChatLogic.SaveChatRecord(data)
|
||||
}
|
||||
|
||||
// 使用id查询ChatRecord
|
||||
func (a *AccountFieeProvider) GetChatRecordDetail(ctx context.Context, req *accountFiee.GetChatRecordByIdRequest) (data *accountFiee.ChatRecordData, err error) {
|
||||
return a.asChatLogic.GetChatRecordById(req)
|
||||
}
|
||||
|
||||
// 批量查询ChatRecord
|
||||
func (a *AccountFieeProvider) GetChatRecordList(ctx context.Context, req *accountFiee.GetChatRecordListRequest) (resp *accountFiee.GetChatRecordListResp, err error) {
|
||||
return a.asChatLogic.GetChatRecordList(req)
|
||||
}
|
||||
|
||||
// 创建ChatMedia
|
||||
func (a *AccountFieeProvider) CreateChatMedia(ctx context.Context, req *accountFiee.ChatMediaData) (*accountFiee.CreateChatMediaResp, error) {
|
||||
return a.asChatLogic.CreateChatMedia(req)
|
||||
}
|
||||
|
||||
// 删除ChatMedia
|
||||
func (a *AccountFieeProvider) DeleteChatMedia(ctx context.Context, req *accountFiee.DeleteChatMediaRequest) (*accountFiee.CommonMsg, error) {
|
||||
return a.asChatLogic.DeleteChatMedias(req)
|
||||
}
|
||||
|
||||
// 更新ChatMedia
|
||||
func (a *AccountFieeProvider) UpdateChatMedia(ctx context.Context, data *accountFiee.ChatMediaData) (*accountFiee.CommonMsg, error) {
|
||||
return a.asChatLogic.UpdateChatMedia(data)
|
||||
}
|
||||
|
||||
// 覆盖ChatMedia
|
||||
func (a *AccountFieeProvider) SaveChatMedia(ctx context.Context, data *accountFiee.ChatMediaData) (*accountFiee.CommonMsg, error) {
|
||||
return a.asChatLogic.SaveChatMedia(data)
|
||||
}
|
||||
|
||||
// 使用id查询ChatMedia
|
||||
func (a *AccountFieeProvider) GetChatMediaDetail(ctx context.Context, req *accountFiee.GetChatMediaByIdRequest) (data *accountFiee.ChatMediaData, err error) {
|
||||
return a.asChatLogic.GetChatMediaById(req)
|
||||
}
|
||||
|
||||
// 批量查询ChatMedia
|
||||
func (a *AccountFieeProvider) GetChatMediaList(ctx context.Context, req *accountFiee.GetChatMediaListRequest) (resp *accountFiee.GetChatMediaListResp, err error) {
|
||||
return a.asChatLogic.GetChatMediaList(req)
|
||||
}
|
41
pkg/service/chatAutoReplyRulerProvider.go
Normal file
41
pkg/service/chatAutoReplyRulerProvider.go
Normal file
@ -0,0 +1,41 @@
|
||||
// Package controller -----------------------------
|
||||
// @author : JJXu
|
||||
// @contact : wavingbear@163.com
|
||||
// @time : 2025-06-12 09:22:02
|
||||
// -------------------------------------------
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/fonchain_enterprise/micro-account/api/accountFiee"
|
||||
)
|
||||
|
||||
// 创建自动回复规则
|
||||
func (a *AccountFieeProvider) CreateChatAutoReplyRuler(ctx context.Context, req *accountFiee.ChatAutoReplyRulerData) (*accountFiee.CreateChatAutoReplyRulerResp, error) {
|
||||
return a.chatAutoReplyRulerLogic.CreateChatAutoReplyRuler(req)
|
||||
}
|
||||
|
||||
// 删除自动回复规则
|
||||
func (a *AccountFieeProvider) DeleteChatAutoReplyRuler(ctx context.Context, req *accountFiee.DeleteChatAutoReplyRulerRequest) (*accountFiee.CommonMsg, error) {
|
||||
return a.chatAutoReplyRulerLogic.DeleteChatAutoReplyRulers(req)
|
||||
}
|
||||
|
||||
// 更新自动回复规则
|
||||
func (a *AccountFieeProvider) UpdateChatAutoReplyRuler(ctx context.Context, data *accountFiee.ChatAutoReplyRulerData) (*accountFiee.CommonMsg, error) {
|
||||
return a.chatAutoReplyRulerLogic.UpdateChatAutoReplyRuler(data)
|
||||
}
|
||||
|
||||
// 覆盖自动回复规则
|
||||
func (a *AccountFieeProvider) SaveChatAutoReplyRuler(ctx context.Context, data *accountFiee.ChatAutoReplyRulerData) (*accountFiee.CommonMsg, error) {
|
||||
return a.chatAutoReplyRulerLogic.SaveChatAutoReplyRuler(data)
|
||||
}
|
||||
|
||||
// 使用id查询自动回复规则
|
||||
func (a *AccountFieeProvider) GetChatAutoReplyRulerDetail(ctx context.Context, req *accountFiee.GetChatAutoReplyRulerByIdRequest) (data *accountFiee.ChatAutoReplyRulerData, err error) {
|
||||
return a.chatAutoReplyRulerLogic.GetChatAutoReplyRulerById(req)
|
||||
}
|
||||
|
||||
// 批量查询自动回复规则
|
||||
func (a *AccountFieeProvider) GetChatAutoReplyRulerList(ctx context.Context, req *accountFiee.GetChatAutoReplyRulerListRequest) (resp *accountFiee.GetChatAutoReplyRulerListResp, err error) {
|
||||
return a.chatAutoReplyRulerLogic.GetChatAutoReplyRulerList(req)
|
||||
}
|
41
pkg/service/chatUserProvider.go
Normal file
41
pkg/service/chatUserProvider.go
Normal file
@ -0,0 +1,41 @@
|
||||
// Package controller -----------------------------
|
||||
// @author : JJXu
|
||||
// @contact : wavingbear@163.com
|
||||
// @time : 2025-06-12 10:06:32
|
||||
// -------------------------------------------
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/fonchain_enterprise/micro-account/api/accountFiee"
|
||||
)
|
||||
|
||||
// 创建聊天用户
|
||||
func (a *AccountFieeProvider) CreateChatUser(ctx context.Context, req *accountFiee.ChatUserData) (*accountFiee.CreateChatUserResp, error) {
|
||||
return a.chatUserLogic.CreateChatUser(req)
|
||||
}
|
||||
|
||||
// 删除聊天用户
|
||||
func (a *AccountFieeProvider) DeleteChatUser(ctx context.Context, req *accountFiee.DeleteChatUserRequest) (*accountFiee.CommonMsg, error) {
|
||||
return a.chatUserLogic.DeleteChatUsers(req)
|
||||
}
|
||||
|
||||
// 更新聊天用户
|
||||
func (a *AccountFieeProvider) UpdateChatUser(ctx context.Context, data *accountFiee.ChatUserData) (*accountFiee.CommonMsg, error) {
|
||||
return a.chatUserLogic.UpdateChatUser(data)
|
||||
}
|
||||
|
||||
// 覆盖聊天用户
|
||||
func (a *AccountFieeProvider) SaveChatUser(ctx context.Context, data *accountFiee.ChatUserData) (*accountFiee.CommonMsg, error) {
|
||||
return a.chatUserLogic.SaveChatUser(data)
|
||||
}
|
||||
|
||||
// 使用id查询聊天用户
|
||||
func (a *AccountFieeProvider) GetChatUserDetail(ctx context.Context, req *accountFiee.GetChatUserByIdRequest) (data *accountFiee.ChatUserData, err error) {
|
||||
return a.chatUserLogic.GetChatUserById(req)
|
||||
}
|
||||
|
||||
// 批量查询聊天用户
|
||||
func (a *AccountFieeProvider) GetChatUserList(ctx context.Context, req *accountFiee.GetChatUserListRequest) (resp *accountFiee.GetChatUserListResp, err error) {
|
||||
return a.chatUserLogic.GetChatUserList(req)
|
||||
}
|
Loading…
Reference in New Issue
Block a user