go_dreamfactory/modules/library/api_activationfetter.go
2023-05-05 10:33:56 +08:00

42 lines
1.1 KiB
Go

package library
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
)
//参数校验
func (this *apiComp) ActivationFetterCheck(session comm.IUserSession, req *pb.LibraryActivationFetterReq) (code pb.ErrorCode) {
if req.Oid == "" {
code = pb.ErrorCode_ReqParameterError
}
return
}
func (this *apiComp) ActivationFetter(session comm.IUserSession, req *pb.LibraryActivationFetterReq) (code pb.ErrorCode, data *pb.ErrorData) {
code = this.ActivationFetterCheck(session, req)
if code != pb.ErrorCode_Success {
return // 参数校验失败直接返回
}
rsp := &pb.LibraryActivationFetterResp{}
fetter := this.module.modelLibrary.getOneLibrary(session.GetUserId(), req.Oid)
if fetter == nil {
code = pb.ErrorCode_LibraryNoData
return
}
if fetter.Activation {
code = pb.ErrorCode_LibraryActivation
return
}
fetter.Activation = true
mapData := make(map[string]interface{}, 0)
mapData["activation"] = fetter.Activation
this.module.modelLibrary.modifyLibraryDataByObjId(session.GetUserId(), fetter.Id, mapData)
rsp.Data = fetter
session.SendMsg(string(this.module.GetType()), LibraryActivationFetterResp, rsp)
return
}