Skip to content

Commit 8d701d2

Browse files
committed
增加接口
1 parent 6c9dd61 commit 8d701d2

File tree

9 files changed

+197
-4
lines changed

9 files changed

+197
-4
lines changed

src/main/java/com/danbai/ys/controller/restful/v1/App.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22

33
import com.alibaba.fastjson.JSONObject;
44
import com.danbai.ys.entity.BaseResult;
5+
import com.danbai.ys.entity.Feedback;
56
import com.danbai.ys.entity.UpdateInfo;
7+
8+
import com.danbai.ys.service.impl.AdminServiceImpl;
9+
import com.danbai.ys.service.impl.CommImpl;
610
import com.danbai.ys.utils.ResultUtil;
711
import org.springframework.beans.factory.annotation.Autowired;
812
import org.springframework.data.redis.core.RedisTemplate;
913
import org.springframework.web.bind.annotation.GetMapping;
14+
import org.springframework.web.bind.annotation.PostMapping;
1015
import org.springframework.web.bind.annotation.RequestMapping;
1116
import org.springframework.web.bind.annotation.RestController;
1217

@@ -20,6 +25,10 @@
2025
public class App {
2126
@Autowired
2227
RedisTemplate redisTemplate;
28+
@Autowired
29+
AdminServiceImpl adminService;
30+
@Autowired
31+
CommImpl comm;
2332
@GetMapping("/update")
2433
public BaseResult update() {
2534
return ResultUtil.success(JSONObject.parseObject((String) redisTemplate.opsForValue().get("appupdate"), UpdateInfo.class));
@@ -28,4 +37,14 @@ public BaseResult update() {
2837
public JSONObject flutter() {
2938
return JSONObject.parseObject((String) redisTemplate.opsForValue().get("flutterAPPUpdate"));
3039
}
40+
@GetMapping("/gg")
41+
public BaseResult gg() {
42+
return ResultUtil.success(adminService.getConfig("appGG"));
43+
}
44+
@PostMapping("/feedback")
45+
public BaseResult feedback(Feedback feedback){
46+
feedback.setDispose(false);
47+
comm.addFeedback(feedback);
48+
return ResultUtil.successOk();
49+
}
3150
}

src/main/java/com/danbai/ys/controller/restful/v1/User.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ public BaseResult thisUser(HttpServletRequest request,Token token) {
4545
* @return BaseResult
4646
*/
4747
@GetMapping("/user/gkls")
48-
public BaseResult thisUserGkls(HttpServletRequest request,Token token) {
48+
public BaseResult thisUserGkls(HttpServletRequest request,Token token,boolean sole) {
4949
if (userService.checkToken(token)){
50-
return ResultUtil.success(ysService.getGkls(token.getUsername()));
50+
if(sole){
51+
return ResultUtil.success(ysService.getGklsSole(token.getUsername()));
52+
}else {
53+
return ResultUtil.success(ysService.getGkls(token.getUsername()));
54+
}
5155
}
5256
com.danbai.ys.entity.User user = (com.danbai.ys.entity.User) request.getSession().getAttribute("user");
5357
if (user != null) {
@@ -60,7 +64,7 @@ public BaseResult token(com.danbai.ys.entity.User user){
6064
return ResultUtil.success(userService.login(user));
6165
}
6266
@DeleteMapping("/token")
63-
public BaseResult login(Token token){
67+
public BaseResult exit(Token token){
6468
userService.deleteToken(token.getUsername());
6569
return ResultUtil.successOk();
6670
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package com.danbai.ys.entity;
2+
3+
import java.util.Date;
4+
import javax.persistence.*;
5+
6+
public class Feedback {
7+
@Id
8+
@GeneratedValue(strategy = GenerationType.IDENTITY)
9+
private Integer id;
10+
11+
private Integer type;//1bug反馈 2求片
12+
13+
private Date time;
14+
15+
private Boolean dispose;
16+
17+
private String content;
18+
19+
/**
20+
* @return id
21+
*/
22+
public Integer getId() {
23+
return id;
24+
}
25+
26+
/**
27+
* @param id
28+
*/
29+
public void setId(Integer id) {
30+
this.id = id;
31+
}
32+
33+
/**
34+
* @return type
35+
*/
36+
public Integer getType() {
37+
return type;
38+
}
39+
40+
/**
41+
* @param type
42+
*/
43+
public void setType(Integer type) {
44+
this.type = type;
45+
}
46+
47+
/**
48+
* @return time
49+
*/
50+
public Date getTime() {
51+
return time;
52+
}
53+
54+
/**
55+
* @param time
56+
*/
57+
public void setTime(Date time) {
58+
this.time = time;
59+
}
60+
61+
/**
62+
* @return dispose
63+
*/
64+
public Boolean getDispose() {
65+
return dispose;
66+
}
67+
68+
/**
69+
* @param dispose
70+
*/
71+
public void setDispose(Boolean dispose) {
72+
this.dispose = dispose;
73+
}
74+
75+
/**
76+
* @return content
77+
*/
78+
public String getContent() {
79+
return content;
80+
}
81+
82+
/**
83+
* @param content
84+
*/
85+
public void setContent(String content) {
86+
this.content = content;
87+
}
88+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.danbai.ys.mapper;
2+
3+
import com.danbai.ys.entity.Feedback;
4+
import com.danbai.ys.utils.MyMapper;
5+
import org.springframework.stereotype.Repository;
6+
7+
@Repository
8+
public interface FeedbackMapper extends MyMapper<Feedback> {
9+
}

src/main/java/com/danbai/ys/service/Comm.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.danbai.ys.service;
22

3+
import com.danbai.ys.entity.Feedback;
4+
35
import java.util.HashMap;
46

57
/**
@@ -11,4 +13,10 @@ public interface Comm {
1113
* @return
1214
*/
1315
HashMap getAllComm();
16+
17+
/**
18+
* 添加反馈
19+
* @param feedback 反馈
20+
*/
21+
void addFeedback(Feedback feedback);
1422
}

src/main/java/com/danbai/ys/service/YsService.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,13 @@ public interface YsService {
113113
* @return List<Gkls>
114114
*/
115115
List<Gkls> getGkls(String username);
116-
116+
/**
117+
* 获取观看历史 不重复
118+
*
119+
* @param username 用户名
120+
* @return List<Gkls>
121+
*/
122+
List<Gkls> getGklsSole(String username);
117123
/**
118124
* 获取影视观看时间
119125
*

src/main/java/com/danbai/ys/service/impl/CommImpl.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.danbai.ys.service.impl;
22

33
import com.danbai.ys.entity.Config;
4+
import com.danbai.ys.entity.Feedback;
5+
import com.danbai.ys.mapper.FeedbackMapper;
46
import com.danbai.ys.service.Comm;
57
import org.springframework.beans.factory.annotation.Autowired;
68
import org.springframework.stereotype.Service;
@@ -16,6 +18,8 @@
1618
public class CommImpl implements Comm {
1719
@Autowired
1820
AdminServiceImpl adminService;
21+
@Autowired
22+
FeedbackMapper feedbackMapper;
1923
@Override
2024
public HashMap getAllComm() {
2125
HashMap<String,Object> map = new HashMap(20);
@@ -26,4 +30,9 @@ public HashMap getAllComm() {
2630
map.put(Config.HEAD,adminService.getConfig(Config.HEAD));
2731
return map;
2832
}
33+
34+
@Override
35+
public void addFeedback(Feedback feedback) {
36+
feedbackMapper.insert(feedback);
37+
}
2938
}

src/main/java/com/danbai/ys/service/impl/YsServiceImpl.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.ArrayList;
2222
import java.util.HashMap;
2323
import java.util.List;
24+
import java.util.concurrent.atomic.AtomicBoolean;
2425

2526

2627
/**
@@ -197,6 +198,41 @@ public List<Gkls> getGkls(String username) {
197198
return list;
198199
}
199200

201+
@Override
202+
public List<Gkls> getGklsSole(String username) {
203+
Example example = new Example(VideoTime.class);
204+
example.createCriteria().andEqualTo("username", username);
205+
example.orderBy("gktime").desc();
206+
List<VideoTime> select = videoTimeMapper.selectByExample(example);
207+
List<Gkls> list = new ArrayList<>();
208+
for (VideoTime v : select) {
209+
if((v.getTime()>30)){
210+
AtomicBoolean in= new AtomicBoolean(false);
211+
list.forEach(gkls -> {
212+
if(gkls.id==v.getYsid()){
213+
in.set(true);
214+
return;
215+
}
216+
});
217+
if(in.get()){
218+
continue;
219+
}
220+
Gkls gkls = new Gkls();
221+
Ysb ysb = selectYsById(v.getYsid());
222+
if (ysb != null) {
223+
gkls.setPm(ysb.getPm());
224+
gkls.setYsimg(ysb.getTp());
225+
}
226+
gkls.setJi(v.getYsjiname());
227+
gkls.setTime(DateUtils.secondToTime(v.getTime().longValue()));
228+
gkls.setGktime(v.getGktime());
229+
gkls.setId(v.getYsid());
230+
list.add(gkls);
231+
}
232+
}
233+
return list;
234+
}
235+
200236
@Override
201237
public HashMap getYsLs(String username, int ysid) {
202238
HashMap<String, String> map = new HashMap<>(30);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3+
<mapper namespace="com.danbai.ys.mapper.FeedbackMapper">
4+
<resultMap id="BaseResultMap" type="com.danbai.ys.entity.Feedback">
5+
<!--
6+
WARNING - @mbg.generated
7+
-->
8+
<id column="id" jdbcType="INTEGER" property="id" />
9+
<result column="type" jdbcType="INTEGER" property="type" />
10+
<result column="time" jdbcType="TIMESTAMP" property="time" />
11+
<result column="dispose" jdbcType="BIT" property="dispose" />
12+
<result column="content" jdbcType="LONGVARCHAR" property="content" />
13+
</resultMap>
14+
</mapper>

0 commit comments

Comments
 (0)