feat:文件格式管理功能
This commit is contained in:
parent
d44de8d924
commit
b578b91b0d
|
|
@ -0,0 +1,43 @@
|
|||
package com.electromagnetic.industry.software.manage.controller;
|
||||
|
||||
import com.electromagnetic.industry.software.common.annotations.UserOperation;
|
||||
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.FileFormat;
|
||||
import com.electromagnetic.industry.software.manage.service.serviceimpl.FileFormatService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data/ed/format")
|
||||
public class FileFormatController {
|
||||
|
||||
@Resource
|
||||
private FileFormatService fileFormatService;
|
||||
|
||||
@PostMapping("/add")
|
||||
@UserOperation(value = "新增文件格式", modelName = UserOperationModuleEnum.DATABASE)
|
||||
public ElectromagneticResult<?> addFileFormat(@RequestBody FileFormat fileFormat) {
|
||||
return ElectromagneticResultUtil.success(fileFormatService.addFileFormat(fileFormat));
|
||||
}
|
||||
|
||||
@GetMapping("/delete/{id}")
|
||||
@UserOperation(value = "删除文件格式", modelName = UserOperationModuleEnum.DATABASE)
|
||||
public ElectromagneticResult<?> deleteFileFormat(@PathVariable Long id) {
|
||||
return ElectromagneticResultUtil.success(fileFormatService.deleteFileFormat(id));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@UserOperation(value = "查询文件格式列表", modelName = UserOperationModuleEnum.DATABASE)
|
||||
public ElectromagneticResult<?> list() {
|
||||
return ElectromagneticResultUtil.success(fileFormatService.getList());
|
||||
}
|
||||
|
||||
@PostMapping("/edit")
|
||||
@UserOperation(value = "修改文件格式", modelName = UserOperationModuleEnum.DATABASE)
|
||||
public ElectromagneticResult<?> editFileFormat(@RequestBody FileFormat fileFormat) {
|
||||
return ElectromagneticResultUtil.success(fileFormatService.updateFileFormat(fileFormat));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.electromagnetic.industry.software.manage.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.FileFormat;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@Mapper
|
||||
public interface FileFormatMapper extends BaseMapper<FileFormat> {
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.models;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("ed_file_format")
|
||||
public class FileFormat {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String fileSuffix;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createdTime;
|
||||
|
||||
private String createdBy;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updatedTime;
|
||||
|
||||
private String updatedBy;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FileFormatVO {
|
||||
private Long id;
|
||||
|
||||
private String fileSuffix;
|
||||
|
||||
private String systemNumber;
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.FileFormat;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.FileFormatVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface FileFormatService extends IService<FileFormat> {
|
||||
|
||||
/**
|
||||
* 创建文件格式
|
||||
* @param fileFormat
|
||||
* @return
|
||||
*/
|
||||
boolean addFileFormat(FileFormat fileFormat);
|
||||
|
||||
/**
|
||||
* 删除文件格式
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
boolean deleteFileFormat(Long id);
|
||||
|
||||
/**
|
||||
* 查询文件格式列表
|
||||
* @return
|
||||
*/
|
||||
List<FileFormatVO> getList();
|
||||
|
||||
/**
|
||||
* 更新文件格式
|
||||
* @param fileFormat
|
||||
* @return
|
||||
*/
|
||||
boolean updateFileFormat(FileFormat fileFormat);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.text.StrFormatter;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||
import com.electromagnetic.industry.software.manage.mapper.FileFormatMapper;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.FileFormat;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.FileFormatVO;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class FileFormatServiceImpl extends ServiceImpl<FileFormatMapper, FileFormat> implements FileFormatService {
|
||||
|
||||
/**
|
||||
* 创建文件格式
|
||||
* @param fileFormat
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean addFileFormat(FileFormat fileFormat) {
|
||||
fileFormat.setCreatedBy(UserThreadLocal.getUserId());
|
||||
Assert.notNull(fileFormat.getFileSuffix(), "文件格式不能为空");
|
||||
boolean isSaved = this.save(fileFormat);
|
||||
if (isSaved) {
|
||||
UserThreadLocal.setSuccessInfo("","", StrFormatter.format("添加了文件格式 {} ", fileFormat.getFileSuffix()));
|
||||
}
|
||||
return isSaved;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件格式
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteFileFormat(Long id) {
|
||||
FileFormat fileFormat = getById(id);
|
||||
UserThreadLocal.setSuccessInfo("","", StrFormatter.format("删除了文件格式 {} ", fileFormat.getFileSuffix()));
|
||||
return removeById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询了文件格式列表
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public List<FileFormatVO> getList() {
|
||||
List<FileFormat> list = this.list();
|
||||
List<FileFormatVO> result = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
FileFormat fileFormat = list.get(i);
|
||||
FileFormatVO fileFormatVO = new FileFormatVO();
|
||||
BeanUtils.copyProperties(fileFormat, fileFormatVO);
|
||||
// 生成系统编号
|
||||
fileFormatVO.setSystemNumber(String.format("%02d", i + 1));
|
||||
result.add(fileFormatVO);
|
||||
}
|
||||
UserThreadLocal.setSuccessInfo("","", "查询了文件格式列表");
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新文件格式
|
||||
* @param fileFormat
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean updateFileFormat(FileFormat fileFormat) {
|
||||
fileFormat.setUpdatedBy(UserThreadLocal.getUserId());
|
||||
Assert.notNull(fileFormat.getId(), "文件格式ID不能为空");
|
||||
Assert.notEmpty(fileFormat.getFileSuffix(), "文件格式不能为空");
|
||||
boolean isUpdated = updateById(fileFormat);
|
||||
if (isUpdated) {
|
||||
UserThreadLocal.setSuccessInfo("","", StrFormatter.format("修改了文件格式 {} ", fileFormat.getFileSuffix()));
|
||||
}
|
||||
return isUpdated;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue