tudc hace 3 años
padre
commit
f9f5fd84df

+ 1 - 1
tianhu-system/src/main/java/com/tianhu/system/controller/OwnNoticeController.java

@@ -66,7 +66,7 @@ public class OwnNoticeController extends BaseController
      */
     @GetMapping("details/{noticeId}")
     public AjaxResult details(@PathVariable("noticeId") String noticeId)throws Exception {
-        return AjaxResult.success(iSysNoticeService.selectNoticeById(noticeId));
+        return AjaxResult.success(iSysNoticeService.getById(noticeId));
     }
 
     /**

+ 9 - 54
tianhu-system/src/main/java/com/tianhu/system/mapper/SysNoticeMapper.java

@@ -1,61 +1,16 @@
 package com.tianhu.system.mapper;
 
-import java.util.List;
-
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.tianhu.system.domain.SysNotice;
 
 /**
- * 通知公告表 数据层
- * 
- * @author tianhu
+ * <p>
+ * 消息通知表 Mapper 接口
+ * </p>
+ *
+ * @author cuixq
+ * @since 2021-09-14
  */
-public interface SysNoticeMapper
-{
-    /**
-     * 查询公告信息
-     * 
-     * @param noticeId 公告ID
-     * @return 公告信息
-     */
-    public SysNotice selectNoticeById(String noticeId);
-
-    /**
-     * 查询公告列表
-     * 
-     * @param notice 公告信息
-     * @return 公告集合
-     */
-    public List<SysNotice> 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(String noticeId);
+public interface SysNoticeMapper extends BaseMapper<SysNotice> {
 
-    /**
-     * 批量删除公告信息
-     * 
-     * @param noticeIds 需要删除的公告ID
-     * @return 结果
-     */
-    public int deleteNoticeByIds(String[] noticeIds);
-}
+}

+ 37 - 39
tianhu-system/src/main/java/com/tianhu/system/service/ISysNoticeService.java

@@ -1,61 +1,59 @@
 package com.tianhu.system.service;
 
-import java.util.List;
 
+import com.keao.tianhu.starter.mybatis.plus.entity.QueryRequest;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.IService;
 import com.tianhu.system.domain.SysNotice;
 
+
+import java.util.List;
+
 /**
- * 公告 服务层
- * 
- * @author tianhu
+ * ClassName: ISysNoticeService<br>
+ * Description: SysNoticeService接口 <br>
+ * Company: keao
+ *
+ * @author cuixq
+ * @version v1.0.0    2021-09-14  cuixq    由Generator自动创建
  */
-public interface ISysNoticeService
-{
+public interface ISysNoticeService extends IService<SysNotice> {
     /**
-     * 查询公告信息
-     * 
-     * @param noticeId 公告ID
-     * @return 公告信息
+     * 查询(分页)
+     *
+     * @param request QueryRequest
+     * @param wrapper LambdaQueryWrapper<SysNotice>
+     * @return IPage<SysNotice>
      */
-    public SysNotice selectNoticeById(String noticeId);
+    IPage<SysNotice> findSysNotices(QueryRequest request, LambdaQueryWrapper<SysNotice> wrapper);
 
     /**
-     * 查询公告列表
-     * 
-     * @param notice 公告信息
-     * @return 公告集合
+     * 查询(所有)
+     *
+     * @param wrapper LambdaQueryWrapper<SysNotice>
+     * @return List<SysNotice>
      */
-    public List<SysNotice> selectNoticeList(SysNotice notice);
+    List<SysNotice> findSysNotices(LambdaQueryWrapper<SysNotice> wrapper);
 
     /**
-     * 新增公告
-     * 
-     * @param notice 公告信息
-     * @return 结果
+     * 新增
+     *
+     * @param sysNotice sysNotice
      */
-    public int insertNotice(SysNotice notice);
+    void createSysNotice(SysNotice sysNotice);
 
     /**
-     * 修改公告
-     * 
-     * @param notice 公告信息
-     * @return 结果
+     * 修改
+     *
+     * @param sysNotice sysNotice
      */
-    public int updateNotice(SysNotice notice);
+    void updateSysNotice(SysNotice sysNotice);
 
     /**
-     * 删除公告信息
-     * 
-     * @param noticeId 公告ID
-     * @return 结果
-     */
-    public int deleteNoticeById(String noticeId);
-    
-    /**
-     * 批量删除公告信息
-     * 
-     * @param noticeIds 需要删除的公告ID
-     * @return 结果
+     * 删除
+     *
+     * @param wrapper LambdaQueryWrapper<SysNotice>
      */
-    public int deleteNoticeByIds(String[] noticeIds);
+    void deleteSysNotice(LambdaQueryWrapper<SysNotice> wrapper);
 }

+ 1 - 1
tianhu-system/src/main/java/com/tianhu/system/service/impl/OwnNoticeServiceImpl.java

@@ -139,7 +139,7 @@ public class OwnNoticeServiceImpl implements IOwnNoticeService
                 notice.setMessageStatus("0");
             }
         }
