枚举类型配置API

This commit is contained in:
yu 2024-10-24 16:35:00 +08:00
parent ccc84e3ad4
commit e56a387169
4 changed files with 462 additions and 9 deletions

View File

@ -111,7 +111,7 @@ public class SysEnumController {
* 删除枚举值
* */
@PostMapping("/deleteEnumValues")
public R<List<SysEnumValuesVo>> deleteEnumValues(@RequestBody SysEnumValuesDto sysEnumValuesDto) {
public R<Void> deleteEnumValues(@RequestBody SysEnumValuesDto sysEnumValuesDto) {
//判断是否有权限
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_MGR.toString());
if(!hasPermission){
@ -123,6 +123,36 @@ public class SysEnumController {
sysEnumService.deleteEnumValues(sysEnumValuesDto);
return R.success();
}
/** 修改枚举类型 */
@PostMapping("/updateEnumTypes")
public R<SysEnumTypesVo> updateEnumTypes(@RequestBody SysEnumTypesDto sysEnumTypesDto) {
//判断是否有权限
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_MGR.toString());
if(!hasPermission){
return R.fail("没有设备管理权限");
}
if (sysEnumTypesDto.getId() ==null) {
throw new ServiceException("参数缺失");
}
SysEnumTypesVo sysEnumTypesVo = sysEnumService.updateEnumTypes(sysEnumTypesDto);
return R.success(sysEnumTypesVo);
}
/** 删除枚举类型 */
@PostMapping("/deleteEnumTypes")
public R<Void> deleteEnumTypes(@RequestBody SysEnumTypesDto sysEnumTypesDto) {
//判断是否有权限
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_MGR.toString());
if(!hasPermission){
return R.fail("没有设备管理权限");
}
if (sysEnumTypesDto.getId() ==null) {
throw new ServiceException("参数缺失");
}
sysEnumService.deleteEnumTypes(sysEnumTypesDto);
return R.success();
}
}

View File

