소스 검색

王志扬

12417 3 년 전
부모
커밋
069565db57

+ 24 - 29
master/src/main/java/com/ruoyi/project/system/controller/SysUserNoticeController.java

@@ -1,5 +1,6 @@
 package com.ruoyi.project.system.controller;
 
+import java.util.Date;
 import java.util.List;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -24,10 +25,10 @@ import com.ruoyi.framework.web.page.TableDataInfo;
  * 用户通知关联Controller
  *
  * @author ruoyi
- * @date 2021-10-13
+ * @date 2021-10-15
  */
 @RestController
-@RequestMapping("/system/noticeUser")
+@RequestMapping("/system/userNotice")
 public class SysUserNoticeController extends BaseController
 {
     @Autowired
@@ -36,7 +37,7 @@ public class SysUserNoticeController extends BaseController
     /**
      * 查询用户通知关联列表
      */
-    @PreAuthorize("@ss.hasPermi('system:noticeUser:list')")
+    @PreAuthorize("@ss.hasPermi('system:userNotice:list')")
     @GetMapping("/list")
     public TableDataInfo list(SysUserNotice sysUserNotice)
     {
@@ -45,69 +46,63 @@ public class SysUserNoticeController extends BaseController
         return getDataTable(list);
     }
 
-    //根据用户id获取用户关联列表
-    @PreAuthorize("@ss.hasPermi('system:noticeUser:query')")
-    @GetMapping(value = "/{userId}")
-    public TableDataInfo listByUserId(@PathVariable("userId")Long userId)
-    {
-        startPage();
-        List<SysUserNotice> list = sysUserNoticeService.selectSysUserNoticeListByUserId(userId);
-        return getDataTable(list);
-    }
-
     /**
      * 导出用户通知关联列表
      */
-    /*@PreAuthorize("@ss.hasPermi('system:noticeUser:export')")
+    /*@PreAuthorize("@ss.hasPermi('system:userNotice:export')")
     @Log(title = "用户通知关联", businessType = BusinessType.EXPORT)
     @GetMapping("/export")
     public AjaxResult export(SysUserNotice sysUserNotice)
     {
         List<SysUserNotice> list = sysUserNoticeService.selectSysUserNoticeList(sysUserNotice);
         ExcelUtil<SysUserNotice> util = new ExcelUtil<SysUserNotice>(SysUserNotice.class);
-        return util.exportExcel(list, "notice");
+        return util.exportExcel(list, "userNotice");
     }*/
 
     /**
      * 获取用户通知关联详细信息
      */
-    /*@PreAuthorize("@ss.hasPermi('system:noticeUser:query')")
-    @GetMapping(value = "/{id}")
-    public AjaxResult getInfo(@PathVariable("id") Long id)
+    /*@PreAuthorize("@ss.hasPermi('system:userNotice:query')")
+    @GetMapping(value = "/{userId}")
+    public AjaxResult getInfo(@PathVariable("userId") Long userId)
     {
-        return AjaxResult.success(sysUserNoticeService.selectSysUserNoticeById(id));
+        return AjaxResult.success(sysUserNoticeService.selectSysUserNoticeById(userId));
     }*/
 
     /**
      * 新增用户通知关联
      */
-    @PreAuthorize("@ss.hasPermi('system:noticeUser:add')")
+    @PreAuthorize("@ss.hasPermi('system:userNotice:add')")
     @Log(title = "用户通知关联", businessType = BusinessType.INSERT)
-    @PostMapping
-    public AjaxResult add(@RequestBody SysUserNotice sysUserNotice)
+    @GetMapping
+    public AjaxResult add(@RequestBody Long noticeId)
     {
+        SysUserNotice sysUserNotice = new SysUserNotice();
+        sysUserNotice.setNoticeId(noticeId);
+        sysUserNotice.setUserId(this.getUserId());
+        sysUserNotice.setCreateTime(new Date());
         return toAjax(sysUserNoticeService.insertSysUserNotice(sysUserNotice));
     }
 
     /**
      * 修改用户通知关联
      */
-    /*@PreAuthorize("@ss.hasPermi('system:noticeUser:edit')")
+    /*@PreAuthorize("@ss.hasPermi('system:userNotice:edit')")
     @Log(title = "用户通知关联", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody SysUserNotice sysUserNotice)
     {
         return toAjax(sysUserNoticeService.updateSysUserNotice(sysUserNotice));
-    }
-*/
+    }*/
+
     /**
      * 删除用户通知关联
      */