-        iSysNoticeService.insertNotice(notice);
+        iSysNoticeService.createSysNotice(notice);
         return R.ok();
     }
 }

+ 39 - 69
tianhu-system/src/main/java/com/tianhu/system/service/impl/SysNoticeServiceImpl.java

@@ -1,94 +1,64 @@
 package com.tianhu.system.service.impl;
 
-import java.util.List;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
 import com.tianhu.system.domain.SysNotice;
 import com.tianhu.system.mapper.SysNoticeMapper;
 import com.tianhu.system.service.ISysNoticeService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.beans.factory.annotation.Autowired;
+import com.keao.tianhu.starter.mybatis.plus.entity.QueryRequest;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+
+
+import java.util.List;
 
 /**
- * 公告 服务层实现
- * 
- * @author tianhu
+ * ClassName: SysNoticeServiceImpl<br>
+ * Description: ISysNoticeService实现 <br>
+ * Company: keao
+ *
+ * @author cuixq
+ * @version v1.0.0    2021-09-14  cuixq    由Generator自动创建
  */
 @Service
-public class SysNoticeServiceImpl implements ISysNoticeService
-{
-    @Autowired
-    private SysNoticeMapper noticeMapper;
+@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
+public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice> implements ISysNoticeService {
 
-    /**
-     * 查询公告信息
-     * 
-     * @param noticeId 公告ID
-     * @return 公告信息
-     */
-    @Override
-    public SysNotice selectNoticeById(String noticeId)
-    {
-        return noticeMapper.selectNoticeById(noticeId);
-    }
+    @Autowired
+    private SysNoticeMapper sysNoticeMapper;
 
-    /**
-     * 查询公告列表
-     * 
-     * @param notice 公告信息
-     * @return 公告集合
-     */
     @Override
-    public List<SysNotice> selectNoticeList(SysNotice notice)
-    {
-        return noticeMapper.selectNoticeList(notice);
+    public IPage<SysNotice> findSysNotices(QueryRequest request, LambdaQueryWrapper<SysNotice> wrapper) {
+        Page<SysNotice> page = new Page<>(request.getPageNum(), request.getPageSize());
+        return this.page(page, wrapper);
     }
 
-    /**
-     * 新增公告
-     * 
-     * @param notice 公告信息
-     * @return 结果
-     */
     @Override
-    public int insertNotice(SysNotice notice)
-    {
-        return noticeMapper.insertNotice(notice);
+    public List<SysNotice> findSysNotices(LambdaQueryWrapper<SysNotice> wrapper) {
+		return this.list(wrapper);
     }
 
-    /**
-     * 修改公告
-     * 
-     * @param notice 公告信息
-     * @return 结果
-     */
     @Override
-    public int updateNotice(SysNotice notice)
-    {
-        return noticeMapper.updateNotice(notice);
+    @Transactional(rollbackFor = Exception.class)
+    public void createSysNotice(SysNotice sysNotice) {
+        this.save(sysNotice);
     }
 
-    /**
-     * 删除公告对象
-     * 
-     * @param noticeId 公告ID
-     * @return 结果
-     */
     @Override
-    public int deleteNoticeById(String noticeId)
-    {
-        return noticeMapper.deleteNoticeById(noticeId);
+    @Transactional(rollbackFor = Exception.class)
+    public void updateSysNotice(SysNotice sysNotice) {
+        this.saveOrUpdate(sysNotice);
     }
 
-    /**
-     * 批量删除公告信息
-     * 
-     * @param noticeIds 需要删除的公告ID
-     * @return 结果
-     */
     @Override
-    public int deleteNoticeByIds(String[] noticeIds)
-    {
-        return noticeMapper.deleteNoticeByIds(noticeIds);
-    }
+    @Transactional(rollbackFor = Exception.class)
+    public void deleteSysNotice(LambdaQueryWrapper<SysNotice> wrapper) {
+	    this.remove(wrapper);
+	}
 }