This commit is contained in:
ykomissarov committed 2019-05-31 15:49:01 +03:00
1 parent 0d956b6bf6
commit 011aaa50e8
10 files changed
+44 -151

No files matched your search

+1 -1
View File
@@ -1 +1 @@
2.0.1
2.0.2
-8
View File
@@ -1,8 +0,0 @@
FROM alpine:latest
RUN mkdir app
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
RUN apk add --no-cache tzdata
RUN cp /usr/share/zoneinfo/UTC /etc/localtime
RUN echo "UTC" > /etc/timezone
Generated
+1
View File
@@ -577,6 +577,7 @@
"github.com/integration-system/isp-lib/structure",
"github.com/integration-system/isp-lib/utils",
"github.com/integration-system/isp-lib/validate",
"github.com/pkg/errors",
"golang.org/x/crypto/bcrypt",
"google.golang.org/grpc/codes",
"google.golang.org/grpc/metadata",
-6
View File
@@ -1,6 +0,0 @@
@echo off
@go get github.com/mitchellh/gox
gox -osarch="linux/amd64"
del admin-service
ren admin-service_linux_amd64 admin-service
-118
View File
@@ -1,118 +0,0 @@
#!/usr/bin/env bash
START=`date +%N`
#########################
# The command line help #
#########################
display_help() {
echo "Usage: $0 [option...]" >&2
echo
echo " -ma, --major increase major version, X.0.0. Minor and build versions will set eq 0"
echo " -mi, --minor increase minor version, 0.X.0. Build version will set eq 0"
echo " -b, --build increase build version, 0.0.X."
echo
echo "Run without option means that will accomplish only build without increase any version"
echo
# echo some stuff here for the -a or --add-options
exit 1
}
INCREASE_MAJOR_VERSION=0
INCREASE_MINOR_VERSION=0
INCREASE_BUILD_VERSION=0
################################
# Check if parameters options #
# are given on the commandline #
################################
case "$1" in
-b | --build)
INCREASE_BUILD_VERSION=1
;;
-ma | --major)
INCREASE_MAJOR_VERSION=1
;;
-mi | --minor)
INCREASE_MINOR_VERSION=1
;;
-h | --help)
display_help # Call your function
exit 0
;;
--) # End of all options
exit 1
;;
-*)
echo "Error: Unknown option: $1" >&2
exit 1
;;
*) # No more options
;;
esac
VERSION="0.1.0"
PREVIOUS_VERSION="0.1.0"
MAJOR_VERSION=0
MINOR_VERSION=1
BUILD_VERSION=0
FILE=".version"
FILE_PATH="./$FILE"
if [ ! -f "$FILE_PATH" ]
then
`echo ${VERSION} > ${FILE_PATH}`
else
PREVIOUS_FILE_VERSION=`head -n 1 ${FILE_PATH}`
MAJOR_FILE_VERSION="$( cut -d'.' -f1 <<<${PREVIOUS_FILE_VERSION} )"
MINOR_FILE_VERSION="$( cut -d'.' -f2 <<<${PREVIOUS_FILE_VERSION} )"
BUILD_FILE_VERSION="$( cut -d'.' -f3 <<<${PREVIOUS_FILE_VERSION} )"
if [ -z "$MAJOR_FILE_VERSION" ] || [ -z "$MINOR_FILE_VERSION" ] || [ -z "$BUILD_FILE_VERSION" ]
then
echo
printf 'Wrong content in the file .version: %s, must contain 3 segments with point as a separator' ${PREVIOUS_FILE_VERSION}
echo
else
MAJOR_VERSION=${MAJOR_FILE_VERSION}
MINOR_VERSION=${MINOR_FILE_VERSION}
BUILD_VERSION=${BUILD_FILE_VERSION}
PREVIOUS_VERSION=${PREVIOUS_FILE_VERSION}
if [ ${INCREASE_MAJOR_VERSION} -ne 0 ]
then
MAJOR_VERSION=$((MAJOR_VERSION + 1))
MINOR_VERSION=0
BUILD_VERSION=0
elif [ ${INCREASE_MINOR_VERSION} -ne 0 ]
then
MINOR_VERSION=$((MINOR_VERSION + 1))
BUILD_VERSION=0
elif [ ${INCREASE_BUILD_VERSION} -ne 0 ]
then
BUILD_VERSION=$((BUILD_VERSION + 1))
fi
fi
fi
VERSION="$MAJOR_VERSION.$MINOR_VERSION.$BUILD_VERSION"
`echo ${VERSION} > ${FILE_PATH}`
divider=====================
divider=$divider$divider$divider$divider$divider
width=100
format="| ${blue}%-20s ${normal} | %-72s |\n"
export GOPATH="$PWD/../../"
NOW="+%Y-%m-%d %H:%M:%S"
NOW=$(date "$NOW")
echo ${NOW}
CGO_ENABLED=0 GOOS=linux go build -installsuffix cgo -v -ldflags="-X 'main.version=$VERSION' -X 'main.date=$NOW'"
END=`date +%N`
DURATION=`echo "scale=2; $(( ($END-$START) ))/1000000" |bc`
echo
printf "%$width.${width}s\n" "$divider"
printf "$format" "VERSION:" "$PREVIOUS_VERSION -> $VERSION"
printf "$format" "DATE:" "$NOW"
printf "$format" "EXECUTED TIME:" "$DURATION ms"
printf "%$width.${width}s\n" "$divider"
echo
+3 -3
View File
@@ -3,7 +3,7 @@ package controller
import (
"fmt"
"github.com/integration-system/isp-lib/logger"
libStr "github.com/integration-system/isp-lib/structure"
"msp-admin-service/entity"
"msp-admin-service/service"
//"github.com/integration-system/isp-lib/token-gen"
"github.com/integration-system/isp-lib/utils"
@@ -90,7 +90,7 @@ func GetUsers(identities structure.UsersRequest) (*structure.UsersResponse, erro
return &structure.UsersResponse{Items: users}, err
}
func CreateUpdateUser(user libStr.AdminUser) (*libStr.AdminUser, error) {
func CreateUpdateUser(user entity.AdminUser) (*entity.AdminUser, error) {
var err error
if user.Id == 0 {
if user.Password == "" {
@@ -165,7 +165,7 @@ func DeleteUser(identities structure.IdentitiesRequest) (*structure.DeleteRespon
return &structure.DeleteResponse{Deleted: count}, err
}
func cryptPassword(user *libStr.AdminUser) error {
func cryptPassword(user *entity.AdminUser) error {
passwordBytes, err := bcrypt.GenerateFromPassword([]byte(user.Password), 12)
if err != nil {
return validate.CreateUnknownError(err)
+25
View File
@@ -0,0 +1,25 @@
package entity
import "time"
type AdminToken struct {
TableName string `sql:"admin_service.tokens" json:"-"`
Id int64 `json:"id"`
UserId int64 `json:"userId"`
Token string `json:"token"`
ExpiredAt *time.Time `json:"expiredAt"`
CreatedAt time.Time `json:"createdAt" sql:",null"`
}
type AdminUser struct {
TableName string `sql:"admin_service.users" json:"-"`
Id int64 `json:"id"`
Image string `json:"image"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Email string `json:"email" valid:"required~Required"`
Password string `json:"password,omitempty"`
Phone string `json:"phone"`
UpdatedAt time.Time `json:"updatedAt" sql:",null"`
CreatedAt time.Time `json:"createdAt" sql:",null"`
}
+2 -2
View File
@@ -1,9 +1,9 @@
package helper
import (
libStr "github.com/integration-system/isp-lib/structure"
"google.golang.org/grpc/metadata"
"msp-admin-service/controller"
"msp-admin-service/entity"
"msp-admin-service/structure"
)
@@ -14,7 +14,7 @@ type Handlers struct {
// ===== USER =====
GetProfile func(metadata.MD) (*structure.AdminUserShort, error) `method:"get_profile" group:"user" inner:"true"`
GetUsers func(structure.UsersRequest) (*structure.UsersResponse, error) `method:"get_users" group:"user" inner:"true"`
CreateUpdateUser func(user libStr.AdminUser) (*libStr.AdminUser, error) `method:"create_update_user" group:"user" inner:"true"`
CreateUpdateUser func(user entity.AdminUser) (*entity.AdminUser, error) `method:"create_update_user" group:"user" inner:"true"`
DeleteUser func(identities structure.IdentitiesRequest) (*structure.DeleteResponse, error) `method:"delete_user" group:"user" inner:"true"`
}
+10 -11
View File
@@ -3,8 +3,8 @@ package model
import (
"github.com/go-pg/pg"
"github.com/integration-system/isp-lib/database"
libStr "github.com/integration-system/isp-lib/structure"
"github.com/integration-system/isp-lib/utils"
"msp-admin-service/entity"
"msp-admin-service/structure"
)
@@ -30,8 +30,8 @@ const DELETE_USERS = "DELETE FROM " + utils.DB_SCHEME + ".users WHERE id IN (?)"
return &user, err
}*/
func GetUserByEmail(email string) (*libStr.AdminUser, error) {
var user libStr.AdminUser
func GetUserByEmail(email string) (*entity.AdminUser, error) {
var user entity.AdminUser
err := database.GetDBManager().Db.Model(&user).
Where("email = ?", email).
First()
@@ -41,8 +41,8 @@ func GetUserByEmail(email string) (*libStr.AdminUser, error) {
return &user, err
}
func GetUserById(identity int64) (*libStr.AdminUser, error) {
var user libStr.AdminUser
func GetUserById(identity int64) (*entity.AdminUser, error) {
var user entity.AdminUser
err := database.GetDBManager().Db.Model(&user).
Where("id = ?", identity).
First()
@@ -52,8 +52,8 @@ func GetUserById(identity int64) (*libStr.AdminUser, error) {
return &user, err
}
func GetUsers(usersRequest structure.UsersRequest) (*[]libStr.AdminUser, error) {
var users []libStr.AdminUser
func GetUsers(usersRequest structure.UsersRequest) (*[]entity.AdminUser, error) {
var users []entity.AdminUser
query := database.GetDBManager().Db.Model(&users)
if len(usersRequest.Ids) > 0 {
query.Where("id IN (?)", pg.In(usersRequest.Ids))
@@ -75,7 +75,7 @@ func GetUsers(usersRequest structure.UsersRequest) (*[]libStr.AdminUser, error)
return &users, err
}
func CreateUser(user libStr.AdminUser) (libStr.AdminUser, error) {
func CreateUser(user entity.AdminUser) (entity.AdminUser, error) {
_, err := database.GetDBManager().Db.Model(&user).
Returning("id").
Returning("created_at").
@@ -84,7 +84,7 @@ func CreateUser(user libStr.AdminUser) (libStr.AdminUser, error) {
return user, err
}
func UpdateUser(user libStr.AdminUser) (libStr.AdminUser, error) {
func UpdateUser(user entity.AdminUser) (entity.AdminUser, error) {
_, err := database.GetDBManager().Db.Model(&user).
WherePK().
Returning("id").
@@ -95,7 +95,6 @@ func UpdateUser(user libStr.AdminUser) (libStr.AdminUser, error) {
}
func DeleteUser(identities structure.IdentitiesRequest) (int, error) {
result, err := database.GetDBManager().Db.
Exec(DELETE_USERS, pg.In(identities.Ids))
result, err := database.GetDBManager().Db.Exec(DELETE_USERS, pg.In(identities.Ids))
return result.RowsAffected(), err
}
+2 -2
View File
@@ -1,11 +1,11 @@
package structure
import (
"github.com/integration-system/isp-lib/structure"
"msp-admin-service/entity"
)
type UsersResponse struct {
Items *[]structure.AdminUser `json:"items,omitempty"`
Items *[]entity.AdminUser `json:"items,omitempty"`
}
type UsersRequest struct {