-    /*@PreAuthorize("@ss.hasPermi('system:noticeUser:remove')")
+    /*@PreAuthorize("@ss.hasPermi('system:userNotice:remove')")
     @Log(title = "用户通知关联", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
-    public AjaxResult remove(@PathVariable Long[] ids)
+	@DeleteMapping("/{userIds}")
+    public AjaxResult remove(@PathVariable Long[] userIds)
     {
-        return toAjax(sysUserNoticeService.deleteSysUserNoticeByIds(ids));
+        return toAjax(sysUserNoticeService.deleteSysUserNoticeByIds(userIds));
     }*/
 }

+ 8 - 40
master/src/main/java/com/ruoyi/project/system/domain/SysUserNotice.java

@@ -1,6 +1,5 @@
 package com.ruoyi.project.system.domain;
 
-import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.framework.aspectj.lang.annotation.Excel;
 import com.ruoyi.framework.web.domain.BaseEntity;
 import org.apache.commons.lang3.builder.ToStringBuilder;
@@ -12,15 +11,12 @@ import java.util.Date;
  * 用户通知关联对象 sys_user_notice
  *
  * @author ruoyi
- * @date 2021-10-13
+ * @date 2021-10-15
  */
 public class SysUserNotice extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
 
-    /** 序号 */
-    private Long id;
-
     /** 用户编号 */
     @Excel(name = "用户编号")
     private Long userId;
@@ -29,32 +25,17 @@ public class SysUserNotice extends BaseEntity
     @Excel(name = "公告编号")
     private Long noticeId;
 
-    /** 是否阅读(是 : 1 ; 否 : 0;) */
-    @Excel(name = "是否阅读(是 : 1 ; 否 : 0;)")
-    private Long read;
-
-    public Date getCreatetime() {
-        return createtime;
-    }
-
-    public void setCreatetime(Date createtime) {
-        this.createtime = createtime;
-    }
-
     /** 创建时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd" , timezone = "GMT+8")
-    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
-    private Date createtime;
+    private Date createTime;
 
-    public void setId(Long id)
-    {
-        this.id = id;
+    public Date getCreateTime() {
+        return createTime;
     }
 
-    public Long getId()
-    {
-        return id;
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
     }
+
     public void setUserId(Long userId)
     {
         this.userId = userId;
@@ -73,26 +54,13 @@ public class SysUserNotice extends BaseEntity
     {
         return noticeId;
     }
-    public void setRead(Long read)
-    {
-        this.read = read;
-    }
-
-    public Long getRead()
-    {
-        return read;
-    }
 
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("id", getId())
             .append("userId", getUserId())
             .append("noticeId", getNoticeId())
-            .append("read", getRead())
-            .append("createtime", getCreatetime())
+            .append("createTime", getCreateTime())
             .toString();
     }
-
-
 }

+ 8 - 17
master/src/main/java/com/ruoyi/project/system/mapper/SysUserNoticeMapper.java

@@ -8,36 +8,27 @@ import com.ruoyi.project.system.domain.SysUserNotice;
  * 用户通知关联Mapper接口
  * 
  * @author ruoyi
- * @date 2021-10-13
+ * @date 2021-10-15
  */
 public interface SysUserNoticeMapper 
 {
     /**
      * 查询用户通知关联
      * 
-     * @param id 用户通知关联ID
+     * @param userId 用户通知关联ID
      * @return 用户通知关联
      */
-    public SysUserNotice selectSysUserNoticeById(Long id);
+    public SysUserNotice selectSysUserNoticeById(Long userId);
 
     /**
      * 查询用户通知关联列表
-     *
+     * 
      * @param sysUserNotice 用户通知关联
      * @return 用户通知关联集合
      */
     @DataScope(deptAlias = "d")
     public List<SysUserNotice> selectSysUserNoticeList(SysUserNotice sysUserNotice);
 
-    /**
-     * 根据用户id,查询用户通知关联列表
-     *
-     * @param userId 用户编号
-     * @return 用户通知关联集合
-     */
-    @DataScope(deptAlias = "d")
-    public List<SysUserNotice> selectSysUserNoticeListByUserId(Long userId);
-
     /**
      * 新增用户通知关联
      * 
@@ -57,16 +48,16 @@ public interface SysUserNoticeMapper
     /**
      * 删除用户通知关联
      * 
-     * @param id 用户通知关联ID
+     * @param userId 用户通知关联ID
      * @return 结果
      */
-    public int deleteSysUserNoticeById(Long id);
+    public int deleteSysUserNoticeById(Long userId);
 
     /**
      * 批量删除用户通知关联
      * 
-     * @param ids 需要删除的数据ID
+     * @param userIds 需要删除的数据ID
      * @return 结果
      */
-    public int deleteSysUserNoticeByIds(Long[] ids);
+    public int deleteSysUserNoticeByIds(Long[] userIds);
 }

