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
8a11d2c1
Commit
8a11d2c1
authored
Mar 31, 2025
by
徐高华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
素材分组排序
parent
601f61a2
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
167 additions
and
82 deletions
+167
-82
MaterialCategoryDTO.java
...va/com/gic/haoban/manage/api/dto/MaterialCategoryDTO.java
+10
-0
MaterialCategorySortQDTO.java
.../haoban/manage/api/dto/qdto/MaterialCategorySortQDTO.java
+36
-0
MaterialApiService.java
...com/gic/haoban/manage/api/service/MaterialApiService.java
+6
-0
TabHaobanMaterialCategoryMapper.java
...e/service/dao/mapper/TabHaobanMaterialCategoryMapper.java
+4
-4
TabHaobanMaterialCategory.java
...oban/manage/service/entity/TabHaobanMaterialCategory.java
+10
-0
MaterialCategoryService.java
...aoban/manage/service/service/MaterialCategoryService.java
+2
-0
MaterialCategoryServiceImpl.java
...age/service/service/impl/MaterialCategoryServiceImpl.java
+50
-0
MaterialApiServiceImpl.java
...nage/service/service/out/impl/MaterialApiServiceImpl.java
+5
-1
TabHaobanMaterialCategoryMapper.xml
...main/resources/mapper/TabHaobanMaterialCategoryMapper.xml
+23
-77
MaterialController.java
.../gic/haoban/manage/web/controller/MaterialController.java
+21
-0
No files found.
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/dto/MaterialCategoryDTO.java
View file @
8a11d2c1
...
...
@@ -19,8 +19,18 @@ public class MaterialCategoryDTO implements Serializable{
private
Date
updateTime
;
private
Integer
sortNum
;
private
static
final
long
serialVersionUID
=
1L
;
public
Integer
getSortNum
()
{
return
sortNum
;
}
public
void
setSortNum
(
Integer
sortNum
)
{
this
.
sortNum
=
sortNum
;
}
public
String
getCategoryId
()
{
return
categoryId
;
}
...
...
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/dto/qdto/MaterialCategorySortQDTO.java
0 → 100644
View file @
8a11d2c1
package
com
.
gic
.
haoban
.
manage
.
api
.
dto
.
qdto
;
import
java.io.Serializable
;
public
class
MaterialCategorySortQDTO
implements
Serializable
{
private
String
categoryId
;
private
String
wxEnterpriseId
;
private
Integer
sortNum
;
public
String
getCategoryId
()
{
return
categoryId
;
}
public
void
setCategoryId
(
String
categoryId
)
{
this
.
categoryId
=
categoryId
;
}
public
String
getWxEnterpriseId
()
{
return
wxEnterpriseId
;
}
public
void
setWxEnterpriseId
(
String
wxEnterpriseId
)
{
this
.
wxEnterpriseId
=
wxEnterpriseId
;
}
public
Integer
getSortNum
()
{
return
sortNum
;
}
public
void
setSortNum
(
Integer
sortNum
)
{
this
.
sortNum
=
sortNum
;
}
}
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/service/MaterialApiService.java
View file @
8a11d2c1
...
...
@@ -7,6 +7,7 @@ import com.gic.haoban.manage.api.dto.BatchAddMaterialDTO;
import
com.gic.haoban.manage.api.dto.ContentMaterialDTO
;
import
com.gic.haoban.manage.api.dto.MaterialCategoryDTO
;
import
com.gic.haoban.manage.api.dto.MaterialDTO
;
import
com.gic.haoban.manage.api.dto.qdto.MaterialCategorySortQDTO
;
import
com.gic.haoban.manage.api.qdto.combined.CombinedQDTO
;
import
java.util.List
;
...
...
@@ -88,4 +89,9 @@ public interface MaterialApiService {
com
.
gic
.
api
.
base
.
commons
.
ServiceResponse
<
String
>
getMaterialIdByCombined
(
String
wxEnterpriseId
,
CombinedQDTO
combinedQDTO
);
/**
* 排序
* @param qdto
*/
void
materialSortCategory
(
MaterialCategorySortQDTO
qdto
);
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/dao/mapper/TabHaobanMaterialCategoryMapper.java
View file @
8a11d2c1
...
...
@@ -8,18 +8,15 @@ import com.gic.haoban.manage.api.dto.MaterialCategoryDTO;
import
com.gic.haoban.manage.service.entity.TabHaobanMaterialCategory
;
public
interface
TabHaobanMaterialCategoryMapper
{
int
deleteByPrimaryKey
(
String
categoryId
);
int
insert
(
TabHaobanMaterialCategory
record
);
int
insertSelective
(
TabHaobanMaterialCategory
record
)
;
int
getMaxSortNum
(
@Param
(
"wxEnterpriseId"
)
String
wxEnterpriseId
,
@Param
(
"parentId"
)
String
parentId
)
;
TabHaobanMaterialCategory
selectByPrimaryKey
(
String
categoryId
);
int
updateByPrimaryKeySelective
(
TabHaobanMaterialCategory
record
);
int
updateByPrimaryKey
(
TabHaobanMaterialCategory
record
);
TabHaobanMaterialCategory
selectByCategoryNameAndParentId
(
@Param
(
"categoryName"
)
String
categoryName
,
@Param
(
"categoryParentId"
)
String
categoryParentId
,
@Param
(
"wxEnterpriseId"
)
String
wxEnterpriseId
);
...
...
@@ -27,4 +24,6 @@ public interface TabHaobanMaterialCategoryMapper {
List
<
TabHaobanMaterialCategory
>
listCategory
(
@Param
(
"wxEnterpriseId"
)
String
wxEnterpriseId
);
List
<
TabHaobanMaterialCategory
>
listByParentCategory
(
@Param
(
"categoryId"
)
String
categoryId
);
void
updateSortNum
(
@Param
(
"list"
)
List
<
MaterialCategoryDTO
>
list
);
}
\ No newline at end of file
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/entity/TabHaobanMaterialCategory.java
View file @
8a11d2c1
...
...
@@ -18,8 +18,18 @@ public class TabHaobanMaterialCategory implements Serializable {
private
Date
updateTime
;
private
Integer
sortNum
;
private
static
final
long
serialVersionUID
=
1L
;
public
Integer
getSortNum
()
{
return
sortNum
;
}
public
void
setSortNum
(
Integer
sortNum
)
{
this
.
sortNum
=
sortNum
;
}
public
String
getCategoryId
()
{
return
categoryId
;
}
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/MaterialCategoryService.java
View file @
8a11d2c1
...
...
@@ -3,6 +3,7 @@ package com.gic.haoban.manage.service.service;
import
java.util.List
;
import
com.gic.haoban.manage.api.dto.MaterialCategoryDTO
;
import
com.gic.haoban.manage.api.dto.qdto.MaterialCategorySortQDTO
;
public
interface
MaterialCategoryService
{
...
...
@@ -18,4 +19,5 @@ public interface MaterialCategoryService {
List
<
MaterialCategoryDTO
>
listByParentCategory
(
String
categoryId
);
void
materialSortCategory
(
MaterialCategorySortQDTO
qdto
);
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/MaterialCategoryServiceImpl.java
View file @
8a11d2c1
...
...
@@ -3,6 +3,8 @@ package com.gic.haoban.manage.service.service.impl;
import
java.util.Date
;
import
java.util.List
;
import
com.gic.haoban.manage.api.dto.qdto.MaterialCategorySortQDTO
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -30,6 +32,7 @@ public class MaterialCategoryServiceImpl implements MaterialCategoryService{
materialCategoryDTO
.
setCreateTime
(
new
Date
());
materialCategoryDTO
.
setUpdateTime
(
materialCategoryDTO
.
getCreateTime
());
materialCategoryDTO
.
setStatusFlag
(
1
);
materialCategoryDTO
.
setSortNum
(
this
.
mapper
.
getMaxSortNum
(
materialCategoryDTO
.
getWxEnterpriseId
(),
materialCategoryDTO
.
getCategoryParentId
())
+
1
);
mapper
.
insert
(
EntityUtil
.
changeEntityByJSON
(
TabHaobanMaterialCategory
.
class
,
materialCategoryDTO
));
}
...
...
@@ -54,4 +57,51 @@ public class MaterialCategoryServiceImpl implements MaterialCategoryService{
return
EntityUtil
.
changeEntityListByJSON
(
MaterialCategoryDTO
.
class
,
mapper
.
listByParentCategory
(
categoryId
));
}
@Override
public
void
materialSortCategory
(
MaterialCategorySortQDTO
qdto
)
{
String
categoryId
=
qdto
.
getCategoryId
();
Integer
sortNum
=
qdto
.
getSortNum
();
MaterialCategoryDTO
dto
=
this
.
selectMaterialCategoryById
(
categoryId
)
;
String
parentId
=
dto
.
getCategoryParentId
();
List
<
MaterialCategoryDTO
>
list
=
this
.
listByParentCategory
(
parentId
)
;
int
oldSortNum
=
0
;
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
MaterialCategoryDTO
item
=
list
.
get
(
i
)
;
if
(
item
.
getCategoryId
().
equals
(
categoryId
))
{
oldSortNum
=
i
+
1
;
}
}
int
index
=
1
;
int
maxIndex
=
sortNum
+
1
;
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
int
x
=
i
+
1
;
MaterialCategoryDTO
item
=
list
.
get
(
i
)
;
if
(
item
.
getCategoryId
().
equals
(
categoryId
))
{
item
.
setSortNum
(
sortNum
);
continue
;
}
// 往后排
if
(
sortNum
>
oldSortNum
)
{
if
(
x
>
sortNum
)
{
item
.
setSortNum
(
maxIndex
);
maxIndex
++
;
}
else
{
item
.
setSortNum
(
index
);
index
++
;
}
continue
;
}
// 往前排
if
(
x
>=
sortNum
)
{
item
.
setSortNum
(
maxIndex
);
maxIndex
++
;
}
else
{
item
.
setSortNum
(
index
);
index
++
;
}
}
}
this
.
mapper
.
updateSortNum
(
list
)
;
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/MaterialApiServiceImpl.java
View file @
8a11d2c1
...
...
@@ -10,6 +10,7 @@ import java.util.stream.Collectors;
import
com.gic.commons.util.TraceIdUtil
;
import
com.gic.dubbo.entity.ProviderLocalTag
;
import
com.gic.haoban.manage.api.dto.qdto.MaterialCategorySortQDTO
;
import
com.gic.haoban.manage.api.qdto.combined.CombinedQDTO
;
import
com.gic.haoban.manage.service.context.combined.ImageCombined
;
import
com.gic.redis.data.util.RedisUtil
;
...
...
@@ -107,8 +108,11 @@ public class MaterialApiServiceImpl implements MaterialApiService {
@Override
public
void
editCategory
(
MaterialCategoryDTO
materialCategoryDTO
)
{
materialCategoryService
.
editCategory
(
materialCategoryDTO
);
}
@Override
public
void
materialSortCategory
(
MaterialCategorySortQDTO
qdto
)
{
this
.
materialCategoryService
.
materialSortCategory
(
qdto
)
;
}
@Override
...
...
haoban-manage3-service/src/main/resources/mapper/TabHaobanMaterialCategoryMapper.xml
View file @
8a11d2c1
...
...
@@ -9,10 +9,11 @@
<result
column=
"status_flag"
property=
"statusFlag"
jdbcType=
"INTEGER"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"update_time"
property=
"updateTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"sort_num"
property=
"sortNum"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
category_id, category_name, category_parent_id, wx_enterprise_id, status_flag, create_time,
update_time
update_time
, sort_num
</sql>
<select
id=
"selectByPrimaryKey"
resultMap=
"BaseResultMap"
parameterType=
"java.lang.String"
>
select
...
...
@@ -20,102 +21,40 @@
from tab_haoban_material_category
where category_id = #{categoryId,jdbcType=VARCHAR}
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.String"
>
delete from tab_haoban_material_category
where category_id = #{categoryId,jdbcType=VARCHAR}
</delete>
<insert
id=
"insert"
parameterType=
"com.gic.haoban.manage.service.entity.TabHaobanMaterialCategory"
>
insert into tab_haoban_material_category (category_id, category_name, category_parent_id,
wx_enterprise_id, status_flag, create_time,
wx_enterprise_id, status_flag, create_time,
sort_num ,
update_time)
values (#{categoryId,jdbcType=VARCHAR}, #{categoryName,jdbcType=VARCHAR}, #{categoryParentId,jdbcType=VARCHAR},
#{wxEnterpriseId,jdbcType=VARCHAR}, #{statusFlag,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{wxEnterpriseId,jdbcType=VARCHAR}, #{statusFlag,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{sortNum} ,
#{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.gic.haoban.manage.service.entity.TabHaobanMaterialCategory"
>
insert into tab_haoban_material_category
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"categoryId != null"
>
category_id,
</if>
<if
test=
"categoryName != null"
>
category_name,
</if>
<if
test=
"categoryParentId != null"
>
category_parent_id,
</if>
<if
test=
"wxEnterpriseId != null"
>
wx_enterprise_id,
</if>
<if
test=
"statusFlag != null"
>
status_flag,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"categoryId != null"
>
#{categoryId,jdbcType=VARCHAR},
</if>
<if
test=
"categoryName != null"
>
#{categoryName,jdbcType=VARCHAR},
</if>
<if
test=
"categoryParentId != null"
>
#{categoryParentId,jdbcType=VARCHAR},
</if>
<if
test=
"wxEnterpriseId != null"
>
#{wxEnterpriseId,jdbcType=VARCHAR},
</if>
<if
test=
"statusFlag != null"
>
#{statusFlag,jdbcType=INTEGER},
</if>
<if
test=
"createTime != null"
>
#{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"com.gic.haoban.manage.service.entity.TabHaobanMaterialCategory"
>
update tab_haoban_material_category
<set
>
<if
test=
"categoryName != null"
>
category_name = #{categoryName,jdbcType=VARCHAR},
</if>
<if
test=
"categoryParentId != null"
>
category_parent_id = #{categoryParentId,jdbcType=VARCHAR},
</if>
<if
test=
"wxEnterpriseId != null"
>
wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR},
</if>
<if
test=
"statusFlag != null"
>
status_flag = #{statusFlag,jdbcType=INTEGER},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where category_id = #{categoryId,jdbcType=VARCHAR}
</update>
<update
id=
"updateByPrimaryKey"
parameterType=
"com.gic.haoban.manage.service.entity.TabHaobanMaterialCategory"
>
update tab_haoban_material_category
set category_name = #{categoryName,jdbcType=VARCHAR},
category_parent_id = #{categoryParentId,jdbcType=VARCHAR},
wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR},
status_flag = #{statusFlag,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where category_id = #{categoryId,jdbcType=VARCHAR}
<update
id=
"updateSortNum"
>
<foreach
collection=
"list"
item=
"item"
separator=
";"
>
UPDATE tab_haoban_material_category
SET sort_num = #{item.sortNum}
WHERE category_id = #{item.categoryId}
</foreach>
</update>
<select
id=
"selectByCategoryNameAndParentId"
resultMap=
"BaseResultMap"
parameterType=
"java.lang.String"
>
select
<include
refid=
"Base_Column_List"
/>
...
...
@@ -131,7 +70,7 @@
<include
refid=
"Base_Column_List"
/>
from tab_haoban_material_category
where status_flag = 1
and wx_enterprise_id = #{wxEnterpriseId} order by sort_num
de
sc , create_time desc
and wx_enterprise_id = #{wxEnterpriseId} order by sort_num
a
sc , create_time desc
</select>
<select
id=
"listByParentCategory"
resultMap=
"BaseResultMap"
parameterType=
"java.lang.String"
>
...
...
@@ -139,6 +78,12 @@
<include
refid=
"Base_Column_List"
/>
from tab_haoban_material_category
where status_flag = 1
and category_parent_id = #{categoryId}
and category_parent_id = #{categoryId} order by sort_num asc , create_time desc
</select>
<select
id=
"getMaxSortNum"
resultType=
"java.lang.Integer"
>
select max(sort_num) from tab_haoban_material_category
where wx_enterprise_id = #{wxEnterpriseId}
and category_parent_id = #{parentId} and status_flag = 1
</select>
</mapper>
\ No newline at end of file
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/MaterialController.java
View file @
8a11d2c1
...
...
@@ -7,6 +7,7 @@ import java.util.Objects;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
com.gic.haoban.manage.api.dto.qdto.MaterialCategorySortQDTO
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
...
@@ -56,6 +57,26 @@ public class MaterialController extends WebBaseController {
}
/**
* 排序
* @param qdto
* @return
*/
@RequestMapping
(
"/mateial-sort-category"
)
public
HaobanResponse
materialSortCategory
(
MaterialCategorySortQDTO
qdto
)
{
WebLoginDTO
login
=
AuthWebRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
qdto
.
setWxEnterpriseId
(
wxEnterpriseId
);
if
(
StringUtils
.
isAnyBlank
(
qdto
.
getCategoryId
()))
{
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
if
(
null
==
qdto
.
getSortNum
())
{
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
this
.
materialApiService
.
materialSortCategory
(
qdto
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
/**
* 素材分组查询
*
* @return
...
...
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