Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-platform-enterprise
Overview
Overview
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
base_platform_enterprise
gic-platform-enterprise
Commits
3a2ed374
Commit
3a2ed374
authored
Aug 08, 2019
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新建商户验证公司名称是否重复
parent
1ad24899
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
130 additions
and
62 deletions
+130
-62
TabEnterpriseMapper.java
...va/com/gic/enterprise/dao/mapper/TabEnterpriseMapper.java
+19
-4
EnterpriseService.java
...in/java/com/gic/enterprise/service/EnterpriseService.java
+70
-22
EnterpriseServiceImpl.java
...om/gic/enterprise/service/impl/EnterpriseServiceImpl.java
+15
-5
EnterpriseApiServiceImpl.java
...ic/enterprise/service/outer/EnterpriseApiServiceImpl.java
+17
-31
TabEnterpriseMapper.xml
...service/src/main/resources/mapper/TabEnterpriseMapper.xml
+9
-0
No files found.
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/dao/mapper/TabEnterpriseMapper.java
View file @
3a2ed374
...
...
@@ -56,15 +56,30 @@ public interface TabEnterpriseMapper {
int
updateByPrimaryKey
(
TabEnterprise
record
);
/**
* 根据企业名称相同的个数
* 根据商户名称相同的个数
* @Title: countByName
* @Description:
* @author guojuxing
* @param enterpriseName
* @param enterpriseId
* @return
*/
* @param enterpriseId
* @return
int
*/
int
countByEnterpriseName
(
@Param
(
"enterpriseName"
)
String
enterpriseName
,
@Param
(
"enterpriseId"
)
Integer
enterpriseId
);
/**
* 根据公司名称相同的个数
* @Title: countByName
* @Description:
* @author guojuxing
* @param companyName
* @param enterpriseId
* @return int
*/
int
countByCompanyName
(
@Param
(
"companyName"
)
String
companyName
,
@Param
(
"enterpriseId"
)
Integer
enterpriseId
);
/**
* 查询列表
* @param search 商户名称或者公司名称
* @param serviceVersion
...
...
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/EnterpriseService.java
View file @
3a2ed374
...
...
@@ -6,53 +6,101 @@ import com.gic.enterprise.entity.TabEnterprise;
import
com.github.pagehelper.Page
;
/**
* @author guojx
* @date 2019/7/16 4:13 PM
* 商户
* @ClassName: EnterpriseService
* @Description:
* @author guojuxing
* @date 2019/8/8 4:43 PM
*/
public
interface
EnterpriseService
{
/**
* 新增商户
* @param enterpriseDTO
* @return
*/
* 新建商户
* @Title: saveEnterprise
* @Description:
* @author guojuxing
* @param enterpriseDTO
* @return int
*/
int
saveEnterprise
(
EnterpriseDTO
enterpriseDTO
);
/**
* 编辑保存
* @param enterpriseDTO
*/
* @Title: editEnterprise
* @Description:
* @author guojuxing
* @param enterpriseDTO
* @return void
*/
void
editEnterprise
(
EnterpriseDTO
enterpriseDTO
);
/**
* 根据主键获取数据
* @param enterpriseId
* @return
*/
* 根据主键获取
* @Title: getEnterpriseById
* @Description:
* @author guojuxing
* @param enterpriseId
* @return com.gic.enterprise.entity.TabEnterprise
*/
TabEnterprise
getEnterpriseById
(
Integer
enterpriseId
);
/**
* 企业名称是否重复
* 商户名称是否重复
* @Title: isRepeatEnterpriseName
* @Description:
* @author guojuxing
* @param enterpriseName
* @param enterpriseId
* @return
*/
* @param enterpriseId
* @return
boolean
*/
boolean
isRepeatEnterpriseName
(
String
enterpriseName
,
Integer
enterpriseId
);
/**
* 停用、启用
* 公司名称是否重复
* @Title: isRepeatEnterpriseName
* @Description:
* @author guojuxing
* @param companyName
* @param enterpriseId
* @return boolean
*/
boolean
isRepeatCompanyName
(
String
companyName
,
Integer
enterpriseId
);
/**
* 商户启用、停用
* @Title: changeEnterpriseStatus
* @Description:
* @author guojuxing
* @param enterpriseId
* @param status
*/
* @param status
* @return void
*/
void
changeEnterpriseStatus
(
Integer
enterpriseId
,
Integer
status
);
/**
* 分页查询商户
* @Title: listEnterprise
* @Description:
* @author guojuxing
* @param search
* @param serviceVersion
* @param status
* @param orderBy
* @param pageNum
* @param pageSize
* @return com.github.pagehelper.Page<com.gic.enterprise.dto.EnterpriseListDTO>
*/
Page
<
EnterpriseListDTO
>
listEnterprise
(
String
search
,
Integer
serviceVersion
,
Integer
status
,
String
orderBy
,
Integer
pageNum
,
Integer
pageSize
);
/**
* 初始化商户
* @param enterpriseId
*/
* 商户初始化字段改为已初始化状态
* @Title: initEnterprise
* @Description:
* @author guojuxing
* @param enterpriseId
* @return void
*/
void
initEnterprise
(
Integer
enterpriseId
);
}
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/impl/EnterpriseServiceImpl.java
View file @
3a2ed374
package
com
.
gic
.
enterprise
.
service
.
impl
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.enterprise.dao.mapper.TabEnterpriseMapper
;
import
com.gic.enterprise.dto.EnterpriseDTO
;
...
...
@@ -8,11 +14,6 @@ import com.gic.enterprise.entity.TabEnterprise;
import
com.gic.enterprise.service.EnterpriseService
;
import
com.github.pagehelper.Page
;
import
com.github.pagehelper.PageHelper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
/**
* @author guojx
...
...
@@ -52,6 +53,15 @@ public class EnterpriseServiceImpl implements EnterpriseService{
}
@Override
public
boolean
isRepeatCompanyName
(
String
companyName
,
Integer
enterpriseId
)
{
int
count
=
tabEnterpriseMapper
.
countByCompanyName
(
companyName
,
enterpriseId
);
if
(
count
>
0
)
{
return
true
;
}
return
false
;
}
@Override
public
void
changeEnterpriseStatus
(
Integer
enterpriseId
,
Integer
status
)
{
TabEnterprise
tabEnterprise
=
new
TabEnterprise
();
tabEnterprise
.
setEnterpriseId
(
enterpriseId
);
...
...
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/outer/EnterpriseApiServiceImpl.java
View file @
3a2ed374
package
com
.
gic
.
enterprise
.
service
.
outer
;
import
java.util.Date
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.gic.api.base.commons.Page
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.auth.dto.UserDTO
;
...
...
@@ -8,7 +14,6 @@ import com.gic.commons.util.EntityUtil;
import
com.gic.commons.util.PageHelperUtils
;
import
com.gic.enterprise.constant.EnterpriseStatusTypeEnum
;
import
com.gic.enterprise.dto.EnterpriseDTO
;
import
com.gic.enterprise.dto.EnterpriseInitDTO
;
import
com.gic.enterprise.dto.EnterpriseListDTO
;
import
com.gic.enterprise.entity.TabEnterprise
;
import
com.gic.enterprise.error.ErrorCode
;
...
...
@@ -17,12 +22,6 @@ import com.gic.enterprise.service.EnterpriseApiService;
import
com.gic.enterprise.service.EnterpriseInitService
;
import
com.gic.enterprise.service.EnterpriseService
;
import
com.gic.store.utils.valid.ValidUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Date
;
import
java.util.List
;
/**
* @author guojx
...
...
@@ -38,27 +37,6 @@ public class EnterpriseApiServiceImpl implements EnterpriseApiService {
private
EnterpriseInitService
enterpriseInitService
;
@Override
public
ServiceResponse
<
Integer
>
saveEnterprise
(
EnterpriseDTO
enterpriseDTO
)
{
//valid param
ServiceResponse
paramResult
=
ValidUtil
.
allCheckValidate
(
enterpriseDTO
,
EnterpriseDTO
.
SaveEnterpriseValid
.
class
);
if
(!
paramResult
.
isSuccess
())
{
return
paramResult
;
}
if
(
enterpriseService
.
isRepeatEnterpriseName
(
enterpriseDTO
.
getEnterpriseName
(),
null
))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"商户名称不能重复"
);
}
enterpriseDTO
.
setCreateTime
(
new
Date
());
enterpriseDTO
.
setUpdateTime
(
new
Date
());
enterpriseDTO
.
setIsInitComplete
(
0
);
enterpriseDTO
.
setStatus
(
EnterpriseStatusTypeEnum
.
EFFECTIVE
.
getCode
());
int
enterpriseId
=
enterpriseService
.
saveEnterprise
(
enterpriseDTO
);
//todo 新增商户初始化配置信息
return
ServiceResponse
.
success
(
enterpriseId
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ServiceResponse
<
Integer
>
saveEnterprise
(
EnterpriseDTO
enterpriseDTO
,
UserDTO
userDTO
)
{
//valid param
...
...
@@ -69,6 +47,9 @@ public class EnterpriseApiServiceImpl implements EnterpriseApiService {
if
(
enterpriseService
.
isRepeatEnterpriseName
(
enterpriseDTO
.
getEnterpriseName
(),
null
))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"商户名称不能重复"
);
}
if
(
enterpriseService
.
isRepeatCompanyName
(
enterpriseDTO
.
getCompanyName
(),
null
))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"公司名称不能重复"
);
}
enterpriseDTO
.
setCreateTime
(
new
Date
());
enterpriseDTO
.
setUpdateTime
(
new
Date
());
...
...
@@ -84,7 +65,7 @@ public class EnterpriseApiServiceImpl implements EnterpriseApiService {
userDTO
.
setSuperAdmin
(
1
);
ServiceResponse
userResult
=
userApiService
.
saveUser
(
userDTO
);
if
(
userResult
.
isSuccess
())
{
return
ServiceResponse
.
success
();
return
ServiceResponse
.
success
(
enterpriseId
);
}
else
{
throw
new
EnterpriseException
(
userResult
.
getCode
(),
userResult
.
getMessage
());
}
...
...
@@ -98,13 +79,18 @@ public class EnterpriseApiServiceImpl implements EnterpriseApiService {
if
(!
paramResult
.
isSuccess
())
{
return
paramResult
;
}
TabEnterprise
tabEnterprise
=
enterpriseService
.
getEnterpriseById
(
enterpriseDTO
.
getEnterpriseId
());
//商户ID
int
enterpriseId
=
enterpriseDTO
.
getEnterpriseId
();
TabEnterprise
tabEnterprise
=
enterpriseService
.
getEnterpriseById
(
enterpriseId
);
if
(
tabEnterprise
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"企业ID错误,查询不到数据"
);
}
if
(
enterpriseService
.
isRepeatEnterpriseName
(
enterpriseDTO
.
getEnterpriseName
(),
enterprise
DTO
.
getEnterpriseId
()
))
{
if
(
enterpriseService
.
isRepeatEnterpriseName
(
enterpriseDTO
.
getEnterpriseName
(),
enterprise
Id
))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"商户名称不能重复"
);
}
if
(
enterpriseService
.
isRepeatCompanyName
(
enterpriseDTO
.
getCompanyName
(),
enterpriseId
))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"公司名称不能重复"
);
}
enterpriseDTO
.
setUpdateTime
(
new
Date
());
enterpriseService
.
editEnterprise
(
enterpriseDTO
);
...
...
gic-platform-enterprise-service/src/main/resources/mapper/TabEnterpriseMapper.xml
View file @
3a2ed374
...
...
@@ -160,6 +160,15 @@
</if>
</select>
<select
id=
"countByCompanyName"
resultType=
"int"
>
select count(1) from tab_enterprise
where status
<![CDATA[ <> ]]>
0
and company_name = #{companyName}
<if
test=
"enterpriseId != null"
>
enterprise_id
<![CDATA[ <> ]]>
#{enterpriseId}
</if>
</select>
<select
id=
"listEnterpriseId"
resultType=
"com.gic.enterprise.dto.EnterpriseListDTO"
>
SELECT
a.enterprise_id enterpriseId,
...
...
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