ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceDonateannexController.java
@@ -3,11 +3,13 @@ import java.util.Arrays; import java.util.List; import com.ruoyi.common.exception.base.BaseException; import com.ruoyi.project.domain.vo.DonateAnnexVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; @@ -35,8 +37,7 @@ @Api("附件管理") @RestController @RequestMapping("/project/donateannex") public class ServiceDonateannexController extends BaseController { public class ServiceDonateannexController extends BaseController { @Autowired private IServiceDonateannexService serviceDonateannexService; @@ -46,16 +47,14 @@ @ApiOperation("附件管理列表") //@PreAuthorize("@ss.hasPermi('project:donateannex:list')") @GetMapping("/list") public TableDataInfo list(ServiceDonateannex serviceDonateannex) { public TableDataInfo list(ServiceDonateannex serviceDonateannex) { startPage(); List<ServiceDonateannex> list = serviceDonateannexService.queryList(serviceDonateannex); return getDataTable(list); } @GetMapping("/listnew") public TableDataInfo listnew(DonateAnnexVO donateAnnexVO) { public TableDataInfo listnew(DonateAnnexVO donateAnnexVO) { startPage(); List<DonateAnnexVO> list = serviceDonateannexService.selectVOList(donateAnnexVO); return getDataTable(list); @@ -69,8 +68,7 @@ //@PreAuthorize("@ss.hasPermi('project:donateannex:export')") @Log(title = "捐献附件", businessType = BusinessType.EXPORT) @GetMapping("/export") public AjaxResult export(ServiceDonateannex serviceDonateannex) { public AjaxResult export(ServiceDonateannex serviceDonateannex) { List<ServiceDonateannex> list = serviceDonateannexService.queryList(serviceDonateannex); ExcelUtil<ServiceDonateannex> util = new ExcelUtil<ServiceDonateannex>(ServiceDonateannex.class); return util.exportExcel(list, "捐献附件数据"); @@ -82,8 +80,7 @@ @ApiOperation("通过id获得捐献附件信息") //@PreAuthorize("@ss.hasPermi('project:donateannex:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { public AjaxResult getInfo(@PathVariable("id") Long id) { return AjaxResult.success(serviceDonateannexService.getById(id)); } @@ -93,11 +90,10 @@ @ApiOperation("新增捐献附件信息") //@PreAuthorize("@ss.hasPermi('project:donateannex:add')") @Log(title = "捐献附件", businessType = BusinessType.INSERT) @PostMapping @PostMapping("/add") @RepeatSubmit public AjaxResult add(@RequestBody ServiceDonateannex serviceDonateannex) { return toAjax(serviceDonateannexService.save(serviceDonateannex)); public AjaxResult add(@RequestBody List<ServiceDonateannex> serviceDonateannexs) { return toAjax(serviceDonateannexService.saveData(serviceDonateannexs)); } /** @@ -108,9 +104,21 @@ @Log(title = "捐献附件", businessType = BusinessType.UPDATE) @PostMapping("/edit") @RepeatSubmit public AjaxResult edit(@RequestBody ServiceDonateannex serviceDonateannex) { public AjaxResult edit(@RequestBody ServiceDonateannex serviceDonateannex) { return toAjax(serviceDonateannexService.updateById(serviceDonateannex)); } /** * 修改捐献附件 */ @ApiOperation("修改潜在捐献、伦理审查、完成登记、医学评估附件信息") //@PreAuthorize("@ss.hasPermi('project:donateannex:edit')") @Log(title = "捐献附件", businessType = BusinessType.UPDATE) @PostMapping("/editannexfiles") @RepeatSubmit public AjaxResult editannexfiles(@RequestBody List<ServiceDonateannex> serviceDonateannexs) { return toAjax(serviceDonateannexService.updateOrSave(serviceDonateannexs)); } /** @@ -120,8 +128,7 @@ //@PreAuthorize("@ss.hasPermi('project:donateannex:remove')") @Log(title = "捐献附件", businessType = BusinessType.DELETE) @GetMapping("/remove/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(serviceDonateannexService.removeByIds(Arrays.asList(ids))); } ruoyi-project/src/main/java/com/ruoyi/project/domain/ServiceDonateannex.java
@@ -16,38 +16,61 @@ */ @Data @ApiModel("捐献附件") public class ServiceDonateannex extends BaseEntity { public class ServiceDonateannex extends BaseEntity { private static final long serialVersionUID = 1L; /** $column.columnComment */ /** * $column.columnComment */ @ApiModelProperty("$column.columnComment") //数据库自增改成@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO) private Long id; /** 关联service_donatebaseinfo表的ID */ /** * 关联service_donatebaseinfo表的ID */ @ApiModelProperty("关联service_donatebaseinfo表的ID") private Long infoid; /** 捐献者编号 */ /** * 捐献者编号 */ @ApiModelProperty("捐献者编号") @Excel(name = "捐献者编号") private String donorno; /** 附件名称 */ /** * 附件名称 */ @ApiModelProperty("附件名称") @Excel(name = "附件名称") private String annexname; /** 附件编号 */ /** * 附件编号 */ @ApiModelProperty("附件编号") @Excel(name = "附件编号") private String annexno; /** 附件路径 */ /** * 附件路径 */ @ApiModelProperty("附件路径") private String annexurl; /** * 附件类型 */ @ApiModelProperty("附件类型") private Integer annexfilestype; /** * 附件类型 */ @ApiModelProperty("附件类型") private Integer delFlag; } ruoyi-project/src/main/java/com/ruoyi/project/service/IServiceDonateannexService.java
@@ -1,6 +1,7 @@ package com.ruoyi.project.service; import java.util.List; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.project.domain.ServiceDonateannex; import com.ruoyi.project.domain.vo.DonateAnnexVO; @@ -11,8 +12,7 @@ * @author ruoyi * @date 2021-11-11 */ public interface IServiceDonateannexService extends IService<ServiceDonateannex> { public interface IServiceDonateannexService extends IService<ServiceDonateannex> { /** * 查询捐献附件列表 @@ -22,5 +22,9 @@ */ public List<ServiceDonateannex> queryList(ServiceDonateannex serviceDonateannex); public Boolean updateOrSave(List<ServiceDonateannex> serviceDonateannexs); List<DonateAnnexVO> selectVOList(DonateAnnexVO donateAnnexVO); Boolean saveData(List<ServiceDonateannex> serviceDonateannexs); } ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceDonateannexServiceImpl.java
@@ -4,6 +4,7 @@ import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.exception.base.BaseException; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.project.domain.vo.DonateAnnexVO; @@ -12,12 +13,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import java.util.ArrayList; import java.util.Map; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.project.mapper.ServiceDonateannexMapper; import com.ruoyi.project.domain.ServiceDonateannex; import com.ruoyi.project.service.IServiceDonateannexService; import org.springframework.transaction.annotation.Transactional; /** * 捐献附件Service业务层处理 @@ -26,8 +30,7 @@ * @date 2021-11-11 */ @Service public class ServiceDonateannexServiceImpl extends ServiceImpl<ServiceDonateannexMapper, ServiceDonateannex> implements IServiceDonateannexService { public class ServiceDonateannexServiceImpl extends ServiceImpl<ServiceDonateannexMapper, ServiceDonateannex> implements IServiceDonateannexService { @Autowired ServiceDonateannexMapper serviceDonateannexMapper; @@ -60,6 +63,22 @@ } @Override @Transactional(rollbackFor = Exception.class) public Boolean updateOrSave(List<ServiceDonateannex> serviceDonateannexs) { for (ServiceDonateannex serviceDonateannex : serviceDonateannexs) { if (serviceDonateannex.getInfoid() == null || serviceDonateannex.getAnnexfilestype() == null) { throw new BaseException("请检查主表id和附件类型是否为空!"); } if (serviceDonateannex.getId() == null) { this.save(serviceDonateannex); } else { boolean b = this.updateById(serviceDonateannex); } } return true; } @Override public List<DonateAnnexVO> selectVOList(DonateAnnexVO donateAnnexVO) { SysUser user = SecurityUtils.getLoginUser().getUser(); @@ -76,4 +95,16 @@ return serviceDonateannexMapper.selectVOList(donateAnnexVO); } @Override @Transactional(rollbackFor = Exception.class) public Boolean saveData(List<ServiceDonateannex> serviceDonateannexs) { for (ServiceDonateannex serviceDonateannex : serviceDonateannexs) { if (serviceDonateannex.getInfoid() == null || serviceDonateannex.getAnnexfilestype() == null) { throw new BaseException("主表id或附件类型ID为空,请检查后再保存"); } this.save(serviceDonateannex); } return true; } } ruoyi-project/src/main/resources/mapper/project/ServiceDonateannexMapper.xml
@@ -8,7 +8,7 @@ <result property="id" column="ID" /> <result property="infoid" column="InfoID" /> <result property="donorno" column="DonorNo" /> <result property="del_flag" column="del_flag" /> <result property="delFlag" column="del_flag" /> <result property="createBy" column="create_by" /> <result property="createTime" column="create_time" /> <result property="updateBy" column="update_by" /> @@ -16,10 +16,11 @@ <result property="annexname" column="AnnexName" /> <result property="annexno" column="AnnexNo" /> <result property="annexurl" column="AnnexUrl" /> <result property="annexfilestype" column="AnnexfilesType" /> </resultMap> <sql id="selectServiceDonateannexVo"> select ID, InfoID, DonorNo, del_flag, create_by, create_time, update_by, update_time, AnnexName, AnnexNo, AnnexUrl from service_donateannex select ID, InfoID, DonorNo, del_flag, create_by, create_time, update_by, update_time, AnnexName, AnnexNo, AnnexUrl,AnnexfilesType from service_donateannex </sql> <select id="selectServiceDonateannexList" parameterType="com.ruoyi.project.domain.ServiceDonateannex" resultMap="ServiceDonateannexResult">