Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_backend
Commits
8c81975d
Commit
8c81975d
authored
Sep 25, 2023
by
muhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改 藏馆的收藏品和收藏册数量
parent
b5239edf
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
5 deletions
+68
-5
ch-core/src/main/java/com/wwdz/ch/core/util/MediaUtil.java
ch-core/src/main/java/com/wwdz/ch/core/util/MediaUtil.java
+49
-0
ch-dao/src/main/java/com/wwdz/ch/db/dao/FavoritesItemsRelationDao.java
...in/java/com/wwdz/ch/db/dao/FavoritesItemsRelationDao.java
+1
-1
ch-dao/src/main/java/com/wwdz/ch/db/impl/FavoritesItemsRelationDaoImpl.java
...va/com/wwdz/ch/db/impl/FavoritesItemsRelationDaoImpl.java
+2
-2
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
...c/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
+2
-1
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemCommonServiceImpl.java
.../main/java/com/wwdz/ch/wx/impl/ItemCommonServiceImpl.java
+5
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/ItemCommonService.java
...c/main/java/com/wwdz/ch/wx/service/ItemCommonService.java
+9
-1
No files found.
ch-core/src/main/java/com/wwdz/ch/core/util/MediaUtil.java
View file @
8c81975d
...
@@ -139,6 +139,55 @@ public class MediaUtil {
...
@@ -139,6 +139,55 @@ public class MediaUtil {
return
map
;
return
map
;
}
}
/**
* 通过文件头判断图片格式
*
* @param inputStream
* @return
* @throws IOException
*/
public
static
String
imgType
(
InputStream
inputStream
)
throws
IOException
{
// 读取文件前几位
byte
[]
fileHeader
=
new
byte
[
4
];
int
read
=
inputStream
.
read
(
fileHeader
,
0
,
fileHeader
.
length
);
inputStream
.
close
();
// 转为十六进制字符串
String
header
=
bytes2Hex
(
fileHeader
);
if
(
header
.
contains
(
"FFD8FF"
))
{
return
"jpg"
;
}
else
if
(
header
.
contains
(
"89504E47"
))
{
return
"png"
;
}
else
if
(
header
.
contains
(
"47494638"
))
{
return
"gif"
;
}
else
if
(
header
.
contains
(
"424D"
))
{
return
"bmp"
;
}
else
if
(
header
.
contains
(
"52494646"
))
{
return
"webp"
;
}
else
if
(
header
.
contains
(
"49492A00"
))
{
return
"tif"
;
}
else
{
return
"unknown"
;
}
}
/**
* 转为十六进制字符串
*
* @param bytes
* @return
*/
public
static
String
bytes2Hex
(
byte
[]
bytes
)
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
byte
b
:
bytes
)
{
String
hex
=
Integer
.
toHexString
(
b
&
0xff
);
sb
.
append
(
hex
.
length
()
==
2
?
hex
:
(
"0"
+
hex
));
}
return
sb
.
toString
();
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
String
vedioUrl
=
"https://cdn.wanwudezhi.com/static/web-static/video/53596700878a572ca4fae35243aaa819.mp4"
;
String
vedioUrl
=
"https://cdn.wanwudezhi.com/static/web-static/video/53596700878a572ca4fae35243aaa819.mp4"
;
String
url
=
getImageByCutVedio
(
vedioUrl
);
String
url
=
getImageByCutVedio
(
vedioUrl
);
...
...
ch-dao/src/main/java/com/wwdz/ch/db/dao/FavoritesItemsRelationDao.java
View file @
8c81975d
...
@@ -128,7 +128,7 @@ public interface FavoritesItemsRelationDao {
...
@@ -128,7 +128,7 @@ public interface FavoritesItemsRelationDao {
* @param userId
* @param userId
* @return
* @return
*/
*/
long
countByUserId
(
Long
userId
);
long
countByUserId
(
Long
userId
,
List
<
Long
>
itemIds
);
/**
/**
* 连表查询获取藏品的图片
* 连表查询获取藏品的图片
...
...
ch-dao/src/main/java/com/wwdz/ch/db/impl/FavoritesItemsRelationDaoImpl.java
View file @
8c81975d
...
@@ -15,7 +15,6 @@ import org.springframework.util.CollectionUtils;
...
@@ -15,7 +15,6 @@ import org.springframework.util.CollectionUtils;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
@Repository
@Repository
public
class
FavoritesItemsRelationDaoImpl
implements
FavoritesItemsRelationDao
{
public
class
FavoritesItemsRelationDaoImpl
implements
FavoritesItemsRelationDao
{
...
@@ -143,10 +142,11 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
...
@@ -143,10 +142,11 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
}
}
@Override
@Override
public
long
countByUserId
(
Long
userId
)
{
public
long
countByUserId
(
Long
userId
,
List
<
Long
>
itemIds
)
{
FavoritesItemsRelationExample
example
=
new
FavoritesItemsRelationExample
();
FavoritesItemsRelationExample
example
=
new
FavoritesItemsRelationExample
();
FavoritesItemsRelationExample
.
Criteria
criteria
=
example
.
createCriteria
();
FavoritesItemsRelationExample
.
Criteria
criteria
=
example
.
createCriteria
();
JdbcHelper
.
ifPresent
(
userId
,
criteria:
:
andUserIdEqualTo
);
JdbcHelper
.
ifPresent
(
userId
,
criteria:
:
andUserIdEqualTo
);
JdbcHelper
.
ifPresent
(
itemIds
,
criteria:
:
andItemIdNotIn
);
return
favoritesItemsRelationMapper
.
countByExample
(
example
);
return
favoritesItemsRelationMapper
.
countByExample
(
example
);
}
}
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
View file @
8c81975d
...
@@ -209,7 +209,8 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -209,7 +209,8 @@ public class FavoritesServiceImpl implements FavoritesService {
@Override
@Override
public
Result
favoritesNum
(
FavoritesRequestDto
dto
)
{
public
Result
favoritesNum
(
FavoritesRequestDto
dto
)
{
try
{
try
{
long
itemNum
=
favoritesItemsRelationDao
.
countByUserId
(
dto
.
getUserId
());
List
<
Long
>
itemIds
=
itemCommonService
.
getOnlyOneselfItemIdsByUserId
(
dto
.
getUserId
());
long
itemNum
=
favoritesItemsRelationDao
.
countByUserId
(
dto
.
getUserId
(),
itemIds
);
long
favoritesNum
=
favoritesDao
.
countByUserId
(
dto
.
getUserId
());
long
favoritesNum
=
favoritesDao
.
countByUserId
(
dto
.
getUserId
());
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"itemNum"
,
itemNum
);
map
.
put
(
"itemNum"
,
itemNum
);
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemCommonServiceImpl.java
View file @
8c81975d
...
@@ -68,6 +68,11 @@ public class ItemCommonServiceImpl implements ItemCommonService {
...
@@ -68,6 +68,11 @@ public class ItemCommonServiceImpl implements ItemCommonService {
return
itemDao
.
findOnlyOneselfItems
(
userId
);
return
itemDao
.
findOnlyOneselfItems
(
userId
);
}
}
@Override
public
List
<
Long
>
getOnlyOneselfItemIdsByUserId
(
Long
userId
)
{
return
itemDao
.
findOnlyOneselfItems
(
userId
);
}
@Override
@Override
public
void
getPageViews
(
UserInfo
userInfo
)
{
public
void
getPageViews
(
UserInfo
userInfo
)
{
long
followersNumber
=
0
;
long
followersNumber
=
0
;
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/ItemCommonService.java
View file @
8c81975d
...
@@ -15,13 +15,21 @@ public interface ItemCommonService {
...
@@ -15,13 +15,21 @@ public interface ItemCommonService {
void
getNicknameAvatar
(
Long
itemId
,
ItemResponseVo
vo
);
void
getNicknameAvatar
(
Long
itemId
,
ItemResponseVo
vo
);
/**
/**
* 获取仅自己可见的用户发布的藏品
* 获取
登录用户
仅自己可见的用户发布的藏品
*
*
* @param token
* @param token
* @return
* @return
*/
*/
List
<
Long
>
getOnlyOneselfItemIds
(
String
token
);
List
<
Long
>
getOnlyOneselfItemIds
(
String
token
);
/**
* 获取被查询用户仅自己可见的用户发布的藏品
*
* @param userId
* @return
*/
List
<
Long
>
getOnlyOneselfItemIdsByUserId
(
Long
userId
);
/**
/**
* 获取关注粉丝收藏和浏览量
* 获取关注粉丝收藏和浏览量
*
*
...
...
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