Commit 70b91186 by Li Feifei

debug

parent 25816068
File added
No preview for this file type
......@@ -34,8 +34,8 @@ func (this *ConfigureReply) Validate() error {
return nil
}
func (this *ConfigureDelRequest) Validate() error {
if !(this.CompanyUserId > 0) {
return github_com_mwitkow_go_proto_validators.FieldError("CompanyUserId", fmt.Errorf(`value '%v' must be greater than '0'`, this.CompanyUserId))
if !(this.Id > 0) {
return github_com_mwitkow_go_proto_validators.FieldError("Id", fmt.Errorf(`value '%v' must be greater than '0'`, this.Id))
}
return nil
}
......
......@@ -43,7 +43,7 @@ func AddImBase(im *validator_struct.ConfigureAddStruct) error {
func DelConfigure(user_id int64) (err error) {
configure := new(db.ImBase)
configure.CompanyUserId = user_id
configure.Id = int(user_id)
_, err = db.MysqlClient.Delete(configure)
if err != nil {
err = status.Error(codes.Internal, err.Error())
......@@ -76,6 +76,6 @@ func UpdateConfiguer(im *validator_struct.ConfigureUpdateStruct) error {
return errors.New("没有数据更改")
}
_, err := db.MysqlClient.QueryTable(b_table_name).
Filter(b_user_id, im.CompanyUserId).Update(orm_params)
Filter("id", im.Id).Update(orm_params)
return err
}
......@@ -51,7 +51,7 @@ func (cs *ConfigureSevice) Delete(ctx context.Context,
return
}
// 执行删除操作
if err = DelConfigure(in.CompanyUserId); err != nil {
if err = DelConfigure(in.Id); err != nil {
return
}
reply = &pb.ConfigureReply{}
......@@ -77,6 +77,7 @@ func (cs *ConfigureSevice) Select(ctx context.Context,
for _, v := range configs {
reply.GetAll = append(reply.GetAll, &pb.GetAllOneReply{
Reply: &pb.Public{
Id:int64(v.Id),
CompanyUserId: v.CompanyUserId,
MultideviceType: v.MultideviceType,
MsgHookUrl: v.MsgHookUrl,
......
......@@ -6,22 +6,21 @@ package pb;
import "github.com/mwitkow/go-proto-validators/validator.proto";
message Public {
int64 CompanyUserId = 1;
int64 MultideviceType = 2;
string MsgHookUrl = 3;
int64 Id = 1;
int64 CompanyUserId = 2;
int64 MultideviceType = 3;
string MsgHookUrl = 4;
}
message ConfigureRequest {
string Appkey= 1;
string Current=2;
Public Public = 3;
int64 AppId = 4 [(validator.field) = {int_gt: 0}];
Public Public = 1;
int64 AppId = 2 [(validator.field) = {int_gt: 0}];
}
message ConfigureReply {}
message ConfigureDelRequest {
int64 CompanyUserId = 1 [(validator.field) = {int_gt: 0}];
int64 Id = 1 [(validator.field) = {int_gt: 0}];
}
message GetAllRequest {
......
......@@ -39,7 +39,7 @@ func NewConfigureAddStruct(inter interface{}) *ConfigureAddStruct {
// 修改配置
type ConfigureUpdateStruct struct {
CompanyUserId int64 `validate:"required,numeric"`
Id int64 `validate:"required,numeric"`
MultideviceType int64
MsgHookUrl string
}
......@@ -48,28 +48,29 @@ func NewConfigureUpdateStruct(in interface{}) *ConfigureUpdateStruct {
var config_update = &ConfigureUpdateStruct{}
switch in.(type) {
case *pb.UpdateRequest:
var v = in.(*pb.ConfigureRequest)
config_update.CompanyUserId = v.Public.GetCompanyUserId()
var v = in.(*pb.UpdateRequest)
config_update.MultideviceType = v.Public.GetMultideviceType()
config_update.MsgHookUrl = v.Public.GetMsgHookUrl()
config_update.Id = v.Public.Id
case map[string]interface{}:
var c = in.(map[string]interface{})
if cui, ok := c["company_user_id"].(int64); ok {
config_update.CompanyUserId = cui
}
if mt, ok := c["multidevice_type"].(int64); ok {
config_update.MultideviceType = mt
}
if mhu, ok := c["msg_hook_url"].(string); ok {
config_update.MsgHookUrl = mhu
}
if id, ok := c["id"].(int64); ok {
config_update.Id = id
}
}
return config_update
}
// 删除配置
type ConfigureDelStruct struct {
CompanyUserId int64 `validate:"required,numeric"`
Id int64 `validate:"required,numeric"`
}
func NewConfigureDelStruct(inter interface{}) *ConfigureDelStruct {
......@@ -77,11 +78,11 @@ func NewConfigureDelStruct(inter interface{}) *ConfigureDelStruct {
switch inter.(type) {
case *pb.ConfigureDelRequest:
var c = inter.(*pb.ConfigureDelRequest)
room.CompanyUserId = c.GetCompanyUserId()
room.Id = c.GetId()
case map[string]interface{}:
var c = inter.(map[string]interface{})
if v, ok := c["company_user_id"].(int64); ok {
room.CompanyUserId = v
room.Id = v
}
}
return room
......
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 to comment