From 42a984c8d0cabef5b8073c05ebf0b0af3d2642e6 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 13 Jan 2021 08:48:12 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=BC=80=E5=A7=8B=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E6=A8=A1=E5=9D=97=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/SysNoticeController.java | 92 --------- .../ruoyi/framework/config/MyBatisConfig.java | 110 ----------- .../ruoyi/system/domain/SysLogininfor.java | 91 +-------- .../com/ruoyi/system/domain/SysNotice.java | 100 ---------- .../ruoyi/system/mapper/SysConfigMapper.java | 68 ------- .../system/mapper/SysLogininforMapper.java | 42 ----- .../ruoyi/system/mapper/SysNoticeMapper.java | 60 ------ .../ruoyi/system/mapper/SysOperLogMapper.java | 48 ----- .../system/service/ISysNoticeService.java | 60 ------ .../service/impl/SysDictDataServiceImpl.java | 101 ---------- .../service/impl/SysDictTypeServiceImpl.java | 177 ------------------ .../mapper/system/SysNoticeMapper.xml | 89 --------- .../notice/SysNoticeController.java | 64 +++++++ .../convert/notice/SysNoticeConvert.java | 11 ++ .../dal/mysql/dao/notice/SysNoticeMapper.java | 9 + .../mysql/dataobject/notice/SysNoticeDO.java | 52 +++++ .../enums/notice/SysNoticeTypeEnum.java | 23 +++ 17 files changed, 160 insertions(+), 1037 deletions(-) delete mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java delete mode 100644 ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java delete mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java delete mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java delete mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLogininforMapper.java delete mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java delete mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java delete mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java delete mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java delete mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java delete mode 100644 ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/SysNoticeController.java create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/convert/notice/SysNoticeConvert.java create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/notice/SysNoticeMapper.java create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/notice/SysNoticeDO.java create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/enums/notice/SysNoticeTypeEnum.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java deleted file mode 100644 index 029ee385b..000000000 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.ruoyi.web.controller.system; - -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -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 com.ruoyi.common.annotation.Log; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.SecurityUtils; -import com.ruoyi.system.domain.SysNotice; -import com.ruoyi.system.service.ISysNoticeService; - -/** - * 公告 信息操作处理 - * - * @author ruoyi - */ -@RestController -@RequestMapping("/system/notice") -public class SysNoticeController extends BaseController -{ - @Autowired - private ISysNoticeService noticeService; - - /** - * 获取通知公告列表 - */ - @PreAuthorize("@ss.hasPermi('system:notice:list')") - @GetMapping("/list") - public TableDataInfo list(SysNotice notice) - { - startPage(); - List list = noticeService.selectNoticeList(notice); - return getDataTable(list); - } - - /** - * 根据通知公告编号获取详细信息 - */ - @PreAuthorize("@ss.hasPermi('system:notice:query')") - @GetMapping(value = "/{noticeId}") - public AjaxResult getInfo(@PathVariable Long noticeId) - { - return AjaxResult.success(noticeService.selectNoticeById(noticeId)); - } - - /** - * 新增通知公告 - */ - @PreAuthorize("@ss.hasPermi('system:notice:add')") - @Log(title = "通知公告", businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@Validated @RequestBody SysNotice notice) - { - notice.setCreateBy(SecurityUtils.getUsername()); - return toAjax(noticeService.insertNotice(notice)); - } - - /** - * 修改通知公告 - */ - @PreAuthorize("@ss.hasPermi('system:notice:edit')") - @Log(title = "通知公告", businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@Validated @RequestBody SysNotice notice) - { - notice.setUpdateBy(SecurityUtils.getUsername()); - return toAjax(noticeService.updateNotice(notice)); - } - - /** - * 删除通知公告 - */ - @PreAuthorize("@ss.hasPermi('system:notice:remove')") - @Log(title = "通知公告", businessType = BusinessType.DELETE) - @DeleteMapping("/{noticeIds}") - public AjaxResult remove(@PathVariable Long[] noticeIds) - { - return toAjax(noticeService.deleteNoticeByIds(noticeIds)); - } -} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java deleted file mode 100644 index 4dccd4f8a..000000000 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.ruoyi.framework.config; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import javax.sql.DataSource; - -import org.apache.ibatis.io.VFS; -import org.apache.ibatis.session.SqlSessionFactory; -import org.mybatis.spring.SqlSessionFactoryBean; -import org.mybatis.spring.boot.autoconfigure.SpringBootVFS; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.env.Environment; -import org.springframework.core.io.DefaultResourceLoader; -import org.springframework.core.io.Resource; -import org.springframework.core.io.support.PathMatchingResourcePatternResolver; -import org.springframework.core.io.support.ResourcePatternResolver; -import org.springframework.core.type.classreading.CachingMetadataReaderFactory; -import org.springframework.core.type.classreading.MetadataReader; -import org.springframework.core.type.classreading.MetadataReaderFactory; -import org.springframework.util.ClassUtils; -import com.ruoyi.common.utils.StringUtils; - -/** - * Mybatis支持*匹配扫描包 - * - * @author ruoyi - */ -@Configuration -public class MyBatisConfig { - @Autowired - private Environment env; - - static final String DEFAULT_RESOURCE_PATTERN = "**/*.class"; - - public static String setTypeAliasesPackage(String typeAliasesPackage) { - ResourcePatternResolver resolver = (ResourcePatternResolver) new PathMatchingResourcePatternResolver(); - MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resolver); - List allResult = new ArrayList(); - try { - for (String aliasesPackage : typeAliasesPackage.split(",")) { - List result = new ArrayList(); - aliasesPackage = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX - + ClassUtils.convertClassNameToResourcePath(aliasesPackage.trim()) + "/" + DEFAULT_RESOURCE_PATTERN; - Resource[] resources = resolver.getResources(aliasesPackage); - if (resources != null && resources.length > 0) { - MetadataReader metadataReader = null; - for (Resource resource : resources) { - if (resource.isReadable()) { - metadataReader = metadataReaderFactory.getMetadataReader(resource); - try { - result.add(Class.forName(metadataReader.getClassMetadata().getClassName()).getPackage().getName()); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - } - } - } - if (result.size() > 0) { - HashSet hashResult = new HashSet(result); - allResult.addAll(hashResult); - } - } - if (allResult.size() > 0) { - typeAliasesPackage = String.join(",", (String[]) allResult.toArray(new String[0])); - } else { - throw new RuntimeException("mybatis typeAliasesPackage 路径扫描错误,参数typeAliasesPackage:" + typeAliasesPackage + "未找到任何包"); - } - } catch (IOException e) { - e.printStackTrace(); - } - return typeAliasesPackage; - } - - public Resource[] resolveMapperLocations(String[] mapperLocations) { - ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver(); - List resources = new ArrayList(); - if (mapperLocations != null) { - for (String mapperLocation : mapperLocations) { - try { - Resource[] mappers = resourceResolver.getResources(mapperLocation); - resources.addAll(Arrays.asList(mappers)); - } catch (IOException e) { - // ignore - } - } - } - return resources.toArray(new Resource[resources.size()]); - } - - @Bean - public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { - String typeAliasesPackage = env.getProperty("mybatis.typeAliasesPackage"); - String mapperLocations = env.getProperty("mybatis.mapperLocations"); - String configLocation = env.getProperty("mybatis.configLocation"); - typeAliasesPackage = setTypeAliasesPackage(typeAliasesPackage); - VFS.addImplClass(SpringBootVFS.class); - - final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); - sessionFactory.setDataSource(dataSource); - sessionFactory.setTypeAliasesPackage(typeAliasesPackage); - sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ","))); - sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation)); - return sessionFactory.getObject(); - } -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java index 02a7fb5c0..ed35aad56 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java @@ -8,7 +8,7 @@ import com.ruoyi.common.core.domain.BaseEntity; /** * 系统访问记录表 sys_logininfor - * + * * @author ruoyi */ public class SysLogininfor extends BaseEntity @@ -52,93 +52,4 @@ public class SysLogininfor extends BaseEntity @Excel(name = "访问时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private Date loginTime; - public Long getInfoId() - { - return infoId; - } - - public void setInfoId(Long infoId) - { - this.infoId = infoId; - } - - public String getUserName() - { - return userName; - } - - public void setUserName(String userName) - { - this.userName = userName; - } - - public String getStatus() - { - return status; - } - - public void setStatus(String status) - { - this.status = status; - } - - public String getIpaddr() - { - return ipaddr; - } - - public void setIpaddr(String ipaddr) - { - this.ipaddr = ipaddr; - } - - public String getLoginLocation() - { - return loginLocation; - } - - public void setLoginLocation(String loginLocation) - { - this.loginLocation = loginLocation; - } - - public String getBrowser() - { - return browser; - } - - public void setBrowser(String browser) - { - this.browser = browser; - } - - public String getOs() - { - return os; - } - - public void setOs(String os) - { - this.os = os; - } - - public String getMsg() - { - return msg; - } - - public void setMsg(String msg) - { - this.msg = msg; - } - - public Date getLoginTime() - { - return loginTime; - } - - public void setLoginTime(Date loginTime) - { - this.loginTime = loginTime; - } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java deleted file mode 100644 index cb739dc41..000000000 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.ruoyi.system.domain; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Size; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.core.domain.BaseEntity; - -/** - * 通知公告表 sys_notice - * - * @author ruoyi - */ -public class SysNotice extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 公告ID */ - private Long noticeId; - - /** 公告标题 */ - private String noticeTitle; - - /** 公告类型(1通知 2公告) */ - private String noticeType; - - /** 公告内容 */ - private String noticeContent; - - /** 公告状态(0正常 1关闭) */ - private String status; - - public Long getNoticeId() - { - return noticeId; - } - - public void setNoticeId(Long noticeId) - { - this.noticeId = noticeId; - } - - public void setNoticeTitle(String noticeTitle) - { - this.noticeTitle = noticeTitle; - } - - @NotBlank(message = "公告标题不能为空") - @Size(min = 0, max = 50, message = "公告标题不能超过50个字符") - public String getNoticeTitle() - { - return noticeTitle; - } - - public void setNoticeType(String noticeType) - { - this.noticeType = noticeType; - } - - public String getNoticeType() - { - return noticeType; - } - - public void setNoticeContent(String noticeContent) - { - this.noticeContent = noticeContent; - } - - public String getNoticeContent() - { - return noticeContent; - } - - public void setStatus(String status) - { - this.status = status; - } - - public String getStatus() - { - return status; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("noticeId", getNoticeId()) - .append("noticeTitle", getNoticeTitle()) - .append("noticeType", getNoticeType()) - .append("noticeContent", getNoticeContent()) - .append("status", getStatus()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); - } -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java deleted file mode 100644 index 847089b89..000000000 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.ruoyi.system.mapper; - -import java.util.List; - -import com.ruoyi.system.domain.SysConfig; - -/** - * 参数配置 数据层 - * - * @author ruoyi - */ -public interface SysConfigMapper { - /** - * 查询参数配置信息 - * - * @param config 参数配置信息 - * @return 参数配置信息 - */ - public SysConfig selectConfig(SysConfig config); - - /** - * 查询参数配置列表 - * - * @param config 参数配置信息 - * @return 参数配置集合 - */ - public List selectConfigList(SysConfig config); - - /** - * 根据键名查询参数配置信息 - * - * @param configKey 参数键名 - * @return 参数配置信息 - */ - public SysConfig checkConfigKeyUnique(String configKey); - - /** - * 新增参数配置 - * - * @param config 参数配置信息 - * @return 结果 - */ - public int insertConfig(SysConfig config); - - /** - * 修改参数配置 - * - * @param config 参数配置信息 - * @return 结果 - */ - public int updateConfig(SysConfig config); - - /** - * 删除参数配置 - * - * @param configId 参数ID - * @return 结果 - */ - public int deleteConfigById(Long configId); - - /** - * 批量删除参数信息 - * - * @param configIds 需要删除的参数ID - * @return 结果 - */ - public int deleteConfigByIds(Long[] configIds); -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLogininforMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLogininforMapper.java deleted file mode 100644 index 490075e4a..000000000 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLogininforMapper.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.ruoyi.system.mapper; - -import java.util.List; - -import com.ruoyi.system.domain.SysLogininfor; - -/** - * 系统访问日志情况信息 数据层 - * - * @author ruoyi - */ -public interface SysLogininforMapper { - /** - * 新增系统登录日志 - * - * @param logininfor 访问日志对象 - */ - public void insertLogininfor(SysLogininfor logininfor); - - /** - * 查询系统登录日志集合 - * - * @param logininfor 访问日志对象 - * @return 登录记录集合 - */ - public List selectLogininforList(SysLogininfor logininfor); - - /** - * 批量删除系统登录日志 - * - * @param infoIds 需要删除的登录日志ID - * @return 结果 - */ - public int deleteLogininforByIds(Long[] infoIds); - - /** - * 清空系统登录日志 - * - * @return 结果 - */ - public int cleanLogininfor(); -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java deleted file mode 100644 index 7eda069b4..000000000 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.ruoyi.system.mapper; - -import java.util.List; - -import com.ruoyi.system.domain.SysNotice; - -/** - * 通知公告表 数据层 - * - * @author ruoyi - */ -public interface SysNoticeMapper { - /** - * 查询公告信息 - * - * @param noticeId 公告ID - * @return 公告信息 - */ - public SysNotice selectNoticeById(Long noticeId); - - /** - * 查询公告列表 - * - * @param notice 公告信息 - * @return 公告集合 - */ - public List selectNoticeList(SysNotice notice); - - /** - * 新增公告 - * - * @param notice 公告信息 - * @return 结果 - */ - public int insertNotice(SysNotice notice); - - /** - * 修改公告 - * - * @param notice 公告信息 - * @return 结果 - */ - public int updateNotice(SysNotice notice); - - /** - * 批量删除公告 - * - * @param noticeId 公告ID - * @return 结果 - */ - public int deleteNoticeById(Long noticeId); - - /** - * 批量删除公告信息 - * - * @param noticeIds 需要删除的公告ID - * @return 结果 - */ - public int deleteNoticeByIds(Long[] noticeIds); -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java deleted file mode 100644 index f7d60d594..000000000 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.ruoyi.system.mapper; - -import java.util.List; - -import com.ruoyi.system.domain.SysOperLog; - -/** - * 操作日志 数据层 - * - * @author ruoyi - */ -public interface SysOperLogMapper { - /** - * 新增操作日志 - * - * @param operLog 操作日志对象 - */ - public void insertOperlog(SysOperLog operLog); - - /** - * 查询系统操作日志集合 - * - * @param operLog 操作日志对象 - * @return 操作日志集合 - */ - public List selectOperLogList(SysOperLog operLog); - - /** - * 批量删除系统操作日志 - * - * @param operIds 需要删除的操作日志ID - * @return 结果 - */ - public int deleteOperLogByIds(Long[] operIds); - - /** - * 查询操作日志详细 - * - * @param operId 操作ID - * @return 操作日志对象 - */ - public SysOperLog selectOperLogById(Long operId); - - /** - * 清空操作日志 - */ - public void cleanOperLog(); -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java deleted file mode 100644 index fb1e420fd..000000000 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.ruoyi.system.service; - -import java.util.List; -import com.ruoyi.system.domain.SysNotice; - -/** - * 公告 服务层 - * - * @author ruoyi - */ -public interface ISysNoticeService -{ - /** - * 查询公告信息 - * - * @param noticeId 公告ID - * @return 公告信息 - */ - public SysNotice selectNoticeById(Long noticeId); - - /** - * 查询公告列表 - * - * @param notice 公告信息 - * @return 公告集合 - */ - public List selectNoticeList(SysNotice notice); - - /** - * 新增公告 - * - * @param notice 公告信息 - * @return 结果 - */ - public int insertNotice(SysNotice notice); - - /** - * 修改公告 - * - * @param notice 公告信息 - * @return 结果 - */ - public int updateNotice(SysNotice notice); - - /** - * 删除公告信息 - * - * @param noticeId 公告ID - * @return 结果 - */ - public int deleteNoticeById(Long noticeId); - - /** - * 批量删除公告信息 - * - * @param noticeIds 需要删除的公告ID - * @return 结果 - */ - public int deleteNoticeByIds(Long[] noticeIds); -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java deleted file mode 100644 index 3034b9025..000000000 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.ruoyi.system.service.impl; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.ruoyi.common.core.domain.entity.SysDictData; -import com.ruoyi.common.utils.DictUtils; -import com.ruoyi.system.mapper.SysDictDataMapper; -import com.ruoyi.system.service.ISysDictDataService; - -/** - * 字典 业务层处理 - * - * @author ruoyi - */ -@Service -public class SysDictDataServiceImpl implements ISysDictDataService { - - @Autowired - private SysDictDataMapper dictDataMapper; - - /** - * 根据条件分页查询字典数据 - * - * @param dictData 字典数据信息 - * @return 字典数据集合信息 - */ - @Override - public List selectDictDataList(SysDictData dictData) { - return dictDataMapper.selectDictDataList(dictData); - } - - /** - * 根据字典类型和字典键值查询字典数据信息 - * - * @param dictType 字典类型 - * @param dictValue 字典键值 - * @return 字典标签 - */ - @Override - public String selectDictLabel(String dictType, String dictValue) { - return dictDataMapper.selectDictLabel(dictType, dictValue); - } - - /** - * 根据字典数据ID查询信息 - * - * @param dictCode 字典数据ID - * @return 字典数据 - */ - @Override - public SysDictData selectDictDataById(Long dictCode) { - return dictDataMapper.selectDictDataById(dictCode); - } - - /** - * 批量删除字典数据信息 - * - * @param dictCodes 需要删除的字典数据ID - * @return 结果 - */ - @Override - public int deleteDictDataByIds(Long[] dictCodes) { - int row = dictDataMapper.deleteDictDataByIds(dictCodes); - if (row > 0) { - DictUtils.clearDictCache(); - } - return row; - } - - /** - * 新增保存字典数据信息 - * - * @param dictData 字典数据信息 - * @return 结果 - */ - @Override - public int insertDictData(SysDictData dictData) { - int row = dictDataMapper.insertDictData(dictData); - if (row > 0) { - DictUtils.clearDictCache(); - } - return row; - } - - /** - * 修改保存字典数据信息 - * - * @param dictData 字典数据信息 - * @return 结果 - */ - @Override - public int updateDictData(SysDictData dictData) { - int row = dictDataMapper.updateDictData(dictData); - if (row > 0) { - DictUtils.clearDictCache(); - } - return row; - } -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java deleted file mode 100644 index 5cbd0f0ae..000000000 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java +++ /dev/null @@ -1,177 +0,0 @@ -package com.ruoyi.system.service.impl; - -import java.util.List; -import javax.annotation.PostConstruct; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.core.domain.entity.SysDictData; -import com.ruoyi.common.core.domain.entity.SysDictType; -import com.ruoyi.common.exception.CustomException; -import com.ruoyi.common.utils.DictUtils; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.system.mapper.SysDictDataMapper; -import com.ruoyi.system.mapper.SysDictTypeMapper; -import com.ruoyi.system.service.ISysDictTypeService; - -/** - * 字典 业务层处理 - * - * @author ruoyi - */ -@Service -public class SysDictTypeServiceImpl implements ISysDictTypeService { - @Autowired - private SysDictTypeMapper dictTypeMapper; - - @Autowired - private SysDictDataMapper dictDataMapper; - - /** - * 项目启动时,初始化字典到缓存 - */ - @PostConstruct - public void init() { - List dictTypeList = dictTypeMapper.selectDictTypeAll(); - for (SysDictType dictType : dictTypeList) { - List dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType()); - DictUtils.setDictCache(dictType.getDictType(), dictDatas); - } - } - - /** - * 根据条件分页查询字典类型 - * - * @param dictType 字典类型信息 - * @return 字典类型集合信息 - */ - @Override - public List selectDictTypeList(SysDictType dictType) { - return dictTypeMapper.selectDictTypeList(dictType); - } - - /** - * 根据所有字典类型 - * - * @return 字典类型集合信息 - */ - @Override - public List selectDictTypeAll() { - return dictTypeMapper.selectDictTypeAll(); - } - - /** - * 根据字典类型查询字典数据 - * - * @param dictType 字典类型 - * @return 字典数据集合信息 - */ - @Override - public List selectDictDataByType(String dictType) { - List dictDatas = DictUtils.getDictCache(dictType); - if (StringUtils.isNotEmpty(dictDatas)) { - return dictDatas; - } - dictDatas = dictDataMapper.selectDictDataByType(dictType); - if (StringUtils.isNotEmpty(dictDatas)) { - DictUtils.setDictCache(dictType, dictDatas); - return dictDatas; - } - return null; - } - - /** - * 根据字典类型ID查询信息 - * - * @param dictId 字典类型ID - * @return 字典类型 - */ - @Override - public SysDictType selectDictTypeById(Long dictId) { - return dictTypeMapper.selectDictTypeById(dictId); - } - - /** - * 根据字典类型查询信息 - * - * @param dictType 字典类型 - * @return 字典类型 - */ - @Override - public SysDictType selectDictTypeByType(String dictType) { - return dictTypeMapper.selectDictTypeByType(dictType); - } - - /** - * 批量删除字典类型信息 - * - * @param dictIds 需要删除的字典ID - * @return 结果 - */ - @Override - public int deleteDictTypeByIds(Long[] dictIds) { - for (Long dictId : dictIds) { - SysDictType dictType = selectDictTypeById(dictId); - if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0) { - throw new CustomException(String.format("%1$s已分配,不能删除", dictType.getDictName())); - } - } - int count = dictTypeMapper.deleteDictTypeByIds(dictIds); - if (count > 0) { - DictUtils.clearDictCache(); - } - return count; - } - - - /** - * 新增保存字典类型信息 - * - * @param dictType 字典类型信息 - * @return 结果 - */ - @Override - public int insertDictType(SysDictType dictType) { - int row = dictTypeMapper.insertDictType(dictType); - if (row > 0) { - DictUtils.clearDictCache(); - } - return row; - } - - /** - * 修改保存字典类型信息 - * - * @param dictType 字典类型信息 - * @return 结果 - */ - @Override - @Transactional - public int updateDictType(SysDictType dictType) { - SysDictType oldDict = dictTypeMapper.selectDictTypeById(dictType.getDictId()); - dictDataMapper.updateDictDataType(oldDict.getDictType(), dictType.getDictType()); - int row = dictTypeMapper.updateDictType(dictType); - if (row > 0) { - DictUtils.clearDictCache(); - } - return row; - } - - /** - * 校验字典类型称是否唯一 - * - * @param dict 字典类型 - * @return 结果 - */ - @Override - public String checkDictTypeUnique(SysDictType dict) { - Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId(); - SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType()); - if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) { - return UserConstants.NOT_UNIQUE; - } - return UserConstants.UNIQUE; - } -} diff --git a/ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml deleted file mode 100644 index 6915a1482..000000000 --- a/ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - select notice_id, notice_title, notice_type, cast(notice_content as char) as notice_content, status, create_by, create_time, update_by, update_time, remark - from sys_notice - - - - - - - - insert into sys_notice ( - notice_title, - notice_type, - notice_content, - status, - remark, - create_by, - create_time - )values( - #{noticeTitle}, - #{noticeType}, - #{noticeContent}, - #{status}, - #{remark}, - #{createBy}, - sysdate() - ) - - - - update sys_notice - - notice_title = #{noticeTitle}, - notice_type = #{noticeType}, - notice_content = #{noticeContent}, - status = #{status}, - update_by = #{updateBy}, - update_time = sysdate() - - where notice_id = #{noticeId} - - - - delete from sys_notice where notice_id = #{noticeId} - - - - delete from sys_notice where notice_id in - - #{noticeId} - - - - \ No newline at end of file diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/SysNoticeController.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/SysNoticeController.java new file mode 100644 index 000000000..64c3542e2 --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/notice/SysNoticeController.java @@ -0,0 +1,64 @@ +package cn.iocoder.dashboard.modules.system.controller.notice; + +import io.swagger.annotations.Api; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Api(tags = "通知公告 API") +@RestController +@RequestMapping("/system/notice") +public class SysNoticeController { + +// /** +// * 获取通知公告列表 +// */ +// @PreAuthorize("@ss.hasPermi('system:notice:list')") +// @GetMapping("/list") +// public TableDataInfo list(SysNotice notice) { +// startPage(); +// List list = noticeService.selectNoticeList(notice); +// return getDataTable(list); +// } +// +// /** +// * 根据通知公告编号获取详细信息 +// */ +// @PreAuthorize("@ss.hasPermi('system:notice:query')") +// @GetMapping(value = "/{noticeId}") +// public AjaxResult getInfo(@PathVariable Long noticeId) { +// return AjaxResult.success(noticeService.selectNoticeById(noticeId)); +// } +// +// /** +// * 新增通知公告 +// */ +// @PreAuthorize("@ss.hasPermi('system:notice:add')") +// @Log(title = "通知公告", businessType = BusinessType.INSERT) +// @PostMapping +// public AjaxResult add(@Validated @RequestBody SysNotice notice) { +// notice.setCreateBy(SecurityUtils.getUsername()); +// return toAjax(noticeService.insertNotice(notice)); +// } +// +// /** +// * 修改通知公告 +// */ +// @PreAuthorize("@ss.hasPermi('system:notice:edit')") +// @Log(title = "通知公告", businessType = BusinessType.UPDATE) +// @PutMapping +// public AjaxResult edit(@Validated @RequestBody SysNotice notice) { +// notice.setUpdateBy(SecurityUtils.getUsername()); +// return toAjax(noticeService.updateNotice(notice)); +// } +// +// /** +// * 删除通知公告 +// */ +// @PreAuthorize("@ss.hasPermi('system:notice:remove')") +// @Log(title = "通知公告", businessType = BusinessType.DELETE) +// @DeleteMapping("/{noticeIds}") +// public AjaxResult remove(@PathVariable Long[] noticeIds) { +// return toAjax(noticeService.deleteNoticeByIds(noticeIds)); +// } + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/convert/notice/SysNoticeConvert.java b/src/main/java/cn/iocoder/dashboard/modules/system/convert/notice/SysNoticeConvert.java new file mode 100644 index 000000000..e5f17649b --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/convert/notice/SysNoticeConvert.java @@ -0,0 +1,11 @@ +package cn.iocoder.dashboard.modules.system.convert.notice; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface SysNoticeConvert { + + SysNoticeConvert INSTANCE = Mappers.getMapper(SysNoticeConvert.class); + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/notice/SysNoticeMapper.java b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/notice/SysNoticeMapper.java new file mode 100644 index 000000000..131ce3797 --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/notice/SysNoticeMapper.java @@ -0,0 +1,9 @@ +package cn.iocoder.dashboard.modules.system.dal.mysql.dao.notice; + +import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.notice.SysNoticeDO; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface SysNoticeMapper extends BaseMapper { +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/notice/SysNoticeDO.java b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/notice/SysNoticeDO.java new file mode 100644 index 000000000..626e58acc --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/notice/SysNoticeDO.java @@ -0,0 +1,52 @@ +package cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.notice; + +import cn.iocoder.dashboard.common.enums.CommonStatusEnum; +import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.dashboard.modules.system.enums.notice.SysNoticeTypeEnum; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; + +/** + * 通知公告表 + * + * @author ruoyi + */ +@TableName("sys_notice") +@Data +@EqualsAndHashCode(callSuper = true) +public class SysNoticeDO extends BaseDO { + + /** + * 公告ID + */ + private Long id; + /** + * 公告标题 + */ + @NotBlank(message = "公告标题不能为空") + @Size(max = 50, message = "公告标题不能超过50个字符") + private String title; + /** + * 公告类型 + * + * 枚举 {@link SysNoticeTypeEnum} + */ + @TableField("notice_type") + private String type; + /** + * 公告内容 + */ + private String content; + /** + * 公告状态 + * + * 枚举 {@link CommonStatusEnum} + */ + private Integer status; + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/enums/notice/SysNoticeTypeEnum.java b/src/main/java/cn/iocoder/dashboard/modules/system/enums/notice/SysNoticeTypeEnum.java new file mode 100644 index 000000000..86a3fea5f --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/enums/notice/SysNoticeTypeEnum.java @@ -0,0 +1,23 @@ +package cn.iocoder.dashboard.modules.system.enums.notice; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 通知类型 + * + * @author 芋道源码 + */ +@Getter +@AllArgsConstructor +public enum SysNoticeTypeEnum { + + NOTICE(1), + ANNOUNCEMENT(2); + + /** + * 类型 + */ + private final Integer type; + +}