作者 陈志颖

chore:精简docker镜像

FROM golang:1.14
ENV APP_DIR $GOPATH/src/partner
RUN mkdir -p $APP_DIR
WORKDIR $APP_DIR/
COPY ./pkg pkg
COPY ./conf conf
COPY ./go.mod go.mod
COPY ./main.go main.go
RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"]
ENV GO111MODULE on
ENV GOPROXY https://goproxy.cn,direct
RUN ["go","mod","tidy"]
RUN ["go","build"]
EXPOSE 8082
ENTRYPOINT ["./partner"]
\ No newline at end of file
#FROM golang:1.14
#ENV APP_DIR $GOPATH/src/partner
#RUN mkdir -p $APP_DIR
#WORKDIR $APP_DIR/
#COPY ./pkg pkg
#COPY ./conf conf
#COPY ./go.mod go.mod
#COPY ./main.go main.go
#RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"]
#ENV GO111MODULE on
#ENV GOPROXY https://goproxy.cn,direct
#RUN ["go","mod","tidy"]
#RUN ["go","build"]
#EXPOSE 8082
#ENTRYPOINT ["./partner"]
############################
# STEP 1 build executable binary
############################
FROM golang:alpine AS builder
RUN mkdir /app
COPY . /app
WORKDIR /app
RUN GO111MODULE="on" GOPROXY="https://goproxy.cn" GOFLAGS=-mod=vendor CGO_ENABLED=0 GOOS=linux go build -o partner
############################
# STEP 2 build a small image
###########################
FROM scratch as final
COPY --from=builder /app/partner /app/partner
COPY --from=builder /app/conf/ /app/conf
ENTRYPOINT ["./app/partner"]
\ No newline at end of file
... ...
version: v1
kind: Attribute
metadata:
name: orderId
description: 订单编号
type:
primitive: int64
... ...
version: v1
kind: Project
metadata:
name: partner
description: 合伙人
version: 0.8.0
repository: gitlab.fjmaimaimai.com/mmm-go/partner
contact:
name: SteveChan
email: steve.d.chan@qq.com
\ No newline at end of file
... ...
不能预览此文件类型
... ... @@ -381,7 +381,7 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
// 通过密码或校验码登录的普通用户或通过校验码登录的游客,注册一个账号到配置的公司去
if request.GrantType == protocol.LoginBySmsCode || request.GrantType == protocol.LoginByPassword {
userErr := loginSvr.RegistryUser(request.Phone)
userErr := loginSvr.RegistryGuest(request.Phone)
if userErr != nil {
log.Error(userErr)
}
... ... @@ -403,25 +403,30 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
return
}
manageLoginErr := loginSvr.ManagerLogin(request.Phone, request.Password)
fmt.Print("用户登录:", manageLoginErr, "\n")
partnerLoginErr := loginSvr.PartnerLogin(request.Phone, request.Password)
fmt.Print("合伙人登录:", partnerLoginErr, "\n")
//manageLoginErr := loginSvr.ManagerLogin(request.Phone, request.Password)
//fmt.Print("用户登录:", manageLoginErr, "\n")
//partnerLoginErr := loginSvr.PartnerLogin(request.Phone, request.Password)
//fmt.Print("合伙人登录:", partnerLoginErr, "\n")
//
//if manageLoginErr != nil && partnerLoginErr != nil {
// //if len(loginSvr.PartnerInfo) == 0 { // 不存在有效用户
// // err = protocol.NewErrWithMessage(10008)
// // return
// //}
// err = protocol.NewCustomMessage(1, "密码输入有误!")
// return
//} else if manageLoginErr != nil && partnerLoginErr == nil {
// if len(loginSvr.PartnerInfo) == 1 && len(loginSvr.NormalUsers) == 0 {
// if loginSvr.PartnerInfo[0].CompanyId == int64(constant.DEFAULT_GUEST_COMPANY) {
// err = protocol.NewCustomMessage(1, "密码输入有误!")
// return
// }
// }
//}
if manageLoginErr != nil && partnerLoginErr != nil {
if len(loginSvr.PartnerInfo) == 0 { // 不存在有效用户
err = protocol.NewErrWithMessage(10008)
return
}
if loginSvr.ManagerLogin(request.Phone, request.Password) != nil && loginSvr.PartnerLogin(request.Phone, request.Password) != nil {
err = protocol.NewCustomMessage(1, "密码输入有误!")
return
} else if manageLoginErr != nil && partnerLoginErr == nil {
if len(loginSvr.PartnerInfo) == 1 && len(loginSvr.NormalUsers) == 0 {
if loginSvr.PartnerInfo[0].CompanyId == int64(constant.DEFAULT_GUEST_COMPANY) {
err = protocol.NewCustomMessage(1, "密码输入有误!")
return
}
}
}
break
case protocol.LoginBySmsCode:
... ...
... ... @@ -454,7 +454,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
isUserSenior bool
)
partnerInfo, _ := PartnerInfoService.FindOne(map[string]interface{}{"account": phone, "isNot": constant.DEFAULT_GUEST_COMPANY}) // 合伙人在正常公司是否存在
partnerInfo, errPartner := PartnerInfoService.FindOne(map[string]interface{}{"account": phone, "isNot": constant.DEFAULT_GUEST_COMPANY}) // 合伙人在正常公司是否存在
if partnerInfo == nil {
isPartner = false
} else {
... ... @@ -480,7 +480,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
isGuestPartnerAvailable = true
}
user, _ := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "deleteAtIsNull": true}) // 用户是否存在
user, errUser := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "deleteAtIsNull": true}) // 用户是否存在
if user == nil {
isUser = false
} else {
... ... @@ -571,27 +571,27 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
// 合伙人不存在、用户存在、非高管(普通用户)-> 注册用户
// 合伙人不存在、用户不存在(游客)-> 注册用户
//if errPartner != nil && errUser == nil && errSenior == nil || errPartner != nil && errUser != nil {
// id := time.Now().Unix()
// errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{
// Id: id,
// CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
// PartnerName: phone,
// Account: phone,
// Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",
// Status: 1,
// PartnerCategory: 1,
// RegionInfo: &domain.RegionInfo{
// RegionName: "客户区域",
// RegionId: 0,
// },
// CooperateTime: time.Now(),
// CreateAt: time.Now(),
// UpdateAt: time.Now(),
// PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},
// Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}},
// })
//}
if errPartner != nil && errUser == nil {
id := time.Now().Unix()
errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{
Id: id,
CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
PartnerName: phone,
Account: phone,
Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",
Status: 1,
PartnerCategory: 1,
RegionInfo: &domain.RegionInfo{
RegionName: "客户区域",
RegionId: 0,
},
CooperateTime: time.Now(),
CreateAt: time.Now(),
UpdateAt: time.Now(),
PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},
Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}},
})
}
return errPartner
}
... ... @@ -627,7 +627,7 @@ func (svr *PgLoginService) RegistryGuest(phone string) error {
CooperateTime: time.Now(),
CreateAt: time.Now(),
UpdateAt: time.Now(),
PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1}},
PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},
Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}},
})
}
... ...