39 lines
998 B
Go
39 lines
998 B
Go
package user
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/utils"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
func (this *apiComp) UpdatesettingCheck(session comm.IUserSession, req *pb.UserUpdateSettingReq) (code pb.ErrorCode) {
|
|
if req.Setting.Huazhi > 3 || req.Setting.Kangjuchi > 3 {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Updatesetting(session comm.IUserSession, req *pb.UserUpdateSettingReq) (code pb.ErrorCode, data proto.Message) {
|
|
if code = this.UpdatesettingCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
|
|
rsp := &pb.UserUpdateSettingResp{}
|
|
|
|
req.Setting.Uid = session.GetUserId()
|
|
update := utils.StructToMap(req.Setting)
|
|
|
|
if err := this.module.modelSetting.UpdateSetting(session.GetUserId(), update); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
|
|
err := session.SendMsg(string(this.module.GetType()), UserSubTypeUpdatesetting, rsp)
|
|
if err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
}
|
|
return
|
|
}
|