Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
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
haoban3.0
haoban-manage3.0
Commits
fd55454e
Commit
fd55454e
authored
May 10, 2022
by
徐高华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登录调整
parent
d6097a4e
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
1249 additions
and
1331 deletions
+1249
-1331
LoginDTO.java
...src/main/java/com/gic/haoban/manage/api/dto/LoginDTO.java
+0
-48
TabHaobanAuditMapper.java
...aoban/manage/service/dao/mapper/TabHaobanAuditMapper.java
+3
-0
TabHaobanAuditMapper.xml
...ervice/src/main/resources/mapper/TabHaobanAuditMapper.xml
+5
-0
AuthRequestUtil.java
.../java/com/gic/haoban/manage/web/auth/AuthRequestUtil.java
+0
-152
ApplicationController.java
...c/haoban/manage/web/controller/ApplicationController.java
+288
-288
AuditController.java
...com/gic/haoban/manage/web/controller/AuditController.java
+239
-245
GicDepartmentController.java
...haoban/manage/web/controller/GicDepartmentController.java
+15
-13
LoginController.java
...com/gic/haoban/manage/web/controller/LoginController.java
+144
-226
MaterialController.java
.../gic/haoban/manage/web/controller/MaterialController.java
+6
-10
RightController.java
...com/gic/haoban/manage/web/controller/RightController.java
+2
-2
StaffController.java
...com/gic/haoban/manage/web/controller/StaffController.java
+3
-16
SyncDealContoller.java
...m/gic/haoban/manage/web/controller/SyncDealContoller.java
+194
-198
WebBaseController.java
...m/gic/haoban/manage/web/controller/WebBaseController.java
+6
-10
WelcomeController.java
...m/gic/haoban/manage/web/controller/WelcomeController.java
+6
-6
WxEnterpriseController.java
.../haoban/manage/web/controller/WxEnterpriseController.java
+15
-41
StaffVO.java
...b/src/main/java/com/gic/haoban/manage/web/vo/StaffVO.java
+323
-76
No files found.
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/dto/LoginDTO.java
deleted
100644 → 0
View file @
d6097a4e
package
com
.
gic
.
haoban
.
manage
.
api
.
dto
;
import
java.io.Serializable
;
public
class
LoginDTO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
StaffDTO
staffDTO
;
private
String
wxEnterpriseId
;
private
String
enterpriseId
;
private
Integer
wxEnterpriseType
;
public
Integer
getWxEnterpriseType
()
{
return
wxEnterpriseType
;
}
public
void
setWxEnterpriseType
(
Integer
wxEnterpriseType
)
{
this
.
wxEnterpriseType
=
wxEnterpriseType
;
}
public
StaffDTO
getStaffDTO
()
{
return
staffDTO
;
}
public
void
setStaffDTO
(
StaffDTO
staffDTO
)
{
this
.
staffDTO
=
staffDTO
;
}
public
String
getWxEnterpriseId
()
{
return
wxEnterpriseId
;
}
public
void
setWxEnterpriseId
(
String
wxEnterpriseId
)
{
this
.
wxEnterpriseId
=
wxEnterpriseId
;
}
public
String
getEnterpriseId
()
{
return
enterpriseId
;
}
public
void
setEnterpriseId
(
String
enterpriseId
)
{
this
.
enterpriseId
=
enterpriseId
;
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/dao/mapper/TabHaobanAuditMapper.java
View file @
fd55454e
...
...
@@ -36,4 +36,6 @@ public interface TabHaobanAuditMapper {
TabHaobanAudit
findByBindRelatedIdAndAuditType
(
@Param
(
"relatedId"
)
String
relatedId
,
@Param
(
"auditType"
)
int
auditType
);
List
<
TabHaobanAudit
>
judgeHavePhoneNumberOrCode
(
@Param
(
"enterpriseId"
)
String
enterpriseId
,
@Param
(
"clerkCode"
)
String
clerkCode
,
@Param
(
"phoneNumber"
)
String
phoneNumber
);
int
getAuditCount
(
String
enterpriseId
,
@Param
(
"storeIds"
)
List
<
String
>
storeIds
)
;
}
\ No newline at end of file
haoban-manage3-service/src/main/resources/mapper/TabHaobanAuditMapper.xml
View file @
fd55454e
...
...
@@ -443,5 +443,9 @@
</if>
)
</select>
<select
id=
"getAuditCount"
>
</select>
</mapper>
\ No newline at end of file
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/auth/AuthRequestUtil.java
deleted
100644 → 0
View file @
d6097a4e
package
com
.
gic
.
haoban
.
manage
.
web
.
auth
;
import
com.alibaba.fastjson.JSON
;
import
com.gic.haoban.common.utils.EntityUtil
;
import
com.gic.haoban.manage.api.dto.LoginDTO
;
import
com.gic.redis.data.util.RedisUtil
;
import
org.apache.commons.beanutils.BeanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
java.util.Date
;
import
java.util.concurrent.TimeUnit
;
/**
* Created 2018/7/26.
* 新方法 AuthWebRequestUtil
* @author hua
*/
@Deprecated
public
class
AuthRequestUtil
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AuthRequestUtil
.
class
);
public
static
final
String
REDIS_LOGIN_USER_TOKEN_PREFIX
=
"GIC:HAOBAN:HAOBAN_MOBILE_APP:LOGIN_USER:"
;
public
static
final
String
REDIS_FAKE_LOGIN_FLAG_PREFIX
=
"GIC:HAOBAN:HAOBAN_MOBILE_APP:FAKE_LOGIN_TOKEN:"
;
public
static
String
LOGIN_SESSION_KEY
=
"HAOBAN:LOGINUSER"
;
public
static
void
setSessionUser
(
Object
obj
)
{
String
userJson
=
JSON
.
toJSONString
(
obj
);
getSession
().
setAttribute
(
LOGIN_SESSION_KEY
,
userJson
);
}
public
static
void
delSessionUser
()
{
getSession
().
removeAttribute
(
LOGIN_SESSION_KEY
);
}
public
static
LoginDTO
getAppLoginUser
(
String
token
)
{
logger
.
info
(
"token-web="
+
token
);
if
(
StringUtils
.
isBlank
(
token
))
{
return
null
;
}
return
EntityUtil
.
changeEntityByJSON
(
LoginDTO
.
class
,
RedisUtil
.
getCache
(
token
));
}
private
static
void
setLoginUserLastToken
(
String
token
,
Object
obj
)
{
try
{
String
userId
=
BeanUtils
.
getProperty
(
obj
,
"user.userId"
);
if
(
StringUtils
.
isNotBlank
(
userId
)
&&
StringUtils
.
isNotBlank
(
token
))
{
RedisUtil
.
setCache
(
REDIS_LOGIN_USER_TOKEN_PREFIX
+
userId
,
token
,
31L
,
TimeUnit
.
DAYS
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
}
}
/**
* 是否为用户最后一次登录token
*
* @param token
* @param userId
* @return
*/
public
static
boolean
isLoginUserLastToken
(
String
token
,
String
userId
)
{
Object
lastUserLoginToken
=
RedisUtil
.
getCache
(
REDIS_LOGIN_USER_TOKEN_PREFIX
+
userId
);
// 如果用户最后一次登录token不符则返回false
return
!(
lastUserLoginToken
instanceof
CharSequence
)
||
StringUtils
.
equals
(
token
,
(
CharSequence
)
lastUserLoginToken
);
}
private
static
void
setFakeLoginFlag
(
String
token
)
{
if
(
StringUtils
.
isNotBlank
(
token
))
{
RedisUtil
.
setCache
(
REDIS_FAKE_LOGIN_FLAG_PREFIX
+
token
,
new
Date
(),
30L
,
TimeUnit
.
DAYS
);
}
}
/**
* 是否为伪登录token
*
* @param token
* @return
*/
public
static
boolean
isFakeLoginToken
(
String
token
)
{
return
StringUtils
.
isNotBlank
(
token
)
&&
RedisUtil
.
getCache
(
REDIS_FAKE_LOGIN_FLAG_PREFIX
+
token
)
!=
null
;
}
public
static
void
setAppLoginUser
(
String
token
,
Object
obj
)
{
RedisUtil
.
setCache
(
token
,
obj
,
30L
,
TimeUnit
.
DAYS
);
getResponse
().
setHeader
(
"token"
,
token
);
}
public
static
void
setAppFakeLoginUser
(
String
token
,
Object
obj
)
{
RedisUtil
.
setCache
(
token
,
obj
,
30L
,
TimeUnit
.
DAYS
);
getResponse
().
setHeader
(
"token"
,
token
);
setFakeLoginFlag
(
token
);
}
public
static
void
delToken
()
{
String
token
=
getRequest
().
getHeader
(
"token"
);
RedisUtil
.
delCache
(
token
);
}
public
static
void
setAppLoginUser
(
Object
obj
,
String
token
)
{
RedisUtil
.
setCache
(
token
,
obj
,
30L
,
TimeUnit
.
DAYS
);
getResponse
().
setHeader
(
"token"
,
token
);
}
public
static
void
setAppFakeLoginUser
(
Object
obj
)
{
String
token
=
getRequest
().
getHeader
(
"token"
);
RedisUtil
.
setCache
(
token
,
obj
,
30L
,
TimeUnit
.
DAYS
);
getResponse
().
setHeader
(
"token"
,
token
);
}
public
static
HttpSession
getSession
()
{
HttpSession
session
=
null
;
try
{
session
=
getRequest
().
getSession
();
}
catch
(
Exception
e
)
{
}
return
session
;
}
public
static
HttpServletRequest
getRequest
()
{
ServletRequestAttributes
attrs
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
return
attrs
.
getRequest
();
}
public
static
HttpServletResponse
getResponse
()
{
ServletRequestAttributes
attrs
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
return
attrs
.
getResponse
();
}
public
static
LoginDTO
getLoginUser
()
{
Cookie
[]
cookies
=
getRequest
().
getCookies
();
String
token
=
""
;
if
(
cookies
!=
null
)
{
for
(
Cookie
cookie
:
cookies
)
{
if
(
cookie
.
getName
().
equals
(
"token"
))
{
token
=
cookie
.
getValue
();
}
}
}
return
getAppLoginUser
(
token
);
}
}
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/ApplicationController.java
View file @
fd55454e
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO
;
import
com.gic.haoban.common.anno.IgnoreLogin
;
import
com.gic.haoban.common.utils.AuthWebRequestUtil
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.manage.api.dto.*
;
import
com.gic.haoban.manage.api.enums.SecretTypeEnum
;
import
com.gic.haoban.manage.api.service.*
;
import
com.gic.haoban.manage.web.config.Config
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.wechat.api.service.qywx.QywxSuiteApiService
;
import
com.gic.wechat.api.service.qywx.QywxUserApiService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@RestController
public
class
ApplicationController
extends
WebBaseController
{
private
static
final
Logger
log
=
LogManager
.
getLogger
(
ApplicationController
.
class
);
@Autowired
private
ApplicationApiService
applicationApiService
;
@Autowired
private
QywxSuiteApiService
qywxSuiteApiService
;
@Autowired
private
WxApplicationApiService
wxApplicationApiService
;
@Autowired
private
WxEnterpriseApiService
wxEnterpriseApiService
;
@Autowired
private
Config
config
;
@Autowired
private
DepartmentApiService
departmentApiService
;
@Autowired
private
ApplicationSettingApiService
applicationSettingApiService
;
@Autowired
private
DealSyncOperationApiService
dealSyncOperationApiService
;
@Autowired
private
QywxUserApiService
qywxUserApiService
;
@RequestMapping
(
"application-list"
)
public
HaobanResponse
applicationList
()
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
List
<
ApplicationDTO
>
list
=
applicationApiService
.
listApplicationByWxEnterpriseId
(
wxEnterpriseId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
list
);
}
@IgnoreLogin
@RequestMapping
(
"application-open-close-list"
)
public
HaobanResponse
applicationList
(
String
wxEnterpriseId
)
{
if
(
StringUtils
.
isAnyBlank
(
wxEnterpriseId
))
{
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
List
<
ApplicationDTO
>
list
=
applicationApiService
.
listApplicationByWxEnterpriseId
(
wxEnterpriseId
);
List
<
String
>
applicationIds
=
list
.
stream
().
map
(
s
->
s
.
getApplicationId
()).
collect
(
Collectors
.
toList
());
List
<
ApplicationSettingDTO
>
result
=
applicationSettingApiService
.
listOpenByWxEnterpriseIdAndApplicationIds
(
wxEnterpriseId
,
applicationIds
);
//开启
List
<
ApplicationDTO
>
openList
=
new
ArrayList
<
ApplicationDTO
>();
List
<
String
>
openApplicationIds
=
new
ArrayList
<>();
if
(
CollectionUtil
.
isNotEmpty
(
result
))
{
openApplicationIds
=
result
.
stream
().
map
(
s
->
s
.
getApplicationId
()).
collect
(
Collectors
.
toList
());
openList
=
applicationApiService
.
listByApplications
(
openApplicationIds
);
}
//关闭
List
<
ApplicationDTO
>
closeList
=
new
ArrayList
<
ApplicationDTO
>();
applicationIds
.
removeAll
(
openApplicationIds
);
if
(
CollectionUtil
.
isNotEmpty
(
applicationIds
))
{
closeList
=
applicationApiService
.
listByApplications
(
applicationIds
);
}
Object
o
=
RedisUtil
.
getCache
(
"haobanWxEnterpriseIdAppOpen"
);
String
wxEnterpriseIds
=
o
==
null
?
""
:
o
.
toString
();
if
(!
wxEnterpriseIds
.
contains
(
wxEnterpriseId
))
{
//不开启
Iterator
<
ApplicationDTO
>
it
=
openList
.
iterator
();
while
(
it
.
hasNext
())
{
ApplicationDTO
s
=
it
.
next
();
if
(
s
.
getApplicationName
().
contains
(
"内购券"
))
{
it
.
remove
();
}
}
Iterator
<
ApplicationDTO
>
it2
=
closeList
.
iterator
();
while
(
it2
.
hasNext
())
{
ApplicationDTO
s
=
it2
.
next
();
if
(
s
.
getApplicationName
().
contains
(
"内购券"
))
{
it2
.
remove
();
}
}
}
map
.
put
(
"open"
,
openList
);
map
.
put
(
"close"
,
closeList
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
map
);
}
@RequestMapping
(
"open-or-close"
)
public
HaobanResponse
applicationList
(
String
wxEnterpriseId
,
String
applicationId
,
Integer
openFlag
)
{
if
(
StringUtils
.
isAnyBlank
(
wxEnterpriseId
,
applicationId
))
{
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
if
(
openFlag
==
null
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
applicationSettingApiService
.
saveSetting
(
wxEnterpriseId
,
applicationId
,
openFlag
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
@RequestMapping
(
"has-bind-contract"
)
public
HaobanResponse
hasBindContract
()
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
WxEnterpriseDTO
enterpriseDTO
=
this
.
wxEnterpriseApiService
.
getOne
(
wxEnterpriseId
);
if
(
enterpriseDTO
!=
null
)
{
SecretSettingDTO
secretSetting
=
wxEnterpriseApiService
.
getSecretSetting
(
enterpriseDTO
.
getWxEnterpriseId
(),
SecretTypeEnum
.
HAOBAN_HELP
.
getVal
(),
null
);
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()
==
0
)
{
log
.
info
(
"没有配置secret:{}"
,
JSONObject
.
toJSONString
(
enterpriseDTO
));
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
true
);
}
if
(
enterpriseDTO
.
getContactFlag
()
!=
null
&&
enterpriseDTO
.
getContactFlag
()
==
0
)
{
String
taskId
=
dealSyncOperationApiService
.
createQywxTask
(
wxEnterpriseId
,
"同步企业微信架构"
,
login
.
getStaff
DTO
().
getStaffId
(),
"首次同步企业微信架构"
);
if
(
StringUtils
.
isBlank
(
taskId
))
{
log
.
info
(
"【是否绑定】taskId={}"
,
taskId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
true
);
}
dealSyncOperationApiService
.
dealQywxDepartment
(
taskId
,
wxEnterpriseId
);
enterpriseDTO
.
setContactFlag
(
1
);
wxEnterpriseApiService
.
update
(
enterpriseDTO
);
applicationApiService
.
insertApplicationRelation
(
wxEnterpriseId
);
}
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
true
);
}
/**
* 初始化同步企业微信架构
*
* @return
*/
@RequestMapping
(
"init-wx-department"
)
public
HaobanResponse
initWxDepartment
()
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
WxEnterpriseDTO
enterpriseDTO
=
this
.
wxEnterpriseApiService
.
getOne
(
wxEnterpriseId
);
if
(
enterpriseDTO
!=
null
)
{
SecretSettingDTO
secretSetting
=
wxEnterpriseApiService
.
getSecretSetting
(
enterpriseDTO
.
getWxEnterpriseId
(),
SecretTypeEnum
.
HAOBAN_HELP
.
getVal
(),
null
);
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()
==
0
)
{
log
.
info
(
"没有配置secret"
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
false
);
}
if
(
StringUtils
.
isNotBlank
(
secretSetting
.
getSecretVal
())
&&
enterpriseDTO
.
getContactFlag
()
!=
null
)
{
String
taskId
=
dealSyncOperationApiService
.
createQywxTask
(
wxEnterpriseId
,
"后门同步企业微信架构"
,
login
.
getStaff
DTO
().
getStaffId
(),
"后门同步企业微信架构"
);
if
(
StringUtils
.
isBlank
(
taskId
))
{
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
false
);
}
dealSyncOperationApiService
.
dealQywxDepartment
(
taskId
,
wxEnterpriseId
);
}
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
true
);
}
@RequestMapping
(
"get-auth-url"
)
public
HaobanResponse
getAuthUrl
()
{
String
suiteId
=
config
.
getSuiteId
();
log
.
info
(
"应用ID:{}"
,
suiteId
);
String
redictUrl
=
config
.
getHost
()
+
"callback"
;
String
authorizationUrl
=
this
.
qywxSuiteApiService
.
getGrantAuthorizationUrl
(
suiteId
,
redictUrl
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
authorizationUrl
);
}
@RequestMapping
(
"callback"
)
public
void
callback
(
String
auth_code
,
HttpServletResponse
response
)
{
String
suiteId
=
config
.
getSuiteId
();
String
result
=
this
.
qywxSuiteApiService
.
corpAuth
(
suiteId
,
auth_code
);
log
.
info
(
"企业微信回调结果:{}. {}"
,
auth_code
,
result
);
QywxCorpInfoDTO
dto
=
JSON
.
parseObject
(
result
,
QywxCorpInfoDTO
.
class
);
WxApplicationDTO
applicationDTO
=
new
WxApplicationDTO
();
WxEnterpriseDTO
enterpriseDTO
=
this
.
wxEnterpriseApiService
.
getEnterpriseBycorpId
(
dto
.
getCorpid
());
if
(
enterpriseDTO
!=
null
)
{
applicationDTO
.
setName
(
dto
.
getAgentName
());
applicationDTO
.
setWxEnterpriseId
(
enterpriseDTO
.
getWxEnterpriseId
());
applicationDTO
.
setAgentId
(
dto
.
getAgentid
());
applicationDTO
.
setApplicationType
(
1
);
applicationDTO
.
setAgentName
(
dto
.
getAgentName
());
applicationDTO
.
setSiteId
(
dto
.
getSuiteId
());
wxApplicationApiService
.
addSuite
(
applicationDTO
);
SecretSettingDTO
secretSetting
=
wxEnterpriseApiService
.
getSecretSetting
(
enterpriseDTO
.
getWxEnterpriseId
(),
SecretTypeEnum
.
HAOBAN_HELP
.
getVal
(),
null
);
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()
==
0
)
{
log
.
info
(
"没有配置secret:{}"
,
JSONObject
.
toJSONString
(
enterpriseDTO
));
return
;
}
this
.
departmentApiService
.
initwxDepartment
(
dto
.
getCorpid
(),
secretSetting
.
getSecretVal
(),
enterpriseDTO
.
getWxEnterpriseId
());
enterpriseDTO
.
setContactFlag
(
1
);
wxEnterpriseApiService
.
update
(
enterpriseDTO
);
}
String
redirectUri
=
config
.
getHost
()
+
"index"
;
redirectUri
=
redirectUri
.
replace
(
"haoban-manage3-web"
,
"haoban-3/#"
);
try
{
response
.
sendRedirect
(
redirectUri
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
@RequestMapping
(
"cancal-suite"
)
@IgnoreLogin
public
HaobanResponse
cancelSuite
(
String
corpId
,
String
suiteId
)
{
this
.
wxApplicationApiService
.
cancelSuite
(
corpId
,
suiteId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_0
,
"s"
);
}
@RequestMapping
(
"list-external-user"
)
@IgnoreLogin
public
Object
list
(
String
corpid
,
String
suiteid
,
String
userid
)
{
return
this
.
qywxUserApiService
.
listExternalUserid
(
corpid
,
suiteid
,
userid
);
}
@RequestMapping
(
"corp-external-user"
)
@IgnoreLogin
public
Object
corpuserid
(
String
corpid
,
String
suiteid
)
{
return
this
.
qywxUserApiService
.
listCorpExternalUser
(
corpid
,
suiteid
);
}
@RequestMapping
(
"get-external-user-info"
)
@IgnoreLogin
public
Object
userInfo
(
String
corpid
,
String
suiteid
,
String
userid
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_0
,
this
.
qywxUserApiService
.
getExternalUseridInfo
(
corpid
,
suiteid
,
userid
));
}
@RequestMapping
(
"get-external-unionid"
)
@IgnoreLogin
public
Object
userInfoUninid
(
String
corpid
,
String
suiteid
,
String
unionid
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_0
,
this
.
qywxUserApiService
.
getExternalUseridByUnionid
(
corpid
,
suiteid
,
unionid
));
}
/**
* 通讯录同步
*
* @return
*/
@RequestMapping
(
"sync-qywx"
)
public
Object
syncQywx
()
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
WxEnterpriseDTO
enterpriseDTO
=
this
.
wxEnterpriseApiService
.
getOne
(
wxEnterpriseId
);
if
(
enterpriseDTO
!=
null
)
{
String
taskId
=
dealSyncOperationApiService
.
createQywxTask
(
wxEnterpriseId
,
"后门同步企业微信架构"
,
login
.
getStaff
DTO
().
getStaffId
(),
"后门同步企业微信架构"
);
if
(
StringUtils
.
isBlank
(
taskId
))
{
return
resultResponse
(
HaoBanErrCode
.
ERR_0
,
false
);
}
String
ret
=
dealSyncOperationApiService
.
dealQywxDepartment
(
taskId
,
wxEnterpriseId
);
if
(
null
!=
ret
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_0
,
ret
,
null
,
null
);
}
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
/**
* 初始化应用
*
* @param wxEnterpriseId
* @return
*/
@RequestMapping
(
"init-application-relation"
)
@IgnoreLogin
public
HaobanResponse
insertApplicationRelation
(
String
wxEnterpriseId
)
{
applicationApiService
.
insertApplicationRelation
(
wxEnterpriseId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
}
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO
;
import
com.gic.haoban.common.anno.IgnoreLogin
;
import
com.gic.haoban.common.utils.AuthWebRequestUtil
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.manage.api.dto.*
;
import
com.gic.haoban.manage.api.enums.SecretTypeEnum
;
import
com.gic.haoban.manage.api.service.*
;
import
com.gic.haoban.manage.web.config.Config
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.wechat.api.service.qywx.QywxSuiteApiService
;
import
com.gic.wechat.api.service.qywx.QywxUserApiService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@RestController
public
class
ApplicationController
extends
WebBaseController
{
private
static
final
Logger
log
=
LogManager
.
getLogger
(
ApplicationController
.
class
);
@Autowired
private
ApplicationApiService
applicationApiService
;
@Autowired
private
QywxSuiteApiService
qywxSuiteApiService
;
@Autowired
private
WxApplicationApiService
wxApplicationApiService
;
@Autowired
private
WxEnterpriseApiService
wxEnterpriseApiService
;
@Autowired
private
Config
config
;
@Autowired
private
DepartmentApiService
departmentApiService
;
@Autowired
private
ApplicationSettingApiService
applicationSettingApiService
;
@Autowired
private
DealSyncOperationApiService
dealSyncOperationApiService
;
@Autowired
private
QywxUserApiService
qywxUserApiService
;
@RequestMapping
(
"application-list"
)
public
HaobanResponse
applicationList
()
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
List
<
ApplicationDTO
>
list
=
applicationApiService
.
listApplicationByWxEnterpriseId
(
wxEnterpriseId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
list
);
}
@IgnoreLogin
@RequestMapping
(
"application-open-close-list"
)
public
HaobanResponse
applicationList
(
String
wxEnterpriseId
)
{
if
(
StringUtils
.
isAnyBlank
(
wxEnterpriseId
))
{
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
List
<
ApplicationDTO
>
list
=
applicationApiService
.
listApplicationByWxEnterpriseId
(
wxEnterpriseId
);
List
<
String
>
applicationIds
=
list
.
stream
().
map
(
s
->
s
.
getApplicationId
()).
collect
(
Collectors
.
toList
());
List
<
ApplicationSettingDTO
>
result
=
applicationSettingApiService
.
listOpenByWxEnterpriseIdAndApplicationIds
(
wxEnterpriseId
,
applicationIds
);
//开启
List
<
ApplicationDTO
>
openList
=
new
ArrayList
<
ApplicationDTO
>();
List
<
String
>
openApplicationIds
=
new
ArrayList
<>();
if
(
CollectionUtil
.
isNotEmpty
(
result
))
{
openApplicationIds
=
result
.
stream
().
map
(
s
->
s
.
getApplicationId
()).
collect
(
Collectors
.
toList
());
openList
=
applicationApiService
.
listByApplications
(
openApplicationIds
);
}
//关闭
List
<
ApplicationDTO
>
closeList
=
new
ArrayList
<
ApplicationDTO
>();
applicationIds
.
removeAll
(
openApplicationIds
);
if
(
CollectionUtil
.
isNotEmpty
(
applicationIds
))
{
closeList
=
applicationApiService
.
listByApplications
(
applicationIds
);
}
Object
o
=
RedisUtil
.
getCache
(
"haobanWxEnterpriseIdAppOpen"
);
String
wxEnterpriseIds
=
o
==
null
?
""
:
o
.
toString
();
if
(!
wxEnterpriseIds
.
contains
(
wxEnterpriseId
))
{
//不开启
Iterator
<
ApplicationDTO
>
it
=
openList
.
iterator
();
while
(
it
.
hasNext
())
{
ApplicationDTO
s
=
it
.
next
();
if
(
s
.
getApplicationName
().
contains
(
"内购券"
))
{
it
.
remove
();
}
}
Iterator
<
ApplicationDTO
>
it2
=
closeList
.
iterator
();
while
(
it2
.
hasNext
())
{
ApplicationDTO
s
=
it2
.
next
();
if
(
s
.
getApplicationName
().
contains
(
"内购券"
))
{
it2
.
remove
();
}
}
}
map
.
put
(
"open"
,
openList
);
map
.
put
(
"close"
,
closeList
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
map
);
}
@RequestMapping
(
"open-or-close"
)
public
HaobanResponse
applicationList
(
String
wxEnterpriseId
,
String
applicationId
,
Integer
openFlag
)
{
if
(
StringUtils
.
isAnyBlank
(
wxEnterpriseId
,
applicationId
))
{
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
if
(
openFlag
==
null
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
applicationSettingApiService
.
saveSetting
(
wxEnterpriseId
,
applicationId
,
openFlag
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
@RequestMapping
(
"has-bind-contract"
)
public
HaobanResponse
hasBindContract
()
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
WxEnterpriseDTO
enterpriseDTO
=
this
.
wxEnterpriseApiService
.
getOne
(
wxEnterpriseId
);
if
(
enterpriseDTO
!=
null
)
{
SecretSettingDTO
secretSetting
=
wxEnterpriseApiService
.
getSecretSetting
(
enterpriseDTO
.
getWxEnterpriseId
(),
SecretTypeEnum
.
HAOBAN_HELP
.
getVal
(),
null
);
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()
==
0
)
{
log
.
info
(
"没有配置secret:{}"
,
JSONObject
.
toJSONString
(
enterpriseDTO
));
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
true
);
}
if
(
enterpriseDTO
.
getContactFlag
()
!=
null
&&
enterpriseDTO
.
getContactFlag
()
==
0
)
{
String
taskId
=
dealSyncOperationApiService
.
createQywxTask
(
wxEnterpriseId
,
"同步企业微信架构"
,
login
.
getStaff
Id
(),
"首次同步企业微信架构"
);
if
(
StringUtils
.
isBlank
(
taskId
))
{
log
.
info
(
"【是否绑定】taskId={}"
,
taskId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
true
);
}
dealSyncOperationApiService
.
dealQywxDepartment
(
taskId
,
wxEnterpriseId
);
enterpriseDTO
.
setContactFlag
(
1
);
wxEnterpriseApiService
.
update
(
enterpriseDTO
);
applicationApiService
.
insertApplicationRelation
(
wxEnterpriseId
);
}
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
true
);
}
/**
* 初始化同步企业微信架构
*
* @return
*/
@RequestMapping
(
"init-wx-department"
)
public
HaobanResponse
initWxDepartment
()
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
WxEnterpriseDTO
enterpriseDTO
=
this
.
wxEnterpriseApiService
.
getOne
(
wxEnterpriseId
);
if
(
enterpriseDTO
!=
null
)
{
SecretSettingDTO
secretSetting
=
wxEnterpriseApiService
.
getSecretSetting
(
enterpriseDTO
.
getWxEnterpriseId
(),
SecretTypeEnum
.
HAOBAN_HELP
.
getVal
(),
null
);
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()
==
0
)
{
log
.
info
(
"没有配置secret"
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
false
);
}
if
(
StringUtils
.
isNotBlank
(
secretSetting
.
getSecretVal
())
&&
enterpriseDTO
.
getContactFlag
()
!=
null
)
{
String
taskId
=
dealSyncOperationApiService
.
createQywxTask
(
wxEnterpriseId
,
"后门同步企业微信架构"
,
login
.
getStaff
Id
(),
"后门同步企业微信架构"
);
if
(
StringUtils
.
isBlank
(
taskId
))
{
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
false
);
}
dealSyncOperationApiService
.
dealQywxDepartment
(
taskId
,
wxEnterpriseId
);
}
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
true
);
}
@RequestMapping
(
"get-auth-url"
)
public
HaobanResponse
getAuthUrl
()
{
String
suiteId
=
config
.
getSuiteId
();
log
.
info
(
"应用ID:{}"
,
suiteId
);
String
redictUrl
=
config
.
getHost
()
+
"callback"
;
String
authorizationUrl
=
this
.
qywxSuiteApiService
.
getGrantAuthorizationUrl
(
suiteId
,
redictUrl
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
authorizationUrl
);
}
@RequestMapping
(
"callback"
)
public
void
callback
(
String
auth_code
,
HttpServletResponse
response
)
{
String
suiteId
=
config
.
getSuiteId
();
String
result
=
this
.
qywxSuiteApiService
.
corpAuth
(
suiteId
,
auth_code
);
log
.
info
(
"企业微信回调结果:{}. {}"
,
auth_code
,
result
);
QywxCorpInfoDTO
dto
=
JSON
.
parseObject
(
result
,
QywxCorpInfoDTO
.
class
);
WxApplicationDTO
applicationDTO
=
new
WxApplicationDTO
();
WxEnterpriseDTO
enterpriseDTO
=
this
.
wxEnterpriseApiService
.
getEnterpriseBycorpId
(
dto
.
getCorpid
());
if
(
enterpriseDTO
!=
null
)
{
applicationDTO
.
setName
(
dto
.
getAgentName
());
applicationDTO
.
setWxEnterpriseId
(
enterpriseDTO
.
getWxEnterpriseId
());
applicationDTO
.
setAgentId
(
dto
.
getAgentid
());
applicationDTO
.
setApplicationType
(
1
);
applicationDTO
.
setAgentName
(
dto
.
getAgentName
());
applicationDTO
.
setSiteId
(
dto
.
getSuiteId
());
wxApplicationApiService
.
addSuite
(
applicationDTO
);
SecretSettingDTO
secretSetting
=
wxEnterpriseApiService
.
getSecretSetting
(
enterpriseDTO
.
getWxEnterpriseId
(),
SecretTypeEnum
.
HAOBAN_HELP
.
getVal
(),
null
);
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()
==
0
)
{
log
.
info
(
"没有配置secret:{}"
,
JSONObject
.
toJSONString
(
enterpriseDTO
));
return
;
}
this
.
departmentApiService
.
initwxDepartment
(
dto
.
getCorpid
(),
secretSetting
.
getSecretVal
(),
enterpriseDTO
.
getWxEnterpriseId
());
enterpriseDTO
.
setContactFlag
(
1
);
wxEnterpriseApiService
.
update
(
enterpriseDTO
);
}
String
redirectUri
=
config
.
getHost
()
+
"index"
;
redirectUri
=
redirectUri
.
replace
(
"haoban-manage3-web"
,
"haoban-3/#"
);
try
{
response
.
sendRedirect
(
redirectUri
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
@RequestMapping
(
"cancal-suite"
)
@IgnoreLogin
public
HaobanResponse
cancelSuite
(
String
corpId
,
String
suiteId
)
{
this
.
wxApplicationApiService
.
cancelSuite
(
corpId
,
suiteId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_0
,
"s"
);
}
@RequestMapping
(
"list-external-user"
)
@IgnoreLogin
public
Object
list
(
String
corpid
,
String
suiteid
,
String
userid
)
{
return
this
.
qywxUserApiService
.
listExternalUserid
(
corpid
,
suiteid
,
userid
);
}
@RequestMapping
(
"corp-external-user"
)
@IgnoreLogin
public
Object
corpuserid
(
String
corpid
,
String
suiteid
)
{
return
this
.
qywxUserApiService
.
listCorpExternalUser
(
corpid
,
suiteid
);
}
@RequestMapping
(
"get-external-user-info"
)
@IgnoreLogin
public
Object
userInfo
(
String
corpid
,
String
suiteid
,
String
userid
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_0
,
this
.
qywxUserApiService
.
getExternalUseridInfo
(
corpid
,
suiteid
,
userid
));
}
@RequestMapping
(
"get-external-unionid"
)
@IgnoreLogin
public
Object
userInfoUninid
(
String
corpid
,
String
suiteid
,
String
unionid
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_0
,
this
.
qywxUserApiService
.
getExternalUseridByUnionid
(
corpid
,
suiteid
,
unionid
));
}
/**
* 通讯录同步
*
* @return
*/
@RequestMapping
(
"sync-qywx"
)
public
Object
syncQywx
()
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
WxEnterpriseDTO
enterpriseDTO
=
this
.
wxEnterpriseApiService
.
getOne
(
wxEnterpriseId
);
if
(
enterpriseDTO
!=
null
)
{
String
taskId
=
dealSyncOperationApiService
.
createQywxTask
(
wxEnterpriseId
,
"后门同步企业微信架构"
,
login
.
getStaff
Id
(),
"后门同步企业微信架构"
);
if
(
StringUtils
.
isBlank
(
taskId
))
{
return
resultResponse
(
HaoBanErrCode
.
ERR_0
,
false
);
}
String
ret
=
dealSyncOperationApiService
.
dealQywxDepartment
(
taskId
,
wxEnterpriseId
);
if
(
null
!=
ret
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_0
,
ret
,
null
,
null
);
}
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
/**
* 初始化应用
*
* @param wxEnterpriseId
* @return
*/
@RequestMapping
(
"init-application-relation"
)
@IgnoreLogin
public
HaobanResponse
insertApplicationRelation
(
String
wxEnterpriseId
)
{
applicationApiService
.
insertApplicationRelation
(
wxEnterpriseId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
}
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/AuditController.java
View file @
fd55454e
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.api.base.commons.Page
;
import
com.gic.enterprise.api.dto.StoreDTO
;
import
com.gic.enterprise.api.service.StoreService
;
import
com.gic.haoban.base.api.common.BasePageInfo
;
import
com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO
;
import
com.gic.haoban.base.api.common.pojo.dto.WebStaffDTO
;
import
com.gic.haoban.common.anno.HttpLimit
;
import
com.gic.haoban.common.utils.AuthWebRequestUtil
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.common.utils.UuidUtil
;
import
com.gic.haoban.manage.api.dto.*
;
import
com.gic.haoban.manage.api.enums.StoreFieldEnum
;
import
com.gic.haoban.manage.api.service.AuditApiService
;
import
com.gic.haoban.manage.api.service.AuditSettingApiService
;
import
com.gic.haoban.manage.api.service.StaffApiService
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.haoban.manage.web.vo.BatchApproveVO
;
import
com.gic.redis.data.util.RedisUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@RestController
@RequestMapping
(
"/audit"
)
public
class
AuditController
extends
WebBaseController
{
private
static
final
Logger
log
=
LogManager
.
getLogger
(
AuditController
.
class
);
@Autowired
private
AuditSettingApiService
auditSettingApiService
;
@Autowired
private
AuditApiService
auditApiService
;
@Autowired
private
StaffApiService
staffApiService
;
@Autowired
private
StoreService
storeService
;
//设置保存
@HttpLimit
@RequestMapping
(
"open-or-close"
)
public
HaobanResponse
openOrClose
(
String
wxEnterpriseId
,
Integer
auditFlag
,
int
clerkChangeFlag
)
{
if
(
StringUtils
.
isAnyBlank
(
wxEnterpriseId
)){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
if
(
auditFlag
==
null
){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
auditSettingApiService
.
saveSetting
(
wxEnterpriseId
,
auditFlag
,
clerkChangeFlag
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
//设置查看
@RequestMapping
(
"find-setting"
)
public
HaobanResponse
findSetting
(
String
wxEnterpriseId
)
{
if
(
StringUtils
.
isAnyBlank
(
wxEnterpriseId
)){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
AuditSettingDTO
auditSettingDTO
=
auditSettingApiService
.
findSettingByWxEnterpriseId
(
wxEnterpriseId
);
if
(
auditSettingDTO
==
null
){
auditSettingDTO
=
new
AuditSettingDTO
();
auditSettingDTO
.
setAuditFlag
(
1
);
auditSettingDTO
.
setClerkChangeFlag
(
1
);
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
auditSettingDTO
);
}
//分页查找
@RequestMapping
(
"find-page"
)
public
HaobanResponse
findPage
(
String
wxEnterpriseId
,
String
enterpriseId
,
String
search
,
BasePageInfo
pageInfo
,
Integer
auditType
,
Integer
auditStatus
,
Integer
auditFlag
)
{
if
(
auditFlag
==
null
){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
if
(
StringUtils
.
isAnyBlank
(
wxEnterpriseId
)){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
Page
<
AuditDTO
>
page
=
auditApiService
.
page
(
auditType
,
search
,
wxEnterpriseId
,
enterpriseId
,
auditStatus
,
auditFlag
,
pageInfo
);
List
<
AuditDTO
>
list
=
page
.
getResult
();
List
<
String
>
storeIds
=
list
.
stream
().
map
(
s
->
s
.
getCommitStoreId
()).
collect
(
Collectors
.
toList
());
String
[]
array
=
storeIds
.
toArray
(
new
String
[
storeIds
.
size
()]);
List
<
StoreDTO
>
stores
=
storeService
.
getStores
(
array
);
Map
<
String
,
StoreDTO
>
map
=
com
.
gic
.
commons
.
util
.
CollectionUtil
.
toMap
(
stores
,
"storeId"
);
for
(
AuditDTO
dto:
list
){
if
(
dto
.
getAuditType
()
!=
null
&&
dto
.
getAuditType
()==
1
){
String
t
=
dto
.
getChangeField
();
String
detail
=
""
;
if
(
StoreFieldEnum
.
STORE_NAME
.
getValue
().
equals
(
t
)){
detail
=
"将"
+
"门店名称"
+
"\""
+
dto
.
getOldValue
()+
"\""
+
"修改为"
+
"\""
+
dto
.
getNewValue
()+
"\""
;
}
else
if
(
StoreFieldEnum
.
STORE_AREA
.
getValue
().
equals
(
t
)){
detail
=
"将"
+
"门店面积"
+
"\""
+
dto
.
getOldValue
()+
"\""
+
"修改为"
+
"\""
+
dto
.
getNewValue
()+
"\""
;
}
else
if
(
StoreFieldEnum
.
CONACTS_PHONE
.
getValue
().
equals
(
t
)){
detail
=
"将"
+
"联系电话"
+
"\""
+
dto
.
getOldValue
()+
"\""
+
"修改为"
+
"\""
+
dto
.
getNewValue
()+
"\""
;
}
else
if
(
StoreFieldEnum
.
BUSINESS_TIME_STRING
.
getValue
().
equals
(
t
)){
detail
=
"将"
+
"营业时间"
+
"\""
+
dto
.
getOldValue
()+
"\""
+
"修改为"
+
"\""
+
dto
.
getNewValue
()+
"\""
;
}
else
if
(
StoreFieldEnum
.
STORE_ADDRESS
.
getValue
().
equals
(
t
)){
String
oldValue
=
dto
.
getOldValue
();
String
newValue
=
dto
.
getNewValue
();
JSONObject
oldJSONObject
=
JSONObject
.
parseObject
(
oldValue
);
String
oldAddress
=
oldJSONObject
.
get
(
"storeAddress"
).
toString
();
JSONObject
newJSONObject
=
JSONObject
.
parseObject
(
newValue
);
String
newAddress
=
newJSONObject
.
get
(
"storeAddress"
).
toString
();
detail
=
"将"
+
"门店地址"
+
"\""
+
oldAddress
+
"\""
+
"修改为"
+
"\""
+
newAddress
+
"\""
;
}
else
if
(
StoreFieldEnum
.
STORE_IMAG
.
getValue
().
equals
(
t
)){
detail
=
"门店图片变更"
;
}
dto
.
setDetail
(
detail
);
}
else
if
(
dto
.
getAuditType
()
!=
null
&&
dto
.
getAuditType
()==
3
){
//新增导购
String
oldValue
=
dto
.
getOldValue
();
AuditStaffDTO
auditStaffDTO
=
JSONObject
.
parseObject
(
oldValue
,
AuditStaffDTO
.
class
);
String
detail
=
"新增导购:"
+
auditStaffDTO
.
getClerkName
()+
"("
+
auditStaffDTO
.
getClerkCode
()+
")"
;
dto
.
setDetail
(
detail
);
}
else
if
(
dto
.
getAuditType
()
!=
null
&&
dto
.
getAuditType
()==
4
){
//删除导购
String
oldValue
=
dto
.
getOldValue
();
AuditStaffDTO
auditStaffDTO
=
JSONObject
.
parseObject
(
oldValue
,
AuditStaffDTO
.
class
);
String
detail
=
"删除导购:"
+
auditStaffDTO
.
getClerkName
()+
"("
+
auditStaffDTO
.
getClerkCode
()+
")"
;
dto
.
setDetail
(
detail
);
}
else
if
(
dto
.
getAuditType
()
!=
null
&&
dto
.
getAuditType
()==
2
){
//门店导购绑定
String
oldValue
=
dto
.
getOldValue
();
AuditStaffDTO
oldAuditStaffDTO
=
JSONObject
.
parseObject
(
oldValue
,
AuditStaffDTO
.
class
);
String
staffName
=
oldAuditStaffDTO
.
getStaffName
();
String
clerkCode
=
oldAuditStaffDTO
.
getClerkCode
();
String
detail
=
staffName
+
"申请关联导购code:"
+
clerkCode
;
dto
.
setDetail
(
detail
);
}
else
if
(
dto
.
getAuditType
()
!=
null
&&
dto
.
getAuditType
()==
5
){
//门店导购解绑
String
oldValue
=
dto
.
getOldValue
();
AuditStaffDTO
oldAuditStaffDTO
=
JSONObject
.
parseObject
(
oldValue
,
AuditStaffDTO
.
class
);
String
staffName
=
oldAuditStaffDTO
.
getStaffName
();
String
clerkCode
=
oldAuditStaffDTO
.
getClerkCode
();
String
detail
=
staffName
+
"申请解绑导购code:"
+
clerkCode
;
dto
.
setDetail
(
detail
);
}
String
storeName
=
map
.
get
(
dto
.
getCommitStoreId
())==
null
?
""
:
map
.
get
(
dto
.
getCommitStoreId
()).
getStoreName
();
dto
.
setCommitStoreName
(
storeName
);
}
page
.
setResult
(
list
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
page
);
}
//获取详情
@RequestMapping
(
"get-staff-detail"
)
public
HaobanResponse
getStaffDetail
(
String
staffId
)
{
if
(
StringUtils
.
isAnyBlank
(
staffId
)){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
StaffDTO
staffDTO
=
staffApiService
.
selectById
(
staffId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
staffDTO
);
}
//批量同意
@HttpLimit
@RequestMapping
(
"batch-approve"
)
public
HaobanResponse
batchApprove
(
String
auditIds
,
String
auditName
)
{
if
(
StringUtils
.
isAnyBlank
(
auditIds
,
auditName
)){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
staffId
=
login
.
getStaffDTO
().
getStaffId
();
String
staffName
=
login
.
getStaffDTO
().
getStaffName
();
String
[]
s
=
auditIds
.
split
(
","
);
int
successCount
=
0
;
int
failCount
=
0
;
String
batchId
=
UuidUtil
.
randomUUID
();
for
(
String
auditId
:
s
){
String
result
=
auditApiService
.
audit
(
batchId
,
auditId
,
staffName
,
staffId
);
if
(
StringUtils
.
isEmpty
(
result
)){
successCount
=
successCount
+
1
;
}
else
{
failCount
=
failCount
+
1
;
}
}
BatchApproveVO
vo
=
new
BatchApproveVO
();
vo
.
setSuccessCount
(
successCount
);
vo
.
setFailCount
(
failCount
);
vo
.
setBatchId
(
batchId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
vo
);
}
//审核拒绝
@HttpLimit
@RequestMapping
(
"refuse"
)
public
HaobanResponse
refuse
(
String
auditId
,
String
auditReason
,
String
auditName
)
{
if
(
StringUtils
.
isAnyBlank
(
auditId
,
auditReason
,
auditName
)){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
staffId
=
login
.
getStaffDTO
().
getStaffId
();
String
staffName
=
login
.
getStaffDTO
().
getStaffName
();
auditApiService
.
refuse
(
auditId
,
auditReason
,
staffId
,
staffName
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
//审核同意
@HttpLimit
@RequestMapping
(
"audit"
)
public
HaobanResponse
audit
(
String
auditId
,
String
auditName
)
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
WebStaffDTO
loginStaffDTO
=
login
.
getStaffDTO
();
if
(
null
==
loginStaffDTO
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_4
);
}
String
staffId
=
login
.
getStaffDTO
().
getStaffId
();
String
staffName
=
login
.
getStaffDTO
().
getStaffName
();
if
(
StringUtils
.
isAnyBlank
(
auditId
)){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
String
key
=
"audit-"
+
auditId
;
RedisUtil
.
lock
(
key
,
10L
);
AuditDTO
audit
=
auditApiService
.
findById
(
auditId
);
if
(
audit
==
null
||
audit
.
getAuditStatus
()
!=
0
)
{
RedisUtil
.
unlock
(
key
);
return
resultResponse
(
HaoBanErrCode
.
ERR_10017
);
}
String
result
=
auditApiService
.
audit
(
""
,
auditId
,
staffName
,
staffId
);
RedisUtil
.
unlock
(
key
);
if
(
StringUtils
.
isEmpty
(
result
)){
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
else
{
HaoBanErrCode
errCode
=
HaoBanErrCode
.
ERR_DEFINE
;
errCode
.
setMsg
(
result
);
return
resultResponse
(
errCode
);
}
}
//批量审核详情
@HttpLimit
@RequestMapping
(
"audit-detail-list"
)
public
HaobanResponse
auditDetailList
(
String
batchId
)
{
if
(
StringUtils
.
isAnyBlank
(
batchId
)){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
List
<
BatchAuditLogDTO
>
list
=
auditApiService
.
listBatchLog
(
batchId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
list
);
}
}
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.api.base.commons.Page
;
import
com.gic.enterprise.api.dto.StoreDTO
;
import
com.gic.enterprise.api.service.StoreService
;
import
com.gic.haoban.base.api.common.BasePageInfo
;
import
com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO
;
import
com.gic.haoban.common.anno.HttpLimit
;
import
com.gic.haoban.common.utils.AuthWebRequestUtil
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.common.utils.UuidUtil
;
import
com.gic.haoban.manage.api.dto.*
;
import
com.gic.haoban.manage.api.enums.StoreFieldEnum
;
import
com.gic.haoban.manage.api.service.AuditApiService
;
import
com.gic.haoban.manage.api.service.AuditSettingApiService
;
import
com.gic.haoban.manage.api.service.StaffApiService
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.haoban.manage.web.vo.BatchApproveVO
;
import
com.gic.redis.data.util.RedisUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@RestController
@RequestMapping
(
"/audit"
)
public
class
AuditController
extends
WebBaseController
{
private
static
final
Logger
log
=
LogManager
.
getLogger
(
AuditController
.
class
);
@Autowired
private
AuditSettingApiService
auditSettingApiService
;
@Autowired
private
AuditApiService
auditApiService
;
@Autowired
private
StaffApiService
staffApiService
;
@Autowired
private
StoreService
storeService
;
//设置保存
@HttpLimit
@RequestMapping
(
"open-or-close"
)
public
HaobanResponse
openOrClose
(
String
wxEnterpriseId
,
Integer
auditFlag
,
int
clerkChangeFlag
)
{
if
(
StringUtils
.
isAnyBlank
(
wxEnterpriseId
)){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
if
(
auditFlag
==
null
){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
auditSettingApiService
.
saveSetting
(
wxEnterpriseId
,
auditFlag
,
clerkChangeFlag
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
//设置查看
@RequestMapping
(
"find-setting"
)
public
HaobanResponse
findSetting
(
String
wxEnterpriseId
)
{
if
(
StringUtils
.
isAnyBlank
(
wxEnterpriseId
)){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
AuditSettingDTO
auditSettingDTO
=
auditSettingApiService
.
findSettingByWxEnterpriseId
(
wxEnterpriseId
);
if
(
auditSettingDTO
==
null
){
auditSettingDTO
=
new
AuditSettingDTO
();
auditSettingDTO
.
setAuditFlag
(
1
);
auditSettingDTO
.
setClerkChangeFlag
(
1
);
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
auditSettingDTO
);
}
//分页查找
@RequestMapping
(
"find-page"
)
public
HaobanResponse
findPage
(
String
wxEnterpriseId
,
String
enterpriseId
,
String
search
,
BasePageInfo
pageInfo
,
Integer
auditType
,
Integer
auditStatus
,
Integer
auditFlag
)
{
if
(
auditFlag
==
null
){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
if
(
StringUtils
.
isAnyBlank
(
wxEnterpriseId
)){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
Page
<
AuditDTO
>
page
=
auditApiService
.
page
(
auditType
,
search
,
wxEnterpriseId
,
enterpriseId
,
auditStatus
,
auditFlag
,
pageInfo
);
List
<
AuditDTO
>
list
=
page
.
getResult
();
List
<
String
>
storeIds
=
list
.
stream
().
map
(
s
->
s
.
getCommitStoreId
()).
collect
(
Collectors
.
toList
());
String
[]
array
=
storeIds
.
toArray
(
new
String
[
storeIds
.
size
()]);
List
<
StoreDTO
>
stores
=
storeService
.
getStores
(
array
);
Map
<
String
,
StoreDTO
>
map
=
com
.
gic
.
commons
.
util
.
CollectionUtil
.
toMap
(
stores
,
"storeId"
);
for
(
AuditDTO
dto:
list
){
if
(
dto
.
getAuditType
()
!=
null
&&
dto
.
getAuditType
()==
1
){
String
t
=
dto
.
getChangeField
();
String
detail
=
""
;
if
(
StoreFieldEnum
.
STORE_NAME
.
getValue
().
equals
(
t
)){
detail
=
"将"
+
"门店名称"
+
"\""
+
dto
.
getOldValue
()+
"\""
+
"修改为"
+
"\""
+
dto
.
getNewValue
()+
"\""
;
}
else
if
(
StoreFieldEnum
.
STORE_AREA
.
getValue
().
equals
(
t
)){
detail
=
"将"
+
"门店面积"
+
"\""
+
dto
.
getOldValue
()+
"\""
+
"修改为"
+
"\""
+
dto
.
getNewValue
()+
"\""
;
}
else
if
(
StoreFieldEnum
.
CONACTS_PHONE
.
getValue
().
equals
(
t
)){
detail
=
"将"
+
"联系电话"
+
"\""
+
dto
.
getOldValue
()+
"\""
+
"修改为"
+
"\""
+
dto
.
getNewValue
()+
"\""
;
}
else
if
(
StoreFieldEnum
.
BUSINESS_TIME_STRING
.
getValue
().
equals
(
t
)){
detail
=
"将"
+
"营业时间"
+
"\""
+
dto
.
getOldValue
()+
"\""
+
"修改为"
+
"\""
+
dto
.
getNewValue
()+
"\""
;
}
else
if
(
StoreFieldEnum
.
STORE_ADDRESS
.
getValue
().
equals
(
t
)){
String
oldValue
=
dto
.
getOldValue
();
String
newValue
=
dto
.
getNewValue
();
JSONObject
oldJSONObject
=
JSONObject
.
parseObject
(
oldValue
);
String
oldAddress
=
oldJSONObject
.
get
(
"storeAddress"
).
toString
();
JSONObject
newJSONObject
=
JSONObject
.
parseObject
(
newValue
);
String
newAddress
=
newJSONObject
.
get
(
"storeAddress"
).
toString
();
detail
=
"将"
+
"门店地址"
+
"\""
+
oldAddress
+
"\""
+
"修改为"
+
"\""
+
newAddress
+
"\""
;
}
else
if
(
StoreFieldEnum
.
STORE_IMAG
.
getValue
().
equals
(
t
)){
detail
=
"门店图片变更"
;
}
dto
.
setDetail
(
detail
);
}
else
if
(
dto
.
getAuditType
()
!=
null
&&
dto
.
getAuditType
()==
3
){
//新增导购
String
oldValue
=
dto
.
getOldValue
();
AuditStaffDTO
auditStaffDTO
=
JSONObject
.
parseObject
(
oldValue
,
AuditStaffDTO
.
class
);
String
detail
=
"新增导购:"
+
auditStaffDTO
.
getClerkName
()+
"("
+
auditStaffDTO
.
getClerkCode
()+
")"
;
dto
.
setDetail
(
detail
);
}
else
if
(
dto
.
getAuditType
()
!=
null
&&
dto
.
getAuditType
()==
4
){
//删除导购
String
oldValue
=
dto
.
getOldValue
();
AuditStaffDTO
auditStaffDTO
=
JSONObject
.
parseObject
(
oldValue
,
AuditStaffDTO
.
class
);
String
detail
=
"删除导购:"
+
auditStaffDTO
.
getClerkName
()+
"("
+
auditStaffDTO
.
getClerkCode
()+
")"
;
dto
.
setDetail
(
detail
);
}
else
if
(
dto
.
getAuditType
()
!=
null
&&
dto
.
getAuditType
()==
2
){
//门店导购绑定
String
oldValue
=
dto
.
getOldValue
();
AuditStaffDTO
oldAuditStaffDTO
=
JSONObject
.
parseObject
(
oldValue
,
AuditStaffDTO
.
class
);
String
staffName
=
oldAuditStaffDTO
.
getStaffName
();
String
clerkCode
=
oldAuditStaffDTO
.
getClerkCode
();
String
detail
=
staffName
+
"申请关联导购code:"
+
clerkCode
;
dto
.
setDetail
(
detail
);
}
else
if
(
dto
.
getAuditType
()
!=
null
&&
dto
.
getAuditType
()==
5
){
//门店导购解绑
String
oldValue
=
dto
.
getOldValue
();
AuditStaffDTO
oldAuditStaffDTO
=
JSONObject
.
parseObject
(
oldValue
,
AuditStaffDTO
.
class
);
String
staffName
=
oldAuditStaffDTO
.
getStaffName
();
String
clerkCode
=
oldAuditStaffDTO
.
getClerkCode
();
String
detail
=
staffName
+
"申请解绑导购code:"
+
clerkCode
;
dto
.
setDetail
(
detail
);
}
String
storeName
=
map
.
get
(
dto
.
getCommitStoreId
())==
null
?
""
:
map
.
get
(
dto
.
getCommitStoreId
()).
getStoreName
();
dto
.
setCommitStoreName
(
storeName
);
}
page
.
setResult
(
list
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
page
);
}
//获取详情
@RequestMapping
(
"get-staff-detail"
)
public
HaobanResponse
getStaffDetail
(
String
staffId
)
{
if
(
StringUtils
.
isAnyBlank
(
staffId
)){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
StaffDTO
staffDTO
=
staffApiService
.
selectById
(
staffId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
staffDTO
);
}
//批量同意
@HttpLimit
@RequestMapping
(
"batch-approve"
)
public
HaobanResponse
batchApprove
(
String
auditIds
,
String
auditName
)
{
if
(
StringUtils
.
isAnyBlank
(
auditIds
,
auditName
)){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
staffId
=
login
.
getStaffId
();
String
staffName
=
login
.
getStaffName
();
String
[]
s
=
auditIds
.
split
(
","
);
int
successCount
=
0
;
int
failCount
=
0
;
String
batchId
=
UuidUtil
.
randomUUID
();
for
(
String
auditId
:
s
){
String
result
=
auditApiService
.
audit
(
batchId
,
auditId
,
staffName
,
staffId
);
if
(
StringUtils
.
isEmpty
(
result
)){
successCount
=
successCount
+
1
;
}
else
{
failCount
=
failCount
+
1
;
}
}
BatchApproveVO
vo
=
new
BatchApproveVO
();
vo
.
setSuccessCount
(
successCount
);
vo
.
setFailCount
(
failCount
);
vo
.
setBatchId
(
batchId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
vo
);
}
//审核拒绝
@HttpLimit
@RequestMapping
(
"refuse"
)
public
HaobanResponse
refuse
(
String
auditId
,
String
auditReason
,
String
auditName
)
{
if
(
StringUtils
.
isAnyBlank
(
auditId
,
auditReason
,
auditName
)){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
staffId
=
login
.
getStaffId
();
String
staffName
=
login
.
getStaffName
();
auditApiService
.
refuse
(
auditId
,
auditReason
,
staffId
,
staffName
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
//审核同意
@HttpLimit
@RequestMapping
(
"audit"
)
public
HaobanResponse
audit
(
String
auditId
,
String
auditName
)
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
staffId
=
login
.
getStaffId
();
String
staffName
=
login
.
getStaffName
();
if
(
StringUtils
.
isAnyBlank
(
auditId
)){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
String
key
=
"audit-"
+
auditId
;
RedisUtil
.
lock
(
key
,
10L
);
AuditDTO
audit
=
auditApiService
.
findById
(
auditId
);
if
(
audit
==
null
||
audit
.
getAuditStatus
()
!=
0
)
{
RedisUtil
.
unlock
(
key
);
return
resultResponse
(
HaoBanErrCode
.
ERR_10017
);
}
String
result
=
auditApiService
.
audit
(
""
,
auditId
,
staffName
,
staffId
);
RedisUtil
.
unlock
(
key
);
if
(
StringUtils
.
isEmpty
(
result
)){
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
else
{
HaoBanErrCode
errCode
=
HaoBanErrCode
.
ERR_DEFINE
;
errCode
.
setMsg
(
result
);
return
resultResponse
(
errCode
);
}
}
//批量审核详情
@HttpLimit
@RequestMapping
(
"audit-detail-list"
)
public
HaobanResponse
auditDetailList
(
String
batchId
)
{
if
(
StringUtils
.
isAnyBlank
(
batchId
)){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
List
<
BatchAuditLogDTO
>
list
=
auditApiService
.
listBatchLog
(
batchId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
list
);
}
}
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/GicDepartmentController.java
View file @
fd55454e
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.gic.enterprise.api.dto.PowerStoreGroupDTO
;
import
com.gic.enterprise.api.service.StoreGroupService
;
import
com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO
;
import
com.gic.haoban.common.utils.AuthWebRequestUtil
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.manage.api.dto.LoginDTO
;
import
com.gic.haoban.manage.api.dto.StoreRangeInfoDTO
;
import
com.gic.haoban.manage.api.dto.WxEnterpriseDTO
;
import
com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.haoban.manage.web.vo.StoreGroupVo
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@RestController
public
class
GicDepartmentController
extends
WebBaseController
{
...
...
@@ -42,7 +44,7 @@ public class GicDepartmentController extends WebBaseController{
@RequestMapping
(
"gic-store-group-list"
)
public
HaobanResponse
storeGroupList
(
String
enterpriseId
,
String
keyWord
)
{
LoginDTO
loginUser
=
this
.
getLoginUser
();
WebLoginDTO
loginUser
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
loginUser
.
getWxEnterpriseId
();
List
<
PowerStoreGroupDTO
>
departmentList
=
storeGroupService
.
getStoreGroupList
(
enterpriseId
,
keyWord
);
List
<
StoreRangeInfoDTO
>
rangeInfoDTOList
=
wxEnterpriseRelatedApiService
.
listAllBindStoreOrGroup
(
enterpriseId
);
...
...
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/LoginController.java
View file @
fd55454e
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
import
cn.hutool.crypto.SecureUtil
;
import
cn.hutool.crypto.symmetric.AES
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.view.RedirectView
;
import
com.alibaba.dubbo.common.URL
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.clerk.api.dto.ClerkDTO
;
import
com.gic.clerk.api.dto.PowerClerkDTO
;
import
com.gic.clerk.api.service.ClerkService
;
import
com.gic.clerk.api.service.UserService
;
import
com.gic.commons.util.ToolUtil
;
import
com.gic.enterprise.api.dto.EnterpriseDTO
;
import
com.gic.enterprise.api.service.EnterpriseService
;
import
com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO
;
import
com.gic.haoban.common.anno.IgnoreLogin
;
import
com.gic.haoban.common.utils.AuthWebRequestUtil
;
import
com.gic.haoban.common.utils.EntityUtil
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.manage.api.dto.EnterpriseDetailDTO
;
import
com.gic.haoban.manage.api.dto.LoginDTO
;
import
com.gic.haoban.manage.api.dto.StaffDTO
;
import
com.gic.haoban.manage.api.dto.WxApplicationDTO
;
import
com.gic.haoban.manage.api.dto.WxEnterpriseDTO
;
...
...
@@ -27,31 +46,14 @@ import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import
com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService
;
import
com.gic.haoban.manage.web.config.Config
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.haoban.manage.web.vo.StaffVO
;
import
com.gic.haoban.manage.web.vo.WebLoginVO
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.wechat.api.dto.qywx.UserDTO
;
import
com.gic.wechat.api.service.qywx.QywxCorpApiService
;
import
com.gic.wechat.api.service.qywx.QywxSuiteApiService
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.view.RedirectView
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
cn.hutool.crypto.SecureUtil
;
import
cn.hutool.crypto.symmetric.AES
;
@RestController
public
class
LoginController
extends
WebBaseController
{
...
...
@@ -69,8 +71,6 @@ public class LoginController extends WebBaseController {
@Autowired
private
WxEnterpriseRelatedApiService
wxEnterpriseRelatedApiService
;
@Autowired
private
QywxSuiteApiService
qywxSuiteApiService
;
@Autowired
private
WxApplicationApiService
wxApplicationApiService
;
@Autowired
private
UserService
userService
;
...
...
@@ -78,6 +78,8 @@ public class LoginController extends WebBaseController {
private
Config
config
;
@Autowired
private
ClerkService
clerkService
;
@Autowired
private
EnterpriseService
enterpriseService
;
/**
* 企微后台登录
...
...
@@ -88,50 +90,44 @@ public class LoginController extends WebBaseController {
public
void
login
(
String
auth_code
,
HttpServletResponse
response
)
{
String
userJson
=
qywxCorpApiService
.
getLoginUserInfo
(
config
.
getCorpid
(),
auth_code
);
if
(
StringUtils
.
isBlank
(
userJson
))
{
logger
.
info
(
"未查询到用户:auth_code:{}"
,
auth_code
);
logger
.
info
(
"未查询到用户:auth_code:{}"
,
auth_code
);
return
;
}
UserDTO
user
=
JSON
.
parseObject
(
userJson
,
UserDTO
.
class
);
String
corpId
=
user
.
getCorpid
();
logger
.
info
(
"【企业微信登录】userId={},auth_code={},corpId={}"
,
user
.
getUserid
(),
auth_code
,
corpId
);
WxEnterpriseDTO
e
nterprise
=
wxEnterpriseApiService
.
getEnterpriseBycorpId
(
corpId
);
logger
.
info
(
"【企业微信】enterprise={}"
,
JSON
.
toJSONString
(
e
nterprise
));
WxEnterpriseDTO
wxE
nterprise
=
wxEnterpriseApiService
.
getEnterpriseBycorpId
(
corpId
);
logger
.
info
(
"【企业微信】enterprise={}"
,
JSON
.
toJSONString
(
wxE
nterprise
));
StaffDTO
loginStaff
=
null
;
if
(
enterprise
!=
null
)
{
loginStaff
=
staffApiService
.
selectByUserIdAndEnterpriseId
(
user
.
getUserid
(),
enterprise
.
getWxEnterpriseId
());
if
(
wxEnterprise
!=
null
)
{
loginStaff
=
staffApiService
.
selectByUserIdAndEnterpriseId
(
user
.
getUserid
(),
wxEnterprise
.
getWxEnterpriseId
());
}
if
(
loginStaff
==
null
)
{
if
(
enterprise
!=
null
)
{
staffApiService
.
wxFristAdd
(
JSON
.
toJSONString
(
user
),
enterprise
.
getWxEnterpriseId
());
loginStaff
=
staffApiService
.
selectByUserIdAndEnterpriseId
(
user
.
getUserid
(),
enterprise
.
getWxEnterpriseId
());
if
(
wxEnterprise
!=
null
)
{
staffApiService
.
wxFristAdd
(
JSON
.
toJSONString
(
user
),
wxEnterprise
.
getWxEnterpriseId
());
loginStaff
=
staffApiService
.
selectByUserIdAndEnterpriseId
(
user
.
getUserid
(),
wxEnterprise
.
getWxEnterpriseId
());
}
}
LoginDTO
loginVO
=
new
LoginDTO
();
logger
.
info
(
"【好办web登录】staff={}"
,
JSON
.
toJSONString
(
loginStaff
));
if
(
loginStaff
==
null
)
{
return
;
}
loginVO
.
setWxEnterpriseId
(
loginStaff
.
getWxEnterpriseId
());
loginVO
.
setStaffDTO
(
loginStaff
);
WebLoginDTO
webLoginDTO
=
EntityUtil
.
changeEntityByOrika
(
WebLoginDTO
.
class
,
loginVO
);
AuthWebRequestUtil
.
setSessionUser
(
webLoginDTO
);
String
redirectUri
=
config
.
getHost
()
+
"index"
;
redirectUri
=
redirectUri
.
replace
(
"haoban-manage3-web"
,
"haoban-3/#"
);
String
token
=
ToolUtil
.
randomUUID
()
+
"-"
+
ToolUtil
.
randomStringByTime
();
AuthWebRequestUtil
.
setAppLoginUser
(
token
,
webLoginDTO
);
try
{
Cookie
cookie
=
new
Cookie
(
"token"
,
token
);
cookie
.
setPath
(
"/"
);
response
.
addCookie
(
cookie
);
response
.
sendRedirect
(
redirectUri
);
response
.
setHeader
(
"token"
,
token
);
}
catch
(
IOException
e
)
{
logger
.
warn
(
"异常"
,
e
);
String
wxEnterpriseId
=
wxEnterprise
.
getWxEnterpriseId
();
List
<
EnterpriseDetailDTO
>
list
=
this
.
wxEnterpriseRelatedApiService
.
listEnterpriseByWxEnterpriseId
(
wxEnterpriseId
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
logger
.
info
(
"企微下无关联GIC商户"
);
return
;
}
String
gicEnterpriseId
=
list
.
get
(
0
).
getEnterpriseId
();
String
loginPhoneNumber
=
loginStaff
.
getPhoneNumber
();
if
(
StringUtils
.
isBlank
(
loginPhoneNumber
))
{
logger
.
info
(
"未配置手机号,staffId ={}"
,
loginStaff
.
getStaffId
());
return
;
}
this
.
doLogin
(
wxEnterpriseId
,
gicEnterpriseId
,
loginPhoneNumber
,
"gic"
,
response
);
}
/**
...
...
@@ -144,26 +140,28 @@ public class LoginController extends WebBaseController {
*/
@IgnoreLogin
@RequestMapping
(
"yw-login"
)
public
HaobanResponse
ywLogin
(
String
enterpriseId
,
String
wxEnterpriseId
,
String
random
,
HttpServletResponse
response
)
{
//判断是否存在random
public
HaobanResponse
ywLogin
(
String
enterpriseId
,
String
wxEnterpriseId
,
String
random
,
HttpServletResponse
response
)
{
// 判断是否存在random
Object
o
=
RedisUtil
.
getCache
(
random
);
if
(
o
==
null
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_4
);
}
if
(
StringUtils
.
isBlank
(
enterpriseId
))
{
List
<
EnterpriseDetailDTO
>
list
=
this
.
wxEnterpriseRelatedApiService
.
listEnterpriseByWxEnterpriseId
(
wxEnterpriseId
)
;
if
(
CollectionUtils
.
isEmpty
(
list
))
{
if
(
StringUtils
.
isBlank
(
enterpriseId
))
{
List
<
EnterpriseDetailDTO
>
list
=
this
.
wxEnterpriseRelatedApiService
.
listEnterpriseByWxEnterpriseId
(
wxEnterpriseId
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
resultResponse
(
HaoBanErrCode
.
ERR_4
);
}
enterpriseId
=
list
.
get
(
0
).
getEnterpriseId
()
;
enterpriseId
=
list
.
get
(
0
).
getEnterpriseId
();
}
String
gicSuperPhone
=
clerkService
.
getSuperAdminPhoneNumber
(
enterpriseId
)
;
logger
.
info
(
"登录商户id={},超管手机={}"
,
enterpriseId
,
gicSuperPhone
);
String
result
=
this
.
doLogin
(
wxEnterpriseId
,
enterpriseId
,
gicSuperPhone
,
response
)
;
if
(
StringUtils
.
isNotBlank
(
result
))
{
return
resultResponse
(
HaoBanErrCode
.
ERR_4
);
String
gicSuperPhone
=
clerkService
.
getSuperAdminPhoneNumber
(
enterpriseId
);
logger
.
info
(
"登录商户id={},超管手机={}"
,
enterpriseId
,
gicSuperPhone
);
String
result
=
this
.
doLogin
(
wxEnterpriseId
,
enterpriseId
,
gicSuperPhone
,
"yw"
,
response
)
;
if
(
StringUtils
.
isNotBlank
(
result
))
{
return
this
.
fail
(
result
);
}
return
null
;
return
null
;
}
/**
...
...
@@ -177,7 +175,7 @@ public class LoginController extends WebBaseController {
@IgnoreLogin
@RequestMapping
(
"gic-login"
)
public
ModelAndView
gicLogin
(
String
random
,
String
wxEnterpriseId
,
HttpServletResponse
response
)
{
//判断是否存在random
//
判断是否存在random
AES
aes
=
SecureUtil
.
aes
(
LOGIN_KEY
.
getBytes
());
String
o
=
aes
.
decryptStr
(
random
);
if
(
o
==
null
||
StringUtils
.
isBlank
(
wxEnterpriseId
))
{
...
...
@@ -195,149 +193,58 @@ public class LoginController extends WebBaseController {
return
model
;
}
WxEnterpriseDTO
detailDTO
=
enterpriseDTOList
.
stream
().
filter
(
dto
->
dto
.
getWxEnterpriseId
().
equals
(
wxEnterpriseId
)).
findFirst
().
orElse
(
null
);
WxEnterpriseDTO
detailDTO
=
enterpriseDTOList
.
stream
()
.
filter
(
dto
->
dto
.
getWxEnterpriseId
().
equals
(
wxEnterpriseId
)).
findFirst
().
orElse
(
null
);
if
(
null
==
detailDTO
)
{
logger
.
info
(
"登录失败,不存在对应企业:gicEnterpriseId:{}"
,
gicEnterpriseId
);
ModelAndView
model
=
new
ModelAndView
(
new
RedirectView
(
"/haoban-3/#/gic-error"
,
false
,
false
));
return
model
;
}
String
result
=
this
.
doLogin
(
wxEnterpriseId
,
gicEnterpriseId
,
loginPhoneNumber
,
response
)
;
if
(
StringUtils
.
isNotBlank
(
result
))
{
ModelAndView
model
=
new
ModelAndView
(
new
RedirectView
(
"/haoban-3/#/gic-error"
,
false
,
false
));
return
model
;
}
/* StaffDTO staff = staffApiService.selectByNationcodeAndPhoneNumber(detailDTO.getWxEnterpriseId(), "86", loginPhoneNumber);
if (null == staff) {
logger.info("登录用户手机号不存在!gicEnterpriseId:{}", gicEnterpriseId);
logger
.
info
(
"登录失败,不存在对应企业:gicEnterpriseId:{}"
,
gicEnterpriseId
);
ModelAndView
model
=
new
ModelAndView
(
new
RedirectView
(
"/haoban-3/#/gic-error"
,
false
,
false
));
return
model
;
}
WxApplicationDTO application = wxApplicationApiService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId, 2);
if (null == application) {
logger.info("登录企业应用 没授权!gicEnterpriseId:{}",gicEnterpriseId);
ModelAndView model = new ModelAndView(new RedirectView("/haoban-3/#/gic-error", false, false));
return model;
}
WxEnterpriseDTO enterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
if (null == enterprise) {
logger.info("登录失败,不存在对应企业:wxEnterpriseId{}", wxEnterpriseId);
String
result
=
this
.
doLogin
(
wxEnterpriseId
,
gicEnterpriseId
,
loginPhoneNumber
,
"gic"
,
response
);
if
(
StringUtils
.
isNotBlank
(
result
))
{
ModelAndView
model
=
new
ModelAndView
(
new
RedirectView
(
"/haoban-3/#/gic-error"
,
false
,
false
));
return
model
;
}
//获取管理员列表
String corpid = enterprise.getCorpid();
String adminList = qywxSuiteApiService.getAdminList(corpid, application.getSiteId(), Integer.parseInt(application.getAgentId()));
List<String> userIds = new ArrayList<String>();
if (StringUtils.isNotBlank(adminList)) {
JSONArray jsonArr = JSON.parseArray(adminList);
for (Object object : jsonArr) {
JSONObject json = JSON.parseObject(JSON.toJSONString(object));
userIds.add(json.getString("userid"));
}
}
//兼容
if (corpid.length() > 20) {
if (!userIds.contains(staff.getWxOpenUseId())) {
logger.info("登录失败,当前用户不是管理员:{}", JSON.toJSONString(userIds));
ModelAndView model = new ModelAndView(new RedirectView("/haoban-3/#/gic-error", false, false));
return model;
}
} else {
if (!userIds.contains(staff.getWxUserId())) {
logger.info("登录失败,当前用户不是管理员:{}", JSON.toJSONString(userIds));
ModelAndView model = new ModelAndView(new RedirectView("/haoban-3/#/gic-error", false, false));
return model;
}
}
LoginDTO loginDTO = new LoginDTO();
loginDTO.setWxEnterpriseId(detailDTO.getWxEnterpriseId());
loginDTO.setEnterpriseId(gicEnterpriseId);
//导购id
ClerkDTO clerk = clerkService.getClerkByPhoneNumber(loginPhoneNumber, gicEnterpriseId);
if (clerk != null) {
staff.setClerkId(clerk.getClerkId());
staff.setClerkName(clerk.getClerkName());
staff.setClerkCode(clerk.getClerkCode());
}
loginDTO.setStaffDTO(staff);
String redirectUri = config.getHost() + "index";
redirectUri = redirectUri.replace("haoban-manage3-web", "haoban-3/#");
String token = ToolUtil.randomUUID() + "-" + ToolUtil.randomStringByTime();
WebLoginDTO webLoginDTO = EntityUtil.changeEntityByOrika(WebLoginDTO.class, loginDTO);
AuthWebRequestUtil.setSessionUser(webLoginDTO);
AuthWebRequestUtil.setAppLoginUser(token, webLoginDTO);
try {
Cookie cookie = new Cookie("token", token);
cookie.setPath("/");
response.addCookie(cookie);
response.sendRedirect(redirectUri);
response.setHeader("token", token);
} catch (IOException e) {
e.printStackTrace();
}*/
return
null
;
}
private
String
doLogin
(
String
wxEnterpriseId
,
String
gicEnterpriseId
,
String
loginPhoneNumber
,
HttpServletResponse
response
)
{
private
String
doLogin
(
String
wxEnterpriseId
,
String
gicEnterpriseId
,
String
loginPhoneNumber
,
String
loginChannel
,
HttpServletResponse
response
)
{
StaffDTO
staff
=
staffApiService
.
selectByNationcodeAndPhoneNumber
(
wxEnterpriseId
,
"86"
,
loginPhoneNumber
);
if
(
null
==
staff
)
{
logger
.
info
(
"登录用户手机号不存在!gicEnterpriseId:{}"
,
gicEnterpriseId
);
return
"登录
用户手机号不存在
"
;
return
"登录
失败,好办用户手机号不存在("
+
loginPhoneNumber
+
")
"
;
}
WxApplicationDTO
application
=
wxApplicationApiService
.
selectByWxEnterpriseIdAndApplicationType
(
wxEnterpriseId
,
2
);
WxApplicationDTO
application
=
wxApplicationApiService
.
selectByWxEnterpriseIdAndApplicationType
(
wxEnterpriseId
,
2
);
if
(
null
==
application
)
{
logger
.
info
(
"登录企业应用 没授权!gicEnterpriseId:{}"
,
gicEnterpriseId
);
return
"登录
企业应用
没授权"
;
logger
.
info
(
"登录企业应用 没授权!gicEnterpriseId:{}"
,
gicEnterpriseId
);
return
"登录
失败,企业应用
没授权"
;
}
WxEnterpriseDTO
enterprise
=
wxEnterpriseApiService
.
getOne
(
wxEnterpriseId
);
if
(
null
==
enterprise
)
{
logger
.
info
(
"登录失败,不存在对应企业:wxEnterpriseId{}"
,
wxEnterpriseId
);
return
"登录失败,不存在对应企业"
;
}
//获取管理员列表
String
corpid
=
enterprise
.
getCorpid
();
String
adminList
=
qywxSuiteApiService
.
getAdminList
(
corpid
,
application
.
getSiteId
(),
Integer
.
parseInt
(
application
.
getAgentId
()));
List
<
String
>
userIds
=
new
ArrayList
<
String
>();
if
(
StringUtils
.
isNotBlank
(
adminList
))
{
JSONArray
jsonArr
=
JSON
.
parseArray
(
adminList
);
for
(
Object
object
:
jsonArr
)
{
JSONObject
json
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
object
));
userIds
.
add
(
json
.
getString
(
"userid"
));
}
return
"登录失败,不存在对应企业"
;
}
//兼容
if
(
corpid
.
length
()
>
20
)
{
if
(!
userIds
.
contains
(
staff
.
getWxOpenUseId
()))
{
logger
.
info
(
"登录失败,当前用户不是管理员:{}"
,
JSON
.
toJSONString
(
userIds
));
return
"登录失败,当前用户不是管理员"
;
}
}
else
{
if
(!
userIds
.
contains
(
staff
.
getWxUserId
()))
{
logger
.
info
(
"登录失败,当前用户不是管理员:{}"
,
JSON
.
toJSONString
(
userIds
));
return
"登录失败,当前用户不是管理员"
;
}
}
LoginDTO
loginDTO
=
new
LoginDTO
();
loginDTO
.
setWxEnterpriseId
(
wxEnterpriseId
);
loginDTO
.
setEnterpriseId
(
gicEnterpriseId
);
//导购id
WebLoginDTO
webLoginDTO
=
EntityUtil
.
changeEntityByJSON
(
WebLoginDTO
.
class
,
staff
);
webLoginDTO
.
setWxEnterpriseId
(
wxEnterpriseId
);
webLoginDTO
.
setEnterpriseId
(
gicEnterpriseId
);
// 导购id
ClerkDTO
clerk
=
clerkService
.
getClerkByPhoneNumber
(
loginPhoneNumber
,
gicEnterpriseId
);
if
(
clerk
!=
null
)
{
staff
.
setClerkId
(
clerk
.
getClerkId
());
staff
.
setClerkName
(
clerk
.
getClerkName
());
staff
.
setClerkCode
(
clerk
.
getClerkCode
());
}
loginDTO
.
setStaffDTO
(
staff
);
if
(
clerk
==
null
)
{
logger
.
info
(
"gic账号不存在,eid={},phone={}"
,
gicEnterpriseId
,
loginPhoneNumber
);
return
"登录失败,gic账号不存在"
;
}
EnterpriseDTO
en
=
this
.
enterpriseService
.
getEnterpriseById
(
gicEnterpriseId
)
;
webLoginDTO
.
setLoginChannel
(
loginChannel
);
webLoginDTO
.
setClerkId
(
clerk
.
getClerkId
());
webLoginDTO
.
setClerkName
(
clerk
.
getClerkName
());
webLoginDTO
.
setBrandName
(
en
.
getBrandName
());
String
redirectUri
=
config
.
getHost
()
+
"index"
;
redirectUri
=
redirectUri
.
replace
(
"haoban-manage3-web"
,
"haoban-3/#"
);
String
token
=
ToolUtil
.
randomUUID
()
+
"-"
+
ToolUtil
.
randomStringByTime
();
WebLoginDTO
webLoginDTO
=
EntityUtil
.
changeEntityByOrika
(
WebLoginDTO
.
class
,
loginDTO
);
AuthWebRequestUtil
.
setSessionUser
(
webLoginDTO
);
AuthWebRequestUtil
.
setAppLoginUser
(
token
,
webLoginDTO
);
try
{
...
...
@@ -350,48 +257,57 @@ public class LoginController extends WebBaseController {
e
.
printStackTrace
();
}
return
null
;
}
@RequestMapping
(
"login_local"
)
@Deprecated
public
HaobanResponse
login
()
{
LoginDTO
loginVO
=
new
LoginDTO
();
StaffDTO
staff
=
staffApiService
.
selectById
(
"2205f92cdb5f468cb996e91dded414c2"
);
String
token
=
ToolUtil
.
randomUUID
()
+
"-"
+
ToolUtil
.
randomStringByTime
();
logger
.
info
(
"【好办登录】staff={}"
,
JSON
.
toJSONString
(
staff
));
loginVO
.
setWxEnterpriseId
(
staff
.
getWxEnterpriseId
());
loginVO
.
setStaffDTO
(
staff
);
AuthWebRequestUtil
.
setAppLoginUser
(
token
,
EntityUtil
.
changeEntityByOrika
(
WebLoginDTO
.
class
,
loginVO
));
Cookie
cookie
=
new
Cookie
(
"token"
,
token
);
cookie
.
setPath
(
"/"
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
loginVO
);
}
/**
* 获取登录信息
*
* @return res
*/
@RequestMapping
(
"get-login-info"
)
public
HaobanResponse
getLoginInfo
()
{
WebLoginDTO
loginUser
=
AuthWebRequestUtil
.
getLoginUser
();
String
phoneNumber
=
loginUser
.
getStaffDTO
().
getPhoneNumber
();
if
(
StringUtils
.
isNotBlank
(
phoneNumber
)){
ClerkDTO
clerkDTO
=
clerkService
.
getClerkByPhoneNumber
(
phoneNumber
);
String
enterpriseId
=
loginUser
.
getEnterpriseId
();
if
(
StringUtils
.
isBlank
(
enterpriseId
))
{
loginUser
.
setEnterpriseId
(
clerkDTO
.
getEnterpriseId
());
}
Integer
superAdmin
=
clerkDTO
.
getSuperAdmin
();
if
(
superAdmin
!=
null
&&
superAdmin
==
1
)
{
loginUser
.
getStaffDTO
().
setSuperManagerFlag
(
1
);
}
WebLoginVO
vo
=
EntityUtil
.
changeEntityByOrika
(
WebLoginVO
.
class
,
loginUser
)
;
String
staffId
=
loginUser
.
getStaffId
()
;
StaffDTO
dto
=
this
.
staffApiService
.
selectById
(
staffId
)
;
StaffVO
staffVO
=
EntityUtil
.
changeEntityByOrika
(
StaffVO
.
class
,
dto
)
;
vo
.
setStaffDTO
(
staffVO
);
return
this
.
success
(
vo
)
;
}
/**
* 切换GIC商户
* @param enterpriseId
* @return
*/
@RequestMapping
(
"enterprise-is-over"
)
public
HaobanResponse
enterpriseIsOver
(
String
enterpriseId
)
{
if
(
StringUtils
.
isEmpty
(
enterpriseId
))
{
return
this
.
fail
(
"企业ID空"
)
;
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
loginUser
);
EnterpriseDTO
enterprise
=
this
.
enterpriseService
.
getEnterpriseById
(
enterpriseId
);
if
(
null
==
enterprise
)
{
return
this
.
fail
(
"gic商户查询不到"
)
;
}
String
token
=
AuthWebRequestUtil
.
getToken
();
WebLoginDTO
loginUser
=
AuthWebRequestUtil
.
getLoginUser
();
if
(
null
==
loginUser
)
{
return
this
.
fail
(
"用户未登录"
)
;
}
logger
.
info
(
"切换商户,登录信息={},enterpriseId"
,
JSON
.
toJSONString
(
loginUser
),
enterpriseId
);
String
phoneNumber
=
loginUser
.
getPhoneNumber
()
;
ClerkDTO
clerk
=
clerkService
.
getClerkByPhoneNumber
(
phoneNumber
,
enterpriseId
);
if
(
clerk
==
null
)
{
logger
.
info
(
"切换商户失败,gic账号不存在,eid={},phone={}"
,
enterpriseId
,
phoneNumber
);
this
.
fail
(
"切换商户失败,gic账号不存在"
)
;
}
loginUser
.
setEnterpriseId
(
enterpriseId
);
loginUser
.
setClerkId
(
clerk
.
getClerkId
());
loginUser
.
setClerkName
(
clerk
.
getClerkName
());
loginUser
.
setBrandName
(
enterprise
.
getBrandName
());
AuthWebRequestUtil
.
setSessionUser
(
loginUser
);
AuthWebRequestUtil
.
setAppLoginUser
(
token
,
loginUser
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
true
);
}
/**
...
...
@@ -403,7 +319,8 @@ public class LoginController extends WebBaseController {
public
HaobanResponse
getLoginQrcode
()
throws
UnsupportedEncodingException
{
String
corpid
=
config
.
getCorpid
();
String
redirectUri
=
config
.
getHost
()
+
"login"
;
String
url
=
"https://open.work.weixin.qq.com/wwopen/sso/3rd_qrConnect?appid="
+
corpid
+
"&redirect_uri="
+
URLEncoder
.
encode
(
redirectUri
,
"UTF-8"
)
+
"&state=web_login@gyoss9&usertype=admin"
;
String
url
=
"https://open.work.weixin.qq.com/wwopen/sso/3rd_qrConnect?appid="
+
corpid
+
"&redirect_uri="
+
URLEncoder
.
encode
(
redirectUri
,
"UTF-8"
)
+
"&state=web_login@gyoss9&usertype=admin"
;
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
URL
.
decode
(
url
));
}
...
...
@@ -414,7 +331,7 @@ public class LoginController extends WebBaseController {
*/
@RequestMapping
(
"login-wx-enterprise-list"
)
public
HaobanResponse
loginWxEnterpriseList
(
String
random
)
{
//判断是否存在random
//
判断是否存在random
AES
aes
=
SecureUtil
.
aes
(
LOGIN_KEY
.
getBytes
());
String
o
=
aes
.
decryptStr
(
random
);
if
(
o
==
null
)
{
...
...
@@ -431,7 +348,8 @@ public class LoginController extends WebBaseController {
return
resultResponse
(
HaoBanErrCode
.
ERR_6
);
}
if
(
StringUtils
.
isNotBlank
(
wxEnterpriseId
))
{
List
<
WxEnterpriseDTO
>
collect
=
enterpriseDTOList
.
stream
().
filter
(
dto
->
dto
.
getWxEnterpriseId
().
equals
(
wxEnterpriseId
)).
collect
(
Collectors
.
toList
());
List
<
WxEnterpriseDTO
>
collect
=
enterpriseDTOList
.
stream
()
.
filter
(
dto
->
dto
.
getWxEnterpriseId
().
equals
(
wxEnterpriseId
)).
collect
(
Collectors
.
toList
());
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
collect
);
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
enterpriseDTOList
);
...
...
@@ -457,19 +375,18 @@ public class LoginController extends WebBaseController {
RedisUtil
.
delCache
(
token
);
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
@RequestMapping
(
"/gic-login-check"
)
public
ModelAndView
gicLogin
(
String
code
,
String
hbEnt
)
{
logger
.
info
(
"gic登录code={},hbEnt={}"
,
code
,
hbEnt
);
logger
.
info
(
"gic登录code={},hbEnt={}"
,
code
,
hbEnt
);
PowerClerkDTO
clerkDTO
=
this
.
userService
.
haobanLoginBack
(
code
);
if
(
clerkDTO
==
null
)
{
logger
.
info
(
"登录失败,code失效:{}"
,
code
);
ModelAndView
model
=
new
ModelAndView
(
new
RedirectView
(
"/haoban-web/#/gic-error"
,
false
));
return
model
;
}
//获取code信息
//
获取code信息
String
gicEnterpriseId
=
clerkDTO
.
getEnterpriseId
();
String
loginPhoneNumber
=
clerkDTO
.
getPhoneNumber
();
boolean
b
=
wxEnterpriseRelatedApiService
.
enterpriseUseNew
(
gicEnterpriseId
);
...
...
@@ -482,7 +399,8 @@ public class LoginController extends WebBaseController {
AES
aes
=
SecureUtil
.
aes
(
LOGIN_KEY
.
getBytes
());
String
random
=
aes
.
encryptHex
(
ret
);
logger
.
info
(
"使用新好办3:{}"
,
random
);
ModelAndView
model
=
new
ModelAndView
(
new
RedirectView
(
"/haoban-3/#/loginMore?random="
+
random
,
false
,
false
));
ModelAndView
model
=
new
ModelAndView
(
new
RedirectView
(
"/haoban-3/#/loginMore?random="
+
random
,
false
,
false
));
return
model
;
}
logger
.
info
(
"登录失败,code失效:{}"
,
code
);
...
...
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/MaterialController.java
View file @
fd55454e
...
...
@@ -125,9 +125,8 @@ public class MaterialController extends WebBaseController {
String
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
materialDTO
.
setWxEnterpriseId
(
wxEnterpriseId
);
WebStaffDTO
staff
=
login
.
getStaffDTO
();
materialDTO
.
setStaffId
(
staff
.
getStaffId
());
materialDTO
.
setStaffName
(
staff
.
getStaffName
());
materialDTO
.
setStaffId
(
login
.
getStaffId
());
materialDTO
.
setStaffName
(
login
.
getStaffName
());
String
materialTitle
=
materialDTO
.
getMaterialTitle
();
String
categoryId
=
materialDTO
.
getCategoryId
();
Integer
categoryType
=
materialDTO
.
getMaterialType
();
...
...
@@ -155,9 +154,8 @@ public class MaterialController extends WebBaseController {
BatchAddMaterialDTO
.
Material
material
=
dto
.
getMaterial
();
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
material
.
setWxEnterpriseId
(
login
.
getWxEnterpriseId
());
WebStaffDTO
staff
=
login
.
getStaffDTO
();
material
.
setStaffId
(
staff
.
getStaffId
());
material
.
setStaffName
(
staff
.
getStaffName
());
material
.
setStaffId
(
login
.
getStaffId
());
material
.
setStaffName
(
login
.
getStaffName
());
if
(
StringUtils
.
isAnyBlank
(
material
.
getCategoryId
(),
material
.
getMaterialTitle
())
||
Objects
.
isNull
(
material
.
getMaterialType
()))
{
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
...
...
@@ -185,10 +183,8 @@ public class MaterialController extends WebBaseController {
@RequestMapping
(
"/material-edit"
)
public
HaobanResponse
materialEdit
(
MaterialDTO
materialDTO
)
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
WebStaffDTO
staff
=
login
.
getStaffDTO
();
materialDTO
.
setStaffId
(
staff
.
getStaffId
());
materialDTO
.
setStaffName
(
staff
.
getStaffName
());
materialDTO
.
setStaffId
(
login
.
getStaffId
());
materialDTO
.
setStaffName
(
login
.
getStaffName
());
String
materialId
=
materialDTO
.
getMaterialId
();
MaterialDTO
dto
=
materialApiService
.
selectMaterialById
(
materialId
);
if
(
dto
==
null
)
{
...
...
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/RightController.java
View file @
fd55454e
...
...
@@ -40,7 +40,7 @@ public class RightController extends WebBaseController {
@RequestMapping
(
"get-haoban-menu"
)
public
HaobanResponse
getHaobanMenu
(
HttpServletRequest
request
,
String
enterpriseId
)
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
phoneNumber
=
login
.
get
StaffDTO
().
get
PhoneNumber
();
String
phoneNumber
=
login
.
getPhoneNumber
();
Enumeration
<
String
>
e
=
request
.
getHeaderNames
()
;
while
(
e
.
hasMoreElements
())
{
String
name
=
e
.
nextElement
()
;
...
...
@@ -67,7 +67,7 @@ public class RightController extends WebBaseController {
@RequestMapping
(
"get-haoban-right"
)
public
HaobanResponse
listHaobanAllMenu
(
HttpServletRequest
request
,
String
enterpriseId
)
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
phoneNumber
=
login
.
get
StaffDTO
().
get
PhoneNumber
();
String
phoneNumber
=
login
.
getPhoneNumber
();
if
(
StringUtils
.
isBlank
(
enterpriseId
))
{
enterpriseId
=
request
.
getHeader
(
"enterpriseid"
)
;
}
...
...
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/StaffController.java
View file @
fd55454e
...
...
@@ -324,16 +324,11 @@ public class StaffController extends WebBaseController {
@RequestMapping
(
"del-clerk-relation"
)
public
HaobanResponse
delStaffClerkList
(
String
staffId
,
String
clerkId
)
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
WebStaffDTO
staffDTO
=
login
.
getStaffDTO
();
if
(
staffDTO
==
null
)
{
logger
.
info
(
"登录异常"
);
return
resultResponse
(
HaoBanErrCode
.
ERR_4
);
}
StaffDTO
staff
=
staffApiService
.
selectById
(
staffId
);
if
(
staff
==
null
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_10007
);
}
boolean
b
=
staffClerkRelationApiService
.
unbindByStaffAndClerkId
(
staffDTO
.
getStaffId
(),
clerkId
);
boolean
b
=
staffClerkRelationApiService
.
unbindByStaffAndClerkId
(
login
.
getStaffId
(),
clerkId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
b
);
}
...
...
@@ -400,10 +395,6 @@ public class StaffController extends WebBaseController {
@RequestMapping
(
"add-clerk-relation"
)
public
HaobanResponse
staffClerkSearch
(
String
staffId
,
String
clerkId
)
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
WebStaffDTO
loginStaffDTO
=
login
.
getStaffDTO
();
if
(
null
==
loginStaffDTO
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_4
);
}
if
(
StringUtils
.
isAnyBlank
(
staffId
,
clerkId
))
{
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
...
...
@@ -425,7 +416,7 @@ public class StaffController extends WebBaseController {
relationDTO
.
setWxUserId
(
staffDTO
.
getWxUserId
());
ServiceResponse
response
=
staffClerkRelationApiService
.
bindStaffClerk
(
relationDTO
,
login
StaffDTO
.
getStaffId
(),
ChannelCodeEnum
.
ADMIN_BIND
.
getCode
());
ServiceResponse
response
=
staffClerkRelationApiService
.
bindStaffClerk
(
relationDTO
,
login
.
getStaffId
(),
ChannelCodeEnum
.
ADMIN_BIND
.
getCode
());
logger
.
info
(
"返回信息:{}"
,
JSONObject
.
toJSONString
(
response
));
if
(
response
.
getCode
()
==
1
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
...
...
@@ -444,11 +435,7 @@ public class StaffController extends WebBaseController {
@RequestMapping
(
"staff-clerk-bind-log"
)
public
HaobanResponse
bindLogs
(
String
search
,
String
enterpriseId
,
@RequestParam
(
defaultValue
=
"-1"
)
Integer
optType
,
BasePageInfo
qo
)
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
WebStaffDTO
loginStaffDTO
=
login
.
getStaffDTO
();
if
(
null
==
loginStaffDTO
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_4
);
}
Page
<
StaffClerkBindLogDetailDTO
>
page
=
staffClerkRelationApiService
.
pageStaffClerkBindLog
(
loginStaffDTO
.
getWxEnterpriseId
(),
search
,
enterpriseId
,
optType
,
qo
);
Page
<
StaffClerkBindLogDetailDTO
>
page
=
staffClerkRelationApiService
.
pageStaffClerkBindLog
(
login
.
getWxEnterpriseId
(),
search
,
enterpriseId
,
optType
,
qo
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
page
);
}
...
...
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/SyncDealContoller.java
View file @
fd55454e
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.api.base.commons.Page
;
import
com.gic.haoban.base.api.common.BasePageInfo
;
import
com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO
;
import
com.gic.haoban.base.api.common.pojo.dto.WebStaffDTO
;
import
com.gic.haoban.common.utils.AuthWebRequestUtil
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.manage.api.dto.PreDealLogInfoDTO
;
import
com.gic.haoban.manage.api.dto.SyncCheckDTO
;
import
com.gic.haoban.manage.api.dto.SyncTaskDTO
;
import
com.gic.haoban.manage.api.service.DealSyncOperationApiService
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.haoban.manage.web.qo.SyncDealQO
;
import
com.gic.redis.data.util.RedisUtil
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang3.time.DateFormatUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Date
;
@RestController
public
class
SyncDealContoller
extends
WebBaseController
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SyncDealContoller
.
class
);
@Autowired
private
DealSyncOperationApiService
dealSyncOperationApiService
;
@RequestMapping
(
"/test/department-sync"
)
@ResponseBody
public
HaobanResponse
departmentBatchSyncTest
(
@RequestBody
SyncDealQO
qo
,
String
wxEid
)
{
String
task
=
null
;
if
(
StringUtils
.
isNotBlank
(
wxEid
))
{
task
=
dealSyncOperationApiService
.
createTask
(
wxEid
,
"门店同步"
,
"11111"
,
"部门同步"
);
dealSyncOperationApiService
.
dealDepartment
(
task
,
wxEid
,
qo
.
getAddDepartment
(),
qo
.
getEditDepartment
());
}
else
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
String
key
=
"haoban-sync-department-"
+
wxEnterpriseId
;
if
(
RedisUtil
.
getCache
(
key
)
!=
null
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_10011
);
}
task
=
dealSyncOperationApiService
.
createTask
(
wxEnterpriseId
,
"门店同步"
,
login
.
getStaffDTO
().
getStaffId
(),
"部门同步"
);
dealSyncOperationApiService
.
dealDepartment
(
task
,
login
.
getWxEnterpriseId
(),
qo
.
getAddDepartment
(),
qo
.
getEditDepartment
());
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
task
);
}
@RequestMapping
(
"/department-sync"
)
@ResponseBody
public
HaobanResponse
departmentBatchSync
(
@RequestBody
SyncDealQO
qo
)
{
String
task
=
null
;
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
logger
.
info
(
"login:{}"
,
JSONObject
.
toJSONString
(
login
));
logger
.
info
(
"data:{}"
,
JSONObject
.
toJSONString
(
qo
));
String
taskLock
=
dealSyncOperationApiService
.
getTaskLock
(
wxEnterpriseId
);
if
(
null
!=
taskLock
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_10011
);
}
WebStaffDTO
staffDTO
=
login
.
getStaffDTO
();
String
staffId
=
"admin"
;
if
(
null
!=
staffDTO
)
{
staffId
=
staffDTO
.
getStaffId
();
}
String
format
=
DateFormatUtils
.
format
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
);
task
=
dealSyncOperationApiService
.
createTask
(
wxEnterpriseId
,
"门店同步-"
+
format
,
staffId
,
"部门同步"
);
if
(
task
==
null
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_10011
);
}
dealSyncOperationApiService
.
dealDepartment
(
task
,
login
.
getWxEnterpriseId
(),
qo
.
getAddDepartment
(),
qo
.
getEditDepartment
());
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
task
);
}
/**
* 同步状态校验
*
* @param syncKey
* @return
*/
@RequestMapping
(
"department-sync-check"
)
public
HaobanResponse
syncSuccess
(
String
wxEnterpriseId
)
{
if
(
StringUtils
.
isBlank
(
wxEnterpriseId
))
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
}
SyncCheckDTO
taskCheck
=
dealSyncOperationApiService
.
getTaskCheck
(
wxEnterpriseId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
taskCheck
);
}
/**
* 同步状态校验
*
* @param syncKey
* @return
*/
@RequestMapping
(
"/test/department-sync-check"
)
public
HaobanResponse
testSyncSuccess
(
String
wxEnterpriseId
)
{
if
(
StringUtils
.
isBlank
(
wxEnterpriseId
))
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
}
SyncCheckDTO
taskCheck
=
dealSyncOperationApiService
.
getTaskCheck
(
wxEnterpriseId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
taskCheck
);
}
@RequestMapping
(
"/re-sync"
)
@ResponseBody
public
HaobanResponse
clerkReSync
(
String
taskId
)
{
if
(
StringUtils
.
isBlank
(
taskId
))
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
taskId
=
dealSyncOperationApiService
.
getTaskLock
(
wxEnterpriseId
);
}
dealSyncOperationApiService
.
reDealDepartment
(
taskId
,
-
1
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
@RequestMapping
(
"/close-sync"
)
@ResponseBody
public
HaobanResponse
closeReSync
(
String
wxEnterpriseId
)
{
if
(
StringUtils
.
isBlank
(
wxEnterpriseId
))
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
}
dealSyncOperationApiService
.
closeTask
(
wxEnterpriseId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
/**
* 同步日志列表
*
* @param wxEnterpriseId
* @param pageInfo
* @return
*/
@RequestMapping
(
"/sync-task"
)
@ResponseBody
public
HaobanResponse
syncTask
(
String
wxEnterpriseId
,
BasePageInfo
pageInfo
)
{
if
(
StringUtils
.
isBlank
(
wxEnterpriseId
))
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
}
Page
<
SyncTaskDTO
>
retPage
=
dealSyncOperationApiService
.
listSyncTask
(
wxEnterpriseId
,
pageInfo
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
retPage
);
}
/**
* 同步日志详情
*
* @param wxEnterpriseId
* @param pageInfo
* @return
*/
@RequestMapping
(
"/sync-task-detail"
)
@ResponseBody
public
HaobanResponse
syncTaskDetail
(
String
wxEnterpriseId
,
String
taskId
,
BasePageInfo
pageInfo
)
{
if
(
StringUtils
.
isBlank
(
wxEnterpriseId
))
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
}
Page
<
PreDealLogInfoDTO
>
retPage
=
dealSyncOperationApiService
.
listSyncTaskDetail
(
wxEnterpriseId
,
taskId
,
pageInfo
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
retPage
);
}
/**
* 同步日志详情
*
* @return
*/
@RequestMapping
(
"/get-fresh-on-off"
)
@ResponseBody
public
HaobanResponse
getfreshonoff
()
{
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
}
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.api.base.commons.Page
;
import
com.gic.haoban.base.api.common.BasePageInfo
;
import
com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO
;
import
com.gic.haoban.base.api.common.pojo.dto.WebStaffDTO
;
import
com.gic.haoban.common.utils.AuthWebRequestUtil
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.manage.api.dto.PreDealLogInfoDTO
;
import
com.gic.haoban.manage.api.dto.SyncCheckDTO
;
import
com.gic.haoban.manage.api.dto.SyncTaskDTO
;
import
com.gic.haoban.manage.api.service.DealSyncOperationApiService
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.haoban.manage.web.qo.SyncDealQO
;
import
com.gic.redis.data.util.RedisUtil
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang3.time.DateFormatUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Date
;
@RestController
public
class
SyncDealContoller
extends
WebBaseController
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SyncDealContoller
.
class
);
@Autowired
private
DealSyncOperationApiService
dealSyncOperationApiService
;
@RequestMapping
(
"/test/department-sync"
)
@ResponseBody
public
HaobanResponse
departmentBatchSyncTest
(
@RequestBody
SyncDealQO
qo
,
String
wxEid
)
{
String
task
=
null
;
if
(
StringUtils
.
isNotBlank
(
wxEid
))
{
task
=
dealSyncOperationApiService
.
createTask
(
wxEid
,
"门店同步"
,
"11111"
,
"部门同步"
);
dealSyncOperationApiService
.
dealDepartment
(
task
,
wxEid
,
qo
.
getAddDepartment
(),
qo
.
getEditDepartment
());
}
else
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
String
key
=
"haoban-sync-department-"
+
wxEnterpriseId
;
if
(
RedisUtil
.
getCache
(
key
)
!=
null
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_10011
);
}
task
=
dealSyncOperationApiService
.
createTask
(
wxEnterpriseId
,
"门店同步"
,
login
.
getStaffId
(),
"部门同步"
);
dealSyncOperationApiService
.
dealDepartment
(
task
,
login
.
getWxEnterpriseId
(),
qo
.
getAddDepartment
(),
qo
.
getEditDepartment
());
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
task
);
}
@RequestMapping
(
"/department-sync"
)
@ResponseBody
public
HaobanResponse
departmentBatchSync
(
@RequestBody
SyncDealQO
qo
)
{
String
task
=
null
;
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
logger
.
info
(
"login:{}"
,
JSONObject
.
toJSONString
(
login
));
logger
.
info
(
"data:{}"
,
JSONObject
.
toJSONString
(
qo
));
String
taskLock
=
dealSyncOperationApiService
.
getTaskLock
(
wxEnterpriseId
);
if
(
null
!=
taskLock
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_10011
);
}
String
staffId
=
"admin"
;
String
format
=
DateFormatUtils
.
format
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
);
task
=
dealSyncOperationApiService
.
createTask
(
wxEnterpriseId
,
"门店同步-"
+
format
,
staffId
,
"部门同步"
);
if
(
task
==
null
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_10011
);
}
dealSyncOperationApiService
.
dealDepartment
(
task
,
login
.
getWxEnterpriseId
(),
qo
.
getAddDepartment
(),
qo
.
getEditDepartment
());
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
task
);
}
/**
* 同步状态校验
*
* @param syncKey
* @return
*/
@RequestMapping
(
"department-sync-check"
)
public
HaobanResponse
syncSuccess
(
String
wxEnterpriseId
)
{
if
(
StringUtils
.
isBlank
(
wxEnterpriseId
))
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
}
SyncCheckDTO
taskCheck
=
dealSyncOperationApiService
.
getTaskCheck
(
wxEnterpriseId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
taskCheck
);
}
/**
* 同步状态校验
*
* @param syncKey
* @return
*/
@RequestMapping
(
"/test/department-sync-check"
)
public
HaobanResponse
testSyncSuccess
(
String
wxEnterpriseId
)
{
if
(
StringUtils
.
isBlank
(
wxEnterpriseId
))
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
}
SyncCheckDTO
taskCheck
=
dealSyncOperationApiService
.
getTaskCheck
(
wxEnterpriseId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
taskCheck
);
}
@RequestMapping
(
"/re-sync"
)
@ResponseBody
public
HaobanResponse
clerkReSync
(
String
taskId
)
{
if
(
StringUtils
.
isBlank
(
taskId
))
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
taskId
=
dealSyncOperationApiService
.
getTaskLock
(
wxEnterpriseId
);
}
dealSyncOperationApiService
.
reDealDepartment
(
taskId
,
-
1
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
@RequestMapping
(
"/close-sync"
)
@ResponseBody
public
HaobanResponse
closeReSync
(
String
wxEnterpriseId
)
{
if
(
StringUtils
.
isBlank
(
wxEnterpriseId
))
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
}
dealSyncOperationApiService
.
closeTask
(
wxEnterpriseId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
/**
* 同步日志列表
*
* @param wxEnterpriseId
* @param pageInfo
* @return
*/
@RequestMapping
(
"/sync-task"
)
@ResponseBody
public
HaobanResponse
syncTask
(
String
wxEnterpriseId
,
BasePageInfo
pageInfo
)
{
if
(
StringUtils
.
isBlank
(
wxEnterpriseId
))
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
}
Page
<
SyncTaskDTO
>
retPage
=
dealSyncOperationApiService
.
listSyncTask
(
wxEnterpriseId
,
pageInfo
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
retPage
);
}
/**
* 同步日志详情
*
* @param wxEnterpriseId
* @param pageInfo
* @return
*/
@RequestMapping
(
"/sync-task-detail"
)
@ResponseBody
public
HaobanResponse
syncTaskDetail
(
String
wxEnterpriseId
,
String
taskId
,
BasePageInfo
pageInfo
)
{
if
(
StringUtils
.
isBlank
(
wxEnterpriseId
))
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
}
Page
<
PreDealLogInfoDTO
>
retPage
=
dealSyncOperationApiService
.
listSyncTaskDetail
(
wxEnterpriseId
,
taskId
,
pageInfo
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
retPage
);
}
/**
* 同步日志详情
*
* @return
*/
@RequestMapping
(
"/get-fresh-on-off"
)
@ResponseBody
public
HaobanResponse
getfreshonoff
()
{
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
}
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/WebBaseController.java
View file @
fd55454e
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
import
com.gic.haoban.common.utils.AuthWebRequestUtil
;
import
com.gic.haoban.common.utils.EntityUtil
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.manage.api.dto.LoginDTO
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
/**
...
...
@@ -39,14 +36,13 @@ public class WebBaseController {
response
.
setErrorCode
(
errCode
.
getCode
());
return
response
;
}
public
HaobanResponse
success
(
Object
obj
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
obj
,
null
);
}
/**
* 获取登陆信息
*
* @return
*/
protected
LoginDTO
getLoginUser
()
{
return
EntityUtil
.
changeEntityByJSON
(
LoginDTO
.
class
,
AuthWebRequestUtil
.
getLoginUser
());
public
HaobanResponse
fail
(
String
message
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_OTHER
,
null
,
message
);
}
}
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/WelcomeController.java
View file @
fd55454e
...
...
@@ -67,15 +67,15 @@ public class WelcomeController extends WebBaseController {
qdto
.
setWxEnterpriseId
(
qo
.
getWxEnterpriseId
());
qdto
.
setTitle
(
qo
.
getTitle
());
qdto
.
setWelcomeContent
(
qo
.
getWelcomeContent
());
qdto
.
setOperatorId
(
login
.
getStaff
DTO
().
getStaff
Id
());
qdto
.
setOperatorName
(
login
.
getStaff
DTO
().
getStaff
Name
());
qdto
.
setOperatorId
(
login
.
getStaffId
());
qdto
.
setOperatorName
(
login
.
getStaffName
());
qdto
.
setDefaultWelcomeFlag
(
qo
.
getDefaultWelcomeFlag
());
qdto
.
setWelcomeMediaList
(
EntityUtil
.
changeEntityListNew
(
SaveWelcomeMediaQDTO
.
class
,
qo
.
getWelcomeMediaList
()));
qdto
.
setSuitDepartmentAddList
(
qo
.
getSuitDepartmentAddList
());
qdto
.
setSuitDepartmentDeleteList
(
qo
.
getSuitDepartmentDeleteList
());
// 员工暂时不传
qdto
.
setCreatorId
(
login
.
getStaff
DTO
().
getStaff
Id
());
qdto
.
setCreatorName
(
login
.
getStaff
DTO
().
getStaff
Name
());
qdto
.
setCreatorId
(
login
.
getStaffId
());
qdto
.
setCreatorName
(
login
.
getStaffName
());
ServiceResponse
<
Boolean
>
response
=
welcomeApiService
.
saveWelcome
(
qdto
);
return
RestResponse
.
successResult
(
response
.
getResult
());
}
...
...
@@ -142,8 +142,8 @@ public class WelcomeController extends WebBaseController {
public
RestResponse
<
Boolean
>
saveFriendSetting
(
@RequestBody
@Valid
SaveFriendSettingQO
qo
)
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
SaveFriendSettingQDTO
qdto
=
EntityUtil
.
changeEntityNew
(
SaveFriendSettingQDTO
.
class
,
qo
);
qdto
.
setUpdateId
(
login
.
getStaff
DTO
().
getStaff
Id
());
qdto
.
setUpdateName
(
login
.
getStaff
DTO
().
getStaff
Name
());
qdto
.
setUpdateId
(
login
.
getStaffId
());
qdto
.
setUpdateName
(
login
.
getStaffName
());
ServiceResponse
<
Boolean
>
response
=
welcomeApiService
.
saveFriendSetting
(
qdto
);
return
RestResponse
.
successResult
(
response
.
getResult
());
}
...
...
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/WxEnterpriseController.java
View file @
fd55454e
...
...
@@ -201,9 +201,8 @@ public class WxEnterpriseController extends WebBaseController {
}
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
WebStaffDTO
staff
=
login
.
getStaffDTO
();
String
staffId
=
staff
.
getStaffId
();
String
staffName
=
staff
.
getStaffName
();
String
staffId
=
login
.
getStaffId
();
String
staffName
=
login
.
getStaffName
();
WxEnterpriseRelationDetailDTO
detailDTO
=
new
WxEnterpriseRelationDetailDTO
();
detailDTO
.
setWxEnterpriseRelatedId
(
bindQo
.
getWxEnterpriseRelatedId
());
...
...
@@ -316,7 +315,7 @@ public class WxEnterpriseController extends WebBaseController {
}
contactSecret
=
contactSecret
.
trim
();
UserDTO
user
=
qywxUserApiService
.
getSelfWorkWxUser
(
wxEnterprise
.
getCorpid
(),
contactSecret
,
getWxUserId
(
wxEnterpriseId
,
login
.
getStaffDTO
()
));
UserDTO
user
=
qywxUserApiService
.
getSelfWorkWxUser
(
wxEnterprise
.
getCorpid
(),
contactSecret
,
getWxUserId
(
wxEnterpriseId
,
login
));
logger
.
info
(
"【保存联系人key】user={}"
,
JSON
.
toJSONString
(
user
));
SecretSettingDTO
secretSetting
=
wxEnterpriseApiService
.
getSecretSetting
(
wxEnterpriseId
,
SecretTypeEnum
.
CONTACT_SECRET
.
getVal
(),
null
);
if
(
null
==
secretSetting
)
{
...
...
@@ -356,7 +355,7 @@ public class WxEnterpriseController extends WebBaseController {
return
resultResponse
(
HaoBanErrCode
.
ERR_10012
);
}
wxSecretKey
=
wxSecretKey
.
trim
();
String
res
=
qywxUserApiService
.
listSelfExternalUserid
(
wxEnterprise
.
getCorpid
(),
wxSecretKey
,
getWxUserId
(
wxEnterpriseId
,
login
.
getStaffDTO
()
));
String
res
=
qywxUserApiService
.
listSelfExternalUserid
(
wxEnterprise
.
getCorpid
(),
wxSecretKey
,
getWxUserId
(
wxEnterpriseId
,
login
));
logger
.
info
(
"【保存联系人key】res={}"
,
res
);
SecretSettingDTO
secretSetting
=
wxEnterpriseApiService
.
getSecretSetting
(
wxEnterpriseId
,
SecretTypeEnum
.
CONTACT_CUSTOMER
.
getVal
(),
null
);
if
(
null
==
secretSetting
)
{
...
...
@@ -403,7 +402,7 @@ public class WxEnterpriseController extends WebBaseController {
return
resultResponse
(
HaoBanErrCode
.
ERR_100017
);
}
}
UserDTO
user
=
qywxUserApiService
.
getSelfWorkWxUser
(
wxEnterprise
.
getCorpid
(),
memberSecret
,
getWxUserId
(
wxEnterpriseId
,
login
.
getStaffDTO
()
));
UserDTO
user
=
qywxUserApiService
.
getSelfWorkWxUser
(
wxEnterprise
.
getCorpid
(),
memberSecret
,
getWxUserId
(
wxEnterpriseId
,
login
));
secretSetting
.
setSecretType
(
SecretTypeEnum
.
MEMBER_WAPP
.
getVal
());
secretSetting
.
setSecretName
(
secretName
);
secretSetting
.
setEnterpriseId
(
enterpriseId
);
...
...
@@ -421,7 +420,7 @@ public class WxEnterpriseController extends WebBaseController {
}
}
private
String
getWxUserId
(
String
wxEnterpriseId
,
Web
Staff
DTO
loginStaffDTO
)
{
private
String
getWxUserId
(
String
wxEnterpriseId
,
Web
Login
DTO
loginStaffDTO
)
{
if
(
loginStaffDTO
!=
null
&&
(!
StringUtils
.
isEmpty
(
loginStaffDTO
.
getWxUserId
())))
{
return
loginStaffDTO
.
getWxUserId
();
}
...
...
@@ -453,7 +452,7 @@ public class WxEnterpriseController extends WebBaseController {
}
contactSecret
=
contactSecret
.
trim
();
UserDTO
user
=
qywxUserApiService
.
getSelfWorkWxUser
(
wxEnterprise
.
getCorpid
(),
contactSecret
,
getWxUserId
(
wxEnterpriseId
,
login
.
getStaffDTO
()
));
UserDTO
user
=
qywxUserApiService
.
getSelfWorkWxUser
(
wxEnterprise
.
getCorpid
(),
contactSecret
,
getWxUserId
(
wxEnterpriseId
,
login
));
logger
.
info
(
"【保存联系人key】user={}"
,
JSON
.
toJSONString
(
user
));
SecretSettingDTO
secretSetting
=
wxEnterpriseApiService
.
getSecretSetting
(
wxEnterpriseId
,
SecretTypeEnum
.
HAOBAN_HELP
.
getVal
(),
null
);
if
(
null
==
secretSetting
)
{
...
...
@@ -516,31 +515,6 @@ public class WxEnterpriseController extends WebBaseController {
}
/**
* 判断企业是否过期
*
* @param enterpriseId
* @return
*/
@RequestMapping
(
"enterprise-is-over"
)
public
HaobanResponse
enterpriseIsOver
(
String
enterpriseId
)
{
if
(
StringUtils
.
isEmpty
(
enterpriseId
))
{
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
boolean
flag
=
wxEnterpriseApiService
.
enterpriseIsOver
(
enterpriseId
);
//切换企业 更新token中的企业id
if
(!
flag
)
{
String
token
=
AuthWebRequestUtil
.
getToken
();
WebLoginDTO
loginUser
=
AuthWebRequestUtil
.
getLoginUser
();
if
(
loginUser
!=
null
)
{
loginUser
.
setEnterpriseId
(
enterpriseId
);
AuthWebRequestUtil
.
setSessionUser
(
loginUser
);
AuthWebRequestUtil
.
setAppLoginUser
(
token
,
loginUser
);
}
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
flag
);
}
/**
* 刷新企业微信好友
*
* @return
...
...
@@ -560,7 +534,7 @@ public class WxEnterpriseController extends WebBaseController {
if
(
monthCount
>=
3
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_100020
);
}
String
taskId
=
dealSyncOperationApiService
.
createWxFriendTask
(
wxEnterpriseId
,
"刷新企微好友"
,
login
.
getStaff
DTO
().
getStaff
Id
(),
"刷新企微好友"
);
String
taskId
=
dealSyncOperationApiService
.
createWxFriendTask
(
wxEnterpriseId
,
"刷新企微好友"
,
login
.
getStaffId
(),
"刷新企微好友"
);
if
(
StringUtils
.
isEmpty
(
taskId
))
{
return
resultResponse
(
HaoBanErrCode
.
ERR_100021
);
}
...
...
@@ -627,7 +601,7 @@ public class WxEnterpriseController extends WebBaseController {
public
HaobanResponse
flushBindStoreList
(
String
enterpriseId
)
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
ServiceResponse
response
=
wxEnterpriseRelatedApiService
.
flushBindStoreByEnterpriseId
(
enterpriseId
,
wxEnterpriseId
,
login
.
getStaff
DTO
().
getStaff
Id
(),
ChannelCodeEnum
.
SYNC_UNBIND
.
getCode
());
ServiceResponse
response
=
wxEnterpriseRelatedApiService
.
flushBindStoreByEnterpriseId
(
enterpriseId
,
wxEnterpriseId
,
login
.
getStaffId
(),
ChannelCodeEnum
.
SYNC_UNBIND
.
getCode
());
logger
.
info
(
"返回信息:{}"
,
JSONObject
.
toJSONString
(
response
));
if
(
response
.
getCode
()
!=
1
)
{
HaoBanErrCode
.
ERR_DEFINE
.
setMsg
(
response
.
getMessage
());
...
...
@@ -709,7 +683,7 @@ public class WxEnterpriseController extends WebBaseController {
*/
@RequestMapping
(
"/agent-wx-enterprise-list"
)
public
HaobanResponse
materialShare
(
String
materialId
)
{
LoginDTO
loginUser
=
this
.
getLoginUser
();
WebLoginDTO
loginUser
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
loginUser
.
getWxEnterpriseId
();
List
<
EnterpriseDetailDTO
>
detailDTOS
=
wxEnterpriseRelatedApiService
.
listEnterpriseByWxEnterpriseId
(
wxEnterpriseId
);
List
<
String
>
enterpriseIds
=
detailDTOS
.
stream
().
filter
(
dto
->
dto
.
getWxEnterpriseType
()
==
0
).
map
(
dto
->
dto
.
getEnterpriseId
()).
collect
(
Collectors
.
toList
());
...
...
@@ -748,7 +722,7 @@ public class WxEnterpriseController extends WebBaseController {
*/
@RequestMapping
(
"save-welcome"
)
public
HaobanResponse
savewelcome
(
String
title
,
String
welcomeContent
,
String
welcomeImg
)
{
LoginDTO
loginUser
=
this
.
getLoginUser
();
WebLoginDTO
loginUser
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
loginUser
.
getWxEnterpriseId
();
if
(
StringUtils
.
isAnyBlank
(
title
,
welcomeContent
))
{
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
...
...
@@ -771,7 +745,7 @@ public class WxEnterpriseController extends WebBaseController {
*/
@RequestMapping
(
"get-welcome"
)
public
HaobanResponse
getWelcome
()
{
LoginDTO
loginUser
=
this
.
getLoginUser
();
WebLoginDTO
loginUser
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
loginUser
.
getWxEnterpriseId
();
WelcomeDTO
welcome
=
wxEnterpriseApiService
.
getWelcome
(
wxEnterpriseId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
welcome
);
...
...
@@ -784,7 +758,7 @@ public class WxEnterpriseController extends WebBaseController {
*/
@RequestMapping
(
"del-welcome"
)
public
HaobanResponse
delWelcome
()
{
LoginDTO
loginUser
=
this
.
getLoginUser
();
WebLoginDTO
loginUser
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
loginUser
.
getWxEnterpriseId
();
wxEnterpriseApiService
.
delWelcome
(
wxEnterpriseId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
...
...
@@ -797,7 +771,7 @@ public class WxEnterpriseController extends WebBaseController {
*/
@RequestMapping
(
"set-welcome"
)
public
HaobanResponse
setWelcome
(
int
openFlag
)
{
LoginDTO
loginUser
=
this
.
getLoginUser
();
WebLoginDTO
loginUser
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
loginUser
.
getWxEnterpriseId
();
wxEnterpriseApiService
.
setWelcome
(
wxEnterpriseId
,
openFlag
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
...
...
@@ -831,7 +805,7 @@ public class WxEnterpriseController extends WebBaseController {
*/
@RequestMapping
(
"agree_external_userid_flag"
)
public
HaobanResponse
agreeExternalUseridFlag
(
Integer
openFlag
)
{
LoginDTO
loginUser
=
this
.
getLoginUser
();
WebLoginDTO
loginUser
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
loginUser
.
getWxEnterpriseId
();
wxEnterpriseApiService
.
agreeExternalUseridFlag
(
wxEnterpriseId
,
openFlag
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
...
...
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/vo/StaffVO.java
View file @
fd55454e
package
com
.
gic
.
haoban
.
manage
.
web
.
vo
;
import
java.io.Serializable
;
import
com.gic.haoban.manage.api.dto.StaffDTO
;
public
class
StaffVO
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
private
String
staffName
;
private
String
phoneNumber
;
private
String
nationCode
;
private
String
position
;
private
String
departmentName
;
private
String
headImg
;
public
String
getHeadImg
()
{
return
headImg
;
}
public
void
setHeadImg
(
String
headImg
)
{
this
.
headImg
=
headImg
;
}
public
String
getStaffName
()
{
return
staffName
;
}
public
void
setStaffName
(
String
staffName
)
{
this
.
staffName
=
staffName
;
}
public
String
getPhoneNumber
()
{
return
phoneNumber
;
}
public
void
setPhoneNumber
(
String
phoneNumber
)
{
this
.
phoneNumber
=
phoneNumber
;
}
public
String
getNationCode
()
{
return
nationCode
;
}
public
void
setNationCode
(
String
nationCode
)
{
this
.
nationCode
=
nationCode
;
}
public
String
getPosition
()
{
return
position
;
}
public
void
setPosition
(
String
position
)
{
this
.
position
=
position
;
}
public
String
getDepartmentName
()
{
return
departmentName
;
}
public
void
setDepartmentName
(
String
departmentName
)
{
this
.
departmentName
=
departmentName
;
}
}
package
com
.
gic
.
haoban
.
manage
.
web
.
vo
;
import
java.io.Serializable
;
import
java.util.Date
;
public
class
StaffVO
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
private
String
staffName
;
private
String
phoneNumber
;
private
String
nationCode
;
private
String
position
;
private
String
departmentName
;
private
String
headImg
;
/**
* 员工id
*/
private
String
staffId
;
/**
* 企业微信id
*/
private
String
wxEnterpriseId
;
/**
* 微信用户id
*/
private
String
wxUserId
;
/**
* 昵称
*/
private
String
nickName
;
/**
* 性别
*/
private
Integer
sex
;
/**
* 职位
*/
private
String
postion
;
/**
* 激活状态
*/
private
Integer
activeFlag
;
/**
* 对外职务
*/
private
String
extendPostion
;
private
Date
updateTime
;
private
int
bindFlag
;
private
String
clerkCode
;
private
String
staffDepartmentRelatedId
;
private
int
clerkType
;
private
Integer
syncPostionFlag
;
private
Integer
superManagerFlag
;
private
Boolean
weixinPush
;
private
Integer
memberCount
;
private
String
clerkId
;
/**
* 关联状态 1 已关联 0 未关联
* 关联状态为 员工是否关联某门店导购
*/
private
Integer
relationFlag
;
private
String
wxOpenUseId
;
private
String
wxOpenId
;
private
String
qrCode
;
private
String
clerkName
;
public
String
getStaffId
()
{
return
staffId
;
}
public
String
getWxEnterpriseId
()
{
return
wxEnterpriseId
;
}
public
String
getWxUserId
()
{
return
wxUserId
;
}
public
String
getNickName
()
{
return
nickName
;
}
public
Integer
getSex
()
{
return
sex
;
}
public
String
getPostion
()
{
return
postion
;
}
public
Integer
getActiveFlag
()
{
return
activeFlag
;
}
public
String
getExtendPostion
()
{
return
extendPostion
;
}
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
int
getBindFlag
()
{
return
bindFlag
;
}
public
String
getClerkCode
()
{
return
clerkCode
;
}
public
String
getStaffDepartmentRelatedId
()
{
return
staffDepartmentRelatedId
;
}
public
int
getClerkType
()
{
return
clerkType
;
}
public
Integer
getSyncPostionFlag
()
{
return
syncPostionFlag
;
}
public
Integer
getSuperManagerFlag
()
{
return
superManagerFlag
;
}
public
Boolean
getWeixinPush
()
{
return
weixinPush
;
}
public
Integer
getMemberCount
()
{
return
memberCount
;
}
public
String
getClerkId
()
{
return
clerkId
;
}
public
Integer
getRelationFlag
()
{
return
relationFlag
;
}
public
String
getWxOpenUseId
()
{
return
wxOpenUseId
;
}
public
String
getWxOpenId
()
{
return
wxOpenId
;
}
public
String
getQrCode
()
{
return
qrCode
;
}
public
String
getClerkName
()
{
return
clerkName
;
}
public
void
setStaffId
(
String
staffId
)
{
this
.
staffId
=
staffId
;
}
public
void
setWxEnterpriseId
(
String
wxEnterpriseId
)
{
this
.
wxEnterpriseId
=
wxEnterpriseId
;
}
public
void
setWxUserId
(
String
wxUserId
)
{
this
.
wxUserId
=
wxUserId
;
}
public
void
setNickName
(
String
nickName
)
{
this
.
nickName
=
nickName
;
}
public
void
setSex
(
Integer
sex
)
{
this
.
sex
=
sex
;
}
public
void
setPostion
(
String
postion
)
{
this
.
postion
=
postion
;
}
public
void
setActiveFlag
(
Integer
activeFlag
)
{
this
.
activeFlag
=
activeFlag
;
}
public
void
setExtendPostion
(
String
extendPostion
)
{
this
.
extendPostion
=
extendPostion
;
}
public
void
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
public
void
setBindFlag
(
int
bindFlag
)
{
this
.
bindFlag
=
bindFlag
;
}
public
void
setClerkCode
(
String
clerkCode
)
{
this
.
clerkCode
=
clerkCode
;
}
public
void
setStaffDepartmentRelatedId
(
String
staffDepartmentRelatedId
)
{
this
.
staffDepartmentRelatedId
=
staffDepartmentRelatedId
;
}
public
void
setClerkType
(
int
clerkType
)
{
this
.
clerkType
=
clerkType
;
}
public
void
setSyncPostionFlag
(
Integer
syncPostionFlag
)
{
this
.
syncPostionFlag
=
syncPostionFlag
;
}
public
void
setSuperManagerFlag
(
Integer
superManagerFlag
)
{
this
.
superManagerFlag
=
superManagerFlag
;
}
public
void
setWeixinPush
(
Boolean
weixinPush
)
{
this
.
weixinPush
=
weixinPush
;
}
public
void
setMemberCount
(
Integer
memberCount
)
{
this
.
memberCount
=
memberCount
;
}
public
void
setClerkId
(
String
clerkId
)
{
this
.
clerkId
=
clerkId
;
}
public
void
setRelationFlag
(
Integer
relationFlag
)
{
this
.
relationFlag
=
relationFlag
;
}
public
void
setWxOpenUseId
(
String
wxOpenUseId
)
{
this
.
wxOpenUseId
=
wxOpenUseId
;
}
public
void
setWxOpenId
(
String
wxOpenId
)
{
this
.
wxOpenId
=
wxOpenId
;
}
public
void
setQrCode
(
String
qrCode
)
{
this
.
qrCode
=
qrCode
;
}
public
void
setClerkName
(
String
clerkName
)
{
this
.
clerkName
=
clerkName
;
}
public
String
getHeadImg
()
{
return
headImg
;
}
public
void
setHeadImg
(
String
headImg
)
{
this
.
headImg
=
headImg
;
}
public
String
getStaffName
()
{
return
staffName
;
}
public
void
setStaffName
(
String
staffName
)
{
this
.
staffName
=
staffName
;
}
public
String
getPhoneNumber
()
{
return
phoneNumber
;
}
public
void
setPhoneNumber
(
String
phoneNumber
)
{
this
.
phoneNumber
=
phoneNumber
;
}
public
String
getNationCode
()
{
return
nationCode
;
}
public
void
setNationCode
(
String
nationCode
)
{
this
.
nationCode
=
nationCode
;
}
public
String
getPosition
()
{
return
position
;
}
public
void
setPosition
(
String
position
)
{
this
.
position
=
position
;
}
public
String
getDepartmentName
()
{
return
departmentName
;
}
public
void
setDepartmentName
(
String
departmentName
)
{
this
.
departmentName
=
departmentName
;
}
}
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