Browse Source

获取电子书是否可读

获取头像是否可以修改
tags/正式3.2.0
雍文秀 2 years ago
parent
commit
d0701ee912

+ 6
- 0
sapi/src/main/java/com/xhkjedu/sapi/controller/itemtool/ReadController.java View File

222
         return new ResultVo(0,"获取电子书列表成功",pageResult);
222
         return new ResultVo(0,"获取电子书列表成功",pageResult);
223
     }
223
     }
224
 
224
 
225
+    @PostMapping("/get_readable")
226
+    public ResultVo getReadable(@RequestBody TRead read) {
227
+        N_Utils.validation(new Object[]{read.getReadid(), "阅读id", 1});
228
+        Integer readable = readService.getReadable(read);
229
+        return new ResultVo(0, "获取电子书是否可读成功", readable);
230
+    }
225
 }
231
 }

+ 4
- 0
sapi/src/main/java/com/xhkjedu/sapi/model/itemtool/TRead.java View File

69
     //开放时间列表
69
     //开放时间列表
70
     private List<ReadDateVo> dates;
70
     private List<ReadDateVo> dates;
71
 
71
 
72
+    @Transient
73
+    //是否可读0不可读1可读
74
+    private Integer readable;
75
+
72
 
76
 
73
 }
77
 }

+ 5
- 0
sapi/src/main/java/com/xhkjedu/sapi/model/itemtool/TReadDate.java View File

4
 import lombok.Data;
4
 import lombok.Data;
5
 
5
 
6
 import javax.persistence.Id;
6
 import javax.persistence.Id;
7
+import javax.persistence.Transient;
7
 
8
 
8
 /**
9
 /**
9
  * @author ywx
10
  * @author ywx
28
 
29
 
29
     //结束时间
30
     //结束时间
30
     private String endtime;
31
     private String endtime;
32
+
33
+    @Transient
34
+    //是否可读0不可读1可读
35
+    private Integer readable;
31
 }
36
 }

+ 8
- 2
sapi/src/main/java/com/xhkjedu/sapi/service/itemtool/ReadDateService.java View File

32
     }
32
     }
33
 
33
 
34
     //关联阅读开放时间
34
     //关联阅读开放时间
35
-    public void setRead(TRead tRead) {
35
+    public Integer setRead(TRead tRead) {
36
+        Integer readable = 0;
36
         List<TReadDate> dateList = readDateMapper.listByReadId(tRead.getReadid());
37
         List<TReadDate> dateList = readDateMapper.listByReadId(tRead.getReadid());
37
-        if (N_Utils.isListEmpty(dateList)) return;
38
+        if (N_Utils.isListEmpty(dateList)) return readable;
38
         List<ReadDateVo> dates = new ArrayList<>();
39
         List<ReadDateVo> dates = new ArrayList<>();
39
         Map<String, List<TReadDate>> collect = dateList.stream().collect(
40
         Map<String, List<TReadDate>> collect = dateList.stream().collect(
40
                 Collectors.groupingBy(d -> d.getBegintime() + "_" + d.getEndtime()));
41
                 Collectors.groupingBy(d -> d.getBegintime() + "_" + d.getEndtime()));
50
             d.setTimestr(timestr);
51
             d.setTimestr(timestr);
51
             for (TReadDate rd : list) {
52
             for (TReadDate rd : list) {
52
                 datenum.add(rd.getWeeknum());
53
                 datenum.add(rd.getWeeknum());
54
+                if (rd.getReadable().equals(1)) {
55
+                    readable = 1;
56
+                }
53
             }
57
             }
54
             d.setDatenum(datenum);
58
             d.setDatenum(datenum);
55
             dates.add(d);
59
             dates.add(d);
56
         }
60
         }
61
+        tRead.setReadable(readable);
57
         tRead.setDates(dates);
62
         tRead.setDates(dates);
63
+        return readable;
58
     }
64
     }
59
 
65
 
60
     public void insertList(List<TReadDate> dateList) {
66
     public void insertList(List<TReadDate> dateList) {

+ 11
- 0
sapi/src/main/java/com/xhkjedu/sapi/service/itemtool/ReadService.java View File

271
         readDateService.setReads(reads);//关联阅读开放时间
271
         readDateService.setReads(reads);//关联阅读开放时间
272
         return reads;
272
         return reads;
273
     }
273
     }
274
+
275
+    /**
276
+     * 获取电子书是否可读
277
+     * @Param [read]
278
+     * @Author ywx
279
+     * @Date 2022/3/14 10:52
280
+     * @return java.lang.Integer
281
+     **/
282
+    public Integer getReadable(TRead read) {
283
+        return readDateService.setRead(read);
284
+    }
274
 }
285
 }