@ -12,6 +12,10 @@ public interface SysEnumService {
SysEnumTypesVo addEnumTypes(SysEnumTypesDto sysEnumTypesDto);
SysEnumTypesVo updateEnumTypes(SysEnumTypesDto sysEnumTypesDto);
void deleteEnumTypes(SysEnumTypesDto sysEnumTypesDto);
SysEnumValuesVo addEnumValues(SysEnumValuesDto sysEnumValuesDto);
SysEnumValuesVo updateEnumValues(SysEnumValuesDto sysEnumValuesDto);

View File

@ -56,6 +56,42 @@ public class SysEnumServiceImpl implements SysEnumService {
return sysEnumTypesVo;
}
/**
* 修改枚举类型
* @param sysEnumTypesDto
* @return
*/
@Override
public SysEnumTypesVo updateEnumTypes(SysEnumTypesDto sysEnumTypesDto) {
SysEnumTypes sysEnumTypes = new SysEnumTypes();
BeanCopyUtils.copy(sysEnumTypesDto, sysEnumTypes);
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
sysEnumTypes.setUpdatedBy(sysUserVo.getAccount());
sysEnumTypes.setUpdatedTime(new Date());
sysEnumTypesMapper.updateById(sysEnumTypes);
SysEnumTypesVo sysEnumTypesVo = new SysEnumTypesVo();
BeanCopyUtils.copy(sysEnumTypes, sysEnumTypesVo);
return sysEnumTypesVo;
}
/**
* 删除枚举类型
* @param sysEnumTypesDto
*/
@Override
public void deleteEnumTypes(SysEnumTypesDto sysEnumTypesDto) {
SysEnumTypes sysEnumTypes = new SysEnumTypes();
BeanCopyUtils.copy(sysEnumTypesDto, sysEnumTypes);
QueryWrapper<SysEnumValues> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("enum_type_id",sysEnumTypesDto.getId());
queryWrapper.eq("is_active",1);
Long count = sysEnumValuesMapper.selectCount(queryWrapper);
if (count >0){
throw new ServiceException("该枚举类型下,存在枚举值,不可删除!");
}
sysEnumTypesMapper.deleteById(sysEnumTypesDto.getId());
}
/** 新增枚举值 */
@Override
public SysEnumValuesVo addEnumValues(SysEnumValuesDto sysEnumValuesDto) {
@ -84,13 +120,6 @@ public class SysEnumServiceImpl implements SysEnumService {
public SysEnumValuesVo updateEnumValues(SysEnumValuesDto sysEnumValuesDto) {
SysEnumValues sysEnumValues = new SysEnumValues();
BeanCopyUtils.copy(sysEnumValuesDto,sysEnumValues);
QueryWrapper<SysEnumValues> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("enum_type_id",sysEnumValuesDto.getEnumTypeId());
queryWrapper.eq("description",sysEnumValuesDto.getDescription());
Long count = sysEnumValuesMapper.selectCount(queryWrapper);
if (count >0){
throw new ServiceException("枚举值描述,不可重复!");
}
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
sysEnumValues.setUpdatedBy(sysUserVo.getAccount());
sysEnumValues.setUpdatedTime(new Date());
@ -117,7 +146,7 @@ public class SysEnumServiceImpl implements SysEnumService {
}
/**
* 查询枚举类型列表
* 查询枚举列表
* @param sysEnumValuesDto
* @return
*/

390
docs/api/enumPage.md Normal file
View File

@ -0,0 +1,390 @@
# 枚举类型配置模块
## API接口一览表
| 接口分类 | 接口描述 | API接口 | 权限 |
|-----------|---------------| ------------------------------------- | --------------------------- |
| 2.1枚举类型配置 | 2.1.1新增枚举类型 | /api/enum/addEnumTypes | SYS_AUTHORITY_ID_DEVICE_MGR|
| | 2.1.2新增枚举值 | /api/enum/addEnumValues | SYS_AUTHORITY_ID_DEVICE_MGR |
| | 2.1.3枚举值修改 | /api/enum/updateEnumValues | SYS_AUTHORITY_ID_DEVICE_MGR |
| | 2.1.4获取枚举类型列表 | /api/enum/queryEnumTypesList | |
| | 2.1.5获取枚举值列表 | /api/enum/queryEnumValuesList | |
| | 2.1.6删除枚举值 | /api/enum/deleteEnumValues | SYS_AUTHORITY_ID_DEVICE_MGR |
| | 2.1.7修改枚举类型 | /api/enum/updateEnumTypes | SYS_AUTHORITY_ID_DEVICE_MGR |
| | 2.1.8删除枚举类型 | /api/enum/deleteEnumTypes | SYS_AUTHORITY_ID_DEVICE_MGR |
### 2.1 枚举类型配置相关接口
#### 2.1.1 新增枚举类型
POST 请求接口
> /api/enum/addEnumTypes
请求参数
```json
{
"name": "testEnum",
"description": "测试枚举类型"
}
```
入参描述
| 参数名 | 参数类型 | 可选 | 描述 |
| ------------ | -------- |----|--------|
| name | String | NO | 枚举类型名称 |
| description | String | NO | 枚举描述 |
返回报文
```json
{
"code": 200,
"success": true,
"data": {
"id": "1849346211333619713",
"name": "testEnum",
"description": "测试枚举类型"
},
"msg": "操作成功"
}
```
返参描述
| 参数名 | 参数类型 | 可选 | 描述 |
| ------------- |---------| ---- |--------|
| id | String | 否 | id |
| name | String | 否 | 枚举类型名称 |
| description | String | 否 | 枚举描述 |
#### 2.1.2 新增枚举值
POST 请求接口
> /api/enum/addEnumValues
请求参数
```json
{
"enumTypeId": 1849346211333619713,
"value": "testenum1",
"description": "测试枚举值1",
"isActive": 1,
"orderNumber": 1
}
```
入参描述
| 参数名 | 参数类型 | 可选 | 描述 |
| ------------ |---------|----|----------------|
| enumTypeId | Long | NO | 枚举类型id |
| value | String | NO | 枚举值内容 |
| description | String | NO | 枚举值描述 |
| isActive | Integer | NO | 是否有效(0:无效,1:有效) |
| orderNumber | Integer | NO | 排序 |
返回报文
```json
{
"code": 200,
"success": true,
"data": {
"id": "1849347701024608258",
"enumTypeId": 1849346211333619713,
"value": "testenum1",
"description": "测试枚举值1",
"orderNumber": 1,
"isActive": 1
},
"msg": "操作成功"
}
```
返参描述
| 参数名 | 参数类型 | 可选 | 描述 |
|---------------|---------| ---- |-----------------|
| id | String | 否 | id |
| enumTypeId | Long | 否 | 枚举类型id |
| value | String | 否 | 枚举值内容 |
| description | String | 否 | 枚举值描述 |
| isActive | Integer | 否 | 是否有效(0:无效,1:有效) |
| orderNumber | Integer | 否 | 排序 |
#### 2.1.3 枚举值修改
POST 请求接口
> /api/enum/updateEnumValues
请求参数
```json
{
"id": 1849347701024608258,
"enumTypeId": 1849346211333619713,
"value": "testenum2",
"description": "测试枚举值2",
"isActive": 1,
"orderNumber": 1
}
```
入参描述
| 参数名 | 参数类型 | 可选 | 描述 |
|-------------|---------|-----|-----------------|
| id | Long | NO | 枚举值id |
| enumTypeId | Long | NO | 枚举类型id |
| value | String | YES | 枚举值内容 |
| description | String | YES | 枚举值描述 |
| isActive | Integer | YES | 是否有效(0:无效,1:有效) |
| orderNumber | Integer | YES | 排序 |
返回报文
```json
{
"code": 200,
"success": true,
"data": {
"id": "1849347701024608258",
"enumTypeId": 1849346211333619713,
"value": "testenum2",
"description": "测试枚举值2",
"orderNumber": 1,
"isActive": 1
},
"msg": "操作成功"
}
```
返参描述
| 参数名 | 参数类型 | 可选 | 描述 |
|---------------|---------| ---- |-----------------|
| id | String | 否 | id |
| enumTypeId | Long | 否 | 枚举类型id |
| value | String | 否 | 枚举值内容 |
| description | String | 否 | 枚举值描述 |
| isActive | Integer | 否 | 是否有效(0:无效,1:有效) |
| orderNumber | Integer | 否 | 排序 |
#### 2.1.4 获取枚举类型列表
POST 请求接口
> /api/enum/queryEnumTypesList
请求参数
返回报文
```json
{
"code": 200,
"success": true,
"data": [
{
"id": "1",
"name": "iTurbineOperationMode",
"description": "运行模式"
},
{
"id": "2",
"name": "iBPLevel",
"description": "刹车等级"
}
],
"msg": "操作成功"
}
```
返参描述
| 参数名 | 参数类型 | 可选 | 描述 |
|---------------|---------| ---- |--------|
| id | String | 否 | id |
| name | String | 否 | 枚举类型名称 |
| description | String | 否 | 枚举值描述 |
#### 2.1.5 获取枚举值列表
POST 请求接口
> /api/enum/queryEnumValuesList
请求参数
```json
{
"pageNum":1,
"pageSize":20,
"description": "通讯断开",
"enumTypeId": "1"
}
```
入参描述
| 参数名 | 参数类型 | 可选 | 描述 |
|-------------|---------|-----|---------|
| pageNum | Integer | NO | 当前页 |
| pageSize | Integer | NO | 每页显示大小 |
| description | String | YES | 枚举值描述 |
| enumTypeId | String | NO | 枚举值类型id |
返回报文
```json
{
"code": 200,
"success": true,
"data": {
"total": 1,
"rows": [
{
"id": "1000",
"enumTypeId": 1,
"enumTypeIdStr": "1",
"value": "0",
"description": "通讯断开",
"orderNumber": 1,
"isActive": 1
}
],
"code": 200,
"msg": "查询成功"
},
"msg": "操作成功"
}
```
返参描述
| 参数名 | 参数类型 | 可选 | 描述 |
|---------------|---------| ---- |-----------------|
| id | String | 否 | id |
| enumTypeId | Long | 否 | 枚举类型id |
| enumTypeIdStr | String | 否 | 枚举类型id(字符串类型) |
| value | String | 否 | 枚举值内容 |
| description | String | 否 | 枚举值描述 |
| isActive | Integer | 否 | 是否有效(0:无效,1:有效) |
| orderNumber | Integer | 否 | 排序 |
#### 2.1.6 删除枚举值
POST 请求接口
> /api/enum/deleteEnumValues
请求参数
```json
{
"id":"1849347701024608258"
}
```
入参描述
| 参数名 | 参数类型 | 可选 | 描述 |
|-------------|---------|----|---------|
| id | String | NO | 枚举值id |
返回报文
```json
{
"code": 200,
"success": true,
"msg": "操作成功"
}
```
#### 2.1.7 修改枚举类型
POST 请求接口
> /api/enum/updateEnumTypes
请求参数
```json
{
"id":1849361189939826689,
"name": "testEnum3",
"description": "测试枚举类型3"
}
```
入参描述
| 参数名 | 参数类型 | 可选 | 描述 |
|-------------|---------|-----|--------|
| id | Long | NO | 枚举类型id |
| name | String | YES | 枚举类型名称 |
| description | String | YES | 枚举类型描述 |
返回报文
```json
{
"code": 200,
"success": true,
"data": {
"id": "1849361189939826689",
"name": "testEnum3",
"description": "测试枚举类型3"
},
"msg": "操作成功"
}
```
返参描述
| 参数名 | 参数类型 | 可选 | 描述 |
|-------------|---------|-----|--------|
| id | Long | 否 | 枚举类型id |
| name | String | 否 | 枚举类型名称 |
| description | String | 否 | 枚举类型描述 |
#### 2.1.8 删除枚举类型
POST 请求接口
> /api/enum/deleteEnumTypes
请求参数
```json
{
"id":1849361189939826689
}
```
入参描述
| 参数名 | 参数类型 | 可选 | 描述 |
|-------------|------|----|--------|
| id | Long | NO | 枚举类型id |
返回报文
```json
{
"code": 200,
"success": true,
"msg": "操作成功"
}
```