Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pms-ci-test
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
test-ci
pms-ci-test
Commits
9c815454
提交
9c815454
authored
5月 25, 2023
作者:
xiaowang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
目录管理及分类管理
上级
248d3bd9
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
858 行增加
和
69 行删除
+858
-69
CategoriesController.java
...ain/java/com/mmc/pms/controller/CategoriesController.java
+81
-0
CategoriesDao.java
src/main/java/com/mmc/pms/dao/CategoriesDao.java
+54
-0
Categories.java
src/main/java/com/mmc/pms/entity/Categories.java
+69
-0
Directory.java
src/main/java/com/mmc/pms/entity/Directory.java
+62
-0
GoodsTypeDO.java
src/main/java/com/mmc/pms/entity/GoodsTypeDO.java
+24
-23
ClassifyDetailsDTO.java
src/main/java/com/mmc/pms/model/dto/ClassifyDetailsDTO.java
+37
-0
ClassifyInfoDTO.java
src/main/java/com/mmc/pms/model/dto/ClassifyInfoDTO.java
+53
-0
CategoriesInfoVO.java
src/main/java/com/mmc/pms/model/vo/CategoriesInfoVO.java
+19
-0
ClassifyInfoVO.java
src/main/java/com/mmc/pms/model/vo/ClassifyInfoVO.java
+32
-46
DirectoryInfoVO.java
src/main/java/com/mmc/pms/model/vo/DirectoryInfoVO.java
+28
-0
QueryClassifyVO.java
src/main/java/com/mmc/pms/model/vo/QueryClassifyVO.java
+41
-0
CategoriesService.java
src/main/java/com/mmc/pms/service/CategoriesService.java
+31
-0
CategoriesServiceImpl.java
.../java/com/mmc/pms/service/Impl/CategoriesServiceImpl.java
+169
-0
CategoriesDao.xml
src/main/resources/mapper/CategoriesDao.xml
+158
-0
没有找到文件。
src/main/java/com/mmc/pms/controller/CategoriesController.java
0 → 100644
浏览文件 @
9c815454
package
com
.
mmc
.
pms
.
controller
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.model.dto.ClassifyDetailsDTO
;
import
com.mmc.pms.model.dto.ClassifyInfoDTO
;
import
com.mmc.pms.model.vo.*
;
import
com.mmc.pms.service.CategoriesService
;
import
io.swagger.annotations.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
/**
* @Author lw @Date 2023/5/15 13:24 @Version 1.0
*/
@Api
(
tags
=
{
"后台-分类管理-接口"
})
@RestController
@RequestMapping
(
"/classify"
)
public
class
CategoriesController
{
@Autowired
private
CategoriesService
categoriesService
;
@ApiOperation
(
value
=
"新增or修改目录"
)
@PostMapping
(
"addOrEditDirectory"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
ResultBody
.
class
)})
public
ResultBody
addOrEditDirectory
(
@RequestBody
DirectoryInfoVO
param
)
{
return
categoriesService
.
addOrEditDirectory
(
param
);
}
@ApiOperation
(
value
=
"目录列表"
)
@GetMapping
(
"directoryList"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
DirectoryInfoVO
.
class
)})
public
ResultBody
directoryList
(
@RequestParam
Integer
pageNo
,
@RequestParam
Integer
pageSize
)
{
return
ResultBody
.
success
(
categoriesService
.
directoryList
(
pageNo
,
pageSize
));
}
@ApiOperation
(
value
=
"删除目录"
)
@GetMapping
(
"removeDirectory"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
ResultBody
.
class
)})
public
ResultBody
removeDirectory
(
@ApiParam
(
value
=
"id"
)
@RequestParam
(
value
=
"id"
)
Integer
id
)
{
return
categoriesService
.
removeDirectory
(
id
);
}
@ApiOperation
(
value
=
"分类新增"
)
@PostMapping
(
"addClassification"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
ResultBody
.
class
)})
public
ResultBody
addClassification
(
@Validated
(
Create
.
class
)
@RequestBody
ClassifyInfoVO
classifyInfoVO
)
{
return
categoriesService
.
addClassification
(
classifyInfoVO
);
}
@ApiOperation
(
value
=
"分类修改"
)
@PostMapping
(
"updateClassification"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
ResultBody
.
class
)})
public
ResultBody
updateClassification
(
@Validated
(
Update
.
class
)
@RequestBody
ClassifyInfoVO
classifyInfoVO
)
{
return
categoriesService
.
updateClassification
(
classifyInfoVO
);
}
@ApiOperation
(
value
=
"分类信息-排序"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
ResultBody
.
class
)})
@GetMapping
(
"exchangeSortType"
)
public
ResultBody
exchangeSortType
(
@ApiParam
(
value
=
"第一个分类id"
,
required
=
true
)
@RequestParam
(
value
=
"firstId"
)
Integer
firstId
,
@ApiParam
(
value
=
"第二个分类id"
,
required
=
true
)
@RequestParam
(
value
=
"secondId"
)
Integer
secondId
)
{
return
categoriesService
.
exchangeSortType
(
firstId
,
secondId
);
}
@ApiOperation
(
value
=
"分类信息-列表"
)
@PostMapping
(
"getClassificationList"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
ClassifyInfoDTO
.
class
)})
public
ResultBody
getClassificationList
(
@RequestBody
QueryClassifyVO
queryClassifyVO
)
{
return
ResultBody
.
success
(
categoriesService
.
getClassificationList
(
queryClassifyVO
));
}
@ApiOperation
(
value
=
"分类详情"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
ClassifyDetailsDTO
.
class
)})
@GetMapping
(
"getClassifyDetails"
)
public
ResultBody
getClassifyDetails
(
@ApiParam
(
value
=
"分类id"
,
required
=
true
)
@RequestParam
(
value
=
"id"
)
Integer
id
)
{
return
categoriesService
.
getClassifyDetails
(
id
);
}
}
src/main/java/com/mmc/pms/dao/CategoriesDao.java
0 → 100644
浏览文件 @
9c815454
package
com
.
mmc
.
pms
.
dao
;
import
com.mmc.pms.entity.Categories
;
import
com.mmc.pms.entity.Directory
;
import
com.mmc.pms.model.vo.ClassifyInfoVO
;
import
com.mmc.pms.model.vo.DirectoryInfoVO
;
import
com.mmc.pms.model.vo.QueryClassifyVO
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.List
;
/**
* @author 23214
* @description 针对表【categories(通用分类表)】的数据库操作Mapper
* @createDate 2023-05-24 10:29:28
* @Entity com.mmc.pms.entity.Categories
*/
@Mapper
public
interface
CategoriesDao
{
int
countUpdateDirectoryName
(
DirectoryInfoVO
param
);
void
insertDirectory
(
Directory
directory
);
void
updateDirectory
(
Directory
directory
);
int
countDirectoryList
();
List
<
Directory
>
directoryList
(
int
i
,
Integer
pageSize
);
int
countDirectory
(
Integer
id
);
void
removeDirectory
(
Integer
id
);
int
countClassificationByName
(
ClassifyInfoVO
classifyInfoVO
);
int
getCountCategoriesByPid
(
Integer
pid
,
Integer
type
);
void
insertClassification
(
Categories
categories
);
void
updateClassification
(
ClassifyInfoVO
classifyInfoVO
);
Categories
getGoodsGroupById
(
Integer
id
);
int
updateTypeSort
(
Integer
firstId
,
Integer
sort
);
List
<
Categories
>
selectAllClassification
(
QueryClassifyVO
queryClassifyVO
);
int
countListClassification
(
QueryClassifyVO
queryClassifyVO
);
}
src/main/java/com/mmc/pms/entity/Categories.java
0 → 100644
浏览文件 @
9c815454
package
com
.
mmc
.
pms
.
entity
;
import
com.mmc.pms.model.dto.ClassifyDetailsDTO
;
import
com.mmc.pms.model.dto.ClassifyInfoDTO
;
import
com.mmc.pms.model.vo.ClassifyInfoVO
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* @author lw
* @TableName categories
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
Categories
implements
Serializable
{
private
Integer
id
;
private
Integer
parentId
;
private
String
name
;
private
String
icon
;
private
String
description
;
private
Integer
sort
;
private
Integer
type
;
private
Date
createTime
;
private
Date
updateTime
;
private
Integer
deleted
;
private
Integer
directoryId
;
private
String
remark
;
public
Categories
(
ClassifyInfoVO
classifyInfoVO
)
{
this
.
id
=
classifyInfoVO
.
getId
();
this
.
parentId
=
classifyInfoVO
.
getPid
();
this
.
name
=
classifyInfoVO
.
getClassifyName
();
this
.
icon
=
classifyInfoVO
.
getIcon
();
this
.
description
=
classifyInfoVO
.
getDescription
();
this
.
type
=
classifyInfoVO
.
getType
();
this
.
directoryId
=
classifyInfoVO
.
getDirectoryId
();
this
.
remark
=
classifyInfoVO
.
getRemark
();
}
public
ClassifyInfoDTO
buildClassifyInfoDTO
()
{
return
ClassifyInfoDTO
.
builder
().
id
(
id
).
description
(
description
)
.
icon
(
icon
).
pid
(
parentId
).
classifyName
(
name
)
.
remark
(
remark
).
createTime
(
createTime
)
.
directoryId
(
directoryId
).
type
(
type
).
build
();
}
public
ClassifyDetailsDTO
buildClassifyDetailsDTO
()
{
return
ClassifyDetailsDTO
.
builder
().
id
(
id
).
description
(
description
)
.
icon
(
icon
).
classifyName
(
name
)
.
remark
(
remark
).
build
();
}
}
\ No newline at end of file
src/main/java/com/mmc/pms/entity/Directory.java
0 → 100644
浏览文件 @
9c815454
package
com
.
mmc
.
pms
.
entity
;
import
com.mmc.pms.model.vo.DirectoryInfoVO
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* 目录管理表(Directory)实体类
*
* @author makejava
* @since 2023-05-24 14:58:31
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
Directory
implements
Serializable
{
private
static
final
long
serialVersionUID
=
713939370607409336L
;
/**
* 主键id
*/
private
Integer
id
;
/**
* 目录名称
*/
private
String
directoryName
;
/**
* 其他目录关联id
*/
private
Integer
relevance
;
/**
* 类型:(0:通用目录 1:作业服务目录 2:设备目录 3:飞手目录 4:商城目录)
*/
private
Integer
type
;
/**
* 创建时间
*/
private
Date
createTime
;
/**
* 修改时间
*/
private
Date
updateTime
;
/**
* 是否删除
*/
private
Integer
deleted
;
public
Directory
(
DirectoryInfoVO
param
)
{
this
.
id
=
param
.
getId
();
this
.
directoryName
=
param
.
getDirectoryName
();
this
.
relevance
=
param
.
getRelevance
();
this
.
type
=
param
.
getType
();
}
public
DirectoryInfoVO
buildDirectoryInfoVO
()
{
return
DirectoryInfoVO
.
builder
().
id
(
id
).
directoryName
(
directoryName
).
relevance
(
relevance
).
type
(
type
).
build
();
}
}
src/main/java/com/mmc/pms/entity/GoodsTypeDO.java
浏览文件 @
9c815454
package
com
.
mmc
.
pms
.
entity
;
package
com
.
mmc
.
pms
.
entity
;
import
com.mmc.pms.model.vo.GoodsGroupVO
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -17,28 +16,30 @@ import java.util.Date;
...
@@ -17,28 +16,30 @@ import java.util.Date;
@NoArgsConstructor
@NoArgsConstructor
@Builder
@Builder
public
class
GoodsTypeDO
implements
Serializable
{
public
class
GoodsTypeDO
implements
Serializable
{
private
Integer
id
;
private
Integer
id
;
private
Integer
pid
;
private
Integer
pid
;
private
Integer
sortTypeId
;
private
Integer
sortTypeId
;
private
String
typeName
;
private
String
typeName
;
private
String
description
;
private
String
description
;
private
Integer
sort
;
private
Integer
sort
;
private
String
icon
;
private
String
icon
;
private
String
remark
;
private
String
remark
;
private
Integer
deleted
;
private
Integer
deleted
;
private
Date
updateTime
;
private
Date
updateTime
;
private
Date
createTime
;
private
Date
createTime
;
/** 辅助字段-start */
/**
private
GoodsTypeDO
slaveType
;
* 辅助字段-start
*/
private
GoodsTypeDO
slaveType
;
/** 辅助字段-end */
/** 辅助字段-end */
public
GoodsTypeDO
(
GoodsGroup
VO
goodsGroupVO
)
{
// public GoodsTypeDO(ClassifyInfo
VO goodsGroupVO) {
this
.
sortTypeId
=
goodsGroupVO
.
getSortTypeId
();
//
this.sortTypeId = goodsGroupVO.getSortTypeId();
this
.
typeName
=
goodsGroupVO
.
getGroupName
();
//
this.typeName = goodsGroupVO.getGroupName();
this
.
pid
=
goodsGroupVO
.
getPid
();
//
this.pid = goodsGroupVO.getPid();
this
.
description
=
goodsGroupVO
.
getDescription
();
//
this.description = goodsGroupVO.getDescription();
this
.
icon
=
goodsGroupVO
.
getIcon
();
//
this.icon = goodsGroupVO.getIcon();
this
.
remark
=
goodsGroupVO
.
getRemark
();
//
this.remark = goodsGroupVO.getRemark();
}
//
}
}
}
src/main/java/com/mmc/pms/model/dto/ClassifyDetailsDTO.java
0 → 100644
浏览文件 @
9c815454
package
com
.
mmc
.
pms
.
model
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
/**
* @Author LW
* @date 2022/3/22 15:50
* 概要:一级分类信息DTO
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
ClassifyDetailsDTO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
1682216002629752311L
;
@ApiModelProperty
(
value
=
"分类id"
)
private
Integer
id
;
@ApiModelProperty
(
value
=
"分类名称"
)
private
String
classifyName
;
@ApiModelProperty
(
value
=
"描述"
)
private
String
description
;
@ApiModelProperty
(
value
=
"icon图标"
)
private
String
icon
;
@ApiModelProperty
(
value
=
"小程序底部备注"
)
private
String
remark
;
}
src/main/java/com/mmc/pms/model/dto/ClassifyInfoDTO.java
0 → 100644
浏览文件 @
9c815454
package
com
.
mmc
.
pms
.
model
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.List
;
/**
* @Author LW
* @date 2022/3/22 15:50
* 概要:一级分类信息DTO
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
ClassifyInfoDTO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
1682216002629752311L
;
@ApiModelProperty
(
value
=
"分类id"
)
private
Integer
id
;
@ApiModelProperty
(
value
=
"所属目录id"
)
private
Integer
directoryId
;
@ApiModelProperty
(
value
=
"分类名称"
)
private
String
classifyName
;
@ApiModelProperty
(
value
=
"pid:一级分类的pid是0 二级分类pid是一级分类id"
)
private
Integer
pid
;
@ApiModelProperty
(
value
=
"描述"
)
private
String
description
;
@ApiModelProperty
(
value
=
"icon图标"
)
private
String
icon
;
@ApiModelProperty
(
value
=
"小程序底部备注"
)
private
String
remark
;
@ApiModelProperty
(
value
=
"分类所属模块id(0:通用分类 1:作业服务分类 2:设备租赁分类 3:飞手培训分类 4:产品商城分类)"
)
private
Integer
type
;
@ApiModelProperty
(
value
=
"创建时间"
)
private
Date
createTime
;
@ApiModelProperty
(
value
=
"二级分类信息"
)
private
List
<
ClassifyInfoDTO
>
children
;
}
src/main/java/com/mmc/pms/model/vo/CategoriesInfoVO.java
0 → 100644
浏览文件 @
9c815454
package
com
.
mmc
.
pms
.
model
.
vo
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @Author LW
* @date 2023/5/24 11:08
* 概要:
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
CategoriesInfoVO
{
private
Integer
id
;
private
String
name
;
private
String
icon
;
}
src/main/java/com/mmc/pms/model/vo/
GoodsGroup
VO.java
→
src/main/java/com/mmc/pms/model/vo/
ClassifyInfo
VO.java
浏览文件 @
9c815454
...
@@ -15,50 +15,36 @@ import java.io.Serializable;
...
@@ -15,50 +15,36 @@ import java.io.Serializable;
@Data
@Data
@AllArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@NoArgsConstructor
// @ApiModel(value = "com.mmc.csf.model.vo.GoodsGroupVO", description = "商品分类")
public
class
ClassifyInfoVO
implements
Serializable
{
public
class
GoodsGroupVO
implements
Serializable
{
@ApiModelProperty
(
value
=
"id"
)
@ApiModelProperty
(
value
=
"id"
)
@NotNull
(
message
=
"id不能为空"
,
groups
=
{
Update
.
class
})
@NotNull
(
private
Integer
id
;
message
=
"id不能为空"
,
groups
=
{
Update
.
class
})
@ApiModelProperty
(
value
=
"所属目录id"
)
private
Integer
id
;
@NotNull
(
message
=
"所属目录id不能为空"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
Integer
directoryId
;
@ApiModelProperty
(
value
=
"分类类型id"
)
@NotNull
(
@ApiModelProperty
(
value
=
"分类名称"
,
required
=
true
)
message
=
"分类类型id不能为空"
,
@Size
(
max
=
15
,
message
=
"分类名称不能超过15个字"
,
groups
=
{
Update
.
class
,
Create
.
class
})
groups
=
{
Update
.
class
,
Create
.
class
})
@NotNull
(
message
=
"分类名称不能为空"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
Integer
sortTypeId
;
private
String
classifyName
;
@ApiModelProperty
(
value
=
"分类名称"
,
required
=
true
)
@ApiModelProperty
(
value
=
"pid:一级分类的pid是0 二级分类pid是一级分类id"
,
required
=
true
)
@Size
(
@NotNull
(
message
=
"pid不能为空"
,
groups
=
{
Create
.
class
,
Update
.
class
})
max
=
15
,
private
Integer
pid
;
message
=
"分类名称不能超过15个字"
,
groups
=
{
Update
.
class
,
Create
.
class
})
@ApiModelProperty
(
value
=
"描述"
)
@NotNull
(
@Size
(
max
=
70
,
message
=
"分类描述不能超过70个字"
,
groups
=
{
Update
.
class
,
Create
.
class
})
message
=
"分类名称不能为空"
,
private
String
description
;
groups
=
{
Update
.
class
,
Create
.
class
})
private
String
groupName
;
@ApiModelProperty
(
value
=
"icon图标"
)
private
String
icon
;
@ApiModelProperty
(
value
=
"pid:一级分类的pid是0 二级分类pid是一级分类id"
,
required
=
true
)
@NotNull
(
@ApiModelProperty
(
value
=
"小程序底部备注"
)
message
=
"pid不能为空"
,
@Size
(
max
=
150
,
message
=
"小程序底部备注不能超过150个字"
,
groups
=
{
Update
.
class
,
Create
.
class
})
groups
=
{
Create
.
class
,
Update
.
class
})
private
String
remark
;
private
Integer
pid
;
@ApiModelProperty
(
value
=
"分类所属模块id(0:通用分类 1:作业服务分类 2:设备租赁分类 3:飞手培训分类 4:产品商城分类)"
)
@ApiModelProperty
(
value
=
"描述"
)
@NotNull
(
message
=
"分类所属模块id不能为空"
,
groups
=
{
Update
.
class
,
Create
.
class
})
@Size
(
private
Integer
type
;
max
=
70
,
message
=
"分类描述不能超过70个字"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
String
description
;
@ApiModelProperty
(
value
=
"icon图标"
)
private
String
icon
;
@ApiModelProperty
(
value
=
"小程序底部备注"
)
@Size
(
max
=
150
,
message
=
"小程序底部备注不能超过150个字"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
String
remark
;
}
}
src/main/java/com/mmc/pms/model/vo/DirectoryInfoVO.java
0 → 100644
浏览文件 @
9c815454
package
com
.
mmc
.
pms
.
model
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @Author LW
* @date 2023/5/24 11:06
* 概要:
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public
class
DirectoryInfoVO
{
@ApiModelProperty
(
value
=
"目录id"
)
private
Integer
id
;
@ApiModelProperty
(
value
=
"目录名称"
)
private
String
directoryName
;
@ApiModelProperty
(
value
=
"关联目录的id"
)
private
Integer
relevance
;
@ApiModelProperty
(
value
=
"分类模块:(0:通用分类 1:作业服务分类 2:设备分类 3:飞手分类 4:商城分类)"
)
private
Integer
type
;
}
src/main/java/com/mmc/pms/model/vo/QueryClassifyVO.java
0 → 100644
浏览文件 @
9c815454
package
com
.
mmc
.
pms
.
model
.
vo
;
import
com.mmc.pms.page.Page
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
javax.validation.constraints.Min
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
/**
* @Author LW
* @date 2023/5/25 11:25
* 概要:
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
QueryClassifyVO
implements
Serializable
{
@ApiModelProperty
(
value
=
"所属目录id"
)
@NotNull
(
message
=
"所属目录id不能为空"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
Integer
directoryId
;
@ApiModelProperty
(
value
=
"分类所属模块id(0:通用分类 1:作业服务分类 2:设备租赁分类 3:飞手培训分类 4:产品商城分类)"
)
private
Integer
type
;
@ApiModelProperty
(
value
=
"页码"
,
required
=
true
)
@NotNull
(
message
=
"页码不能为空"
,
groups
=
{
Page
.
class
,
Freeze
.
class
})
@Min
(
value
=
1
,
groups
=
Page
.
class
)
private
Integer
pageNo
;
@ApiModelProperty
(
value
=
"每页显示数"
,
required
=
true
)
@NotNull
(
message
=
"每页显示数不能为空"
,
groups
=
{
Page
.
class
,
Freeze
.
class
})
@Min
(
value
=
1
,
groups
=
Page
.
class
)
private
Integer
pageSize
;
public
void
buildCurrentPage
()
{
this
.
pageNo
=
(
pageNo
-
1
)
*
pageSize
;
}
}
src/main/java/com/mmc/pms/service/CategoriesService.java
0 → 100644
浏览文件 @
9c815454
package
com
.
mmc
.
pms
.
service
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.model.vo.ClassifyInfoVO
;
import
com.mmc.pms.model.vo.DirectoryInfoVO
;
import
com.mmc.pms.model.vo.QueryClassifyVO
;
import
com.mmc.pms.page.PageResult
;
/**
* @author 23214
* @description 针对表【categories(通用分类表)】的数据库操作Service
* @createDate 2023-05-24 10:29:28
*/
public
interface
CategoriesService
{
ResultBody
addOrEditDirectory
(
DirectoryInfoVO
param
);
PageResult
directoryList
(
Integer
pageNo
,
Integer
pageSize
);
ResultBody
removeDirectory
(
Integer
id
);
ResultBody
addClassification
(
ClassifyInfoVO
classifyInfoVO
);
ResultBody
updateClassification
(
ClassifyInfoVO
classifyInfoVO
);
ResultBody
exchangeSortType
(
Integer
firstId
,
Integer
secondId
);
PageResult
getClassificationList
(
QueryClassifyVO
queryClassifyVO
);
ResultBody
getClassifyDetails
(
Integer
id
);
}
src/main/java/com/mmc/pms/service/Impl/CategoriesServiceImpl.java
0 → 100644
浏览文件 @
9c815454
package
com
.
mmc
.
pms
.
service
.
Impl
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.common.ResultEnum
;
import
com.mmc.pms.dao.CategoriesDao
;
import
com.mmc.pms.entity.Categories
;
import
com.mmc.pms.entity.Directory
;
import
com.mmc.pms.model.dto.ClassifyInfoDTO
;
import
com.mmc.pms.model.vo.ClassifyInfoVO
;
import
com.mmc.pms.model.vo.DirectoryInfoVO
;
import
com.mmc.pms.model.vo.QueryClassifyVO
;
import
com.mmc.pms.page.PageResult
;
import
com.mmc.pms.service.CategoriesService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* @author lw
* @description 针对表【categories(通用分类表)】的数据库操作Service实现
* @createDate 2023-05-24 10:29:28
*/
@Service
public
class
CategoriesServiceImpl
implements
CategoriesService
{
@Autowired
private
CategoriesDao
categoriesDao
;
@Override
public
ResultBody
addOrEditDirectory
(
DirectoryInfoVO
param
)
{
int
type
=
categoriesDao
.
countUpdateDirectoryName
(
param
);
if
(
type
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
DIRECTORY_NAME_HAS_BEEN_EXIST
);
}
Directory
directory
=
new
Directory
(
param
);
if
(
param
.
getId
()
==
null
)
{
categoriesDao
.
insertDirectory
(
directory
);
}
else
{
categoriesDao
.
updateDirectory
(
directory
);
}
return
ResultBody
.
success
();
}
@Override
public
PageResult
directoryList
(
Integer
pageNo
,
Integer
pageSize
)
{
int
count
=
categoriesDao
.
countDirectoryList
();
if
(
count
==
0
)
{
return
PageResult
.
buildPage
(
pageNo
,
pageSize
,
count
);
}
List
<
Directory
>
directoryList
=
categoriesDao
.
directoryList
((
pageNo
-
1
)
*
pageSize
,
pageSize
);
List
<
DirectoryInfoVO
>
list
=
directoryList
.
stream
().
map
(
Directory:
:
buildDirectoryInfoVO
).
collect
(
Collectors
.
toList
());
return
PageResult
.
buildPage
(
pageNo
,
pageSize
,
count
,
list
);
}
@Override
public
ResultBody
removeDirectory
(
Integer
id
)
{
// 查询该目录下是否有分类有的话就不给删除
int
count
=
categoriesDao
.
countDirectory
(
id
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
THERE_ARE_CATEGORIES_IN_THE_DIRECTORY
);
}
categoriesDao
.
removeDirectory
(
id
);
return
ResultBody
.
success
();
}
@Override
public
ResultBody
addClassification
(
ClassifyInfoVO
classifyInfoVO
)
{
int
count
=
categoriesDao
.
countClassificationByName
(
classifyInfoVO
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
WARE_TYPE_NAME_HAS_BEEN_EXIST
);
}
Categories
categories
=
new
Categories
(
classifyInfoVO
);
if
(
classifyInfoVO
.
getPid
()
==
0
)
{
if
(
classifyInfoVO
.
getIcon
()
!=
null
)
{
int
typeCount
=
categoriesDao
.
getCountCategoriesByPid
(
0
,
classifyInfoVO
.
getType
());
categories
.
setSort
(
typeCount
+
1
);
categoriesDao
.
insertClassification
(
categories
);
}
else
{
return
ResultBody
.
error
(
ResultEnum
.
WARE_TYPE_ICON_NOT_NULL
);
}
}
else
{
categoriesDao
.
insertClassification
(
categories
);
}
return
ResultBody
.
success
();
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ResultBody
updateClassification
(
ClassifyInfoVO
classifyInfoVO
)
{
int
count
=
categoriesDao
.
countClassificationByName
(
classifyInfoVO
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
WARE_TYPE_NAME_HAS_BEEN_EXIST
);
}
if
(
classifyInfoVO
.
getPid
()
==
0
)
{
if
(
classifyInfoVO
.
getIcon
()
!=
null
)
{
categoriesDao
.
updateClassification
(
classifyInfoVO
);
}
else
{
return
ResultBody
.
error
(
ResultEnum
.
WARE_TYPE_ICON_NOT_NULL
);
}
}
else
{
categoriesDao
.
updateClassification
(
classifyInfoVO
);
}
return
ResultBody
.
success
();
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ResultBody
exchangeSortType
(
Integer
firstId
,
Integer
secondId
)
{
Categories
firstCategories
=
categoriesDao
.
getGoodsGroupById
(
firstId
);
Categories
secondCategories
=
categoriesDao
.
getGoodsGroupById
(
secondId
);
int
updateCount1
=
categoriesDao
.
updateTypeSort
(
firstId
,
secondCategories
.
getSort
());
int
updateCount2
=
categoriesDao
.
updateTypeSort
(
secondId
,
firstCategories
.
getSort
());
if
(
updateCount1
==
updateCount2
)
{
return
ResultBody
.
success
();
}
else
{
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
return
ResultBody
.
error
(
"排序失败"
);
}
}
@Override
public
PageResult
getClassificationList
(
QueryClassifyVO
queryClassifyVO
)
{
int
count
=
categoriesDao
.
countListClassification
(
queryClassifyVO
);
if
(
count
==
0
)
{
return
PageResult
.
buildPage
(
queryClassifyVO
.
getPageNo
(),
queryClassifyVO
.
getPageSize
(),
count
);
}
int
pageNo
=
queryClassifyVO
.
getPageNo
();
queryClassifyVO
.
buildCurrentPage
();
List
<
Categories
>
categories
=
categoriesDao
.
selectAllClassification
(
queryClassifyVO
);
List
<
ClassifyInfoDTO
>
categoriesList
=
categories
.
stream
().
map
(
Categories:
:
buildClassifyInfoDTO
).
collect
(
Collectors
.
toList
());
List
<
ClassifyInfoDTO
>
topLevelCategories
=
new
ArrayList
<>();
Map
<
Integer
,
ClassifyInfoDTO
>
categoriesMap
=
new
HashMap
<>();
// 将每个数据模型对象添加到Map中,以便在递归过程中查找它们的父母
for
(
ClassifyInfoDTO
category
:
categoriesList
)
{
category
.
setChildren
(
new
ArrayList
<>());
categoriesMap
.
put
(
category
.
getId
(),
category
);
}
// 构建树结构
for
(
ClassifyInfoDTO
category
:
categoriesList
)
{
if
(
category
.
getPid
()
==
0
)
{
topLevelCategories
.
add
(
category
);
}
else
{
ClassifyInfoDTO
parent
=
categoriesMap
.
get
(
category
.
getPid
());
parent
.
getChildren
().
add
(
category
);
}
}
return
PageResult
.
buildPage
(
pageNo
,
queryClassifyVO
.
getPageSize
(),
count
,
topLevelCategories
);
}
@Override
public
ResultBody
getClassifyDetails
(
Integer
id
)
{
Categories
goodsGroup
=
categoriesDao
.
getGoodsGroupById
(
id
);
return
ResultBody
.
success
(
goodsGroup
==
null
?
null
:
goodsGroup
.
buildClassifyDetailsDTO
()
);
}
}
src/main/resources/mapper/CategoriesDao.xml
0 → 100644
浏览文件 @
9c815454
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.mmc.pms.dao.CategoriesDao"
>
<resultMap
id=
"BaseResultMap"
type=
"com.mmc.pms.entity.Categories"
>
<id
property=
"id"
column=
"id"
jdbcType=
"OTHER"
/>
<result
property=
"parentId"
column=
"parent_id"
jdbcType=
"INTEGER"
/>
<result
property=
"name"
column=
"name"
jdbcType=
"VARCHAR"
/>
<result
property=
"icon"
column=
"icon"
jdbcType=
"VARCHAR"
/>
<result
property=
"description"
column=
"description"
jdbcType=
"VARCHAR"
/>
<result
property=
"sort"
column=
"sort"
jdbcType=
"INTEGER"
/>
<result
property=
"type"
column=
"type"
jdbcType=
"TINYINT"
/>
<result
property=
"createTime"
column=
"create_time"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"updateTime"
column=
"update_time"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"deleted"
column=
"is_deleted"
jdbcType=
"TINYINT"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id
,parent_id,name,
icon,description,sort,
type,create_time,update_time,
is_deleted
</sql>
<insert
id=
"insertDirectory"
>
insert into directory(directory_name, relevance,
`type`)
values (#{directoryName}, #{relevance}, #{type})
</insert>
<insert
id=
"insertClassification"
>
insert into categories (parent_id,
directory_id,
`name`,
icon,
description,
sort,
`type`, remark)
values (#{parentId}, #{directoryId}, #{name}, #{icon}, #{description}, #{sort}, #{type}, #{remark})
</insert>
<update
id=
"updateDirectory"
>
update directory
set directory_name = #{directoryName},
relevance = #{relevance},
`type` = #{type}
where id = #{id}
</update>
<update
id=
"removeDirectory"
>
update directory
set is_deleted = 1
where id = #{id}
</update>
<update
id=
"updateClassification"
>
update categories
<set>
<if
test=
"name != null and name != ''"
>
`name` = #{classifyName},
</if>
<if
test=
"description != null"
>
description = #{description},
</if>
<if
test=
"icon != null and icon != ''"
>
icon = #{icon},
</if>
<if
test=
"remark != null"
>
remark = #{remark}
</if>
</set>
where id = #{id}
</update>
<update
id=
"updateTypeSort"
>
update categories
set sort = #{sort}
where id = #{id}
</update>
<select
id=
"countUpdateDirectoryName"
resultType=
"java.lang.Integer"
>
SELECT COUNT(*) FROM directory
WHERE directory_name = #{directoryName} and is_deleted = 0 and `type` = #{type}
<if
test=
"id!=null and id!=''"
>
and id
<![CDATA[<>]]>
#{id}
</if>
</select>
<select
id=
"countDirectoryList"
resultType=
"java.lang.Integer"
>
select count(*)
from directory
where is_deleted = 0
</select>
<select
id=
"directoryList"
resultType=
"com.mmc.pms.entity.Directory"
>
select id,
directory_name,
relevance,
`type`,
create_time
from directory
where is_deleted = 0
</select>
<select
id=
"countDirectory"
resultType=
"java.lang.Integer"
>
SELECT count(*)
FROM directory d
INNER JOIN categories c ON d.id = c.directory_id
AND c.is_deleted = 0
WHERE d.id = #{id}
</select>
<select
id=
"countClassificationByName"
resultType=
"java.lang.Integer"
>
SELECT COUNT(*)
FROM categories
WHERE `name` = #{classifyName} and `type` = #{type}
and is_deleted = 0
<if
test=
"id!=null and id!=''"
>
and id
<![CDATA[<>]]>
#{id}
</if>
</select>
<select
id=
"getCountCategoriesByPid"
resultType=
"java.lang.Integer"
>
select count(*)
from categories
where parent_id = #{pid}
and `type` = #{type}
</select>
<select
id=
"getGoodsGroupById"
resultType=
"com.mmc.pms.entity.Categories"
>
select id,
parent_id,
directory_id,
`name`,
icon,
description,
sort,
`type`,
remark
from categories
where id = #{id}
</select>
<select
id=
"selectAllClassification"
resultType=
"com.mmc.pms.entity.Categories"
>
SELECT id,
parent_id,
directory_id,
`name`,
icon,
description,
sort,
`type`,
remark,
create_time
FROM categories
WHERE is_deleted = 0
AND directory_id = #{directoryId}
AND type = #{type}
ORDER BY sort asc
LIMIT #{pageNo}, #{pageSize}
</select>
<select
id=
"countListClassification"
resultType=
"java.lang.Integer"
>
select count(*)
FROM categories
WHERE is_deleted = 0
AND directory_id = #{directoryId}
AND type = #{type}
</select>
</mapper>
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论