+ 61 - 0
master/src/main/java/com/ruoyi/project/system/service/ISysUserNoticeService.java

@@ -0,0 +1,61 @@
+package com.ruoyi.project.system.service;
+
+import java.util.List;
+import com.ruoyi.project.system.domain.SysUserNotice;
+
+/**
+ * 用户通知关联Service接口
+ * 
+ * @author ruoyi
+ * @date 2021-10-15
+ */
+public interface ISysUserNoticeService 
+{
+    /**
+     * 查询用户通知关联
+     * 
+     * @param userId 用户通知关联ID
+     * @return 用户通知关联
+     */
+    public SysUserNotice selectSysUserNoticeById(Long userId);
+
+    /**
+     * 查询用户通知关联列表
+     * 
+     * @param sysUserNotice 用户通知关联
+     * @return 用户通知关联集合
+     */
+    public List<SysUserNotice> selectSysUserNoticeList(SysUserNotice sysUserNotice);
+
+    /**
+     * 新增用户通知关联
+     * 
+     * @param sysUserNotice 用户通知关联
+     * @return 结果
+     */
+    public int insertSysUserNotice(SysUserNotice sysUserNotice);
+
+    /**
+     * 修改用户通知关联
+     * 
+     * @param sysUserNotice 用户通知关联
+     * @return 结果
+     */
+    public int updateSysUserNotice(SysUserNotice sysUserNotice);
+
+    /**
+     * 批量删除用户通知关联
+     * 
+     * @param userIds 需要删除的用户通知关联ID
+     * @return 结果
+     */
+    public int deleteSysUserNoticeByIds(Long[] userIds);
+
+    /**
+     * 删除用户通知关联信息
+     * 
+     * @param userId 用户通知关联ID
+     * @return 结果
+     */
+    public int deleteSysUserNoticeById(Long userId);
+}

+ 10 - 15
master/src/main/java/com/ruoyi/project/system/service/impl/SysUserNoticeServiceImpl.java

@@ -11,7 +11,7 @@ import com.ruoyi.project.system.service.ISysUserNoticeService;
  * 用户通知关联Service业务层处理
  *
  * @author ruoyi
- * @date 2021-10-13
+ * @date 2021-10-15
  */
 @Service
 public class SysUserNoticeServiceImpl implements ISysUserNoticeService
@@ -22,13 +22,13 @@ public class SysUserNoticeServiceImpl implements ISysUserNoticeService
     /**
      * 查询用户通知关联
      *
-     * @param id 用户通知关联ID
+     * @param userId 用户通知关联ID
      * @return 用户通知关联
      */
     @Override
-    public SysUserNotice selectSysUserNoticeById(Long id)
+    public SysUserNotice selectSysUserNoticeById(Long userId)
     {
-        return sysUserNoticeMapper.selectSysUserNoticeById(id);
+        return sysUserNoticeMapper.selectSysUserNoticeById(userId);
     }
 
     /**
@@ -43,11 +43,6 @@ public class SysUserNoticeServiceImpl implements ISysUserNoticeService
         return sysUserNoticeMapper.selectSysUserNoticeList(sysUserNotice);
     }
 
-    @Override
-    public List<SysUserNotice> selectSysUserNoticeListByUserId(Long userId) {
-        return sysUserNoticeMapper.selectSysUserNoticeListByUserId(userId);
-    }
-
     /**
      * 新增用户通知关联
      *
@@ -75,24 +70,24 @@ public class SysUserNoticeServiceImpl implements ISysUserNoticeService
     /**
      * 批量删除用户通知关联
      *
-     * @param ids 需要删除的用户通知关联ID
+     * @param userIds 需要删除的用户通知关联ID
      * @return 结果
      */
     @Override
-    public int deleteSysUserNoticeByIds(Long[] ids)
+    public int deleteSysUserNoticeByIds(Long[] userIds)
     {
-        return sysUserNoticeMapper.deleteSysUserNoticeByIds(ids);
+        return sysUserNoticeMapper.deleteSysUserNoticeByIds(userIds);
     }
 
     /**
      * 删除用户通知关联信息
      *
-     * @param id 用户通知关联ID
+     * @param userId 用户通知关联ID
      * @return 结果
      */
     @Override
