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
ab6c3841
Commit
ab6c3841
authored
May 19, 2020
by
qwmqiuwenmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
de2bc095
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
107 additions
and
30 deletions
+107
-30
StaffDepartmentRelatedMapper.java
...nage/service/dao/mapper/StaffDepartmentRelatedMapper.java
+3
-0
StaffDepartmentRelatedApiServiceImpl.java
...ervice/out/impl/StaffDepartmentRelatedApiServiceImpl.java
+12
-3
StaffDepartmentRelatedMapper.xml
...rc/main/resources/mapper/StaffDepartmentRelatedMapper.xml
+8
-0
ServiceTest.java
haoban-manage3-service/src/test/java/ServiceTest.java
+38
-3
LoginController.java
...com/gic/haoban/manage/web/controller/LoginController.java
+46
-24
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/dao/mapper/StaffDepartmentRelatedMapper.java
View file @
ab6c3841
...
@@ -48,6 +48,8 @@ public interface StaffDepartmentRelatedMapper {
...
@@ -48,6 +48,8 @@ public interface StaffDepartmentRelatedMapper {
List
<
TabHaobanStaffDepartmentRelated
>
listByClerkCode
(
@Param
(
"clerkCode"
)
String
clerkCode
);
List
<
TabHaobanStaffDepartmentRelated
>
listByClerkCode
(
@Param
(
"clerkCode"
)
String
clerkCode
);
List
<
TabHaobanStaffDepartmentRelated
>
listByWxEnterpriseIdAndClerkCode
(
@Param
(
"wxEnterpriseId"
)
String
wxEnterpriseId
,
@Param
(
"clerkCode"
)
String
clerkCode
);
List
<
TabHaobanStaffDepartmentRelated
>
listStaffDepartmentByStaffIds
(
@Param
(
"staffIds"
)
List
<
String
>
staffIds
);
List
<
TabHaobanStaffDepartmentRelated
>
listStaffDepartmentByStaffIds
(
@Param
(
"staffIds"
)
List
<
String
>
staffIds
);
}
}
\ No newline at end of file
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/StaffDepartmentRelatedApiServiceImpl.java
View file @
ab6c3841
...
@@ -29,9 +29,11 @@ import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
...
@@ -29,9 +29,11 @@ import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
import
com.gic.haoban.manage.service.config.Config
;
import
com.gic.haoban.manage.service.config.Config
;
import
com.gic.haoban.manage.service.dao.mapper.StaffDepartmentRelatedMapper
;
import
com.gic.haoban.manage.service.dao.mapper.StaffDepartmentRelatedMapper
;
import
com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper
;
import
com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper
;
import
com.gic.haoban.manage.service.dao.mapper.WxEnterpriseRelatedMapper
;
import
com.gic.haoban.manage.service.entity.TabHaobanApplication
;
import
com.gic.haoban.manage.service.entity.TabHaobanApplication
;
import
com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated
;
import
com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated
;
import
com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise
;
import
com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise
;
import
com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated
;
import
com.gic.haoban.manage.service.service.ApplicationService
;
import
com.gic.haoban.manage.service.service.ApplicationService
;
import
com.gic.haoban.manage.service.service.StaffDepartmentRelatedService
;
import
com.gic.haoban.manage.service.service.StaffDepartmentRelatedService
;
import
com.gic.wechat.api.dto.qywx.ItemDTO
;
import
com.gic.wechat.api.dto.qywx.ItemDTO
;
...
@@ -54,7 +56,8 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
...
@@ -54,7 +56,8 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
private
QywxSuiteApiService
qywxSuiteApiService
;
private
QywxSuiteApiService
qywxSuiteApiService
;
@Autowired
@Autowired
private
WxEnterpriseMapper
wxEnterpriseMapper
;
private
WxEnterpriseMapper
wxEnterpriseMapper
;
@Autowired
private
WxEnterpriseRelatedMapper
wxEnterpriseRelatedMapper
;
@Autowired
@Autowired
private
Config
config
;
private
Config
config
;
...
@@ -137,12 +140,18 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
...
@@ -137,12 +140,18 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
if
(
StringUtil
.
isEmpty
(
clerkCode
)
){
if
(
StringUtil
.
isEmpty
(
clerkCode
)
){
return
map
;
return
map
;
}
}
List
<
TabHaobanStaffDepartmentRelated
>
list
=
staffDepartmentRelatedMapper
.
listByClerkCode
(
clerkCode
);
String
enterpriseId
=
clerkDTO
.
getEnterpriseId
();
TabHaobanWxEnterpriseRelated
relate
=
wxEnterpriseRelatedMapper
.
findOneByEnterpriseId
(
enterpriseId
);
if
(
relate
==
null
){
return
map
;
}
String
wxEnterpriseId
=
relate
.
getWxEnterpriseId
();
List
<
TabHaobanStaffDepartmentRelated
>
list
=
staffDepartmentRelatedMapper
.
listByWxEnterpriseIdAndClerkCode
(
wxEnterpriseId
,
clerkCode
);
if
(
CollectionUtil
.
isEmpty
(
list
)){
if
(
CollectionUtil
.
isEmpty
(
list
)){
return
map
;
return
map
;
}
}
String
wxUserId
=
list
.
get
(
0
).
getWxUserId
();
String
wxUserId
=
list
.
get
(
0
).
getWxUserId
();
String
wxEnterpriseId
=
list
.
get
(
0
).
getWxEnterpriseId
();
TabHaobanWxEnterprise
tabHaobanWxEnterprise
=
wxEnterpriseMapper
.
selectByPrimaryKey
(
wxEnterpriseId
);
TabHaobanWxEnterprise
tabHaobanWxEnterprise
=
wxEnterpriseMapper
.
selectByPrimaryKey
(
wxEnterpriseId
);
map
.
put
(
"wxUserId"
,
wxUserId
);
map
.
put
(
"wxUserId"
,
wxUserId
);
...
...
haoban-manage3-service/src/main/resources/mapper/StaffDepartmentRelatedMapper.xml
View file @
ab6c3841
...
@@ -249,6 +249,14 @@
...
@@ -249,6 +249,14 @@
and status_flag = 1
and status_flag = 1
</select>
</select>
<select
id=
"listByWxEnterpriseIdAndClerkCode"
resultMap=
"BaseResultMap"
parameterType=
"java.lang.String"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_haoban_staff_department_related
where clerk_code = #{clerkCode}
and wx_enterprise_id = #{wxEnterpriseId}
and status_flag = 1
</select>
<select
id=
"countByDepartmentId"
resultType=
"java.lang.Integer"
parameterType=
"java.lang.String"
>
<select
id=
"countByDepartmentId"
resultType=
"java.lang.Integer"
parameterType=
"java.lang.String"
>
select
select
...
...
haoban-manage3-service/src/test/java/ServiceTest.java
View file @
ab6c3841
...
@@ -20,6 +20,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
...
@@ -20,6 +20,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import
javax.imageio.ImageIO
;
import
javax.imageio.ImageIO
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.BufferedImage
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -47,8 +49,7 @@ public class ServiceTest {
...
@@ -47,8 +49,7 @@ public class ServiceTest {
@Test
@Test
public
void
test
()
{
public
void
test
()
{
RedisUtil
.
delCache
(
"check-user-haoban3-84ed2f59889c4e74815f7988b6c647bc"
);
System
.
err
.
println
(
RedisUtil
.
getCache
(
"init-enterprise-ca66a01b79474c40b3e7c7f93daf1a3b"
));
//System.err.println(RedisUtil.getCache("check-user-haoban3-84ed2f59889c4e74815f7988b6c647bc"));
}
}
...
@@ -187,6 +188,14 @@ public void sendMessage() {
...
@@ -187,6 +188,14 @@ public void sendMessage() {
@Test
@Test
public
void
extensionList2
()
{
String
img
=
"d:/test2.jpg"
;
byte
[]
aByte
=
getFileByteArray
(
new
File
(
img
));
JSONResponse
response
=
qywxSuiteApiService
.
uploadMedia
(
"ww9ede832a84b7ae5f"
,
"ww2c34dc56739bb105"
,
aByte
,
"测试文件"
,
QywxMediaTypeEnum
.
IMAGE
.
getCode
());
System
.
out
.
println
(
JSONObject
.
toJSONString
(
response
));
}
@Test
public
void
extensionList3
()
{
public
void
extensionList3
()
{
// msg59NLDQAAKvRi-fguFcKRVOjeoJKRJw
// msg59NLDQAAKvRi-fguFcKRVOjeoJKRJw
// String img="https://pic01-10001430.image.myqcloud.com/53205d69-01f1-4706-a258-014d59d8d106";
// String img="https://pic01-10001430.image.myqcloud.com/53205d69-01f1-4706-a258-014d59d8d106";
...
@@ -194,7 +203,7 @@ public void sendMessage() {
...
@@ -194,7 +203,7 @@ public void sendMessage() {
// JSONResponse response = qywxSuiteApiService.uploadMedia("ww9ede832a84b7ae5f", "ww2c34dc56739bb105", aByte, QywxMediaTypeEnum.IMAGE.getCode());
// JSONResponse response = qywxSuiteApiService.uploadMedia("ww9ede832a84b7ae5f", "ww2c34dc56739bb105", aByte, QywxMediaTypeEnum.IMAGE.getCode());
// System.out.println(JSONObject.toJSONString(response));
// System.out.println(JSONObject.toJSONString(response));
QywxImageExternalMessageDTO
messageDTO
=
new
QywxImageExternalMessageDTO
();
QywxImageExternalMessageDTO
messageDTO
=
new
QywxImageExternalMessageDTO
();
messageDTO
.
setMediaId
(
"
3U5qDJRn46ZPUCQk3h2-7iqESryRICPLv6XHFEGy0r7MIJMVNkzpDjpPOo6k-R2uB
"
);
messageDTO
.
setMediaId
(
"
msg59NLDQAANPwzc9aMWNCBky8EElovyg
"
);
messageDTO
.
setSenderUserId
(
"9ae4c4f1277340a186b16a17d937c72c"
);
messageDTO
.
setSenderUserId
(
"9ae4c4f1277340a186b16a17d937c72c"
);
List
<
String
>
list
=
new
ArrayList
<>();
List
<
String
>
list
=
new
ArrayList
<>();
list
.
add
(
"wm59NLDQAAL0fHb-QEbx-U9pdtRFA1bg"
);
list
.
add
(
"wm59NLDQAAL0fHb-QEbx-U9pdtRFA1bg"
);
...
@@ -245,4 +254,30 @@ public void sendMessage() {
...
@@ -245,4 +254,30 @@ public void sendMessage() {
}
}
}
}
public
static
byte
[]
getFileByteArray
(
File
file
)
{
long
fileSize
=
file
.
length
();
if
(
fileSize
>
Integer
.
MAX_VALUE
)
{
System
.
out
.
println
(
"file too big..."
);
return
null
;
}
byte
[]
buffer
=
null
;
try
(
FileInputStream
fi
=
new
FileInputStream
(
file
))
{
buffer
=
new
byte
[(
int
)
fileSize
];
int
offset
=
0
;
int
numRead
=
0
;
while
(
offset
<
buffer
.
length
&&
(
numRead
=
fi
.
read
(
buffer
,
offset
,
buffer
.
length
-
offset
))
>=
0
)
{
offset
+=
numRead
;
}
// 确保所有数据均被读取
if
(
offset
!=
buffer
.
length
)
{
throw
new
IOException
(
"Could not completely read file "
+
file
.
getName
());
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
buffer
;
}
}
}
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/LoginController.java
View file @
ab6c3841
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
import
org.apache.commons.lang3.StringUtils
;
import
cn.hutool.crypto.SecureUtil
;
import
org.slf4j.Logger
;
import
cn.hutool.crypto.symmetric.AES
;
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.alibaba.dubbo.common.URL
;
import
com.alibaba.dubbo.common.URL
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.commons.util.ToolUtil
;
import
com.gic.commons.util.ToolUtil
;
import
com.gic.commons.web.ResponseThreadLocal
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.
common.utils.StringUtil
;
import
com.gic.haoban.
manage.api.dto.EnterpriseDetailDTO
;
import
com.gic.haoban.manage.api.dto.StaffDTO
;
import
com.gic.haoban.manage.api.dto.StaffDTO
;
import
com.gic.haoban.manage.api.dto.WxEnterpriseDTO
;
import
com.gic.haoban.manage.api.dto.WxEnterpriseDTO
;
import
com.gic.haoban.manage.api.service.StaffApiService
;
import
com.gic.haoban.manage.api.service.StaffApiService
;
import
com.gic.haoban.manage.api.service.WxEnterpriseApiService
;
import
com.gic.haoban.manage.api.service.WxEnterpriseApiService
;
import
com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService
;
import
com.gic.haoban.manage.web.anno.IgnoreLogin
;
import
com.gic.haoban.manage.web.anno.IgnoreLogin
;
import
com.gic.haoban.manage.web.auth.AuthRequestUtil
;
import
com.gic.haoban.manage.web.auth.AuthRequestUtil
;
import
com.gic.haoban.manage.web.config.Config
;
import
com.gic.haoban.manage.web.config.Config
;
...
@@ -25,23 +21,29 @@ import com.gic.haoban.manage.web.vo.LoginVO;
...
@@ -25,23 +21,29 @@ import com.gic.haoban.manage.web.vo.LoginVO;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.wechat.api.dto.qywx.UserDTO
;
import
com.gic.wechat.api.dto.qywx.UserDTO
;
import
com.gic.wechat.api.service.qywx.QywxCorpApiService
;
import
com.gic.wechat.api.service.qywx.QywxCorpApiService
;
import
com.gic.wechat.api.service.qywx.QywxUserApiService
;
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.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletResponse
;
@RestController
@RestController
public
class
LoginController
extends
WebBaseController
{
public
class
LoginController
extends
WebBaseController
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
LoginController
.
class
);
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
LoginController
.
class
);
private
static
final
String
LOGIN_KEY
=
"haoban#login$key"
;
@Autowired
@Autowired
StaffApiService
staffApiService
;
StaffApiService
staffApiService
;
...
@@ -50,6 +52,9 @@ public class LoginController extends WebBaseController{
...
@@ -50,6 +52,9 @@ public class LoginController extends WebBaseController{
@Autowired
@Autowired
private
WxEnterpriseApiService
wxEnterpriseApiService
;
private
WxEnterpriseApiService
wxEnterpriseApiService
;
@Autowired
private
WxEnterpriseRelatedApiService
wxEnterpriseRelatedApiService
;
@Autowired
@Autowired
...
@@ -136,18 +141,35 @@ public class LoginController extends WebBaseController{
...
@@ -136,18 +141,35 @@ public class LoginController extends WebBaseController{
}
}
//运维登录
//运维登录
@IgnoreLogin
@IgnoreLogin
@RequestMapping
(
"
yw
-login"
)
@RequestMapping
(
"
gic
-login"
)
public
HaobanResponse
ywLogin
(
String
wxEnterpriseId
,
String
random
,
HttpServletResponse
response
)
{
public
ModelAndView
ywLogin
(
String
random
,
HttpServletResponse
response
)
{
//判断是否存在random
//判断是否存在random
Object
o
=
RedisUtil
.
getCache
(
random
);
AES
aes
=
SecureUtil
.
aes
(
LOGIN_KEY
.
getBytes
());
String
o
=
aes
.
decryptStr
(
random
);
if
(
o
==
null
){
if
(
o
==
null
){
return
resultResponse
(
HaoBanErrCode
.
ERR_4
);
logger
.
info
(
"解密异常"
);
ModelAndView
model
=
new
ModelAndView
(
new
RedirectView
(
"/haoban-3/#/gic-error"
,
false
));
return
model
;
}
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
o
);
String
gicEnterpriseId
=
jsonObject
.
getString
(
"enterpriseId"
);
String
loginPhoneNumber
=
jsonObject
.
getString
(
"phoneNumber"
);
EnterpriseDetailDTO
detailDTO
=
wxEnterpriseRelatedApiService
.
getByEnterpriseId
(
gicEnterpriseId
);
if
(
null
==
detailDTO
)
{
logger
.
info
(
"登录失败,不存在对应企业:{}"
,
o
);
ModelAndView
model
=
new
ModelAndView
(
new
RedirectView
(
"/haoban-3/#/gic-error"
,
false
));
return
model
;
}
}
//TODO 获取超级管理员账号接口
//TODO 获取超级管理员账号接口
StaffDTO
staff
=
staffApiService
.
selectSuperByWxEnterpriseId
(
wxEnterpriseId
);
StaffDTO
staff
=
staffApiService
.
selectByNationcodeAndPhoneNumber
(
detailDTO
.
getWxEnterpriseId
(),
"86"
,
loginPhoneNumber
);
if
(
null
==
staff
)
{
logger
.
info
(
"登录用户手机号不存在!{}"
,
o
);
ModelAndView
model
=
new
ModelAndView
(
new
RedirectView
(
"/haoban-3/#/gic-error"
,
false
));
return
model
;
}
// StaffDTO staff = staffApiService.selectById("1");
// StaffDTO staff = staffApiService.selectById("1");
LoginVO
loginVO
=
new
LoginVO
();
LoginVO
loginVO
=
new
LoginVO
();
loginVO
.
setWxEnterpriseId
(
wxEnterpriseId
);
loginVO
.
setWxEnterpriseId
(
detailDTO
.
getWxEnterpriseId
()
);
loginVO
.
setStaffDTO
(
staff
);
loginVO
.
setStaffDTO
(
staff
);
AuthRequestUtil
.
setSessionUser
(
loginVO
);
AuthRequestUtil
.
setSessionUser
(
loginVO
);
String
redirectUri
=
config
.
getHost
()
+
"index"
;
String
redirectUri
=
config
.
getHost
()
+
"index"
;
...
@@ -163,8 +185,8 @@ public class LoginController extends WebBaseController{
...
@@ -163,8 +185,8 @@ public class LoginController extends WebBaseController{
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
// TODO Auto-generated catch block
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
)
;
return
null
;
}
}
...
...
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