8 changed files with 494 additions and 6 deletions
@ -0,0 +1,105 @@ |
|||
package org.dromara.platform.controller; |
|||
|
|||
import java.util.List; |
|||
|
|||
import lombok.RequiredArgsConstructor; |
|||
import jakarta.servlet.http.HttpServletResponse; |
|||
import jakarta.validation.constraints.*; |
|||
import cn.dev33.satoken.annotation.SaCheckPermission; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.dromara.common.idempotent.annotation.RepeatSubmit; |
|||
import org.dromara.common.log.annotation.Log; |
|||
import org.dromara.common.web.core.BaseController; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
import org.dromara.common.core.domain.R; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
import org.dromara.common.log.enums.BusinessType; |
|||
import org.dromara.common.excel.utils.ExcelUtil; |
|||
import org.dromara.platform.domain.vo.DocumentInfoVo; |
|||
import org.dromara.platform.domain.bo.DocumentInfoBo; |
|||
import org.dromara.platform.service.IDocumentInfoService; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
|
|||
/** |
|||
* 文档信息 |
|||
* |
|||
* @author gejunhao |
|||
* @date 2025-04-07 |
|||
*/ |
|||
@Validated |
|||
@RequiredArgsConstructor |
|||
@RestController |
|||
@RequestMapping("/platform/documentInfo") |
|||
public class DocumentInfoController extends BaseController { |
|||
|
|||
private final IDocumentInfoService documentInfoService; |
|||
|
|||
/** |
|||
* 查询文档信息列表 |
|||
*/ |
|||
@SaCheckPermission("platform:documentInfo:list") |
|||
@GetMapping("/list") |
|||
public TableDataInfo<DocumentInfoVo> list(DocumentInfoBo bo, PageQuery pageQuery) { |
|||
return documentInfoService.queryPageList(bo, pageQuery); |
|||
} |
|||
|
|||
/** |
|||
* 导出文档信息列表 |
|||
*/ |
|||
@SaCheckPermission("platform:documentInfo:export") |
|||
@Log(title = "文档信息", businessType = BusinessType.EXPORT) |
|||
@PostMapping("/export") |
|||
public void export(DocumentInfoBo bo, HttpServletResponse response) { |
|||
List<DocumentInfoVo> list = documentInfoService.queryList(bo); |
|||
ExcelUtil.exportExcel(list, "文档信息", DocumentInfoVo.class, response); |
|||
} |
|||
|
|||
/** |
|||
* 获取文档信息详细信息 |
|||
* |
|||
* @param id 主键 |
|||
*/ |
|||
@SaCheckPermission("platform:documentInfo:query") |
|||
@GetMapping("/{id}") |
|||
public R<DocumentInfoVo> getInfo(@NotNull(message = "主键不能为空") |
|||
@PathVariable String id) { |
|||
return R.ok(documentInfoService.queryById(id)); |
|||
} |
|||
|
|||
/** |
|||
* 新增文档信息 |
|||
*/ |
|||
@SaCheckPermission("platform:documentInfo:add") |
|||
@Log(title = "文档信息", businessType = BusinessType.INSERT) |
|||
@RepeatSubmit() |
|||
@PostMapping() |
|||
public R<Void> add(@Validated(AddGroup.class) @RequestBody DocumentInfoBo bo) { |
|||
return toAjax(documentInfoService.insertByBo(bo)); |
|||
} |
|||
|
|||
/** |
|||
* 修改文档信息 |
|||
*/ |
|||
@SaCheckPermission("platform:documentInfo:edit") |
|||
@Log(title = "文档信息", businessType = BusinessType.UPDATE) |
|||
@RepeatSubmit() |
|||
@PutMapping() |
|||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody DocumentInfoBo bo) { |
|||
return toAjax(documentInfoService.updateByBo(bo)); |
|||
} |
|||
|
|||
/** |
|||
* 删除文档信息 |
|||
* |
|||
* @param ids 主键串 |
|||
*/ |
|||
@SaCheckPermission("platform:documentInfo:remove") |
|||
@Log(title = "文档信息", businessType = BusinessType.DELETE) |
|||
@DeleteMapping("/{ids}") |
|||
public R<Void> remove(@NotEmpty(message = "主键不能为空") |
|||
@PathVariable String[] ids) { |
|||
return toAjax(documentInfoService.deleteWithValidByIds(List.of(ids), true)); |
|||
} |
|||
} |
@ -0,0 +1,57 @@ |
|||
package org.dromara.platform.domain; |
|||
|
|||
import org.dromara.common.tenant.core.TenantEntity; |
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.io.Serial; |
|||
|
|||
/** |
|||
* 文档信息对象 document_info |
|||
* |
|||
* @author gejunhao |
|||
* @date 2025-04-07 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@TableName("document_info") |
|||
public class DocumentInfo extends TenantEntity { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 唯一标识符 |
|||
*/ |
|||
@TableId(value = "id") |
|||
private String id; |
|||
|
|||
/** |
|||
* 文档名称 |
|||
*/ |
|||
private String documentName; |
|||
|
|||
/** |
|||
* 文档类型 |
|||
*/ |
|||
private String districtType; |
|||
|
|||
/** |
|||
* 附件 |
|||
*/ |
|||
private String attachment; |
|||
|
|||
/** |
|||
* 当前状态:0启用 1禁用 |
|||
*/ |
|||
private Long status; |
|||
|
|||
/** |
|||
* 删除标志(0代表存在 2代表删除) |
|||
*/ |
|||
@TableLogic |
|||
private String delFlag; |
|||
|
|||
|
|||
} |
@ -0,0 +1,54 @@ |
|||
package org.dromara.platform.domain.bo; |
|||
|
|||
import org.dromara.platform.domain.DocumentInfo; |
|||
import org.dromara.common.mybatis.core.domain.BaseEntity; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import jakarta.validation.constraints.*; |
|||
|
|||
/** |
|||
* 文档信息业务对象 document_info |
|||
* |
|||
* @author gejunhao |
|||
* @date 2025-04-07 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@AutoMapper(target = DocumentInfo.class, reverseConvertGenerate = false) |
|||
public class DocumentInfoBo extends BaseEntity { |
|||
|
|||
/** |
|||
* 唯一标识符 |
|||
*/ |
|||
@NotBlank(message = "唯一标识符不能为空", groups = { EditGroup.class }) |
|||
private String id; |
|||
|
|||
/** |
|||
* 文档名称 |
|||
*/ |
|||
@NotBlank(message = "文档名称不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String documentName; |
|||
|
|||
/** |
|||
* 文档类型 |
|||
*/ |
|||
@NotBlank(message = "文档类型不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String districtType; |
|||
|
|||
/** |
|||
* 附件 |
|||
*/ |
|||
@NotBlank(message = "附件不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String attachment; |
|||
|
|||
/** |
|||
* 当前状态:0启用 1禁用 |
|||
*/ |
|||
@NotNull(message = "当前状态:0启用 1禁用不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private Long status; |
|||
|
|||
|
|||
} |
@ -0,0 +1,62 @@ |
|||
package org.dromara.platform.domain.vo; |
|||
|
|||
import org.dromara.platform.domain.DocumentInfo; |
|||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import org.dromara.common.excel.annotation.ExcelDictFormat; |
|||
import org.dromara.common.excel.convert.ExcelDictConvert; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
|
|||
|
|||
/** |
|||
* 文档信息视图对象 document_info |
|||
* |
|||
* @author gejunhao |
|||
* @date 2025-04-07 |
|||
*/ |
|||
@Data |
|||
@ExcelIgnoreUnannotated |
|||
@AutoMapper(target = DocumentInfo.class) |
|||
public class DocumentInfoVo implements Serializable { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 唯一标识符 |
|||
*/ |
|||
@ExcelProperty(value = "唯一标识符") |
|||
private String id; |
|||
|
|||
/** |
|||
* 文档名称 |
|||
*/ |
|||
@ExcelProperty(value = "文档名称") |
|||
private String documentName; |
|||
|
|||
/** |
|||
* 文档类型 |
|||
*/ |
|||
@ExcelProperty(value = "文档类型") |
|||
private String districtType; |
|||
|
|||
/** |
|||
* 附件 |
|||
*/ |
|||
@ExcelProperty(value = "附件") |
|||
private String attachment; |
|||
|
|||
/** |
|||
* 当前状态:0启用 1禁用 |
|||
*/ |
|||
@ExcelProperty(value = "当前状态:0启用 1禁用") |
|||
private Long status; |
|||
|
|||
|
|||
} |
@ -0,0 +1,15 @@ |
|||
package org.dromara.platform.mapper; |
|||
|
|||
import org.dromara.platform.domain.DocumentInfo; |
|||
import org.dromara.platform.domain.vo.DocumentInfoVo; |
|||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
|||
|
|||
/** |
|||
* 文档信息Mapper接口 |
|||
* |
|||
* @author gejunhao |
|||
* @date 2025-04-07 |
|||
*/ |
|||
public interface DocumentInfoMapper extends BaseMapperPlus<DocumentInfo, DocumentInfoVo> { |
|||
|
|||
} |
@ -0,0 +1,68 @@ |
|||
package org.dromara.platform.service; |
|||
|
|||
import org.dromara.platform.domain.vo.DocumentInfoVo; |
|||
import org.dromara.platform.domain.bo.DocumentInfoBo; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
|
|||
import java.util.Collection; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 文档信息Service接口 |
|||
* |
|||
* @author gejunhao |
|||
* @date 2025-04-07 |
|||
*/ |
|||
public interface IDocumentInfoService { |
|||
|
|||
/** |
|||
* 查询文档信息 |
|||
* |
|||
* @param id 主键 |
|||
* @return 文档信息 |
|||
*/ |
|||
DocumentInfoVo queryById(String id); |
|||
|
|||
/** |
|||
* 分页查询文档信息列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return 文档信息分页列表 |
|||
*/ |
|||
TableDataInfo<DocumentInfoVo> queryPageList(DocumentInfoBo bo, PageQuery pageQuery); |
|||
|
|||
/** |
|||
* 查询符合条件的文档信息列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @return 文档信息列表 |
|||
*/ |
|||
List<DocumentInfoVo> queryList(DocumentInfoBo bo); |
|||
|
|||
/** |
|||
* 新增文档信息 |
|||
* |
|||
* @param bo 文档信息 |
|||
* @return 是否新增成功 |
|||
*/ |
|||
Boolean insertByBo(DocumentInfoBo bo); |
|||
|
|||
/** |
|||
* 修改文档信息 |
|||
* |
|||
* @param bo 文档信息 |
|||
* @return 是否修改成功 |
|||
*/ |
|||
Boolean updateByBo(DocumentInfoBo bo); |
|||
|
|||
/** |
|||
* 校验并批量删除文档信息信息 |
|||
* |
|||
* @param ids 待删除的主键集合 |
|||
* @param isValid 是否进行有效性校验 |
|||
* @return 是否删除成功 |
|||
*/ |
|||
Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid); |
|||
} |
@ -0,0 +1,132 @@ |
|||
package org.dromara.platform.service.impl; |
|||
|
|||
import org.dromara.common.core.utils.MapstructUtils; |
|||
import org.dromara.common.core.utils.StringUtils; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.stereotype.Service; |
|||
import org.dromara.platform.domain.bo.DocumentInfoBo; |
|||
import org.dromara.platform.domain.vo.DocumentInfoVo; |
|||
import org.dromara.platform.domain.DocumentInfo; |
|||
import org.dromara.platform.mapper.DocumentInfoMapper; |
|||
import org.dromara.platform.service.IDocumentInfoService; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Collection; |
|||
|
|||
/** |
|||
* 文档信息Service业务层处理 |
|||
* |
|||
* @author gejunhao |
|||
* @date 2025-04-07 |
|||
*/ |
|||
@RequiredArgsConstructor |
|||
@Service |
|||
public class DocumentInfoServiceImpl implements IDocumentInfoService { |
|||
|
|||
private final DocumentInfoMapper baseMapper; |
|||
|
|||
/** |
|||
* 查询文档信息 |
|||
* |
|||
* @param id 主键 |
|||
* @return 文档信息 |
|||
*/ |
|||
@Override |
|||
public DocumentInfoVo queryById(String id){ |
|||
return baseMapper.selectVoById(id); |
|||
} |
|||
|
|||
/** |
|||
* 分页查询文档信息列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return 文档信息分页列表 |
|||
*/ |
|||
@Override |
|||
public TableDataInfo<DocumentInfoVo> queryPageList(DocumentInfoBo bo, PageQuery pageQuery) { |
|||
LambdaQueryWrapper<DocumentInfo> lqw = buildQueryWrapper(bo); |
|||
Page<DocumentInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
|||
return TableDataInfo.build(result); |
|||
} |
|||
|
|||
/** |
|||
* 查询符合条件的文档信息列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @return 文档信息列表 |
|||
*/ |
|||
@Override |
|||
public List<DocumentInfoVo> queryList(DocumentInfoBo bo) { |
|||
LambdaQueryWrapper<DocumentInfo> lqw = buildQueryWrapper(bo); |
|||
return baseMapper.selectVoList(lqw); |
|||
} |
|||
|
|||
private LambdaQueryWrapper<DocumentInfo> buildQueryWrapper(DocumentInfoBo bo) { |
|||
Map<String, Object> params = bo.getParams(); |
|||
LambdaQueryWrapper<DocumentInfo> lqw = Wrappers.lambdaQuery(); |
|||
lqw.like(StringUtils.isNotBlank(bo.getDocumentName()), DocumentInfo::getDocumentName, bo.getDocumentName()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getDistrictType()), DocumentInfo::getDistrictType, bo.getDistrictType()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getAttachment()), DocumentInfo::getAttachment, bo.getAttachment()); |
|||
lqw.eq(bo.getStatus() != null, DocumentInfo::getStatus, bo.getStatus()); |
|||
return lqw; |
|||
} |
|||
|
|||
/** |
|||
* 新增文档信息 |
|||
* |
|||
* @param bo 文档信息 |
|||
* @return 是否新增成功 |
|||
*/ |
|||
@Override |
|||
public Boolean insertByBo(DocumentInfoBo bo) { |
|||
DocumentInfo add = MapstructUtils.convert(bo, DocumentInfo.class); |
|||
validEntityBeforeSave(add); |
|||
boolean flag = baseMapper.insert(add) > 0; |
|||
if (flag) { |
|||
bo.setId(add.getId()); |
|||
} |
|||
return flag; |
|||
} |
|||
|
|||
/** |
|||
* 修改文档信息 |
|||
* |
|||
* @param bo 文档信息 |
|||
* @return 是否修改成功 |
|||
*/ |
|||
@Override |
|||
public Boolean updateByBo(DocumentInfoBo bo) { |
|||
DocumentInfo update = MapstructUtils.convert(bo, DocumentInfo.class); |
|||
validEntityBeforeSave(update); |
|||
return baseMapper.updateById(update) > 0; |
|||
} |
|||
|
|||
/** |
|||
* 保存前的数据校验 |
|||
*/ |
|||
private void validEntityBeforeSave(DocumentInfo entity){ |
|||
//TODO 做一些数据校验,如唯一约束
|
|||
} |
|||
|
|||
/** |
|||
* 校验并批量删除文档信息信息 |
|||
* |
|||
* @param ids 待删除的主键集合 |
|||
* @param isValid 是否进行有效性校验 |
|||
* @return 是否删除成功 |
|||
*/ |
|||
@Override |
|||
public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) { |
|||
if(isValid){ |
|||
//TODO 做一些业务上的校验,判断是否需要校验
|
|||
} |
|||
return baseMapper.deleteByIds(ids) > 0; |
|||
} |
|||
} |
Loading…
Reference in new issue