This commit is contained in:
liulu
2024-10-28 11:32:18 +08:00
parent e59811ced4
commit 17356d0314
76 changed files with 3304 additions and 135 deletions
@@ -0,0 +1,8 @@
package com.sunyard.chsm.controller;
/**
* @author liulu
* @since 2024/10/23
*/
public class AsymKeyController {
}
@@ -0,0 +1,120 @@
package com.sunyard.chsm.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sunyard.chsm.dto.ApiGroupDTO;
import com.sunyard.chsm.dto.CryptoServiceDTO;
import com.sunyard.chsm.enums.ApiFunEnum;
import com.sunyard.chsm.model.R;
import com.sunyard.chsm.service.CryptoServiceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* 密码服务管理接口
*
* @author liulu
* @since 2024/10/15
*/
@Slf4j
@RestController
@RequestMapping("/crypto/service")
public class CryptoServiceController {
@Resource
private CryptoServiceService cryptoServiceService;
/**
* 查询密码服务接口分组列表
*
* @return
*/
@GetMapping("/apiGroupList")
public R<List<ApiGroupDTO>> getApiGroupList() {
List<ApiGroupDTO> res = Arrays.stream(ApiFunEnum.values())
.collect(Collectors.groupingBy(ApiFunEnum::getGroup))
.entrySet().stream()
.map(it -> {
ApiGroupDTO group = new ApiGroupDTO();
group.setGroupCode(it.getKey().getCode());
group.setGroupName(it.getKey().getName());
group.setApiList(it.getValue().stream().map(it2 -> {
ApiGroupDTO.Api api = new ApiGroupDTO.Api();
api.setCode(it2.getCode());
api.setName(it2.getName());
return api;
})
.collect(Collectors.toList()));
return group;
})
.collect(Collectors.toList());
return R.data(res);
}
/**
* 分页查询密码服务列表
*
* @param query 查询条件
* @return 密码服务列表
*/
@GetMapping("/pageList")
public R<Page<CryptoServiceDTO.View>> servicePageList(CryptoServiceDTO.Query query) {
Page<CryptoServiceDTO.View> page = cryptoServiceService.selectPageList(query);
return R.data(page);
}
/**
* 创建密码服务
*
* @param save 参数
* @return 密码服务id
*/
@PostMapping
public R<String> saveService(@Valid @RequestBody CryptoServiceDTO.Save save) {
Long id = cryptoServiceService.save(save);
return R.data(String.valueOf(id));
}
/**
* 修改密码服务
*
* @param update 参数
* @return 密码服务id
*/
@PutMapping
public R<Void> updateService(@Valid @RequestBody CryptoServiceDTO.Save update) {
Assert.notNull(update.getId(), "密码服务id不能为空");
cryptoServiceService.update(update);
return R.ok();
}
/**
* 删除密码服务
*
* @param id 密码服务id
* @return
*/
@DeleteMapping
public R<Void> deleteService(Long id) {
Assert.notNull(id, "密码服务id不能为空");
cryptoServiceService.delete(id);
return R.ok();
}
}
@@ -0,0 +1,143 @@
package com.sunyard.chsm.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sunyard.chsm.dto.DeviceDTO;
import com.sunyard.chsm.dto.ManufacturersDeviceDTO;
import com.sunyard.chsm.enums.ManufacturerModelEnum;
import com.sunyard.chsm.model.R;
import com.sunyard.chsm.service.DeviceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* 密码机管理接口
*
* @author liulu
* @since 2024/10/15
*/
@Slf4j
@RestController("sp_DeviceController")
@RequestMapping("/device")
public class DeviceController {
@Resource
private DeviceService deviceService;
/**
* 分页查询密码设备列表
*
* @param query 查询条件
* @return 分页列表
*/
@GetMapping("/pageList")
public R<Page<DeviceDTO.View>> servicePageList(DeviceDTO.Query query) {
Page<DeviceDTO.View> page = deviceService.selectPageList(query);
return R.data(page);
}
/**
* 查询未分组设备列表
*
* @return 列表
*/
@GetMapping("/ungrouped/list")
public R<List<DeviceDTO.View>> getUngroupedList() {
List<DeviceDTO.View> res = deviceService.getUngroupedList();
return R.data(res);
}
/**
* 查询设备详情
*
* @param id id
* @return 详情
*/
@GetMapping("/detail")
public R<DeviceDTO.Detail> getById(Long id) {
DeviceDTO.Detail res = deviceService.getDetailById(id);
return R.data(res);
}
/**
* 查询已适配的厂商设备列表
*
* @return 列表
*/
@GetMapping("/adapted/list")
public R<List<ManufacturersDeviceDTO>> getAdaptedList() {
List<ManufacturersDeviceDTO> manufacturers = Arrays.stream(ManufacturerModelEnum.values())
.collect(Collectors.groupingBy(ManufacturerModelEnum::getManufacturer))
.entrySet().stream()
.map(it -> {
ManufacturersDeviceDTO adaptedDevices = new ManufacturersDeviceDTO();
adaptedDevices.setCode(it.getKey().getCode());
adaptedDevices.setName(it.getKey().getName());
List<ManufacturersDeviceDTO.Model> modelList = it.getValue().stream().map(it2 -> {
ManufacturersDeviceDTO.Model model = new ManufacturersDeviceDTO.Model();
model.setModel(it2.getModel());
model.setName(it2.getName());
return model;
})
.collect(Collectors.toList());
adaptedDevices.setModels(modelList);
return adaptedDevices;
})
.collect(Collectors.toList());
return R.data(manufacturers);
}
/**
* 添加密码设备
*
* @param save 参数
* @return id
*/
@PostMapping
public R<String> save(@Valid @RequestBody DeviceDTO.Save save) {
Long id = deviceService.save(save);
return R.data(String.valueOf(id));
}
/**
* 修改密码设备
*
* @param update 参数
* @return void
*/
@PutMapping
public R<Void> update(@Valid @RequestBody DeviceDTO.Save update) {
deviceService.update(update);
return R.ok();
}
/**
* 删除密码设备
*
* @param id id
* @return void
*/
@DeleteMapping
public R<Void> delete(Long id) {
deviceService.delete(id);
return R.ok();
}
}
@@ -0,0 +1,81 @@
package com.sunyard.chsm.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sunyard.chsm.dto.DeviceGroupDTO;
import com.sunyard.chsm.model.R;
import com.sunyard.chsm.service.DeviceGroupService;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
/**
* 设备组管理接口
*
* @author liulu
* @since 2024/10/21
*/
@RestController("sp_DeviceGroupController")
@RequestMapping("/device/group")
public class DeviceGroupController {
@Resource
private DeviceGroupService deviceGroupService;
/**
* 分页查询设备组列表
*
* @param query 查询条件
* @return 分页列表
*/
@GetMapping("/pageList")
public R<Page<DeviceGroupDTO.View>> servicePageList(DeviceGroupDTO.Query query) {
Page<DeviceGroupDTO.View> page = deviceGroupService.selectPageList(query);
return R.data(page);
}
/**
* 添加设备组
*
* @param save 参数
* @return id
*/
@PostMapping
public R<String> save(@Valid @RequestBody DeviceGroupDTO.Save save) {
Long id = deviceGroupService.save(save);
return R.data(String.valueOf(id));
}
/**
* 修改设备组
*
* @param update 参数
* @return void
*/
@PutMapping
public R<Void> update(@Valid @RequestBody DeviceGroupDTO.Save update) {
deviceGroupService.update(update);
return R.ok();
}
/**
* 删除设备组
*
* @param id id
* @return void
*/
@DeleteMapping
public R<Void> delete(Long id) {
deviceGroupService.delete(id);
return R.ok();
}
}
@@ -0,0 +1,80 @@
package com.sunyard.chsm.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sunyard.chsm.dto.KeyTemplateDTO;
import com.sunyard.chsm.model.R;
import com.sunyard.chsm.service.KeyTemplateService;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
/**
* 密钥模版管理接口
* @author liulu
* @since 2024/10/22
*/
@RestController
@RequestMapping("/key/template")
public class KeyTemplateController {
@Resource
private KeyTemplateService keyTemplateService;
/**
* 分页查询密钥模版
*
* @param query 查询条件
* @return 分页列表
*/
@GetMapping("/pageList")
public R<Page<KeyTemplateDTO.View>> servicePageList(KeyTemplateDTO.Query query) {
Page<KeyTemplateDTO.View> page = keyTemplateService.selectPageList(query);
return R.data(page);
}
/**
* 添加密钥模版
*
* @param save 参数
* @return id
*/
@PostMapping
public R<String> save(@Valid @RequestBody KeyTemplateDTO.Save save) {
Long id = keyTemplateService.save(save);
return R.data(String.valueOf(id));
}
/**
* 修改密钥模版
*
* @param update 参数
* @return void
*/
@PutMapping
public R<Void> update(@Valid @RequestBody KeyTemplateDTO.Save update) {
keyTemplateService.update(update);
return R.ok();
}
/**
* 删除密钥模版
*
* @param id id
* @return void
*/
@DeleteMapping
public R<Void> delete(Long id) {
keyTemplateService.delete(id);
return R.ok();
}
}
@@ -0,0 +1,41 @@
package com.sunyard.chsm.controller;
import com.sunyard.chsm.dto.KeyInfoDTO;
import com.sunyard.chsm.model.R;
import com.sunyard.chsm.service.KeyInfoService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
/**
* 对称密钥管理接口
*
* @author liulu
* @since 2024/10/23
*/
@RestController
@RequestMapping("/sym/key")
public class SymKeyController {
@Resource
private KeyInfoService keyInfoService;
/**
* 创建密钥
*
* @param save 参数
* @return id
*/
@PostMapping
public R<String> save(@Valid @RequestBody KeyInfoDTO.Save save) {
Long id = keyInfoService.save(save);
return R.data(String.valueOf(id));
}
}