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
ba774870
Commit
ba774870
authored
May 08, 2020
by
qwmqiuwenmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
b95b9255
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
118 additions
and
12 deletions
+118
-12
MaterialApiService.java
...com/gic/haoban/manage/api/service/MaterialApiService.java
+2
-2
MaterialService.java
...om/gic/haoban/manage/service/service/MaterialService.java
+1
-1
MaterialServiceImpl.java
...oban/manage/service/service/impl/MaterialServiceImpl.java
+1
-1
MaterialApiServiceImpl.java
...nage/service/service/out/impl/MaterialApiServiceImpl.java
+110
-4
MaterialController.java
.../gic/haoban/manage/web/controller/MaterialController.java
+4
-4
No files found.
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/service/MaterialApiService.java
View file @
ba774870
...
@@ -21,11 +21,11 @@ public interface MaterialApiService {
...
@@ -21,11 +21,11 @@ public interface MaterialApiService {
List
<
MaterialDTO
>
listMaterialByCategoryId
(
String
categoryId
);
List
<
MaterialDTO
>
listMaterialByCategoryId
(
String
categoryId
);
void
insert
Category
(
MaterialDTO
materialDTO
);
void
insert
Material
(
MaterialDTO
materialDTO
);
MaterialDTO
selectMaterialById
(
String
materialId
);
MaterialDTO
selectMaterialById
(
String
materialId
);
void
edit
Category
(
MaterialDTO
materialDTO
);
void
edit
Material
(
MaterialDTO
materialDTO
);
Page
<
MaterialDTO
>
listMaterial
(
String
wxEnterpriseId
,
String
keyword
,
String
categoryId
,
Integer
materialType
,
BasePageInfo
pageInfo
);
Page
<
MaterialDTO
>
listMaterial
(
String
wxEnterpriseId
,
String
keyword
,
String
categoryId
,
Integer
materialType
,
BasePageInfo
pageInfo
);
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/MaterialService.java
View file @
ba774870
...
@@ -8,7 +8,7 @@ public interface MaterialService {
...
@@ -8,7 +8,7 @@ public interface MaterialService {
List
<
MaterialDTO
>
listMaterialByCategoryId
(
String
categoryId
);
List
<
MaterialDTO
>
listMaterialByCategoryId
(
String
categoryId
);
void
insert
Category
(
MaterialDTO
materialDTO
);
void
insert
Material
(
MaterialDTO
materialDTO
);
MaterialDTO
selectMaterialById
(
String
materialId
);
MaterialDTO
selectMaterialById
(
String
materialId
);
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/MaterialServiceImpl.java
View file @
ba774870
...
@@ -26,7 +26,7 @@ public class MaterialServiceImpl implements MaterialService {
...
@@ -26,7 +26,7 @@ public class MaterialServiceImpl implements MaterialService {
}
}
@Override
@Override
public
void
insert
Category
(
MaterialDTO
materialDTO
)
{
public
void
insert
Material
(
MaterialDTO
materialDTO
)
{
materialDTO
.
setCreateTime
(
new
Date
());
materialDTO
.
setCreateTime
(
new
Date
());
materialDTO
.
setUpdateTime
(
materialDTO
.
getCreateTime
());
materialDTO
.
setUpdateTime
(
materialDTO
.
getCreateTime
());
materialDTO
.
setStatusFlag
(
1
);
materialDTO
.
setStatusFlag
(
1
);
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/MaterialApiServiceImpl.java
View file @
ba774870
package
com
.
gic
.
haoban
.
manage
.
service
.
service
.
out
.
impl
;
package
com
.
gic
.
haoban
.
manage
.
service
.
service
.
out
.
impl
;
import
java.io.InputStream
;
import
java.net.URL
;
import
java.util.List
;
import
java.util.List
;
import
org.apache.commons.io.IOUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.alibaba.fastjson.JSON
;
import
com.gic.api.base.commons.JSONResponse
;
import
com.gic.api.base.commons.Page
;
import
com.gic.api.base.commons.Page
;
import
com.gic.commons.util.GlobalInfo
;
import
com.gic.commons.util.GlobalVar
;
import
com.gic.haoban.base.api.common.BasePageInfo
;
import
com.gic.haoban.base.api.common.BasePageInfo
;
import
com.gic.haoban.common.utils.PageUtil
;
import
com.gic.haoban.common.utils.PageUtil
;
import
com.gic.haoban.manage.api.dto.DepartmentDTO
;
import
com.gic.haoban.manage.api.dto.DepartmentDTO
;
import
com.gic.haoban.manage.api.dto.MaterialCategoryDTO
;
import
com.gic.haoban.manage.api.dto.MaterialCategoryDTO
;
import
com.gic.haoban.manage.api.dto.MaterialDTO
;
import
com.gic.haoban.manage.api.dto.MaterialDTO
;
import
com.gic.haoban.manage.api.dto.WxEnterpriseDTO
;
import
com.gic.haoban.manage.api.service.MaterialApiService
;
import
com.gic.haoban.manage.api.service.MaterialApiService
;
import
com.gic.haoban.manage.service.config.Config
;
import
com.gic.haoban.manage.service.service.MaterialCategoryService
;
import
com.gic.haoban.manage.service.service.MaterialCategoryService
;
import
com.gic.haoban.manage.service.service.MaterialService
;
import
com.gic.haoban.manage.service.service.MaterialService
;
import
com.gic.haoban.manage.service.service.WxEnterpriseService
;
import
com.gic.thirdparty.api.dto.PicUploadResDTO
;
import
com.gic.wechat.api.enums.QywxMediaTypeEnum
;
import
com.gic.wechat.api.service.qywx.QywxSuiteApiService
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageHelper
;
@Service
@Service
...
@@ -24,6 +39,17 @@ public class MaterialApiServiceImpl implements MaterialApiService {
...
@@ -24,6 +39,17 @@ public class MaterialApiServiceImpl implements MaterialApiService {
@Autowired
@Autowired
private
MaterialService
materialService
;
private
MaterialService
materialService
;
@Autowired
private
QywxSuiteApiService
qywxSuiteApiService
;
@Autowired
private
WxEnterpriseService
wxEnterpriseService
;
@Autowired
private
Config
config
;
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
MaterialApiServiceImpl
.
class
);
@Override
@Override
public
boolean
hasCategoryNameExsit
(
String
categoryName
,
String
categoryParentId
,
String
categoryId
)
{
public
boolean
hasCategoryNameExsit
(
String
categoryName
,
String
categoryParentId
,
String
categoryId
)
{
...
@@ -68,8 +94,39 @@ public class MaterialApiServiceImpl implements MaterialApiService {
...
@@ -68,8 +94,39 @@ public class MaterialApiServiceImpl implements MaterialApiService {
}
}
@Override
@Override
public
void
insertCategory
(
MaterialDTO
materialDTO
)
{
public
void
insertMaterial
(
MaterialDTO
materialDTO
)
{
materialService
.
insertCategory
(
materialDTO
);
Integer
type
=
materialDTO
.
getMaterialType
();
String
wxEnterpriseId
=
materialDTO
.
getWxEnterpriseId
();
WxEnterpriseDTO
enterprise
=
wxEnterpriseService
.
selectById
(
wxEnterpriseId
);
if
(
type
==
null
){
return
;
}
if
(
enterprise
==
null
){
return
;
}
QywxMediaTypeEnum
fileType
=
null
;
String
url
=
""
;
if
(
type
==
2
){
fileType
=
QywxMediaTypeEnum
.
IMAGE
;
url
=
materialDTO
.
getImgUrl
();
}
if
(
type
==
4
){
fileType
=
QywxMediaTypeEnum
.
VIDEO
;
url
=
materialDTO
.
getLink
();
}
if
(
type
==
5
){
fileType
=
QywxMediaTypeEnum
.
FILE
;
url
=
materialDTO
.
getLink
();
}
if
(
fileType
!=
null
){
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
enterprise
.
getCorpid
(),
config
.
getWxSuiteid
(),
getFileByte
(
url
),
fileType
.
getCode
());
if
(
jp
.
getErrorCode
()
==
0
){
materialDTO
.
setMediaId
(
jp
.
getResult
().
toString
());
materialService
.
insertMaterial
(
materialDTO
);
}
}
else
{
materialService
.
insertMaterial
(
materialDTO
);
}
}
}
@Override
@Override
...
@@ -78,8 +135,45 @@ public class MaterialApiServiceImpl implements MaterialApiService {
...
@@ -78,8 +135,45 @@ public class MaterialApiServiceImpl implements MaterialApiService {
}
}
@Override
@Override
public
void
editCategory
(
MaterialDTO
materialDTO
)
{
public
void
editMaterial
(
MaterialDTO
materialDTO
)
{
materialService
.
edit
(
materialDTO
);
Integer
type
=
materialDTO
.
getMaterialType
();
String
materialId
=
materialDTO
.
getMaterialId
();
MaterialDTO
old
=
materialService
.
selectMaterialById
(
materialId
);
String
wxEnterpriseId
=
old
.
getWxEnterpriseId
();
WxEnterpriseDTO
enterprise
=
wxEnterpriseService
.
selectById
(
wxEnterpriseId
);
if
(
type
==
null
){
return
;
}
if
(
enterprise
==
null
){
return
;
}
QywxMediaTypeEnum
fileType
=
null
;
String
url
=
""
;
String
oldUrl
=
""
;
if
(
type
==
2
){
fileType
=
QywxMediaTypeEnum
.
IMAGE
;
url
=
materialDTO
.
getImgUrl
();
oldUrl
=
old
.
getImgUrl
();
}
if
(
type
==
4
){
fileType
=
QywxMediaTypeEnum
.
VIDEO
;
url
=
materialDTO
.
getLink
();
oldUrl
=
old
.
getLink
();
}
if
(
type
==
5
){
fileType
=
QywxMediaTypeEnum
.
FILE
;
url
=
materialDTO
.
getLink
();
oldUrl
=
old
.
getLink
();
}
if
(
fileType
!=
null
&&
!
url
.
equals
(
oldUrl
)){
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
enterprise
.
getCorpid
(),
config
.
getWxSuiteid
(),
getFileByte
(
url
),
fileType
.
getCode
());
if
(
jp
.
getErrorCode
()
==
0
){
materialDTO
.
setMediaId
(
jp
.
getResult
().
toString
());
materialService
.
edit
(
materialDTO
);
}
}
else
{
materialService
.
edit
(
materialDTO
);
}
}
}
...
@@ -89,5 +183,17 @@ public class MaterialApiServiceImpl implements MaterialApiService {
...
@@ -89,5 +183,17 @@ public class MaterialApiServiceImpl implements MaterialApiService {
PageHelper
.
startPage
(
pageInfo
.
getPageNum
(),
pageInfo
.
getPageSize
());
PageHelper
.
startPage
(
pageInfo
.
getPageNum
(),
pageInfo
.
getPageSize
());
return
PageUtil
.
changePageHelperToCurrentPage
(
materialService
.
listMaterial
(
wxEnterpriseId
,
keyword
,
categoryId
,
materialType
),
MaterialDTO
.
class
);
return
PageUtil
.
changePageHelperToCurrentPage
(
materialService
.
listMaterial
(
wxEnterpriseId
,
keyword
,
categoryId
,
materialType
),
MaterialDTO
.
class
);
}
}
private
byte
[]
getFileByte
(
String
url
)
{
try
{
InputStream
in
=
new
URL
(
url
).
openStream
();
byte
[]
data
=
IOUtils
.
toByteArray
(
in
);
return
data
;
}
catch
(
Exception
e
){
}
return
null
;
}
}
}
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/MaterialController.java
View file @
ba774870
...
@@ -124,7 +124,7 @@ public class MaterialController extends WebBaseController{
...
@@ -124,7 +124,7 @@ public class MaterialController extends WebBaseController{
if
(
categoryType
==
null
){
if
(
categoryType
==
null
){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
}
materialApiService
.
insert
Category
(
materialDTO
);
materialApiService
.
insert
Material
(
materialDTO
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
}
...
@@ -144,7 +144,7 @@ public class MaterialController extends WebBaseController{
...
@@ -144,7 +144,7 @@ public class MaterialController extends WebBaseController{
if
(
dto
==
null
){
if
(
dto
==
null
){
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
}
materialApiService
.
edit
Category
(
materialDTO
);
materialApiService
.
edit
Material
(
materialDTO
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
}
...
@@ -164,7 +164,7 @@ public class MaterialController extends WebBaseController{
...
@@ -164,7 +164,7 @@ public class MaterialController extends WebBaseController{
continue
;
continue
;
}
}
dto
.
setStatusFlag
(
0
);
dto
.
setStatusFlag
(
0
);
materialApiService
.
edit
Category
(
dto
);
materialApiService
.
edit
Material
(
dto
);
}
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
}
...
@@ -192,7 +192,7 @@ public class MaterialController extends WebBaseController{
...
@@ -192,7 +192,7 @@ public class MaterialController extends WebBaseController{
continue
;
continue
;
}
}
dto
.
setCategoryId
(
categoryId
);;
dto
.
setCategoryId
(
categoryId
);;
materialApiService
.
edit
Category
(
dto
);
materialApiService
.
edit
Material
(
dto
);
}
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
}
...
...
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