作者 陈志颖

feat:共创合约模型调整,增加共创项目编号

... ... @@ -15,7 +15,7 @@ logrus.log
*.local
*.dev
*.test
.idea
#.idea
.vscode
.log
*.tmp
... ...
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
... ...
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/allied-creation-cooperation.iml" filepath="$PROJECT_DIR$/.idea/allied-creation-cooperation.iml" />
</modules>
</component>
</project>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectTasksOptions">
<enabled-global>
<option value="go fmt" />
</enabled-global>
</component>
</project>
\ No newline at end of file
... ...
... ... @@ -15,16 +15,22 @@ type UpdateCooperationContractCommand struct {
CooperationContractDescription string `cname:"共创合约描述" json:"cooperationContractDescription" valid:"Required"`
// 共创项目编号
CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber" valid:"Required"`
// 部门编码
// 部门ID
DepartmentId string `cname:"部门ID" json:"departmentId" valid:"Required"`
// 共创合约承接对象,1员工,2共创用户,3公开
CooperationContractUndertakerTypes []int32 `cname:"共创合约承接对象" json:"cooperationContractUndertakerTypes" valid:"Required"`
// 共创合约名称
CooperationContractName string `cname:"共创合约名称" json:"cooperationContractName" valid:"Required"`
// 共创模式编码,手动输入,唯一确定
CooperationModeNumber string `cname:"共创模式编码" json:"cooperationModeNumber" valid:"Required"`
// 共创合约发起人uid
SponsorUid string `cname:"共创合约发起人uid" json:"sponsorUid,omitempty"`
// 业绩分红激励规则列表
DividendsIncentivesRules []*CreateDividendsIncentivesRulesCommand `cname:"业绩分红激励规则列表" json:"dividendsIncentivesRules,omitempty"`
// 金额激励规则列表
MoneyIncentivesRules []*CreateMoneyIncentivesRulesCommand `cname:"金额激励规则列表" json:"moneyIncentivesRules,omitempty"`
// 承接方列表
Undertakers []*CreateUndertakersCommand `cname:"承接方列表" json:"undertakers,omitempty"`
// 相关人UID列表
RelevantPeople []string `cname:"相关人列表" json:"relevantPeople,omitempty"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"`
// 组织机构ID
... ...
... ... @@ -251,6 +251,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
CooperationContractDescription: createCooperationContractCommand.CooperationContractDescription,
CooperationContractName: createCooperationContractCommand.CooperationContractName,
CooperationContractNumber: contractNumber,
CooperationProjectNumber: createCooperationContractCommand.CooperationProjectNumber,
CooperationContractUndertakerTypes: createCooperationContractCommand.CooperationContractUndertakerTypes,
CooperationContractSponsor: sponsor,
CooperationMode: cooperationMode,
... ... @@ -500,6 +501,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
defer func() {
_ = transactionContext.RollbackTransaction()
}()
var cooperationContractRepository domain.CooperationContractRepository
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -515,6 +517,38 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
if cooperationContract == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationContractCommand.CooperationContractId)))
}
// 用户REST服务初始化
var userService service.UserService
if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userService = value
}
// 获取相关人
var relevantPeople []*domain.Relevant
for _, relevantPersonUid := range updateCooperationContractCommand.RelevantPeople {
var relevantDomain *domain.Relevant
relevantUid, _ := strconv.ParseInt(relevantPersonUid, 10, 64)
if data, err := userService.RelevantFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, relevantUid); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
relevantDomain = data
}
relevantPeople = append(relevantPeople, &domain.Relevant{
RelevantId: relevantDomain.RelevantId,
CooperationContractNumber: cooperationContract.CooperationContractNumber,
UserId: relevantDomain.UserId,
UserBaseId: relevantDomain.UserBaseId,
Org: relevantDomain.Org,
Orgs: relevantDomain.Orgs,
Department: relevantDomain.Department,
Roles: relevantDomain.Roles,
UserInfo: relevantDomain.UserInfo,
UserType: relevantDomain.UserType,
Status: relevantDomain.Status,
Company: relevantDomain.Company,
})
}
if err := cooperationContract.Update(tool_funs.SimpleStructToMap(updateCooperationContractCommand)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
... ...
... ... @@ -14,8 +14,10 @@ type CooperationContract struct {
CooperationContractName string `json:"cooperationContractName"`
// 共创合约编号
CooperationContractNumber string `json:"cooperationContractNumber"`
// 共创项目编号
CooperationProjectNumber string `json:"cooperationProjectNumber"`
// 共创合约承接对象,1员工,2共创用户,3公开
CooperationContractUndertakerTypes []int32 `json:"cooperationContractUndertakerType"`
CooperationContractUndertakerTypes []int32 `json:"cooperationContractUndertakerTypes"`
// 共创合约发起人
CooperationContractSponsor *User `json:"cooperationContractSponsor"`
// 共创模式或者合伙模式
... ... @@ -70,8 +72,8 @@ func (cooperationContract *CooperationContract) Update(data map[string]interface
if cooperationContractNumber, ok := data["cooperationContractNumber"]; ok {
cooperationContract.CooperationContractNumber = cooperationContractNumber.(string)
}
if cooperationContractUndertakerType, ok := data["cooperationContractUndertakerType"]; ok {
cooperationContract.CooperationContractUndertakerTypes = cooperationContractUndertakerType.([]int32)
if cooperationContractUndertakerTypes, ok := data["cooperationContractUndertakerTypes"]; ok {
cooperationContract.CooperationContractUndertakerTypes = cooperationContractUndertakerTypes.([]int32)
}
if status, ok := data["status"]; ok {
cooperationContract.Status = status.(int32)
... ...
... ... @@ -15,6 +15,8 @@ type CooperationContract struct {
CooperationContractName string `comment:"共创合约名称"`
// 共创合约编号
CooperationContractNumber string `comment:"共创合约编号"`
// 共创项目编号
CooperationProjectNumber string `comment:"共创项目编号"`
// 共创合约承接对象,1员工,2共创用户,3公开
CooperationContractUndertakerTypes []int32 `comment:"共创合约承接对象,1员工,2共创用户,3公开" pg:",array"`
// 共创合约发起人
... ...
... ... @@ -89,6 +89,7 @@ func TransformToCooperationContractDomainModelFromPgModels(
CooperationContractDescription: cooperationContractModel.CooperationContractDescription,
CooperationContractName: cooperationContractModel.CooperationContractName,
CooperationContractNumber: cooperationContractModel.CooperationContractNumber,
CooperationProjectNumber: cooperationContractModel.CooperationProjectNumber,
CooperationContractUndertakerTypes: cooperationContractModel.CooperationContractUndertakerTypes,
CooperationContractSponsor: cooperationContractModel.CooperationContractSponsor,
CooperationMode: &domain.CooperationMode{
... ...
... ... @@ -32,6 +32,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
"cooperation_contract_description",
"cooperation_contract_name",
"cooperation_contract_number",
"cooperation_project_number",
"cooperation_contract_undertaker_types",
"cooperation_contract_sponsor",
"cooperation_mode_number",
... ... @@ -63,6 +64,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
&cooperationContract.CooperationContractDescription,
&cooperationContract.CooperationContractName,
&cooperationContract.CooperationContractNumber,
&cooperationContract.CooperationProjectNumber,
pg.Array(&cooperationContract.CooperationContractUndertakerTypes),
&cooperationContract.CooperationContractSponsor,
&cooperationContract.CooperationMode.CooperationModeNumber,
... ... @@ -80,6 +82,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
cooperationContract.CooperationContractDescription,
cooperationContract.CooperationContractName,
cooperationContract.CooperationContractNumber,
cooperationContract.CooperationProjectNumber,
pg.Array(cooperationContract.CooperationContractUndertakerTypes),
cooperationContract.CooperationContractSponsor,
cooperationContract.CooperationMode.CooperationModeNumber,
... ... @@ -196,6 +199,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
&cooperationContract.CooperationContractDescription,
&cooperationContract.CooperationContractName,
&cooperationContract.CooperationContractNumber,
&cooperationContract.CooperationProjectNumber,
pg.Array(&cooperationContract.CooperationContractUndertakerTypes),
&cooperationContract.CooperationContractSponsor,
&cooperationContract.CooperationMode.CooperationModeNumber,
... ... @@ -213,6 +217,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
cooperationContract.CooperationContractDescription,
cooperationContract.CooperationContractName,
cooperationContract.CooperationContractNumber,
cooperationContract.CooperationProjectNumber,
pg.Array(cooperationContract.CooperationContractUndertakerTypes),
cooperationContract.CooperationContractSponsor,
cooperationContract.CooperationMode.CooperationModeNumber,
... ...