切换导航条
此项目
正在载入...
登录
mmm-go
/
partnermg
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
差异文件
浏览文件
作者
yangfu
5 years ago
提交
711a9d6e020e84cb04d791a1227d170e196b961b
2 个父辈
02316f87
b75e6898
Merge branch 'dev' of
http://gitlab.fjmaimaimai.com/mmm-go/partnermg
into dev
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
70 行增加
和
25 行删除
pkg/application/partnerInfo/command/create_partner_info.go
pkg/application/partnerInfo/command/status_partner_info.go
pkg/application/partnerInfo/command/update_partner_info.go
pkg/infrastructure/pg/models/partner_info.go
pkg/port/beego/controllers/base_controller.go
pkg/port/beego/controllers/partner_info_controller.go
pkg/application/partnerInfo/command/create_partner_info.go
查看文件 @
711a9d6
...
...
@@ -35,5 +35,25 @@ func (command CreatePartnerInfoCommand) ValidateCommand() error {
command
.
PartnerCategory
==
domain
.
PARTNER_CATEGORY_3
)
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"合伙类别错误"
)
}
if
len
(
command
.
PartnerName
)
==
0
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"合伙人名称必填"
)
}
if
len
(
command
.
Account
)
==
0
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"合伙人账号必填"
)
}
if
command
.
RegionInfo
==
nil
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"区域必填"
)
}
if
len
(
command
.
Salesman
)
==
0
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"关联业务员必填"
)
}
for
i
:=
range
command
.
Salesman
{
if
len
(
command
.
Salesman
[
i
]
.
Name
)
==
0
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"关联业务员名称必填"
)
}
if
len
(
command
.
Salesman
[
i
]
.
Telephone
)
==
0
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"关联业务员电话必填"
)
}
}
return
nil
}
...
...
pkg/application/partnerInfo/command/status_partner_info.go
查看文件 @
711a9d6
...
...
@@ -15,5 +15,8 @@ func (command *StatusPartnerInfoCommand) ValidateCommand() error {
if
!
(
command
.
Status
==
domain
.
PARTNER_STATUS_NO
||
command
.
Status
==
domain
.
PARTNER_STATUS_YES
)
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"合伙人状态错误"
)
}
if
command
.
Id
==
0
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"合伙人id错误"
)
}
return
nil
}
...
...
pkg/application/partnerInfo/command/update_partner_info.go
查看文件 @
711a9d6
...
...
@@ -9,7 +9,7 @@ import (
type
UpdatePartnerInfoCommand
struct
{
// 合伙人Id
Id
int64
`json:"id
,omitempty
"`
Id
int64
`json:"id"`
// 状态(1:启用或者0:禁用)
Status
int
`json:"status"`
// 合伙类别 (1.研发合伙人 2.业务合伙人 3.事业)
...
...
@@ -31,5 +31,22 @@ func (command *UpdatePartnerInfoCommand) ValidateCommand() error {
command
.
PartnerCategory
==
domain
.
PARTNER_CATEGORY_3
)
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"合伙类别错误"
)
}
if
command
.
RegionInfo
==
nil
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"区域必填"
)
}
if
len
(
command
.
Salesman
)
==
0
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"关联业务员必填"
)
}
if
command
.
Id
==
0
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"合伙人id错误"
)
}
for
i
:=
range
command
.
Salesman
{
if
len
(
command
.
Salesman
[
i
]
.
Name
)
==
0
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"关联业务员名称必填"
)
}
if
len
(
command
.
Salesman
[
i
]
.
Telephone
)
==
0
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"关联业务员电话必填"
)
}
}
return
nil
}
...
...
pkg/infrastructure/pg/models/partner_info.go
查看文件 @
711a9d6
...
...
@@ -19,7 +19,7 @@ type PartnerInfo struct {
// 登录密码
Password
string
// 状态(1:启用或者0:禁用)
Status
int
`pg:",
notnull
,default:1"`
Status
int
`pg:",
use_zero
,default:1"`
// 合伙类别 (1.研发合伙人 2.业务合伙人 3.事业)
PartnerCategory
int
`pg:",default:1"`
//partner_category
//所属区域信息
...
...
pkg/port/beego/controllers/base_controller.go
查看文件 @
711a9d6
...
...
@@ -33,9 +33,12 @@ func (controller BaseController) ResponseError(err error) {
Data
:
struct
{}{},
}
controller
.
ServeJSON
()
logs
.
Error
(
e
rr
)
logs
.
Error
(
e
.
Prefix
,
e
.
Message
)
return
}
else
{
logs
.
Error
(
e
.
Prefix
,
e
.
Message
)
}
}
controller
.
Data
[
"json"
]
=
protocol
.
ResponseData
{
Code
:
-
1
,
...
...
pkg/port/beego/controllers/partner_info_controller.go
查看文件 @
711a9d6
...
...
@@ -40,7 +40,7 @@ func (c *PartnerInfoController) CreatePartnerInfo() {
PartnerType
int
`json:"partnerType"`
Area
string
`json:"area"`
Account
string
`json:"account"`
State
string
`json:"state"`
State
int
`json:"state"`
CooperationTime
string
`json:"cooperationTime"`
SalesmanName
string
`json:"salesmanName"`
Phone
string
`json:"phone"`
...
...
@@ -55,10 +55,9 @@ func (c *PartnerInfoController) CreatePartnerInfo() {
return
}
defaultPwd
:=
fmt
.
Sprintf
(
"%x"
,
sha1
.
Sum
([]
byte
(
"123456"
)))
state
,
_
:=
strconv
.
Atoi
(
param
.
State
)
cooperateTime
,
err
:=
time
.
ParseInLocation
(
"2006-01-02"
,
param
.
CooperationTime
,
time
.
Local
)
if
err
!=
nil
{
e
:=
lib
.
ThrowError
(
lib
.
INTERNAL_SERVER
_ERROR
,
err
.
Error
())
e
:=
lib
.
ThrowError
(
lib
.
ARG
_ERROR
,
err
.
Error
())
c
.
ResponseError
(
e
)
return
}
...
...
@@ -66,12 +65,9 @@ func (c *PartnerInfoController) CreatePartnerInfo() {
PartnerName
:
param
.
PartnerName
,
Account
:
param
.
Account
,
Password
:
defaultPwd
,
Status
:
s
tate
,
Status
:
param
.
S
tate
,
PartnerCategory
:
param
.
PartnerType
,
CooperateTime
:
cooperateTime
,
RegionInfo
:
&
domain
.
RegionInfo
{
RegionName
:
param
.
Area
,
},
Salesman
:
[]
domain
.
Salesman
{
domain
.
Salesman
{
Name
:
param
.
SalesmanName
,
...
...
@@ -79,6 +75,11 @@ func (c *PartnerInfoController) CreatePartnerInfo() {
},
},
}
if
len
(
param
.
Area
)
>
0
{
cmd
.
RegionInfo
=
&
domain
.
RegionInfo
{
RegionName
:
param
.
Area
,
}
}
serve
:=
partnerInfoService
.
NewPartnerInfoService
(
nil
)
_
,
err
=
serve
.
CreatePartnerInfo
(
&
cmd
)
if
err
!=
nil
{
...
...
@@ -96,7 +97,7 @@ func (c *PartnerInfoController) UpdatePartnerInfo() {
ID
int64
`json:"id"`
PartnerType
int
`json:"partnerType"`
Area
string
`json:"area"`
State
string
`json:"state"`
State
int
`json:"state"`
CooperationTime
string
`json:"cooperationTime"`
SalesmanName
string
`json:"salesmanName"`
Phone
string
`json:"phone"`
...
...
@@ -110,7 +111,6 @@ func (c *PartnerInfoController) UpdatePartnerInfo() {
c
.
ResponseError
(
errors
.
New
(
"json数据解析失败"
))
return
}
state
,
_
:=
strconv
.
Atoi
(
param
.
State
)
cooperateTime
,
err
:=
time
.
ParseInLocation
(
"2006-01-02"
,
param
.
CooperationTime
,
time
.
Local
)
if
err
!=
nil
{
e
:=
lib
.
ThrowError
(
lib
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
...
...
@@ -118,7 +118,8 @@ func (c *PartnerInfoController) UpdatePartnerInfo() {
return
}
cmd
:=
partnerInfoCmd
.
UpdatePartnerInfoCommand
{
Status
:
state
,
Id
:
param
.
ID
,
Status
:
param
.
State
,
PartnerCategory
:
param
.
PartnerType
,
CooperateTime
:
cooperateTime
,
RegionInfo
:
&
domain
.
RegionInfo
{
...
...
@@ -168,13 +169,13 @@ func (c *PartnerInfoController) GetPartnerInfo() {
rspResult
:=
map
[
string
]
interface
{}{
"account"
:
partnerInfo
.
Account
,
"partnerName"
:
partnerInfo
.
PartnerName
,
"partner
t
ype"
:
partnerInfo
.
PartnerCategory
,
"partner
T
ype"
:
partnerInfo
.
PartnerCategory
,
"area"
:
partnerInfo
.
RegionInfo
.
RegionName
,
"salesmanName"
:
""
,
"phone"
:
""
,
"createTime"
:
partnerInfo
.
CreateAt
.
Format
(
"2006-01-02 15:04:05"
),
"cooperationTime"
:
partnerInfo
.
CooperateTime
.
Format
(
"2006-01-02"
),
"state"
:
fmt
.
Sprint
(
partnerInfo
.
Status
),
"createTime"
:
partnerInfo
.
CreateAt
.
Local
()
.
Format
(
"2006-01-02 15:04:05"
),
"cooperationTime"
:
partnerInfo
.
CooperateTime
.
Local
()
.
Format
(
"2006-01-02"
),
"state"
:
partnerInfo
.
Status
,
"id"
:
partnerInfo
.
Id
,
}
if
len
(
partnerInfo
.
Salesman
)
>
0
{
...
...
@@ -185,12 +186,12 @@ func (c *PartnerInfoController) GetPartnerInfo() {
return
}
//
GetPartnerInfo 移除合伙人
//
PartnerInfoSetState 合伙人禁用启用
func
(
c
*
PartnerInfoController
)
PartnerInfoSetState
()
{
//用与适配前端定义的数据结构
type
Parameter
struct
{
Id
int64
`json:"id"`
status
string
`json:"status"`
Id
int64
`json:"id"`
Status
int
`json:"status"`
}
var
(
param
Parameter
...
...
@@ -205,10 +206,10 @@ func (c *PartnerInfoController) PartnerInfoSetState() {
cmd
:=
partnerInfoCmd
.
StatusPartnerInfoCommand
{
Id
:
param
.
Id
,
}
if
param
.
status
==
"1"
{
if
param
.
Status
==
1
{
//禁用操作
cmd
.
Status
=
domain
.
PARTNER_STATUS_NO
}
else
if
param
.
status
==
"2"
{
}
else
if
param
.
Status
==
2
{
//启用操作
cmd
.
Status
=
domain
.
PARTNER_STATUS_YES
}
else
{
...
...
@@ -272,9 +273,10 @@ func (c *PartnerInfoController) ListPartnerInfo() {
"account"
:
partners
[
i
]
.
Account
,
"partnerName"
:
partners
[
i
]
.
PartnerName
,
"area"
:
partners
[
i
]
.
RegionInfo
.
RegionName
,
"createTime"
:
partners
[
i
]
.
CreateAt
.
Format
(
"2006-01-02 15:04:05"
),
"cooperationTime"
:
partners
[
i
]
.
CooperateTime
.
Format
(
"2006-01-02"
),
"state"
:
fmt
.
Sprint
(
partners
[
i
]
.
Status
),
"createTime"
:
partners
[
i
]
.
CreateAt
.
Local
()
.
Format
(
"2006-01-02 15:04:05"
),
"cooperationTime"
:
partners
[
i
]
.
CooperateTime
.
Local
()
.
Format
(
"2006-01-02"
),
"state"
:
partners
[
i
]
.
Status
,
"partnerType"
:
partners
[
i
]
.
PartnerCategory
,
"salesmanName"
:
""
,
"phone"
:
""
,
}
...
...
请
注册
或
登录
后发表评论