-    public int deleteSysUserNoticeById(Long id)
+    public int deleteSysUserNoticeById(Long userId)
     {
-        return sysUserNoticeMapper.deleteSysUserNoticeById(id);
+        return sysUserNoticeMapper.deleteSysUserNoticeById(userId);
     }
 }

+ 14 - 28
master/src/main/resources/mybatis/system/SysUserNoticeMapper.xml

@@ -5,16 +5,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 <mapper namespace="com.ruoyi.project.system.mapper.SysUserNoticeMapper">
     
     <resultMap type="SysUserNotice" id="SysUserNoticeResult">
-        <result property="id"    column="id"    />
         <result property="userId"    column="user_id"    />
         <result property="noticeId"    column="notice_id"    />
-        <result property="read"    column="read"    />
         <result property="createtime"    column="createtime"    />
         <result property="deptName" column="dept_name" />
     </resultMap>
 
     <sql id="selectSysUserNoticeVo">
-        select d.id, d.user_id, d.notice_id, d.read, d.createtime ,s.dept_name from sys_user_notice d
+        select d.user_id, d.notice_id, d.createtime ,s.dept_name from sys_user_notice d
       left join sys_dept s on s.dept_id = d.dept_id
     </sql>
 
@@ -23,7 +21,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <where>  
             <if test="userId != null "> and user_id = #{userId}</if>
             <if test="noticeId != null "> and notice_id = #{noticeId}</if>
-            <if test="read != null "> and read = #{read}</if>
             <if test="createtime != null "> and createtime = #{createtime}</if>
             and d.del_flag = 0
         </where>
@@ -33,55 +30,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     
     <select id="selectSysUserNoticeById" parameterType="Long" resultMap="SysUserNoticeResult">
         <include refid="selectSysUserNoticeVo"/>
-        where id = #{id}
+        where user_id = #{userId}
     </select>
 
-    <select id="selectSysUserNoticeByUserId" parameterType="Long" resultMap="SysUserNoticeResult">
-        <include refid="selectSysUserNoticeVo"/>
-        where USER_ID = #{userId}
-    </select>
-        
+
+
+
     <insert id="insertSysUserNotice" parameterType="SysUserNotice">
-        <selectKey keyProperty="id" resultType="long" order="BEFORE">
-            SELECT seq_sys_user_notice.NEXTVAL as id FROM DUAL
-        </selectKey>
         insert into sys_user_notice
         <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="id != null">id,</if>
             <if test="userId != null">user_id,</if>
             <if test="noticeId != null">notice_id,</if>
-            <if test="read != null">read,</if>
             <if test="createtime != null">createtime,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
-            <if test="id != null">#{id},</if>
             <if test="userId != null">#{userId},</if>
             <if test="noticeId != null">#{noticeId},</if>
-            <if test="read != null">#{read},</if>
             <if test="createtime != null">#{createtime},</if>
          </trim>
     </insert>
 
-    <update id="updateSysUserNotice" parameterType="SysUserNotice">
+    <!--<update id="updateSysUserNotice" parameterType="SysUserNotice">
         update sys_user_notice
         <trim prefix="SET" suffixOverrides=",">
-            <if test="userId != null">user_id = #{userId},</if>
             <if test="noticeId != null">notice_id = #{noticeId},</if>
-            <if test="read != null">read = #{read},</if>
             <if test="createtime != null">createtime = #{createtime},</if>
         </trim>
-        where id = #{id}
-    </update>
+        where user_id = #{userId}
+    </update>-->
 
-    <update id="deleteSysUserNoticeById" parameterType="Long">
-        update sys_user_notice set del_flag = 2 where id = #{id}
+   <!-- <update id="deleteSysUserNoticeById" parameterType="Long">
+        update sys_user_notice set del_flag = 2 where user_id = #{userId}
     </update>
 
     <update id="deleteSysUserNoticeByIds" parameterType="String">
-        update sys_user_notice set del_flag = 2 where id in
-        <foreach item="id" collection="array" open="(" separator="," close=")">
-            #{id}
+        update sys_user_notice set del_flag = 2 where user_id in
+        <foreach item="userId" collection="array" open="(" separator="," close=")">
+            #{userId}
         </foreach>
-    </update>
+    </update>-->
     
 </mapper>