Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pms
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
iuav
pms
Commits
2a6b406e
提交
2a6b406e
authored
7月 21, 2023
作者:
张小凤
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CategoryNew(add)
上级
10d6b13e
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
861 行增加
和
0 行删除
+861
-0
ResultEnum.java
src/main/java/com/mmc/pms/common/ResultEnum.java
+0
-0
CategoryController.java
...a/com/mmc/pms/controller/category/CategoryController.java
+98
-0
CategoryDao.java
src/main/java/com/mmc/pms/dao/category/CategoryDao.java
+49
-0
CategoryPrimaryDO.java
...n/java/com/mmc/pms/entity/category/CategoryPrimaryDO.java
+84
-0
CategorySubDO.java
src/main/java/com/mmc/pms/entity/category/CategorySubDO.java
+77
-0
CategoryPrimaryDTO.java
...va/com/mmc/pms/model/category/dto/CategoryPrimaryDTO.java
+58
-0
CategorySubDTO.java
...n/java/com/mmc/pms/model/category/dto/CategorySubDTO.java
+55
-0
CategoryQO.java
src/main/java/com/mmc/pms/model/category/qo/CategoryQO.java
+40
-0
CategoryPrimaryVO.java
...java/com/mmc/pms/model/category/vo/CategoryPrimaryVO.java
+38
-0
CategorySubVO.java
...ain/java/com/mmc/pms/model/category/vo/CategorySubVO.java
+38
-0
CategoryService.java
...in/java/com/mmc/pms/service/category/CategoryService.java
+32
-0
CategoryServiceImpl.java
...om/mmc/pms/service/category/impl/CategoryServiceImpl.java
+110
-0
CategoryDao.xml
src/main/resources/mapper/category/CategoryDao.xml
+182
-0
没有找到文件。
src/main/java/com/mmc/pms/common/ResultEnum.java
浏览文件 @
2a6b406e
差异被折叠。
点击展开。
src/main/java/com/mmc/pms/controller/category/CategoryController.java
0 → 100644
浏览文件 @
2a6b406e
package
com
.
mmc
.
pms
.
controller
.
category
;
import
com.mmc.pms.common.Page
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.model.category.dto.CategoryPrimaryDTO
;
import
com.mmc.pms.model.category.dto.CategorySubDTO
;
import
com.mmc.pms.model.category.qo.CategoryQO
;
import
com.mmc.pms.model.category.vo.CategoryPrimaryVO
;
import
com.mmc.pms.model.category.vo.CategorySubVO
;
import
com.mmc.pms.model.group.Create
;
import
com.mmc.pms.model.group.Update
;
import
com.mmc.pms.service.category.CategoryService
;
import
io.swagger.annotations.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
/**
* @Author small
* @Date 2023/7/20 16:17
* @Version 1.0
* <p>
* 新版本分类管理
*/
@RestController
@RequestMapping
(
"/category"
)
@Api
(
tags
=
{
"后台-新版-分类管理"
})
public
class
CategoryController
{
@Autowired
private
CategoryService
categoryService
;
@ApiOperation
(
value
=
"一级分类————新增"
)
@PostMapping
(
"/addPrimaryCategory"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
ResultBody
.
class
)})
public
ResultBody
addPrimaryCategory
(
HttpServletRequest
request
,
@RequestBody
@Validated
(
value
=
{
Create
.
class
})
CategoryPrimaryVO
primaryVO
)
{
return
categoryService
.
addPrimaryCategory
(
primaryVO
);
}
@ApiOperation
(
value
=
"一级分类————编辑"
)
@PostMapping
(
"/updatePrimaryCategory"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
ResultBody
.
class
)})
public
ResultBody
updatePrimaryCategory
(
HttpServletRequest
request
,
@RequestBody
@Validated
(
value
=
{
Update
.
class
})
CategoryPrimaryVO
primaryVO
)
{
return
categoryService
.
updatePrimaryCategory
(
primaryVO
);
}
@ApiOperation
(
value
=
"一级分类————删除"
)
@GetMapping
(
"/deletePrimaryCategory"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
ResultBody
.
class
)})
public
ResultBody
deletePrimaryCategory
(
HttpServletRequest
request
,
@RequestParam
(
value
=
"id"
,
required
=
true
)
Integer
id
)
{
return
categoryService
.
deletePrimaryCategory
(
id
);
}
@ApiOperation
(
value
=
"一级分类————列表/包含二级分类"
)
@PostMapping
(
"/categoryList"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
ResultBody
.
class
)})
public
ResultBody
<
CategoryPrimaryDTO
>
categoryList
(
HttpServletRequest
request
,
@Validated
(
value
=
{
Page
.
class
})
@ApiParam
(
value
=
"角色查询QO"
,
required
=
true
)
@RequestBody
CategoryQO
param
)
{
return
ResultBody
.
success
(
categoryService
.
categoryList
(
param
));
}
@ApiOperation
(
value
=
"二级分类————新增"
)
@PostMapping
(
"/addSubCategory"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
ResultBody
.
class
)})
public
ResultBody
addSubCategory
(
HttpServletRequest
request
,
@RequestBody
@Validated
(
value
=
{
Create
.
class
})
CategorySubVO
subVO
)
{
return
categoryService
.
addSubCategory
(
subVO
);
}
@ApiOperation
(
value
=
"二级分类————编辑"
)
@PostMapping
(
"/updateSubCategory"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
ResultBody
.
class
)})
public
ResultBody
updateSubCategory
(
HttpServletRequest
request
,
@RequestBody
@Validated
(
value
=
{
Update
.
class
})
CategorySubVO
subVO
)
{
return
categoryService
.
updateSubCategory
(
subVO
);
}
@ApiOperation
(
value
=
"二级分类————删除"
)
@GetMapping
(
"/deleteSubCategory"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
ResultBody
.
class
)})
public
ResultBody
deleteSubCategory
(
HttpServletRequest
request
,
@RequestParam
(
value
=
"id"
,
required
=
true
)
Integer
id
)
{
return
categoryService
.
deleteSubCategory
(
id
);
}
@ApiOperation
(
value
=
"二级分类————详情"
)
@GetMapping
(
"/detailSubCategory"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
ResultBody
.
class
)})
public
ResultBody
<
CategorySubDTO
>
detailSubCategory
(
HttpServletRequest
request
,
@RequestParam
(
value
=
"id"
,
required
=
true
)
Integer
id
)
{
return
categoryService
.
detailSubCategory
(
id
);
}
}
src/main/java/com/mmc/pms/dao/category/CategoryDao.java
0 → 100644
浏览文件 @
2a6b406e
package
com
.
mmc
.
pms
.
dao
.
category
;
import
com.mmc.pms.entity.category.CategoryPrimaryDO
;
import
com.mmc.pms.entity.category.CategorySubDO
;
import
com.mmc.pms.model.category.qo.CategoryQO
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.List
;
/**
* @Author small
* @Date 2023/7/21 10:20
* @Version 1.0
*/
@Mapper
public
interface
CategoryDao
{
int
getCountName
(
String
name
);
void
addPrimaryCategory
(
CategoryPrimaryDO
primaryDO
);
void
updateSort
(
Integer
id
);
void
deletePrimaryCategory
(
Integer
id
);
Integer
categoryCount
(
CategoryPrimaryDO
primaryDO
);
void
updatePrimaryCategory
(
CategoryPrimaryDO
primaryDO
);
int
getCountSubName
(
String
name
,
Integer
categoryPrimaryId
);
void
addSubCategory
(
CategorySubDO
subDO
);
Integer
categorySubCount
(
CategorySubDO
subDO
);
void
updateSubCategory
(
CategorySubDO
subDO
);
void
deleteSubCategory
(
Integer
id
);
CategorySubDO
detailSubCategory
(
Integer
id
);
List
<
CategoryPrimaryDO
>
categoryList
(
CategoryQO
param
);
List
<
CategorySubDO
>
selectSubList
(
Integer
id
);
int
categoryListCount
(
CategoryQO
param
);
}
src/main/java/com/mmc/pms/entity/category/CategoryPrimaryDO.java
0 → 100644
浏览文件 @
2a6b406e
package
com
.
mmc
.
pms
.
entity
.
category
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.mmc.pms.model.category.dto.CategoryPrimaryDTO
;
import
com.mmc.pms.model.category.vo.CategoryPrimaryVO
;
import
com.mmc.pms.model.group.Create
;
import
com.mmc.pms.model.group.Update
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
javax.validation.constraints.Min
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Size
;
import
java.util.Date
;
import
java.util.List
;
/**
* @Author small
* @Date 2023/7/21 10:15
* @Version 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public
class
CategoryPrimaryDO
{
@ApiModelProperty
(
value
=
"id"
)
@NotNull
(
message
=
"id不能为空"
,
groups
=
{
Update
.
class
})
@Min
(
value
=
1
,
groups
=
{
Update
.
class
})
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
id
;
@ApiModelProperty
(
value
=
"分类名称"
,
required
=
true
,
example
=
"无人机"
)
@Size
(
max
=
15
,
message
=
"分类名称不能超过15个字"
,
groups
=
{
Update
.
class
,
Create
.
class
})
@NotBlank
(
message
=
"分类名称不能为空或空字符"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
String
name
;
@ApiModelProperty
(
value
=
"描述"
)
@Size
(
max
=
70
,
message
=
"分类描述不能超过70个字"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
String
description
;
@ApiModelProperty
(
value
=
"icon图标"
)
private
String
icon
;
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty
(
value
=
"创建时间"
,
example
=
"2023-07-14 10:13:12"
,
required
=
true
)
private
Date
createTime
;
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty
(
value
=
"更新时间"
,
example
=
"2023-07-14 10:13:12"
,
required
=
true
)
private
Date
updateTime
;
@ApiModelProperty
(
value
=
"子分类"
)
private
List
<
CategorySubDO
>
subDOList
;
public
CategoryPrimaryDO
(
CategoryPrimaryVO
primaryVO
)
{
this
.
id
=
primaryVO
.
getId
();
this
.
name
=
primaryVO
.
getName
();
this
.
description
=
primaryVO
.
getDescription
();
this
.
icon
=
primaryVO
.
getIcon
();
}
public
CategoryPrimaryDTO
buildCategoryPrimaryDTO
()
{
return
CategoryPrimaryDTO
.
builder
()
.
id
(
this
.
id
)
.
name
(
this
.
name
)
.
description
(
this
.
description
)
.
icon
(
this
.
icon
)
.
createTime
(
this
.
createTime
)
.
updateTime
(
this
.
updateTime
)
.
subDTOList
(
this
.
subDOList
)
.
build
();
}
}
src/main/java/com/mmc/pms/entity/category/CategorySubDO.java
0 → 100644
浏览文件 @
2a6b406e
package
com
.
mmc
.
pms
.
entity
.
category
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.mmc.pms.model.category.dto.CategorySubDTO
;
import
com.mmc.pms.model.category.vo.CategorySubVO
;
import
com.mmc.pms.model.group.Create
;
import
com.mmc.pms.model.group.Update
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
javax.validation.constraints.Min
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Size
;
import
java.util.Date
;
/**
* @Author small
* @Date 2023/7/21 10:16
* @Version 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public
class
CategorySubDO
{
@ApiModelProperty
(
value
=
"id"
)
@NotNull
(
message
=
"id不能为空"
,
groups
=
{
Update
.
class
})
@Min
(
value
=
1
,
groups
=
{
Update
.
class
})
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
id
;
@ApiModelProperty
(
value
=
"分类名称"
,
required
=
true
,
example
=
"无人机"
)
@Size
(
max
=
15
,
message
=
"分类名称不能超过15个字"
,
groups
=
{
Update
.
class
,
Create
.
class
})
@NotBlank
(
message
=
"分类名称不能为空或空字符"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
String
name
;
@ApiModelProperty
(
value
=
"描述"
)
@Size
(
max
=
70
,
message
=
"分类描述不能超过70个字"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
String
description
;
@ApiModelProperty
(
value
=
"一级id不能为空"
,
required
=
true
,
example
=
"1"
)
@NotNull
(
message
=
"一级id不能为空"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
Integer
categoryPrimaryId
;
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty
(
value
=
"创建时间"
,
example
=
"2023-07-14 10:13:12"
,
required
=
true
)
private
Date
createTime
;
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty
(
value
=
"更新时间"
,
example
=
"2023-07-14 10:13:12"
,
required
=
true
)
private
Date
updateTime
;
public
CategorySubDO
(
CategorySubVO
subVO
)
{
this
.
id
=
subVO
.
getId
();
this
.
name
=
subVO
.
getName
();
this
.
description
=
subVO
.
getDescription
();
this
.
categoryPrimaryId
=
subVO
.
getCategoryPrimaryId
();
}
public
CategorySubDTO
buildCategorySubDTO
()
{
return
CategorySubDTO
.
builder
()
.
id
(
this
.
id
)
.
name
(
this
.
name
)
.
description
(
this
.
description
)
.
categoryPrimaryId
(
this
.
categoryPrimaryId
)
.
createTime
(
this
.
createTime
)
.
updateTime
(
this
.
updateTime
)
.
build
();
}
}
src/main/java/com/mmc/pms/model/category/dto/CategoryPrimaryDTO.java
0 → 100644
浏览文件 @
2a6b406e
package
com
.
mmc
.
pms
.
model
.
category
.
dto
;
import
com.mmc.pms.entity.category.CategorySubDO
;
import
com.mmc.pms.model.group.Create
;
import
com.mmc.pms.model.group.Update
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
javax.validation.constraints.Min
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Size
;
import
java.util.Date
;
import
java.util.List
;
/**
* @Author small
* @Date 2023/7/20 16:35
* @Version 1.0
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public
class
CategoryPrimaryDTO
{
@ApiModelProperty
(
value
=
"id"
)
@NotNull
(
message
=
"id不能为空"
,
groups
=
{
Update
.
class
})
@Min
(
value
=
1
,
groups
=
{
Update
.
class
})
private
Integer
id
;
@ApiModelProperty
(
value
=
"分类名称"
,
required
=
true
,
example
=
"无人机"
)
@Size
(
max
=
15
,
message
=
"分类名称不能超过15个字"
,
groups
=
{
Update
.
class
,
Create
.
class
})
@NotBlank
(
message
=
"分类名称不能为空或空字符"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
String
name
;
@ApiModelProperty
(
value
=
"描述"
)
@Size
(
max
=
70
,
message
=
"分类描述不能超过70个字"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
String
description
;
@ApiModelProperty
(
value
=
"icon图标"
)
private
String
icon
;
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty
(
value
=
"创建时间"
,
example
=
"2023-07-14 10:13:12"
,
required
=
true
)
private
Date
createTime
;
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty
(
value
=
"更新时间"
,
example
=
"2023-07-14 10:13:12"
,
required
=
true
)
private
Date
updateTime
;
@ApiModelProperty
(
value
=
"二级分类"
)
private
List
<
CategorySubDO
>
subDTOList
;
}
src/main/java/com/mmc/pms/model/category/dto/CategorySubDTO.java
0 → 100644
浏览文件 @
2a6b406e
package
com
.
mmc
.
pms
.
model
.
category
.
dto
;
import
com.mmc.pms.model.group.Create
;
import
com.mmc.pms.model.group.Update
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
javax.validation.constraints.Min
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Size
;
import
java.util.Date
;
/**
* @Author small
* @Date 2023/7/21 10:10
* @Version 1.0
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public
class
CategorySubDTO
{
@ApiModelProperty
(
value
=
"id"
)
@NotNull
(
message
=
"id不能为空"
,
groups
=
{
Update
.
class
})
@Min
(
value
=
1
,
groups
=
{
Update
.
class
})
private
Integer
id
;
@ApiModelProperty
(
value
=
"分类名称"
,
required
=
true
,
example
=
"无人机"
)
@Size
(
max
=
15
,
message
=
"分类名称不能超过15个字"
,
groups
=
{
Update
.
class
,
Create
.
class
})
@NotBlank
(
message
=
"分类名称不能为空或空字符"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
String
name
;
@ApiModelProperty
(
value
=
"描述"
)
@Size
(
max
=
70
,
message
=
"分类描述不能超过70个字"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
String
description
;
@ApiModelProperty
(
value
=
"一级id不能为空"
,
required
=
true
,
example
=
"1"
)
@NotNull
(
message
=
"一级id不能为空"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
Integer
categoryPrimaryId
;
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty
(
value
=
"创建时间"
,
example
=
"2023-07-14 10:13:12"
,
required
=
true
)
private
Date
createTime
;
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty
(
value
=
"更新时间"
,
example
=
"2023-07-14 10:13:12"
,
required
=
true
)
private
Date
updateTime
;
}
src/main/java/com/mmc/pms/model/category/qo/CategoryQO.java
0 → 100644
浏览文件 @
2a6b406e
package
com
.
mmc
.
pms
.
model
.
category
.
qo
;
import
com.mmc.pms.common.Page
;
import
com.mmc.pms.model.group.Freeze
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
javax.validation.constraints.Min
;
import
javax.validation.constraints.NotNull
;
/**
* @Author small
* @Date 2023/7/21 15:22
* @Version 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
CategoryQO
{
private
static
final
long
serialVersionUID
=
-
3729786590325257669L
;
@ApiModelProperty
(
value
=
"一级分类id"
,
required
=
false
,
example
=
"1"
)
private
Integer
id
;
@ApiModelProperty
(
value
=
"当前页"
,
required
=
true
,
example
=
"1"
)
@NotNull
(
message
=
"当前页不能为空"
,
groups
=
{
Page
.
class
,
Freeze
.
class
})
@Min
(
value
=
1
,
groups
=
Page
.
class
)
private
Integer
pageNo
;
@ApiModelProperty
(
value
=
"页大小"
,
required
=
true
,
example
=
"10"
)
@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/model/category/vo/CategoryPrimaryVO.java
0 → 100644
浏览文件 @
2a6b406e
package
com
.
mmc
.
pms
.
model
.
category
.
vo
;
import
com.mmc.pms.model.group.Create
;
import
com.mmc.pms.model.group.Update
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.constraints.Min
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Size
;
/**
* @Author small
* @Date 2023/7/20 16:34
* @Version 1.0
*/
@Data
public
class
CategoryPrimaryVO
{
@ApiModelProperty
(
value
=
"id"
,
example
=
"1"
)
@NotNull
(
message
=
"id不能为空"
,
groups
=
{
Update
.
class
})
@Min
(
value
=
1
,
groups
=
{
Update
.
class
})
private
Integer
id
;
@ApiModelProperty
(
value
=
"分类名称"
,
required
=
true
,
example
=
"无人机"
)
@Size
(
max
=
15
,
message
=
"分类名称不能超过15个字"
,
groups
=
{
Update
.
class
,
Create
.
class
})
@NotBlank
(
message
=
"分类名称不能为空或空字符"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
String
name
;
@ApiModelProperty
(
value
=
"描述"
,
example
=
"描述一下"
)
@Size
(
max
=
70
,
message
=
"分类描述不能超过70个字"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
String
description
;
@ApiModelProperty
(
value
=
"icon图标"
,
example
=
"http://"
)
private
String
icon
;
}
src/main/java/com/mmc/pms/model/category/vo/CategorySubVO.java
0 → 100644
浏览文件 @
2a6b406e
package
com
.
mmc
.
pms
.
model
.
category
.
vo
;
import
com.mmc.pms.model.group.Create
;
import
com.mmc.pms.model.group.Update
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.constraints.Min
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Size
;
/**
* @Author small
* @Date 2023/7/21 10:10
* @Version 1.0
*/
@Data
public
class
CategorySubVO
{
@ApiModelProperty
(
value
=
"id"
,
example
=
"1"
)
@NotNull
(
message
=
"id不能为空"
,
groups
=
{
Update
.
class
})
@Min
(
value
=
1
,
groups
=
{
Update
.
class
})
private
Integer
id
;
@ApiModelProperty
(
value
=
"分类名称"
,
required
=
true
,
example
=
"无人机"
)
@Size
(
max
=
15
,
message
=
"分类名称不能超过15个字"
,
groups
=
{
Update
.
class
,
Create
.
class
})
@NotBlank
(
message
=
"分类名称不能为空或空字符"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
String
name
;
@ApiModelProperty
(
value
=
"描述"
,
example
=
"描述001"
)
@Size
(
max
=
70
,
message
=
"分类描述不能超过70个字"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
String
description
;
@ApiModelProperty
(
value
=
"一级分类id不能为空"
,
required
=
true
,
example
=
"1"
)
@NotNull
(
message
=
"一级分类id不能为空"
,
groups
=
{
Update
.
class
,
Create
.
class
})
private
Integer
categoryPrimaryId
;
}
src/main/java/com/mmc/pms/service/category/CategoryService.java
0 → 100644
浏览文件 @
2a6b406e
package
com
.
mmc
.
pms
.
service
.
category
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.model.category.dto.CategoryPrimaryDTO
;
import
com.mmc.pms.model.category.qo.CategoryQO
;
import
com.mmc.pms.model.category.vo.CategoryPrimaryVO
;
import
com.mmc.pms.model.category.vo.CategorySubVO
;
import
com.mmc.pms.page.PageResult
;
/**
* @Author small
* @Date 2023/7/20 16:26
* @Version 1.0
*/
public
interface
CategoryService
{
ResultBody
addPrimaryCategory
(
CategoryPrimaryVO
primaryVO
);
ResultBody
deletePrimaryCategory
(
Integer
id
);
ResultBody
updatePrimaryCategory
(
CategoryPrimaryVO
primaryVO
);
ResultBody
addSubCategory
(
CategorySubVO
subVO
);
ResultBody
updateSubCategory
(
CategorySubVO
subVO
);
ResultBody
deleteSubCategory
(
Integer
id
);
ResultBody
detailSubCategory
(
Integer
id
);
PageResult
<
CategoryPrimaryDTO
>
categoryList
(
CategoryQO
param
);
}
src/main/java/com/mmc/pms/service/category/impl/CategoryServiceImpl.java
0 → 100644
浏览文件 @
2a6b406e
package
com
.
mmc
.
pms
.
service
.
category
.
impl
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.common.ResultEnum
;
import
com.mmc.pms.dao.category.CategoryDao
;
import
com.mmc.pms.entity.category.CategoryPrimaryDO
;
import
com.mmc.pms.entity.category.CategorySubDO
;
import
com.mmc.pms.model.category.dto.CategoryPrimaryDTO
;
import
com.mmc.pms.model.category.dto.CategorySubDTO
;
import
com.mmc.pms.model.category.qo.CategoryQO
;
import
com.mmc.pms.model.category.vo.CategoryPrimaryVO
;
import
com.mmc.pms.model.category.vo.CategorySubVO
;
import
com.mmc.pms.page.PageResult
;
import
com.mmc.pms.service.category.CategoryService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @Author small
* @Date 2023/7/20 16:26
* @Version 1.0
*/
@Service
public
class
CategoryServiceImpl
implements
CategoryService
{
@Autowired
private
CategoryDao
categoryDao
;
@Override
public
ResultBody
addPrimaryCategory
(
CategoryPrimaryVO
primaryVO
)
{
int
count
=
categoryDao
.
getCountName
(
primaryVO
.
getName
());
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
THE_NAME_OF_A_CLASS_MUST_BE_UNIQUE
);
}
CategoryPrimaryDO
primaryDO
=
new
CategoryPrimaryDO
(
primaryVO
);
categoryDao
.
addPrimaryCategory
(
primaryDO
);
Integer
id
=
primaryDO
.
getId
();
categoryDao
.
updateSort
(
id
);
return
ResultBody
.
success
();
}
@Override
public
ResultBody
deletePrimaryCategory
(
Integer
id
)
{
categoryDao
.
deletePrimaryCategory
(
id
);
return
ResultBody
.
success
();
}
@Override
public
ResultBody
updatePrimaryCategory
(
CategoryPrimaryVO
primaryVO
)
{
CategoryPrimaryDO
primaryDO
=
new
CategoryPrimaryDO
(
primaryVO
);
Integer
count
=
categoryDao
.
categoryCount
(
primaryDO
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
THE_NAME_OF_A_CLASS_MUST_BE_UNIQUE
);
}
categoryDao
.
updatePrimaryCategory
(
primaryDO
);
return
ResultBody
.
success
();
}
@Override
public
ResultBody
addSubCategory
(
CategorySubVO
subVO
)
{
int
count
=
categoryDao
.
getCountSubName
(
subVO
.
getName
(),
subVO
.
getCategoryPrimaryId
());
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
THE_NAME_OF_THE_SECONDARY_CLASS_MUST_BE_UNIQUE
);
}
CategorySubDO
subDO
=
new
CategorySubDO
(
subVO
);
categoryDao
.
addSubCategory
(
subDO
);
return
ResultBody
.
success
();
}
@Override
public
ResultBody
updateSubCategory
(
CategorySubVO
subVO
)
{
CategorySubDO
subDO
=
new
CategorySubDO
(
subVO
);
Integer
count
=
categoryDao
.
categorySubCount
(
subDO
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
THE_NAME_OF_THE_SECONDARY_CLASS_MUST_BE_UNIQUE
);
}
categoryDao
.
updateSubCategory
(
subDO
);
return
ResultBody
.
success
();
}
@Override
public
ResultBody
deleteSubCategory
(
Integer
id
)
{
categoryDao
.
deleteSubCategory
(
id
);
return
ResultBody
.
success
();
}
@Override
public
ResultBody
<
CategorySubDTO
>
detailSubCategory
(
Integer
id
)
{
CategorySubDO
subDO
=
categoryDao
.
detailSubCategory
(
id
);
CategorySubDTO
categorySubDTO
=
subDO
.
buildCategorySubDTO
();
return
ResultBody
.
success
(
categorySubDTO
);
}
@Override
public
PageResult
<
CategoryPrimaryDTO
>
categoryList
(
CategoryQO
param
)
{
int
count
=
categoryDao
.
categoryListCount
(
param
);
if
(
count
==
0
)
{
return
PageResult
.
buildPage
(
param
.
getPageNo
(),
param
.
getPageSize
(),
count
);
}
param
.
buildCurrentPage
();
List
<
CategoryPrimaryDO
>
categoryPrimaryDOS
=
categoryDao
.
categoryList
(
param
);
List
<
CategoryPrimaryDTO
>
collect
=
categoryPrimaryDOS
.
stream
().
map
(
t
->
t
.
buildCategoryPrimaryDTO
()).
collect
(
Collectors
.
toList
());
return
PageResult
.
buildPage
(
param
.
getPageNo
(),
param
.
getPageSize
(),
count
,
collect
);
}
}
src/main/resources/mapper/category/CategoryDao.xml
0 → 100644
浏览文件 @
2a6b406e
<?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.category.CategoryDao"
>
<resultMap
id=
"CategoryList"
type=
"com.mmc.pms.entity.category.CategoryPrimaryDO"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"name"
column=
"name"
/>
<result
property=
"description"
column=
"description"
/>
<result
property=
"icon"
column=
"icon"
/>
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<collection
property=
"subDOList"
ofType=
"com.mmc.pms.entity.category.CategorySubDO"
select=
"selectSubList"
column=
"{categoryPrimaryId=id}"
>
</collection>
</resultMap>
<select
id=
"selectSubList"
resultType=
"com.mmc.pms.entity.category.CategorySubDO"
>
select id,
`name`,
description,
category_primary_id AS categoryPrimaryId,
create_time AS createTime,
update_time AS updateTime
from category_sub
where category_primary_id = #{categoryPrimaryId}
</select>
<select
id=
"categoryListCount"
resultType=
"int"
parameterType=
"com.mmc.pms.model.category.qo.CategoryQO"
>
SELECT count(*)
FROM
category_primary
WHERE 1=1
<if
test=
" id != null and id != '' "
>
and id=#{id}
</if>
</select>
<select
id=
"getCountName"
resultType=
"java.lang.Integer"
>
select count(*)
from category_primary
where 1=1
<if
test=
" name != null and name != '' "
>
and `name` = #{name}
</if>
</select>
<insert
id=
"addPrimaryCategory"
useGeneratedKeys=
"true"
keyProperty=
"id"
parameterType=
"com.mmc.pms.entity.category.CategoryPrimaryDO"
>
insert into category_primary(`name`, description, create_time, update_time, icon)
values (#{name}, #{description}, NOW(), NOW(), #{icon})
</insert>
<update
id=
"updateSort"
>
update category_primary
<set>
<if
test=
"id!=null"
>
sort = #{id}
</if>
</set>
where id=#{id}
</update>
<delete
id=
"deletePrimaryCategory"
>
delete
from category_primary
where id = #{id}
</delete>
<select
id=
"categoryCount"
resultType=
"java.lang.Integer"
>
select count(*)
from category_primary
where 1=1
<if
test=
" name != null and name != '' "
>
and `name` = #{name}
</if>
<if
test=
" id != null and id != '' "
>
and id != #{id}
</if>
</select>
<update
id=
"updatePrimaryCategory"
parameterType=
"com.mmc.pms.entity.category.CategoryPrimaryDO"
>
UPDATE category_primary
<set>
<if
test=
" name != null and name != '' "
>
`name` = #{name},
</if>
<if
test=
" description != null and description != '' "
>
description = #{description},
</if>
<if
test=
" icon != null and icon != '' "
>
icon = #{icon},
</if>
update_time=NOW()
</set>
where id = #{id}
</update>
<select
id=
"getCountSubName"
resultType=
"java.lang.Integer"
>
select count(*)
from category_sub
where 1=1
<if
test=
" name != null and name != '' "
>
and `name` = #{name}
</if>
<if
test=
" categoryPrimaryId != null and categoryPrimaryId != '' "
>
and category_primary_id = #{categoryPrimaryId}
</if>
</select>
<insert
id=
"addSubCategory"
useGeneratedKeys=
"true"
keyProperty=
"id"
parameterType=
"com.mmc.pms.entity.category.CategorySubDO"
>
insert into category_sub(`name`, description, create_time, update_time, category_primary_id)
values (#{name}, #{description}, NOW(), NOW(), #{categoryPrimaryId})
</insert>
<select
id=
"categorySubCount"
resultType=
"java.lang.Integer"
>
select count(*)
from category_sub
where 1=1
<if
test=
" name != null and name != '' "
>
and `name` = #{name}
</if>
<if
test=
" id != null and id != '' "
>
and id != #{id}
</if>
<if
test=
" categoryPrimaryId != null and categoryPrimaryId != '' "
>
and category_primary_id != #{categoryPrimaryId}
</if>
</select>
<update
id=
"updateSubCategory"
parameterType=
"com.mmc.pms.entity.category.CategorySubDO"
>
UPDATE category_sub
<set>
<if
test=
" name != null and name != '' "
>
`name` = #{name},
</if>
<if
test=
" description != null and description != '' "
>
description = #{description},
</if>
update_time=NOW()
</set>
where id = #{id}
</update>
<delete
id=
"deleteSubCategory"
>
delete
from category_sub
where id = #{id}
</delete>
<select
id=
"detailSubCategory"
resultType=
"com.mmc.pms.entity.category.CategorySubDO"
>
select id,
`name`,
description,
create_time AS createTime,
update_time AS updateTime,
category_primary_id AS categoryPrimaryId
from category_sub
where id = #{id}
</select>
<select
id=
"categoryList"
resultMap=
"CategoryList"
>
select id, `name`, description, create_time, update_time, icon
from category_primary where 1=1
<if
test=
" id != null and id != '' "
>
and id =#{id}
</if>
order by update_time desc, create_time desc
limit #{pageNo},#{pageSize}
</select>
</mapper>
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论