Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
ef65c43e
Commit
ef65c43e
authored
Oct 25, 2022
by
zhangyingbin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化代码结构,优化企业审核创建企业管理员角色信息
parent
a10f27e1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
55 deletions
+96
-55
OrgEnum.java
...va/com/yeejoin/amos/boot/module/ugp/api/Enum/OrgEnum.java
+1
-1
CompanyController.java
...mos/boot/module/ugp/biz/controller/CompanyController.java
+3
-51
CompanyServiceImpl.java
.../boot/module/ugp/biz/service/impl/CompanyServiceImpl.java
+92
-3
No files found.
amos-boot-system-ugp/amos-boot-module-ugp-api/src/main/java/com/yeejoin/amos/boot/module/ugp/api/Enum/OrgEnum.java
View file @
ef65c43e
...
...
@@ -33,7 +33,7 @@ public enum OrgEnum {
static
{
for
(
OrgPersonEnum
orgPersonEnum:
OrgPersonEnum
.
values
()){
map
.
put
(
orgPersonEnum
.
get
Name
(),
orgPersonEnum
.
getKey
());
map
.
put
(
orgPersonEnum
.
get
Key
(),
orgPersonEnum
.
getName
());
}
}
}
amos-boot-system-ugp/amos-boot-module-ugp-biz/src/main/java/com/yeejoin/amos/boot/module/ugp/biz/controller/CompanyController.java
View file @
ef65c43e
...
...
@@ -18,6 +18,7 @@ import com.yeejoin.amos.component.feign.model.FeignClientResult;
import
com.yeejoin.amos.feign.privilege.Privilege
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
com.yeejoin.amos.feign.privilege.model.CompanyModel
;
import
com.yeejoin.amos.feign.privilege.model.RoleModel
;
import
com.yeejoin.amos.feign.privilege.util.DesUtil
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -60,9 +61,6 @@ public class CompanyController extends BaseController {
@Autowired
OrgServiceImpl
orgServiceImpl
;
@Value
(
"${amos.secret.key}"
)
String
secretKey
;
/**
* 新增企业信息表
*
...
...
@@ -179,58 +177,12 @@ public class CompanyController extends BaseController {
@PostMapping
(
value
=
"check"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"根据sequenceNbr更新,并创建单位及管理员"
,
notes
=
"根据sequenceNbr更新,并创建单位及管理员"
)
public
ResponseModel
<
Boolean
>
companyCheck
(
@RequestBody
CompanyDto
model
,
Long
sequenceNbr
,
String
bizOrgType
)
throws
Exception
{
Company
company
=
companyServiceImpl
.
getById
(
sequenceNbr
);
company
.
setApproved
(
model
.
getApproved
());
if
(
company
.
getApproved
().
equals
(
"已审核"
)){
final
CompanyModel
companyModel
=
new
CompanyModel
();
AgencyUserModel
agencyUserModel
=
new
AgencyUserModel
();
//创建平台企业
companyModel
.
setCompanyName
(
company
.
getName
());
companyModel
.
setCompanyCode
(
company
.
getCreditCode
());
companyModel
.
setAddress
(
company
.
getAddress
());
companyModel
.
setParentId
(
0L
);
companyModel
.
setLevel
(
"headquarter"
);
companyModel
.
setAgencyCode
(
"ugp"
);
CompanyModel
companyModelFeignClient
=
Privilege
.
companyClient
.
create
(
companyModel
).
getResult
();
//创建平台用户
String
adminName
=
company
.
getAdminName
();
String
adminLoginName
=
company
.
getAdminLoginName
();
String
adminPhone
=
company
.
getAdminTel
();
String
adminPassword
=
company
.
getAdminLoginPwd
();
agencyUserModel
.
setRealName
(
adminName
);
agencyUserModel
.
setAgencyCode
(
"ugp"
);
agencyUserModel
.
setLockStatus
(
"UNLOCK"
);
agencyUserModel
.
setMobile
(
adminPhone
);
agencyUserModel
.
setCreateTime
(
new
Date
());
agencyUserModel
.
setUserName
(
adminLoginName
);
agencyUserModel
.
setPassword
(
DesUtil
.
encode
(
adminPassword
,
secretKey
));
agencyUserModel
.
setRePassword
(
DesUtil
.
encode
(
adminPassword
,
secretKey
));
Privilege
.
agencyUserClient
.
create
(
agencyUserModel
);
//企业动态表单存储
JSONObject
jsonObject
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
company
));
jsonObject
.
put
(
"amosOrgId"
,
companyModelFeignClient
.
getSequenceNbr
());
jsonObject
.
put
(
"amosOrgCode"
,
companyModelFeignClient
.
getOrgCode
());
orgServiceImpl
.
dataHandling
(
jsonObject
,
bizOrgType
,
null
);
//企业管理员人员 动态表单存储
jsonObject
=
null
;
jsonObject
.
put
(
"name"
,
adminName
);
jsonObject
.
put
(
"phone"
,
adminPhone
);
jsonObject
.
put
(
"amosOrgId"
,
agencyUserModel
.
getSequenceNbr
());
jsonObject
.
put
(
"amosOrgCode"
,
agencyUserModel
.
getUserId
());
orgServiceImpl
.
dataHandling
(
jsonObject
,
OrgEnum
.
企业管理员
.
getKey
(),
null
);
}
return
ResponseHelper
.
buildResponse
(
companyServiceImpl
.
updateById
(
company
));
return
ResponseHelper
.
buildResponse
(
companyServiceImpl
.
companyCheck
(
model
,
sequenceNbr
,
bizOrgType
));
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@PostMapping
(
value
=
"test"
)
@ApiOperation
(
httpMethod
=
"Post"
,
value
=
"
根据sequenceNbr更新,并创建单位及管理员"
,
notes
=
"根据sequenceNbr更新,并创建单位及管理员
"
)
@ApiOperation
(
httpMethod
=
"Post"
,
value
=
"
(测试)存储动态表单"
,
notes
=
"(测试)存储动态表单
"
)
public
ResponseModel
<
OrgUsrDto
>
getInfo
(
@RequestBody
JSONObject
jsonObject
,
String
bizOrgType
,
String
sequenceNbr
){
return
ResponseHelper
.
buildResponse
(
orgServiceImpl
.
dataHandling
(
jsonObject
,
bizOrgType
,
sequenceNbr
));
}
...
...
amos-boot-system-ugp/amos-boot-module-ugp-biz/src/main/java/com/yeejoin/amos/boot/module/ugp/biz/service/impl/CompanyServiceImpl.java
View file @
ef65c43e
package
com
.
yeejoin
.
amos
.
boot
.
module
.
ugp
.
biz
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.AbstractWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.yeejoin.amos.boot.module.ugp.api.Enum.OrgEnum
;
import
com.yeejoin.amos.boot.module.ugp.api.entity.Company
;
import
com.yeejoin.amos.boot.module.ugp.api.mapper.CompanyMapper
;
import
com.yeejoin.amos.boot.module.ugp.api.service.ICompanyService
;
import
com.yeejoin.amos.boot.module.ugp.api.dto.CompanyDto
;
import
com.yeejoin.amos.feign.privilege.Privilege
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
com.yeejoin.amos.feign.privilege.model.CompanyModel
;
import
com.yeejoin.amos.feign.privilege.model.RoleModel
;
import
com.yeejoin.amos.feign.privilege.util.DesUtil
;
import
org.apache.lucene.queryparser.flexible.messages.Message
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
org.typroject.tyboot.core.restful.utils.ResponseHelper
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -33,6 +42,12 @@ public class CompanyServiceImpl extends BaseService<CompanyDto, Company, Company
@Autowired
CompanyMapper
companyMapper
;
@Value
(
"${amos.secret.key}"
)
String
secretKey
;
@Autowired
OrgServiceImpl
orgServiceImpl
;
/**
* 列表查询 示例
*/
...
...
@@ -58,4 +73,77 @@ public class CompanyServiceImpl extends BaseService<CompanyDto, Company, Company
return
page1
;
}
public
Boolean
companyCheck
(
CompanyDto
model
,
Long
sequenceNbr
,
String
bizOrgType
)
throws
Exception
{
Set
<
String
>
roleNameSet
=
new
HashSet
<>();
List
<
RoleModel
>
userRoleList
=
new
ArrayList
<>();
List
<
Long
>
roleIds
=
new
ArrayList
<>();
Map
<
Long
,
List
<
Long
>>
roleSeqsMap
=
new
HashMap
<>();
Company
company
=
this
.
getById
(
sequenceNbr
);
company
.
setApproved
(
model
.
getApproved
());
if
(
company
.
getApproved
().
equals
(
"已审核"
)){
final
CompanyModel
companyModel
=
new
CompanyModel
();
AgencyUserModel
agencyUserModel
=
new
AgencyUserModel
();
//创建平台企业
companyModel
.
setCompanyName
(
company
.
getName
());
companyModel
.
setCompanyCode
(
company
.
getCreditCode
());
companyModel
.
setAddress
(
company
.
getAddress
());
companyModel
.
setParentId
(
0L
);
companyModel
.
setLevel
(
"headquarter"
);
companyModel
.
setAgencyCode
(
"ugp"
);
CompanyModel
companyModelFeignClient
=
Privilege
.
companyClient
.
create
(
companyModel
).
getResult
();
//创建平台用户
//设置用户角色
List
<
RoleModel
>
allRoleList
=
Privilege
.
roleClient
.
queryRoleList
(
null
,
null
).
getResult
();
String
[]
unitTypeCodes
=
company
.
getType
().
split
(
","
);
for
(
String
code
:
unitTypeCodes
)
{
roleNameSet
.
add
(
OrgEnum
.
map
.
get
(
code
));
}
allRoleList
.
stream
().
forEach
(
t
->
{
if
(
roleNameSet
.
contains
(
t
.
getRoleName
()))
{
userRoleList
.
add
(
t
);
}
});
userRoleList
.
stream
().
forEach
(
r
->
{
roleIds
.
add
(
r
.
getSequenceNbr
());
});
roleSeqsMap
.
put
(
companyModelFeignClient
.
getSequenceNbr
(),
roleIds
);
agencyUserModel
.
setOrgRoleSeqs
(
roleSeqsMap
);
//设置用户信息
String
adminName
=
company
.
getAdminName
();
String
adminLoginName
=
company
.
getAdminLoginName
();
String
adminPhone
=
company
.
getAdminTel
();
String
adminPassword
=
company
.
getAdminLoginPwd
();
agencyUserModel
.
setRealName
(
adminName
);
agencyUserModel
.
setAgencyCode
(
"ugp"
);
agencyUserModel
.
setLockStatus
(
"UNLOCK"
);
agencyUserModel
.
setMobile
(
adminPhone
);
agencyUserModel
.
setCreateTime
(
new
Date
());
agencyUserModel
.
setUserName
(
adminLoginName
);
agencyUserModel
.
setPassword
(
DesUtil
.
encode
(
adminPassword
,
secretKey
));
agencyUserModel
.
setRePassword
(
DesUtil
.
encode
(
adminPassword
,
secretKey
));
Privilege
.
agencyUserClient
.
create
(
agencyUserModel
);
//企业动态表单存储
JSONObject
jsonObject
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
company
));
jsonObject
.
put
(
"amosOrgId"
,
companyModelFeignClient
.
getSequenceNbr
());
jsonObject
.
put
(
"amosOrgCode"
,
companyModelFeignClient
.
getOrgCode
());
orgServiceImpl
.
dataHandling
(
jsonObject
,
bizOrgType
,
null
);
//企业管理员人员 动态表单存储
jsonObject
=
null
;
jsonObject
.
put
(
"name"
,
adminName
);
jsonObject
.
put
(
"phone"
,
adminPhone
);
jsonObject
.
put
(
"amosOrgId"
,
agencyUserModel
.
getSequenceNbr
());
jsonObject
.
put
(
"amosOrgCode"
,
agencyUserModel
.
getUserId
());
orgServiceImpl
.
dataHandling
(
jsonObject
,
OrgEnum
.
企业管理员
.
getKey
(),
null
);
}
return
this
.
updateById
(
company
);
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment