Commit 7c8e7a55 by wangjf

fix

parent 97c1aeb9
......@@ -139,11 +139,10 @@ public class ResultController {
@PostMapping("/list")
@ResponseBody
public PageUtil list(@SessionAttribute(WebSecurityConfig.SESSION_KEY) String username, @RequestBody Query query)
throws IOException {
public PageUtil list(@SessionAttribute(WebSecurityConfig.SESSION_KEY) String username, @RequestBody Query query) {
PageHelper.startPage(query.getOffset() / query.getLimit() + 1, query.getLimit());
List<TagResult> results = resultService.list(username);
int total = resultDao.count(username);
int total = resultService.count(username);
PageUtil pageUtil = new PageUtil(results, total);
return pageUtil;
}
......
......@@ -19,25 +19,38 @@ public interface ResultDao {
boolean save(TagResult tagResult);
@Select("SELECT * FROM tag_result WHERE package_name = #{packageName}")
@Results({ @Result(property = "packageName", column = "package_name"),
@Results({@Result(property = "packageName", column = "package_name"),
@Result(property = "appName", column = "app_name"),
@Result(property = "platform", column = "platform"),
@Result(property = "featId", column = "feat_id"),
@Result(property = "comments", column = "comments"),
@Result(property = "userId", column = "user_id"),
@Result(property = "updateTime", column = "update_time") })
@Result(property = "updateTime", column = "update_time")})
TagResult find(String packageName);
@Select("SELECT * FROM tag_result WHERE user_id = #{userId}")
@Results({ @Result(property = "packageName", column = "package_name"),
@Results({@Result(property = "packageName", column = "package_name"),
@Result(property = "appName", column = "app_name"),
@Result(property = "platform", column = "platform"),
@Result(property = "featId", column = "feat_id"),
@Result(property = "comments", column = "comments"),
@Result(property = "userId", column = "user_id"),
@Result(property = "updateTime", column = "update_time") })
@Result(property = "updateTime", column = "update_time")})
List<TagResult> list(String userId);
@Select("SELECT * FROM tag_result")
@Results({@Result(property = "packageName", column = "package_name"),
@Result(property = "appName", column = "app_name"),
@Result(property = "platform", column = "platform"),
@Result(property = "featId", column = "feat_id"),
@Result(property = "comments", column = "comments"),
@Result(property = "userId", column = "user_id"),
@Result(property = "updateTime", column = "update_time")})
List<TagResult> listAll();
@Select("SELECT COUNT(1) FROM tag_result WHERE user_id = #{userId}")
int count(String userId);
@Select("SELECT COUNT(1) FROM tag_result")
int countAll();
}
\ No newline at end of file
......@@ -17,4 +17,5 @@ public interface ResultService {
List<TagResult> list(String userId);
int count(String userId);
}
\ No newline at end of file
......@@ -63,7 +63,14 @@ public class ResultServiceImpl implements ResultService {
@Override
public List<TagResult> list(String userId) {
List<TagResult> results = resultDao.list(userId);
User user = userDao.find(userId);
List<TagResult> results;
if (user.getRole() == 0) {
results = resultDao.list(userId);
} else {
results = resultDao.listAll();
}
List<TagResult> results2 = new ArrayList<>();
for (TagResult result : results) {
JSONObject jsonObject = JSONObject.parseObject(result.getFeatId());
......@@ -72,4 +79,14 @@ public class ResultServiceImpl implements ResultService {
}
return results2;
}
@Override
public int count(String userId) {
User user = userDao.find(userId);
if (user.getRole() == 0) {
return resultDao.count(userId);
} else {
return resultDao.countAll();
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment