diff --git a/vetti-admin/src/main/java/com/vetti/web/controller/hotake/HotakeSysNoticeTypeController.java b/vetti-admin/src/main/java/com/vetti/web/controller/hotake/HotakeSysNoticeTypeController.java new file mode 100644 index 0000000..43dfcc0 --- /dev/null +++ b/vetti-admin/src/main/java/com/vetti/web/controller/hotake/HotakeSysNoticeTypeController.java @@ -0,0 +1,108 @@ +package com.vetti.web.controller.hotake; + +import java.util.List; + +import com.vetti.hotake.domain.dto.HotakeSysNoticeTypeDto; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import com.vetti.common.annotation.Log; +import com.vetti.common.core.controller.BaseController; +import com.vetti.common.core.domain.AjaxResult; +import com.vetti.common.enums.BusinessType; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import com.vetti.hotake.domain.HotakeSysNoticeType; +import com.vetti.hotake.service.IHotakeSysNoticeTypeService; +import com.vetti.common.utils.poi.ExcelUtil; +import com.vetti.common.core.page.TableDataInfo; +import org.springframework.web.multipart.MultipartFile; + +/** + * 通知类型Controller + * + * @author ID + * @date 2025-11-01 + */ +@Api(tags = "通知类型") +@RestController +@RequestMapping("/hotake/sysNoticeType") +public class HotakeSysNoticeTypeController extends BaseController { + @Autowired + private IHotakeSysNoticeTypeService hotakeSysNoticeTypeService; + + /** + * 查询通知类型列表 + */ + @ApiOperation("查询通知类型列表") + @PreAuthorize("@ss.hasPermi('hotake:sysNoticeType:list')") + @GetMapping("/list") + public TableDataInfo list(HotakeSysNoticeType hotakeSysNoticeType) { + startPage(); + List list = hotakeSysNoticeTypeService.selectHotakeSysNoticeTypeList(hotakeSysNoticeType); + return getDataTable(list); + } + + @ApiOperation("查询通知类型列表") + @PreAuthorize("@ss.hasPermi('hotake:sysNoticeType:list')") + @GetMapping("/listall") + public AjaxResult listAll(HotakeSysNoticeType hotakeSysNoticeType) { + return AjaxResult.success(hotakeSysNoticeTypeService.selectHotakeSysNoticeTypeList(hotakeSysNoticeType)); + } + + /** + * 导出通知类型列表 + */ + @ApiOperation("导出通知类型列表") + @PreAuthorize("@ss.hasPermi('hotake:sysNoticeType:export')") + @Log(title = "通知类型", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(HotakeSysNoticeType hotakeSysNoticeType) { + List list = hotakeSysNoticeTypeService.selectHotakeSysNoticeTypeList(hotakeSysNoticeType); + ExcelUtil util = new ExcelUtil<>(HotakeSysNoticeTypeDto.class); + return util.exportExcel(list, "通知类型数据"); + } + + /** + * 获取通知类型详细信息 + */ + @ApiOperation("获取通知类型详细信息") + @PreAuthorize("@ss.hasPermi('hotake:sysNoticeType:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(hotakeSysNoticeTypeService.selectHotakeSysNoticeTypeById(id)); + } + + /** + * 新增通知类型 + */ + @ApiOperation("新增通知类型") + @PreAuthorize("@ss.hasPermi('hotake:sysNoticeType:add')") + @Log(title = "通知类型", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestPart(value = "files", required = false) List files, HotakeSysNoticeType hotakeSysNoticeType) { + return toAjax(hotakeSysNoticeTypeService.insertHotakeSysNoticeType(files, hotakeSysNoticeType)); + } + + /** + * 修改通知类型 + */ + @ApiOperation("修改通知类型(不修改图片不需要传files,只要修改一个,所有图片都需要传)") + @PreAuthorize("@ss.hasPermi('hotake:sysNoticeType:edit')") + @Log(title = "通知类型", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestPart(value = "files", required = false) List files, HotakeSysNoticeType hotakeSysNoticeType) { + return toAjax(hotakeSysNoticeTypeService.updateHotakeSysNoticeType(files, hotakeSysNoticeType)); + } + + /** + * 删除通知类型 + */ + @ApiOperation("删除通知类型") + @PreAuthorize("@ss.hasPermi('hotake:sysNoticeType:remove')") + @Log(title = "通知类型", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + return toAjax(hotakeSysNoticeTypeService.deleteHotakeSysNoticeTypeByIds(ids)); + } +} diff --git a/vetti-hotake/src/main/java/com/vetti/hotake/domain/HotakeSysNoticeType.java b/vetti-hotake/src/main/java/com/vetti/hotake/domain/HotakeSysNoticeType.java new file mode 100644 index 0000000..0dcf5f7 --- /dev/null +++ b/vetti-hotake/src/main/java/com/vetti/hotake/domain/HotakeSysNoticeType.java @@ -0,0 +1,42 @@ +package com.vetti.hotake.domain; + +import lombok.Data; +import lombok.experimental.Accessors; +import io.swagger.annotations.ApiModelProperty; +import com.vetti.common.annotation.Excel; +import com.vetti.common.core.domain.BaseEntity; + +import java.util.List; + +/** + * 通知类型对象 hotake_sys_notice_type + * + * @author ID + * @date 2025-11-01 + */ +@Data +@Accessors(chain = true) +public class HotakeSysNoticeType extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键ID */ + @ApiModelProperty("主键ID") + private Long id; + + /** 类型名称 */ + @ApiModelProperty("类型名称") + @Excel(name = "类型名称") + private String typeName; + + /** 图片 */ + @ApiModelProperty("图片") + @Excel(name = "图片") + private List imagePath; + + /** 删除状态(0正常 1删除) */ + @ApiModelProperty("删除状态(0正常 1删除)") + @Excel(name = "删除状态", readConverterExp = "0=正常,1=删除") + private String isDel; + +} diff --git a/vetti-hotake/src/main/java/com/vetti/hotake/domain/dto/HotakeSysNoticeTypeDto.java b/vetti-hotake/src/main/java/com/vetti/hotake/domain/dto/HotakeSysNoticeTypeDto.java new file mode 100644 index 0000000..66af0d2 --- /dev/null +++ b/vetti-hotake/src/main/java/com/vetti/hotake/domain/dto/HotakeSysNoticeTypeDto.java @@ -0,0 +1,26 @@ +package com.vetti.hotake.domain.dto; + +import com.vetti.common.utils.bean.BeanUtils; +import com.vetti.hotake.domain.HotakeSysNoticeType; +import lombok.Data; + +import java.util.List; + +/** + * @author ID + * @date 2025/11/1 11:54 + */ +@Data +public class HotakeSysNoticeTypeDto extends HotakeSysNoticeType { + + private List imgs; + + + public static HotakeSysNoticeTypeDto build(List urls, HotakeSysNoticeType data) { + HotakeSysNoticeTypeDto dto = new HotakeSysNoticeTypeDto(); + BeanUtils.copyBeanProp(dto, data); + dto.setImgs(urls); + return dto; + } + +} diff --git a/vetti-hotake/src/main/java/com/vetti/hotake/mapper/HotakeSysNoticeTypeMapper.java b/vetti-hotake/src/main/java/com/vetti/hotake/mapper/HotakeSysNoticeTypeMapper.java new file mode 100644 index 0000000..c1fd802 --- /dev/null +++ b/vetti-hotake/src/main/java/com/vetti/hotake/mapper/HotakeSysNoticeTypeMapper.java @@ -0,0 +1,69 @@ +package com.vetti.hotake.mapper; + +import java.util.List; +import com.vetti.hotake.domain.HotakeSysNoticeType; + +/** + * 通知类型Mapper接口 + * + * @author ID + * @date 2025-11-01 + */ +public interface HotakeSysNoticeTypeMapper +{ + /** + * 查询通知类型 + * + * @param id 通知类型主键 + * @return 通知类型 + */ + public HotakeSysNoticeType selectHotakeSysNoticeTypeById(Long id); + + /** + * 查询通知类型列表 + * + * @param hotakeSysNoticeType 通知类型 + * @return 通知类型集合 + */ + public List selectHotakeSysNoticeTypeList(HotakeSysNoticeType hotakeSysNoticeType); + + /** + * 新增通知类型 + * + * @param hotakeSysNoticeType 通知类型 + * @return 结果 + */ + public int insertHotakeSysNoticeType(HotakeSysNoticeType hotakeSysNoticeType); + + /** + * 修改通知类型 + * + * @param hotakeSysNoticeType 通知类型 + * @return 结果 + */ + public int updateHotakeSysNoticeType(HotakeSysNoticeType hotakeSysNoticeType); + + /** + * 删除通知类型 + * + * @param id 通知类型主键 + * @return 结果 + */ + public int deleteHotakeSysNoticeTypeById(Long id); + + /** + * 批量删除通知类型 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteHotakeSysNoticeTypeByIds(Long[] ids); + /** + * 批量新增通知类型 + * + * @param hotakeSysNoticeTypeList 通知类型列表 + * @return 结果 + */ + public int batchInsertHotakeSysNoticeType(List hotakeSysNoticeTypeList); + +} diff --git a/vetti-hotake/src/main/java/com/vetti/hotake/service/IHotakeSysNoticeTypeService.java b/vetti-hotake/src/main/java/com/vetti/hotake/service/IHotakeSysNoticeTypeService.java new file mode 100644 index 0000000..fa91dd3 --- /dev/null +++ b/vetti-hotake/src/main/java/com/vetti/hotake/service/IHotakeSysNoticeTypeService.java @@ -0,0 +1,72 @@ +package com.vetti.hotake.service; + +import java.util.List; + +import com.vetti.hotake.domain.HotakeSysNoticeType; +import com.vetti.hotake.domain.dto.HotakeSysNoticeTypeDto; +import org.springframework.web.multipart.MultipartFile; + +/** + * 通知类型Service接口 + * + * @author ID + * @date 2025-11-01 + */ +public interface IHotakeSysNoticeTypeService { + /** + * 查询通知类型 + * + * @param id 通知类型主键 + * @return 通知类型 + */ + public HotakeSysNoticeTypeDto selectHotakeSysNoticeTypeById(Long id); + + /** + * 查询通知类型列表 + * + * @param hotakeSysNoticeType 通知类型 + * @return 通知类型集合 + */ + public List selectHotakeSysNoticeTypeList(HotakeSysNoticeType hotakeSysNoticeType); + + /** + * 新增通知类型 + * + * @param hotakeSysNoticeType 通知类型 + * @return 结果 + */ + public int insertHotakeSysNoticeType(List files, HotakeSysNoticeType hotakeSysNoticeType); + + /** + * 修改通知类型 + * + * @param hotakeSysNoticeType 通知类型 + * @return 结果 + */ + public int updateHotakeSysNoticeType(List files,HotakeSysNoticeType hotakeSysNoticeType); + + /** + * 批量删除通知类型 + * + * @param ids 需要删除的通知类型主键集合 + * @return 结果 + */ + public int deleteHotakeSysNoticeTypeByIds(Long[] ids); + + /** + * 删除通知类型信息 + * + * @param id 通知类型主键 + * @return 结果 + */ + public int deleteHotakeSysNoticeTypeById(Long id); + + /** + * 批量新增通知类型 + * + * @param hotakeSysNoticeTypeList 通知类型列表 + * @return 结果 + */ + public int batchInsertHotakeSysNoticeType(List hotakeSysNoticeTypeList); + +} diff --git a/vetti-hotake/src/main/java/com/vetti/hotake/service/impl/HotakeSysNoticeTypeServiceImpl.java b/vetti-hotake/src/main/java/com/vetti/hotake/service/impl/HotakeSysNoticeTypeServiceImpl.java new file mode 100644 index 0000000..0164b10 --- /dev/null +++ b/vetti-hotake/src/main/java/com/vetti/hotake/service/impl/HotakeSysNoticeTypeServiceImpl.java @@ -0,0 +1,192 @@ +package com.vetti.hotake.service.impl; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import cn.hutool.core.collection.CollectionUtil; +import com.vetti.common.constant.SysDictDataConstants; +import com.vetti.common.core.service.BaseServiceImpl; +import com.vetti.common.enums.FillTypeEnum; +import com.vetti.common.utils.DateUtils; +import com.vetti.hotake.domain.HotakeSysFile; +import com.vetti.hotake.domain.dto.HotakeSysNoticeTypeDto; +import com.vetti.hotake.service.IHotakeSysFileService; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.vetti.hotake.mapper.HotakeSysNoticeTypeMapper; +import com.vetti.hotake.domain.HotakeSysNoticeType; +import com.vetti.hotake.service.IHotakeSysNoticeTypeService; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; + +/** + * 通知类型Service业务层处理 + * + * @author ID + * @date 2025-11-01 + */ +@SuppressWarnings("all") +@Service +public class HotakeSysNoticeTypeServiceImpl extends BaseServiceImpl implements IHotakeSysNoticeTypeService { + @Autowired + private HotakeSysNoticeTypeMapper hotakeSysNoticeTypeMapper; + @Autowired + IHotakeSysFileService hotakeSysFileService; + + private final String MINIO_BUCKET_NAME = "noticetype-fs"; + + /** + * 查询通知类型 + * + * @param id 通知类型主键 + * @return 通知类型 + */ + @Transactional(readOnly = true) + @Override + public HotakeSysNoticeTypeDto selectHotakeSysNoticeTypeById(Long id) { + HotakeSysNoticeType data = hotakeSysNoticeTypeMapper.selectHotakeSysNoticeTypeById(id); + List urls = new ArrayList<>(); + if (data != null) { + if (CollectionUtil.isNotEmpty(data.getImagePath())) { + Map m = hotakeSysFileService.url( + data.getImagePath().stream().map(s -> Long.parseLong(s)).toArray(Long[]::new) + ); + if (CollectionUtil.isNotEmpty(m)) { + m.forEach((k, v) -> urls.add(v)); + } + } + } + return HotakeSysNoticeTypeDto.build(urls, data); + } + + /** + * 查询通知类型列表 + * + * @param hotakeSysNoticeType 通知类型 + * @return 通知类型 + */ + @Transactional(readOnly = true) + @Override + public List selectHotakeSysNoticeTypeList(HotakeSysNoticeType hotakeSysNoticeType) { + List reList = new ArrayList<>(); + hotakeSysNoticeType.setIsDel("0"); + List list = hotakeSysNoticeTypeMapper.selectHotakeSysNoticeTypeList(hotakeSysNoticeType); + if (CollectionUtil.isNotEmpty(list)) { + list.forEach(e -> { + List urls = new ArrayList<>(); + if (CollectionUtil.isNotEmpty(e.getImagePath())) { + Map m = hotakeSysFileService.url( + e.getImagePath().stream().map(s -> Long.parseLong(s)).toArray(Long[]::new) + ); + if (CollectionUtil.isNotEmpty(m)) { + m.forEach((k, v) -> urls.add(v)); + } + } + reList.add(HotakeSysNoticeTypeDto.build(urls, e)); + }); + } + return reList; + } + + /** + * 新增通知类型 + * + * @param hotakeSysNoticeType 通知类型 + * @return 结果 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int insertHotakeSysNoticeType(List files, HotakeSysNoticeType hotakeSysNoticeType) { + fill(FillTypeEnum.INSERT.getCode(), hotakeSysNoticeType); + if (CollectionUtil.isNotEmpty(files)) { + List l = new ArrayList(); + for (MultipartFile file : files) { + HotakeSysFile sf = uploadFile(file); + l.add(sf.getId() + ""); + } + hotakeSysNoticeType.setImagePath(l); + } + return hotakeSysNoticeTypeMapper.insertHotakeSysNoticeType(hotakeSysNoticeType); + } + + private HotakeSysFile uploadFile(MultipartFile file) { + HotakeSysFile commandSysFile = new HotakeSysFile(); + commandSysFile.setCode(System.currentTimeMillis() + ""); + commandSysFile.setMinioBucketName(MINIO_BUCKET_NAME); + return hotakeSysFileService.insertHotakeSysFile(file, commandSysFile); + } + + /** + * 修改通知类型 + * + * @param hotakeSysNoticeType 通知类型 + * @return 结果 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int updateHotakeSysNoticeType(List files, HotakeSysNoticeType hotakeSysNoticeType) { + fill(FillTypeEnum.UPDATE.getCode(), hotakeSysNoticeType); + if (CollectionUtils.isNotEmpty(files)) { + List l = new ArrayList(); + for (MultipartFile file : files) { + HotakeSysFile sf = uploadFile(file); + l.add(sf.getId() + ""); + } + hotakeSysNoticeType.setImagePath(l); + } + return hotakeSysNoticeTypeMapper.updateHotakeSysNoticeType(hotakeSysNoticeType); + } + + /** + * 批量删除通知类型 + * + * @param ids 需要删除的通知类型主键 + * @return 结果 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int deleteHotakeSysNoticeTypeByIds(Long[] ids) { + if (ids != null && ids.length > 0) { + for (Long id : ids) { + HotakeSysNoticeType hotakeSysNoticeType = selectHotakeSysNoticeTypeById(id); + hotakeSysNoticeType.setIsDel("1"); + fill(FillTypeEnum.UPDATE.getCode(), hotakeSysNoticeType); + hotakeSysNoticeTypeMapper.updateHotakeSysNoticeType(hotakeSysNoticeType); + + } + } + return 1; + } + + /** + * 删除通知类型信息 + * + * @param id 通知类型主键 + * @return 结果 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int deleteHotakeSysNoticeTypeById(Long id) { + HotakeSysNoticeType hotakeSysNoticeType = selectHotakeSysNoticeTypeById(id); + hotakeSysNoticeType.setIsDel("1"); + fill(FillTypeEnum.UPDATE.getCode(), hotakeSysNoticeType); + return hotakeSysNoticeTypeMapper.updateHotakeSysNoticeType(hotakeSysNoticeType); + } + + /** + * 批量新增通知类型 + * + * @param hotakeSysNoticeTypeList 通知类型列表 + * @return 结果 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int batchInsertHotakeSysNoticeType(List hotakeSysNoticeTypeList) { + return hotakeSysNoticeTypeMapper.batchInsertHotakeSysNoticeType(hotakeSysNoticeTypeList); + } +} diff --git a/vetti-hotake/src/main/resources/mapper/hotake/HotakeSysNoticeTypeMapper.xml b/vetti-hotake/src/main/resources/mapper/hotake/HotakeSysNoticeTypeMapper.xml new file mode 100644 index 0000000..0d84583 --- /dev/null +++ b/vetti-hotake/src/main/resources/mapper/hotake/HotakeSysNoticeTypeMapper.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + select id, + type_name, + image_path, + is_del, + create_by, + create_time, + update_by, + update_time, + remark + from hotake_sys_notice_type + + + + + + + + insert into hotake_sys_notice_type + + type_name, + image_path, + is_del, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{typeName}, + #{imagePath, typeHandler=com.vetti.common.handle.JsonTypeHandler}, + #{isDel}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update hotake_sys_notice_type + + type_name = #{typeName}, + image_path = + #{imagePath, typeHandler=com.vetti.common.handle.JsonTypeHandler}, + + is_del = #{isDel}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete + from hotake_sys_notice_type + where id = #{id} + + + + delete from hotake_sys_notice_type where id in + + #{id} + + + + + insert into hotake_sys_notice_type( id, type_name, image_path, is_del, create_by, create_time, update_by, + update_time, remark,) values + + ( #{item.id}, #{item.typeName}, #{item.imagePath, typeHandler=com.vetti.common.handle.JsonTypeHandler}, + #{item.isDel}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.remark},) + + + \ No newline at end of file