作者 yangfu

fix

@@ -14,6 +14,8 @@ RUN go mod download @@ -14,6 +14,8 @@ RUN go mod download
14 14
15 COPY . . 15 COPY . .
16 RUN GOOS=linux CGO_ENABLED=0 go build -ldflags="-s -w" -installsuffix cgo -o opp main.go 16 RUN GOOS=linux CGO_ENABLED=0 go build -ldflags="-s -w" -installsuffix cgo -o opp main.go
  17 +#EXPOSE 8080
  18 +#CMD ["./opp"]
17 19
18 FROM alpine:latest 20 FROM alpine:latest
19 21
@@ -21,7 +23,7 @@ RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories @@ -21,7 +23,7 @@ RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
21 RUN apk add --no-cache tzdata \ 23 RUN apk add --no-cache tzdata \
22 && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ 24 && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
23 && echo "Asia/Shanghai" > /etc/timezone \ 25 && echo "Asia/Shanghai" > /etc/timezone \
24 - && rm -rf /var/cache/apk/* /tmp/* /var/tmp/* $HOME/.cache ## 清除缓存 26 +# && rm -rf /var/cache/apk/* /tmp/* /var/tmp/* $HOME/.cache ## 清除缓存
25 WORKDIR /root/ 27 WORKDIR /root/
26 COPY --from=builder /go/src/opp . 28 COPY --from=builder /go/src/opp .
27 EXPOSE 8080 29 EXPOSE 8080
@@ -12,8 +12,8 @@ aliyun_logs_access ="${aliyun_logs_access||app.log}" @@ -12,8 +12,8 @@ aliyun_logs_access ="${aliyun_logs_access||app.log}"
12 12
13 13
14 #redis相关配置 14 #redis相关配置
15 -redis_add = "${REDIS_HOST||192.168.0.247}"  
16 -redis_add_port = "${REDIS_PORT||30379}" 15 +redis_add = "${REDIS_HOST||127.0.0.1}"
  16 +redis_add_port = "${REDIS_PORT||6379}"
17 redis_auth = "" 17 redis_auth = ""
18 18
19 #sms相关配置 19 #sms相关配置
@@ -72,7 +72,7 @@ func (this *ChanceController) Comments() { @@ -72,7 +72,7 @@ func (this *ChanceController) Comments() {
72 return 72 return
73 } 73 }
74 header := controllers.GetRequestHeader(this.Ctx) 74 header := controllers.GetRequestHeader(this.Ctx)
75 - request.SourceType = protocol.SourceType_Chance 75 + request.SourceType = protocol.SourceTypeChance
76 msg = protocol.NewReturnResponse(chance.Comments(header, request)) 76 msg = protocol.NewReturnResponse(chance.Comments(header, request))
77 } 77 }
78 78
@@ -156,7 +156,7 @@ func (this *ChanceController) SympathyAction() { @@ -156,7 +156,7 @@ func (this *ChanceController) SympathyAction() {
156 msg = m 156 msg = m
157 return 157 return
158 } 158 }
159 - if !(request.SourceType == protocol.SourceType_Chance || request.SourceType == protocol.SourceType_Comment) { 159 + if !(request.SourceType == protocol.SourceTypeChance || request.SourceType == protocol.SourceTypeComment) {
160 msg = protocol.BadRequestParam(2) 160 msg = protocol.BadRequestParam(2)
161 return 161 return
162 } 162 }
@@ -224,7 +224,7 @@ func (this *ChanceController) ChanceSubmit() { @@ -224,7 +224,7 @@ func (this *ChanceController) ChanceSubmit() {
224 return 224 return
225 } 225 }
226 header := controllers.GetRequestHeader(this.Ctx) 226 header := controllers.GetRequestHeader(this.Ctx)
227 - if request.Id>0{ 227 + if request.Id > 0 {
228 msg = protocol.NewReturnResponse(chance.ChanceUpdate(header, request)) 228 msg = protocol.NewReturnResponse(chance.ChanceUpdate(header, request))
229 return 229 return
230 } 230 }
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 export PATH=/root/local/bin:$PATH 2 export PATH=/root/local/bin:$PATH
3 kubectl -n mmm-suplus-dev get pods | grep -q opp 3 kubectl -n mmm-suplus-dev get pods | grep -q opp
4 if [ "$?" == "1" ];then 4 if [ "$?" == "1" ];then
5 - kubectl create -f /tmp/dev/opp/opp.yaml --record 5 + kubectl create -f /tmp/dev/mmm-go-opp/opp.yaml --record
6 kubectl -n mmm-suplus-dev get svc | grep -q opp 6 kubectl -n mmm-suplus-dev get svc | grep -q opp
7 if [ "$?" == "0" ];then 7 if [ "$?" == "0" ];then
8 echo "opp service install success!" 8 echo "opp service install success!"
@@ -16,7 +16,7 @@ if [ "$?" == "1" ];then @@ -16,7 +16,7 @@ if [ "$?" == "1" ];then
16 echo "opp deployment install fail!" 16 echo "opp deployment install fail!"
17 fi 17 fi
18 else 18 else
19 - kubectl delete -f /tmp/dev/opp/opp.yaml 19 + kubectl delete -f /tmp/dev/mmm-go-opp/opp.yaml
20 kubectl -n mmm-suplus-dev get svc | grep -q opp 20 kubectl -n mmm-suplus-dev get svc | grep -q opp
21 while [ "$?" == "0" ] 21 while [ "$?" == "0" ]
22 do 22 do
@@ -27,7 +27,7 @@ else @@ -27,7 +27,7 @@ else
27 do 27 do
28 kubectl -n mmm-suplus-dev get pods | grep -q opp 28 kubectl -n mmm-suplus-dev get pods | grep -q opp
29 done 29 done
30 - kubectl create -f /tmp/dev/opp/opp.yaml --record 30 + kubectl create -f /tmp/dev/mmm-go-opp/opp.yaml --record
31 kubectl -n mmm-suplus-dev get svc | grep -q opp 31 kubectl -n mmm-suplus-dev get svc | grep -q opp
32 if [ "$?" == "0" ];then 32 if [ "$?" == "0" ];then
33 echo "opp service update success!" 33 echo "opp service update success!"
@@ -46,19 +46,14 @@ spec: @@ -46,19 +46,14 @@ spec:
46 - name: opp 46 - name: opp
47 image: 192.168.0.243:5000/mmm/opp:dev 47 image: 192.168.0.243:5000/mmm/opp:dev
48 imagePullPolicy: Always 48 imagePullPolicy: Always
49 - ports:  
50 - - containerPort: 8080  
51 volumeMounts: 49 volumeMounts:
52 - mountPath: /opt/logs 50 - mountPath: /opt/logs
53 name: accesslogs 51 name: accesslogs
54 - mountPath: /var/www/opp/file 52 - mountPath: /var/www/opp/file
55 - name: mmmjihuitest-pvc 53 + name: mmmjihuitest-pvc1
  54 + ports:
  55 + - containerPort: 8080
56 env: 56 env:
57 - - name: ENTERPRISE_SERVICE_HOST  
58 - valueFrom:  
59 - configMapKeyRef:  
60 - name: suplus-config  
61 - key: service.enterprise  
62 - name: MYSQL_HOST 57 - name: MYSQL_HOST
63 valueFrom: 58 valueFrom:
64 configMapKeyRef: 59 configMapKeyRef:
@@ -69,41 +64,39 @@ spec: @@ -69,41 +64,39 @@ spec:
69 configMapKeyRef: 64 configMapKeyRef:
70 name: suplus-config 65 name: suplus-config
71 key: mysql.port 66 key: mysql.port
72 - - name: MYSQL_USER 67 + - name: REDIS_HOST
73 valueFrom: 68 valueFrom:
74 configMapKeyRef: 69 configMapKeyRef:
75 name: suplus-config 70 name: suplus-config
76 - key: mysql.user  
77 - - name: MYSQL_PASSWORD 71 + key: redis.ip
  72 + - name: REDIS_PORT
78 valueFrom: 73 valueFrom:
79 configMapKeyRef: 74 configMapKeyRef:
80 name: suplus-config 75 name: suplus-config
81 - key: mysql.password  
82 - - name: REDIS_HOST 76 + key: redis.port
  77 + - name: MYSQL_USER
83 valueFrom: 78 valueFrom:
84 configMapKeyRef: 79 configMapKeyRef:
85 name: suplus-config 80 name: suplus-config
86 - key: redis.ip  
87 - - name: REDIS_PORT 81 + key: mysql.user
  82 + - name: MYSQL_PASSWORD
88 valueFrom: 83 valueFrom:
89 configMapKeyRef: 84 configMapKeyRef:
90 name: suplus-config 85 name: suplus-config
91 - key: redis.port 86 + key: mysql.password
92 - name: MYSQL_DB_NAME 87 - name: MYSQL_DB_NAME
93 value: "opportunity_dev" 88 value: "opportunity_dev"
94 - - name: LOG_LEVEL  
95 - value: "debug"  
96 - name: RUN_MODE 89 - name: RUN_MODE
97 value: "test" 90 value: "test"
98 - - name: aliyun_logs_suplus 91 + - name: LOG_LEVEL
  92 + value: "debug"
  93 + - name: aliyun_logs_suplusfile
99 value: "stdout" 94 value: "stdout"
100 - name: aliyun_logs_access 95 - name: aliyun_logs_access
101 - value: "/opt/logs/opp_app.log"  
102 - - name: aliyun_file_access  
103 - value: "/var/www/opp/file" 96 + value: " /opt/logs/app.log"
104 volumes: 97 volumes:
105 - name: accesslogs 98 - name: accesslogs
106 emptyDir: {} 99 emptyDir: {}
107 - - name: suplusupload-pvc1 100 + - name: mmmjihuitest-pvc1
108 persistentVolumeClaim: 101 persistentVolumeClaim:
109 - claimName: suplusupload-pvc  
  102 + claimName: mmmjihuitest-pvc
@@ -12,7 +12,7 @@ import ( @@ -12,7 +12,7 @@ import (
12 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/websocket" 12 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/websocket"
13 "opp/internal/utils" 13 "opp/internal/utils"
14 _ "opp/routers" 14 _ "opp/routers"
15 - "opp/services/im" 15 + "os"
16 "time" 16 "time"
17 ) 17 )
18 18
@@ -30,6 +30,7 @@ func init() { @@ -30,6 +30,7 @@ func init() {
30 //}) 30 //})
31 redisSource := fmt.Sprintf("%v:%v", beego.AppConfig.String("redis_add"), beego.AppConfig.String("redis_add_port")) 31 redisSource := fmt.Sprintf("%v:%v", beego.AppConfig.String("redis_add"), beego.AppConfig.String("redis_add_port"))
32 err := redis.InitWithDb(100, redisSource, beego.AppConfig.String("redis_auth"), "0") 32 err := redis.InitWithDb(100, redisSource, beego.AppConfig.String("redis_auth"), "0")
  33 + log.Info(fmt.Sprintf("init redis:%v", redisSource))
33 if err != nil { 34 if err != nil {
34 log.Fatal("connect to redis error address:", beego.AppConfig.String("redis_add_port"), beego.AppConfig.String("redis_auth"), err) 35 log.Fatal("connect to redis error address:", beego.AppConfig.String("redis_add_port"), beego.AppConfig.String("redis_auth"), err)
35 //panic(err) 36 //panic(err)
@@ -41,6 +42,7 @@ func init() { @@ -41,6 +42,7 @@ func init() {
41 beego.AppConfig.String("mysql_port"), 42 beego.AppConfig.String("mysql_port"),
42 beego.AppConfig.String("mysql_db_name"), 43 beego.AppConfig.String("mysql_db_name"),
43 ) 44 )
  45 + log.Info(fmt.Sprintf("init mysql:%v", dataSource))
44 orm.NewBeeormEngine(config.Mysql{ 46 orm.NewBeeormEngine(config.Mysql{
45 //AliasName: "default", 47 //AliasName: "default",
46 DataSource: dataSource, 48 DataSource: dataSource,
@@ -55,8 +57,19 @@ func init() { @@ -55,8 +57,19 @@ func init() {
55 //Password:"ibfduqhfmgypbffe", //授权码 57 //Password:"ibfduqhfmgypbffe", //授权码
56 //IsUseSsl:true, 58 //IsUseSsl:true,
57 }) 59 })
58 - im.InitImClient(beego.AppConfig.String("net_im_base_url"), beego.AppConfig.String("net_im_app_key"), beego.AppConfig.String("net_im_app_secret")) 60 + //im.InitImClient(beego.AppConfig.String("net_im_base_url"), beego.AppConfig.String("net_im_app_key"), beego.AppConfig.String("net_im_app_secret"))
59 websocket.InitWebsocketConnmgrs(10) 61 websocket.InitWebsocketConnmgrs(10)
  62 +
  63 + log.Info(fmt.Sprintf("env MYSQL_USER:%v", os.Getenv("MYSQL_USER")))
  64 + log.Info(fmt.Sprintf("env MYSQL_PASSWORD:%v", os.Getenv("MYSQL_PASSWORD")))
  65 + log.Info(fmt.Sprintf("env MYSQL_HOST:%v", os.Getenv("MYSQL_HOST")))
  66 + log.Info(fmt.Sprintf("env MYSQL_PORT:%v", os.Getenv("MYSQL_PORT")))
  67 + log.Info(fmt.Sprintf("env MYSQL_DB_NAME:%v", os.Getenv("MYSQL_DB_NAME")))
  68 + log.Info(fmt.Sprintf("env LOG_LEVEL:%v", os.Getenv("LOG_LEVEL")))
  69 + log.Info(fmt.Sprintf("env aliyun_logs_access:%v", os.Getenv("aliyun_logs_access")))
  70 + log.Info(fmt.Sprintf("env REDIS_HOST:%v", os.Getenv("REDIS_HOST")))
  71 + log.Info(fmt.Sprintf("env REDIS_PORT:%v", os.Getenv("REDIS_PORT")))
  72 + log.Info(fmt.Sprintf("env aliyun_file_access:%v", os.Getenv("aliyun_file_access")))
60 } 73 }
61 74
62 func main() { 75 func main() {
1 package protocol 1 package protocol
2 2
3 const ( 3 const (
4 - SourceType_Chance = 1  
5 - SourceType_Comment = 2 4 + SourceTypeChance = 1
  5 + SourceTypeComment = 2
  6 + SourceTypeBulletin = 3
6 ) 7 )
7 8
8 /*IComment */ 9 /*IComment */
@@ -3,8 +3,10 @@ package routers @@ -3,8 +3,10 @@ package routers
3 import ( 3 import (
4 "github.com/astaxie/beego" 4 "github.com/astaxie/beego"
5 "github.com/prometheus/client_golang/prometheus/promhttp" 5 "github.com/prometheus/client_golang/prometheus/promhttp"
  6 + "net/http"
6 "opp/controllers" 7 "opp/controllers"
7 "opp/controllers/v1" 8 "opp/controllers/v1"
  9 + "opp/services/websocket"
8 ) 10 )
9 11
10 var nsV1 *beego.Namespace 12 var nsV1 *beego.Namespace
@@ -23,6 +25,7 @@ func init() { @@ -23,6 +25,7 @@ func init() {
23 ) 25 )
24 beego.AddNamespace(nsV1) 26 beego.AddNamespace(nsV1)
25 beego.SetStaticPath("/file/opp", beego.AppConfig.String("source_path")) 27 beego.SetStaticPath("/file/opp", beego.AppConfig.String("source_path"))
  28 + beego.SetStaticPath("/log/opp", beego.AppConfig.String("aliyun_logs_access"))
