作者 yangfu

log/opp 打印日志

... ... @@ -14,15 +14,17 @@ RUN go mod download
COPY . .
RUN GOOS=linux CGO_ENABLED=0 go build -ldflags="-s -w" -installsuffix cgo -o opp main.go
FROM alpine:latest
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk add --no-cache tzdata \
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone \
# && rm -rf /var/cache/apk/* /tmp/* /var/tmp/* $HOME/.cache ## 清除缓存
WORKDIR /root/
COPY --from=builder /go/src/opp .
EXPOSE 8080
CMD ["./opp"]
#FROM alpine:latest
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
#RUN apk add --no-cache tzdata \
# && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
# && echo "Asia/Shanghai" > /etc/timezone \
## && rm -rf /var/cache/apk/* /tmp/* /var/tmp/* $HOME/.cache ## 清除缓存
#WORKDIR /root/
#COPY --from=builder /go/src/opp .
#EXPOSE 8080
#CMD ["./opp"]
\ No newline at end of file
... ...
... ... @@ -72,7 +72,7 @@ func (this *ChanceController) Comments() {
return
}
header := controllers.GetRequestHeader(this.Ctx)
request.SourceType = protocol.SourceType_Chance
request.SourceType = protocol.SourceTypeChance
msg = protocol.NewReturnResponse(chance.Comments(header, request))
}
... ... @@ -156,7 +156,7 @@ func (this *ChanceController) SympathyAction() {
msg = m
return
}
if !(request.SourceType == protocol.SourceType_Chance || request.SourceType == protocol.SourceType_Comment) {
if !(request.SourceType == protocol.SourceTypeChance || request.SourceType == protocol.SourceTypeComment) {
msg = protocol.BadRequestParam(2)
return
}
... ... @@ -224,7 +224,7 @@ func (this *ChanceController) ChanceSubmit() {
return
}
header := controllers.GetRequestHeader(this.Ctx)
if request.Id>0{
if request.Id > 0 {
msg = protocol.NewReturnResponse(chance.ChanceUpdate(header, request))
return
}
... ...
... ... @@ -31,7 +31,6 @@ else
kubectl -n mmm-suplus-prd get svc | grep -q opp
if [ "$?" == "0" ];then
echo "opp service update success!"
cat /tmp/prd/opp/opp.yaml
else
echo "opp service update fail!"
fi
... ...
package protocol
const (
SourceType_Chance = 1
SourceType_Comment = 2
SourceTypeChance = 1
SourceTypeComment = 2
SourceTypeBulletin = 3
)
/*IComment */
... ...
... ... @@ -40,7 +40,7 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest)
Id: f.Id,
}
switch f.SourceType {
case protocol.SourceType_Chance:
case protocol.SourceTypeChance:
chance, err = agg.GetChance(f.SourceId, f.CompanyId)
if err != nil {
log.Error(err)
... ... @@ -49,7 +49,7 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest)
chance.IsZan = (f.MarkFlag & protocol.MarkFlag_Zan) == protocol.MarkFlag_Zan
chance.IsCollect = (f.MarkFlag & protocol.MarkFlag_Collect) == protocol.MarkFlag_Collect
item.Favorite = chance
case protocol.SourceType_Comment:
case protocol.SourceTypeComment:
}
rsp.Lists[i] = item
}
... ... @@ -71,7 +71,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc
log.Error(err)
return
}
if request.SourceType == protocol.SourceType_Chance {
if request.SourceType == protocol.SourceTypeChance {
if chance, err = repository.Chance.GetChanceById(request.Id); err != nil {
log.Error("机会不存在", err)
return
... ... @@ -258,14 +258,14 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
}
//6.文件
{
data :=&models.ChanceData{
Id:idgen.Next(),
ChanceId:chance.Id,
Speechs:common.AssertJson(request.Speechs),
Images:common.AssertJson(request.Pictures),
Videos:common.AssertJson(request.Videos),
CreateAt:time.Now(),
UpdateAt:time.Now(),
data := &models.ChanceData{
Id: idgen.Next(),
ChanceId: chance.Id,
Speechs: common.AssertJson(request.Speechs),
Images: common.AssertJson(request.Pictures),
Videos: common.AssertJson(request.Videos),
CreateAt: time.Now(),
UpdateAt: time.Now(),
}
if _, err = orm.Insert(data); err != nil {
log.Error(err)
... ... @@ -288,16 +288,16 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit
auditConfig *protocol.AuditConfig
chanceData *models.ChanceData
//auditFlows []*models.AuditFlowProcess
updateMap =make(map[string]interface{})
updateMap = make(map[string]interface{})
)
if chance,err =models.GetChanceById(request.Id);err!=nil{
if chance, err = models.GetChanceById(request.Id); err != nil {
log.Error(err)
return
}
//TODO:非本人 1.需要验证角色权限,是否是审核人
if chance.UserId!=header.Uid{
if chance.UserId != header.Uid {
err = protocol.NewErrWithMessage(1)
log.Error(fmt.Sprintf("user:%v 无权限操作机会 chance:%v",header.Uid,chance.Id))
log.Error(fmt.Sprintf("user:%v 无权限操作机会 chance:%v", header.Uid, chance.Id))
return
}
//TODO:验证机会当前是否在审核中
... ... @@ -315,14 +315,13 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit
updateMap["SourceContent"] = common.AssertJson(request.FormList)
updateMap["DepartmentId"] = request.RelatedDepartment
if err = utils.UpdateTableByMapWithOrmer(orm,&models.Chance{Id:chance.Id},updateMap); err != nil {
if err = utils.UpdateTableByMapWithOrmer(orm, &models.Chance{Id: chance.Id}, updateMap); err != nil {
log.Error(err)
orm.Rollback()
return
}
}
//4.查询审核配置
//5.生成审核流 删除旧的 生成新的
//if auditFlows, err = GenAuditFlowProcess(header, chance.Id, template.Id, auditConfig); err != nil {
... ... @@ -340,26 +339,26 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit
//6.更新文件
{
if chanceData,err = models.GetChanceDataByChanceId(chance.Id);err==nil{
if err = utils.UpdateTableByMapWithOrmer(orm,chanceData,map[string]interface{}{
"Speechs":common.AssertJson(request.Speechs),
"Images":common.AssertJson(request.Pictures),
"Videos":common.AssertJson(request.Videos),
"UpdateAt":time.Now(),
});err!=nil{
if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil {
if err = utils.UpdateTableByMapWithOrmer(orm, chanceData, map[string]interface{}{
"Speechs": common.AssertJson(request.Speechs),
"Images": common.AssertJson(request.Pictures),
"Videos": common.AssertJson(request.Videos),
"UpdateAt": time.Now(),
}); err != nil {
log.Error(err)
orm.Rollback()
return
}
}else{
data :=&models.ChanceData{
Id:idgen.Next(),
ChanceId:chance.Id,
Speechs:common.AssertJson(request.Speechs),
Images:common.AssertJson(request.Pictures),
Videos:common.AssertJson(request.Videos),
CreateAt:time.Now(),
UpdateAt:time.Now(),
} else {
data := &models.ChanceData{
Id: idgen.Next(),
ChanceId: chance.Id,
Speechs: common.AssertJson(request.Speechs),
Images: common.AssertJson(request.Pictures),
Videos: common.AssertJson(request.Videos),
CreateAt: time.Now(),
UpdateAt: time.Now(),
}
if _, err = orm.Insert(data); err != nil {
log.Error(err)
... ...
... ... @@ -22,14 +22,14 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest)
updateMap = make(map[string]interface{})
)
switch request.SourceType {
case protocol.SourceType_Chance:
case protocol.SourceTypeChance:
if chance, err = repository.Chance.GetChanceById(request.Id); err != nil {
log.Error(err)
return
}
updateTable = chance
updateMap["CommentTotal"] = chance.CommentTotal + 1
case protocol.SourceType_Comment:
case protocol.SourceTypeComment:
if comment, err = repository.Comment.GetCommentById(request.Id); err != nil {
log.Error(err)
return
... ... @@ -74,7 +74,7 @@ func IComments(header *protocol.RequestHeader, request *protocol.ICommentsReques
baseUserInfo *protocol.BaseUserInfo
total int
)
if comments, total, err = repository.Comment.GetComments(header.Uid, protocol.SourceType_Chance, 0, request.LastId, request.PageSize); err != nil {
if comments, total, err = repository.Comment.GetComments(header.Uid, protocol.SourceTypeChance, 0, request.LastId, request.PageSize); err != nil {
log.Error(err)
return
}
... ... @@ -187,7 +187,7 @@ func CommentDetailsMulti(header *protocol.RequestHeader, request *protocol.Comme
}
rsp.Comment = commentDetailSingle.Comment
}
if commentDetailMulti, err = Comments(header, &protocol.CommentsRequest{LastId: request.LastId, SourceId: request.SourceId, PageSize: request.PageSize, SourceType: protocol.SourceType_Comment}); err != nil {
if commentDetailMulti, err = Comments(header, &protocol.CommentsRequest{LastId: request.LastId, SourceId: request.SourceId, PageSize: request.PageSize, SourceType: protocol.SourceTypeComment}); err != nil {
log.Error(err)
return
}
... ...
... ... @@ -60,8 +60,8 @@ func MsgInteractive(header *protocol.RequestHeader, request *protocol.MsgInterac
SourceType: msg.SourceType,
}
switch msg.SourceType {
case protocol.SourceType_Chance:
case protocol.SourceType_Comment:
case protocol.SourceTypeChance:
case protocol.SourceTypeComment:
}
rsp.Lists[i] = userMsg
}
... ...