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,4 +222,10 @@ public class ReadController {
222 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,5 +69,9 @@ public class TRead extends BaseBean {
69 69
     //开放时间列表
70 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,6 +4,7 @@ import com.xhkjedu.sapi.model.BaseBean;
4 4
 import lombok.Data;
5 5
 
6 6
 import javax.persistence.Id;
7
+import javax.persistence.Transient;
7 8
 
8 9
 /**
9 10
  * @author ywx
@@ -28,4 +29,8 @@ public class TReadDate extends BaseBean {
28 29
 
29 30
     //结束时间
30 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,9 +32,10 @@ public class ReadDateService {
32 32
     }
33 33
 
34 34
     //关联阅读开放时间
35
-    public void setRead(TRead tRead) {
35
+    public Integer setRead(TRead tRead) {
36
+        Integer readable = 0;
36 37
         List<TReadDate> dateList = readDateMapper.listByReadId(tRead.getReadid());
37
-        if (N_Utils.isListEmpty(dateList)) return;
38
+        if (N_Utils.isListEmpty(dateList)) return readable;
38 39
         List<ReadDateVo> dates = new ArrayList<>();
39 40
         Map<String, List<TReadDate>> collect = dateList.stream().collect(
40 41
                 Collectors.groupingBy(d -> d.getBegintime() + "_" + d.getEndtime()));
@@ -50,11 +51,16 @@ public class ReadDateService {
50 51
             d.setTimestr(timestr);
51 52
             for (TReadDate rd : list) {
52 53
                 datenum.add(rd.getWeeknum());
54
+                if (rd.getReadable().equals(1)) {
55
+                    readable = 1;
56
+                }
53 57
             }
54 58
             d.setDatenum(datenum);
55 59
             dates.add(d);
56 60
         }
61
+        tRead.setReadable(readable);
57 62
         tRead.setDates(dates);
63
+        return readable;
58 64
     }
59 65
 
60 66
     public void insertList(List<TReadDate> dateList) {

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

@@ -271,4 +271,15 @@ public class ReadService {
271 271
         readDateService.setReads(reads);//关联阅读开放时间
272 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,6 +8,8 @@
8 8
     <!--根据阅读id获取阅读开放时间-->
9 9
     <select id="listByReadId" resultType="com.xhkjedu.sapi.model.itemtool.TReadDate">
10 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 13
         from t_read_date where readid=#{readid}
12 14
     </select>
13 15
 </mapper>

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

@@ -375,4 +375,12 @@ public class UserController {
375 375
         user.setLoginname(map.get("loginname").toString());
376 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,4 +174,7 @@ public interface UserMapper extends TkMapper<TUser> {
174 174
 
175 175
     //用户选择列表
176 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,6 +45,9 @@ public class TUser extends BaseBean {
45 45
     //头像地址
46 46
     private String headpic;
47 47
 
48
+    //修改头像时间
49
+    private Integer headtime;
50
+
48 51
     //用户类型999超级管理员0学校管理员1老师2学生
49 52
     private Integer usertype;
50 53
 

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

@@ -743,4 +743,15 @@ public class UserService extends JedisUtil {
743 743
 
744 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,7 +60,7 @@
60 60
     </update>
61 61
     <!--修改用户头像-->
62 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 64
     </update>
65 65
     <!--检查登录账号是否存在-->
66 66
     <select id="checkLoginName" resultType="java.lang.Integer">
@@ -162,6 +162,11 @@
162 162
         group by u.userid
163 163
         order by convert(u.username using gbk)
164 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 172
 </mapper>

Loading…
Cancel
Save