+ 2
- 0
sapi/src/main/resources/mapper/itemtool/ReadDateMapper.xml View File

8
     <!--根据阅读id获取阅读开放时间-->
8
     <!--根据阅读id获取阅读开放时间-->
9
     <select id="listByReadId" resultType="com.xhkjedu.sapi.model.itemtool.TReadDate">
9
     <select id="listByReadId" resultType="com.xhkjedu.sapi.model.itemtool.TReadDate">
10
         select weeknum,begintime,endtime
10
         select weeknum,begintime,endtime
11
+        ,(case when weeknum=DATE_FORMAT(CURDATE(),'%w') and CURRENT_TIME() between begintime
12
+        and concat(endtime,':59') then 1 else 0 end)readable
11
         from t_read_date where readid=#{readid}
13
         from t_read_date where readid=#{readid}
12
     </select>
14
     </select>
13
 </mapper>
15
 </mapper>

+ 8
- 0
suser/src/main/java/com/xhkjedu/suser/controller/system/UserController.java View File

375
         user.setLoginname(map.get("loginname").toString());
375
         user.setLoginname(map.get("loginname").toString());
376
         return userService.loginByName(user, request);
376
         return userService.loginByName(user, request);
377
     }
377
     }
378
+
379
+    @PostMapping("/get_headtime")
380
+    public ResultVo getHeadTime(@RequestBody TUser user){
381
+        Integer userid = user.getUserid();
382
+        N_Utils.validation(new Object[]{userid,"用户id",1});
383
+        Integer headtime = userService.getHeadTime(userid);
384
+        return new ResultVo(0,"获取头像是否可以修改成功",headtime);
385
+    }
378
 }
386
 }

+ 3
- 0
suser/src/main/java/com/xhkjedu/suser/mapper/system/UserMapper.java View File

174
 
174
 
175
     //用户选择列表
175
     //用户选择列表
176
     List<Map> listForSel(@Param("user") AssessParams user, @Param("year") Integer year);
176
     List<Map> listForSel(@Param("user") AssessParams user, @Param("year") Integer year);
177
+
178
+    //获取修改头像时间
179
+    Integer getHeadTime(Integer userid);
177
 }
180
 }

+ 3
- 0
suser/src/main/java/com/xhkjedu/suser/model/system/TUser.java View File

45
     //头像地址
45
     //头像地址
46
     private String headpic;
46
     private String headpic;
47
 
47
 
48
+    //修改头像时间
49
+    private Integer headtime;
50
+
48
     //用户类型999超级管理员0学校管理员1老师2学生
51
     //用户类型999超级管理员0学校管理员1老师2学生
49
     private Integer usertype;
52
     private Integer usertype;
50
 
53
 

+ 11
- 0
suser/src/main/java/com/xhkjedu/suser/service/system/UserService.java View File

743
 
743
 
744
         return getLogResultVo(user, resultVo, "", request);
744
         return getLogResultVo(user, resultVo, "", request);
745
     }
745
     }
746
+
747
+    /**
748
+     * 获取头像是否可以修改
749
+     * @Param [userid]
750
+     * @Author ywx
751
+     * @Date 2022/3/14 9:58
752
+     * @return java.lang.Integer
753
+     **/
754
+    public Integer getHeadTime(Integer userid) {
755
+        return userMapper.getHeadTime(userid);
756
+    }
746
 }
757
 }

+ 6
- 1
suser/src/main/resources/mapper/system/UserMapper.xml View File

60
     </update>
60
     </update>
61
     <!--修改用户头像-->
61
     <!--修改用户头像-->
62
     <update id="updateHeadPic">
62
     <update id="updateHeadPic">
63
-        update t_user set headpic=#{user.headpic} where userid=#{user.userid}
63
+        update t_user set headpic=#{user.headpic},headtime=UNIX_TIMESTAMP() where userid=#{user.userid}
64
     </update>
64
     </update>
65
     <!--检查登录账号是否存在-->
65
     <!--检查登录账号是否存在-->
66
     <select id="checkLoginName" resultType="java.lang.Integer">
66
     <select id="checkLoginName" resultType="java.lang.Integer">
162
         group by u.userid
162
         group by u.userid
163
         order by convert(u.username using gbk)
163
         order by convert(u.username using gbk)
164
     </select>
164
     </select>
165
+    <!--获取头像是否可以修改-->
166
+    <select id="getHeadTime" resultType="java.lang.Integer">
167
+        select (case when headtime is null then 1 when headtime+6*30*24*60*60>unix_timestamp() then 1 else 0 end)
168
+        from t_user where userid=#{userid}
169
+    </select>
165
 
170
 
166
 
171
 
167
 </mapper>
172
 </mapper>

Loading…
Cancel
Save