26 beego.Handler("/metrics", promhttp.Handler()) 29 beego.Handler("/metrics", promhttp.Handler())
27 - //beego.Handler("/upgrage", http.HandlerFunc(websocket.Upgrage)) 30 + beego.Handler("/upgrage", http.HandlerFunc(websocket.Upgrage))
28 } 31 }
@@ -40,7 +40,7 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest) @@ -40,7 +40,7 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest)
40 Id: f.Id, 40 Id: f.Id,
41 } 41 }
42 switch f.SourceType { 42 switch f.SourceType {
43 - case protocol.SourceType_Chance: 43 + case protocol.SourceTypeChance:
44 chance, err = agg.GetChance(f.SourceId, f.CompanyId) 44 chance, err = agg.GetChance(f.SourceId, f.CompanyId)
45 if err != nil { 45 if err != nil {
46 log.Error(err) 46 log.Error(err)
@@ -49,7 +49,7 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest) @@ -49,7 +49,7 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest)
49 chance.IsZan = (f.MarkFlag & protocol.MarkFlag_Zan) == protocol.MarkFlag_Zan 49 chance.IsZan = (f.MarkFlag & protocol.MarkFlag_Zan) == protocol.MarkFlag_Zan
50 chance.IsCollect = (f.MarkFlag & protocol.MarkFlag_Collect) == protocol.MarkFlag_Collect 50 chance.IsCollect = (f.MarkFlag & protocol.MarkFlag_Collect) == protocol.MarkFlag_Collect
51 item.Favorite = chance 51 item.Favorite = chance
52 - case protocol.SourceType_Comment: 52 + case protocol.SourceTypeComment:
53 } 53 }
54 rsp.Lists[i] = item 54 rsp.Lists[i] = item
55 } 55 }
@@ -71,7 +71,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc @@ -71,7 +71,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc
71 log.Error(err) 71 log.Error(err)
72 return 72 return
73 } 73 }
74 - if request.SourceType == protocol.SourceType_Chance { 74 + if request.SourceType == protocol.SourceTypeChance {
75 if chance, err = repository.Chance.GetChanceById(request.Id); err != nil { 75 if chance, err = repository.Chance.GetChanceById(request.Id); err != nil {
76 log.Error("机会不存在", err) 76 log.Error("机会不存在", err)
77 return 77 return
@@ -258,14 +258,14 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit @@ -258,14 +258,14 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
258 } 258 }
259 //6.文件 259 //6.文件
260 { 260 {
261 - data :=&models.ChanceData{  
262 - Id:idgen.Next(),  
263 - ChanceId:chance.Id,  
264 - Speechs:common.AssertJson(request.Speechs),  
265 - Images:common.AssertJson(request.Pictures),  
266 - Videos:common.AssertJson(request.Videos),  
267 - CreateAt:time.Now(),  
268 - UpdateAt:time.Now(), 261 + data := &models.ChanceData{
  262 + Id: idgen.Next(),
  263 + ChanceId: chance.Id,
  264 + Speechs: common.AssertJson(request.Speechs),
  265 + Images: common.AssertJson(request.Pictures),
  266 + Videos: common.AssertJson(request.Videos),
  267 + CreateAt: time.Now(),
  268 + UpdateAt: time.Now(),
269 } 269 }
270 if _, err = orm.Insert(data); err != nil { 270 if _, err = orm.Insert(data); err != nil {
271 log.Error(err) 271 log.Error(err)
@@ -288,16 +288,16 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit @@ -288,16 +288,16 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit
288 auditConfig *protocol.AuditConfig 288 auditConfig *protocol.AuditConfig
289 chanceData *models.ChanceData 289 chanceData *models.ChanceData
290 //auditFlows []*models.AuditFlowProcess 290 //auditFlows []*models.AuditFlowProcess
291 - updateMap =make(map[string]interface{}) 291 + updateMap = make(map[string]interface{})
292 ) 292 )
293 - if chance,err =models.GetChanceById(request.Id);err!=nil{ 293 + if chance, err = models.GetChanceById(request.Id); err != nil {
294 log.Error(err) 294 log.Error(err)
295 return 295 return
296 } 296 }
297 //TODO:非本人 1.需要验证角色权限,是否是审核人 297 //TODO:非本人 1.需要验证角色权限,是否是审核人
298 - if chance.UserId!=header.Uid{ 298 + if chance.UserId != header.Uid {
299 err = protocol.NewErrWithMessage(1) 299 err = protocol.NewErrWithMessage(1)
300 - log.Error(fmt.Sprintf("user:%v 无权限操作机会 chance:%v",header.Uid,chance.Id)) 300 + log.Error(fmt.Sprintf("user:%v 无权限操作机会 chance:%v", header.Uid, chance.Id))
301 return 301 return
302 } 302 }
303 //TODO:验证机会当前是否在审核中 303 //TODO:验证机会当前是否在审核中
@@ -315,14 +315,13 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit @@ -315,14 +315,13 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit
315 updateMap["SourceContent"] = common.AssertJson(request.FormList) 315 updateMap["SourceContent"] = common.AssertJson(request.FormList)
316 updateMap["DepartmentId"] = request.RelatedDepartment 316 updateMap["DepartmentId"] = request.RelatedDepartment
317 317
318 - if err = utils.UpdateTableByMapWithOrmer(orm,&models.Chance{Id:chance.Id},updateMap); err != nil { 318 + if err = utils.UpdateTableByMapWithOrmer(orm, &models.Chance{Id: chance.Id}, updateMap); err != nil {
319 log.Error(err) 319 log.Error(err)
320 orm.Rollback() 320 orm.Rollback()
321 return 321 return
322 } 322 }
323 } 323 }
324 324
325 -  
326 //4.查询审核配置 325 //4.查询审核配置
327 //5.生成审核流 删除旧的 生成新的 326 //5.生成审核流 删除旧的 生成新的
328 //if auditFlows, err = GenAuditFlowProcess(header, chance.Id, template.Id, auditConfig); err != nil { 327 //if auditFlows, err = GenAuditFlowProcess(header, chance.Id, template.Id, auditConfig); err != nil {
@@ -340,26 +339,26 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit @@ -340,26 +339,26 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit
340 339
341 //6.更新文件 340 //6.更新文件
342 { 341 {
343 - if chanceData,err = models.GetChanceDataByChanceId(chance.Id);err==nil{  
344 - if err = utils.UpdateTableByMapWithOrmer(orm,chanceData,map[string]interface{}{  
345 - "Speechs":common.AssertJson(request.Speechs),  
346 - "Images":common.AssertJson(request.Pictures),  
347 - "Videos":common.AssertJson(request.Videos),  
348 - "UpdateAt":time.Now(),  
349 - });err!=nil{ 342 + if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil {
  343 + if err = utils.UpdateTableByMapWithOrmer(orm, chanceData, map[string]interface{}{
  344 + "Speechs": common.AssertJson(request.Speechs),
  345 + "Images": common.AssertJson(request.Pictures),
  346 + "Videos": common.AssertJson(request.Videos),
  347 + "UpdateAt": time.Now(),
  348 + }); err != nil {
350 log.Error(err) 349 log.Error(err)
351 orm.Rollback() 350 orm.Rollback()
352 return 351 return
353 } 352 }
354 - }else{  
355 - data :=&models.ChanceData{  
356 - Id:idgen.Next(),  
357 - ChanceId:chance.Id,  
358 - Speechs:common.AssertJson(request.Speechs),  
359 - Images:common.AssertJson(request.Pictures),  
360 - Videos:common.AssertJson(request.Videos),  
361 - CreateAt:time.Now(),  
362 - UpdateAt:time.Now(), 353 + } else {
  354 + data := &models.ChanceData{
  355 + Id: idgen.Next(),
  356 + ChanceId: chance.Id,
  357 + Speechs: common.AssertJson(request.Speechs),
  358 + Images: common.AssertJson(request.Pictures),
  359 + Videos: common.AssertJson(request.Videos),
  360 + CreateAt: time.Now(),
  361 + UpdateAt: time.Now(),
363 } 362 }
364 if _, err = orm.Insert(data); err != nil { 363 if _, err = orm.Insert(data); err != nil {
365 log.Error(err) 364 log.Error(err)
@@ -22,14 +22,14 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest) @@ -22,14 +22,14 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest)
22 updateMap = make(map[string]interface{}) 22 updateMap = make(map[string]interface{})
23 ) 23 )
24 switch request.SourceType { 24 switch request.SourceType {
25 - case protocol.SourceType_Chance: 25 + case protocol.SourceTypeChance:
26 if chance, err = repository.Chance.GetChanceById(request.Id); err != nil { 26 if chance, err = repository.Chance.GetChanceById(request.Id); err != nil {
27 log.Error(err) 27 log.Error(err)
28 return 28 return
29 } 29 }
30 updateTable = chance 30 updateTable = chance
31 updateMap["CommentTotal"] = chance.CommentTotal + 1 31 updateMap["CommentTotal"] = chance.CommentTotal + 1
32 - case protocol.SourceType_Comment: 32 + case protocol.SourceTypeComment:
33 if comment, err = repository.Comment.GetCommentById(request.Id); err != nil { 33 if comment, err = repository.Comment.GetCommentById(request.Id); err != nil {
34 log.Error(err) 34 log.Error(err)
35 return 35 return
@@ -74,7 +74,7 @@ func IComments(header *protocol.RequestHeader, request *protocol.ICommentsReques @@ -74,7 +74,7 @@ func IComments(header *protocol.RequestHeader, request *protocol.ICommentsReques
74 baseUserInfo *protocol.BaseUserInfo 74 baseUserInfo *protocol.BaseUserInfo
75 total int 75 total int
76 ) 76 )
77 - if comments, total, err = repository.Comment.GetComments(header.UserId, protocol.SourceType_Chance, 0, request.LastId, request.PageSize); err != nil { 77 + if comments, total, err = repository.Comment.GetComments(header.UserId, protocol.SourceTypeChance, 0, request.LastId, request.PageSize); err != nil {
78 log.Error(err) 78 log.Error(err)
79 return 79 return
80 } 80 }
@@ -187,7 +187,7 @@ func CommentDetailsMulti(header *protocol.RequestHeader, request *protocol.Comme @@ -187,7 +187,7 @@ func CommentDetailsMulti(header *protocol.RequestHeader, request *protocol.Comme
187 } 187 }
188 rsp.Comment = commentDetailSingle.Comment 188 rsp.Comment = commentDetailSingle.Comment
189 } 189 }
190 - if commentDetailMulti, err = Comments(header, &protocol.CommentsRequest{LastId: request.LastId, SourceId: request.SourceId, PageSize: request.PageSize, SourceType: protocol.SourceType_Comment}); err != nil { 190 + if commentDetailMulti, err = Comments(header, &protocol.CommentsRequest{LastId: request.LastId, SourceId: request.SourceId, PageSize: request.PageSize, SourceType: protocol.SourceTypeComment}); err != nil {
191 log.Error(err) 191 log.Error(err)
192 return 192 return
193 } 193 }
@@ -60,8 +60,8 @@ func MsgInteractive(header *protocol.RequestHeader, request *protocol.MsgInterac @@ -60,8 +60,8 @@ func MsgInteractive(header *protocol.RequestHeader, request *protocol.MsgInterac
60 SourceType: msg.SourceType, 60 SourceType: msg.SourceType,
61 } 61 }
62 switch msg.SourceType { 62 switch msg.SourceType {
63 - case protocol.SourceType_Chance:  
64 - case protocol.SourceType_Comment: 63 + case protocol.SourceTypeChance:
  64 + case protocol.SourceTypeComment:
65 } 65 }
66 rsp.Lists[i] = userMsg 66 rsp.Lists[i] = userMsg
67 } 67 }