Commit 7c8e7a55 by wangjf

fix

parent 97c1aeb9
...@@ -139,11 +139,10 @@ public class ResultController { ...@@ -139,11 +139,10 @@ public class ResultController {
@PostMapping("/list") @PostMapping("/list")
@ResponseBody @ResponseBody
public PageUtil list(@SessionAttribute(WebSecurityConfig.SESSION_KEY) String username, @RequestBody Query query) public PageUtil list(@SessionAttribute(WebSecurityConfig.SESSION_KEY) String username, @RequestBody Query query) {
throws IOException {
PageHelper.startPage(query.getOffset() / query.getLimit() + 1, query.getLimit()); PageHelper.startPage(query.getOffset() / query.getLimit() + 1, query.getLimit());
List<TagResult> results = resultService.list(username); List<TagResult> results = resultService.list(username);
int total = resultDao.count(username); int total = resultService.count(username);
PageUtil pageUtil = new PageUtil(results, total); PageUtil pageUtil = new PageUtil(results, total);
return pageUtil; return pageUtil;
} }
......
...@@ -15,29 +15,42 @@ import org.apache.ibatis.annotations.Select; ...@@ -15,29 +15,42 @@ import org.apache.ibatis.annotations.Select;
public interface ResultDao { public interface ResultDao {
@Insert("REPLACE INTO tag_result(package_name,app_name,platform,feat_id,comment,user_id,update_time) VALUES(#{packageName}, #{appName}, #{platform}, #{featId}, #{comment}, #{userId}, #{updateTime})") @Insert("REPLACE INTO tag_result(package_name,app_name,platform,feat_id,comment,user_id,update_time) VALUES(#{packageName}, #{appName}, #{platform}, #{featId}, #{comment}, #{userId}, #{updateTime})")
boolean save(TagResult tagResult); boolean save(TagResult tagResult);
@Select("SELECT * FROM tag_result WHERE package_name = #{packageName}") @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 = "appName", column = "app_name"),
@Result(property = "platform", column = "platform"), @Result(property = "platform", column = "platform"),
@Result(property = "featId", column = "feat_id"), @Result(property = "featId", column = "feat_id"),
@Result(property = "comments", column = "comments"), @Result(property = "comments", column = "comments"),
@Result(property = "userId", column = "user_id"), @Result(property = "userId", column = "user_id"),
@Result(property = "updateTime", column = "update_time") }) @Result(property = "updateTime", column = "update_time")})
TagResult find(String packageName); TagResult find(String packageName);
@Select("SELECT * FROM tag_result WHERE user_id = #{userId}") @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 = "appName", column = "app_name"),
@Result(property = "platform", column = "platform"), @Result(property = "platform", column = "platform"),
@Result(property = "featId", column = "feat_id"), @Result(property = "featId", column = "feat_id"),
@Result(property = "comments", column = "comments"), @Result(property = "comments", column = "comments"),
@Result(property = "userId", column = "user_id"), @Result(property = "userId", column = "user_id"),
@Result(property = "updateTime", column = "update_time") }) @Result(property = "updateTime", column = "update_time")})
List<TagResult> list(String userId); List<TagResult> list(String userId);
@Select("SELECT COUNT(1) FROM tag_result WHERE user_id = #{userId}") @Select("SELECT * FROM tag_result")
int count(String userId); @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 { ...@@ -17,4 +17,5 @@ public interface ResultService {
List<TagResult> list(String userId); List<TagResult> list(String userId);
int count(String userId);
} }
\ No newline at end of file
...@@ -63,7 +63,14 @@ public class ResultServiceImpl implements ResultService { ...@@ -63,7 +63,14 @@ public class ResultServiceImpl implements ResultService {
@Override @Override
public List<TagResult> list(String userId) { 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<>(); List<TagResult> results2 = new ArrayList<>();
for (TagResult result : results) { for (TagResult result : results) {
JSONObject jsonObject = JSONObject.parseObject(result.getFeatId()); JSONObject jsonObject = JSONObject.parseObject(result.getFeatId());
...@@ -72,4 +79,14 @@ public class ResultServiceImpl implements ResultService { ...@@ -72,4 +79,14 @@ public class ResultServiceImpl implements ResultService {
} }
return results2; 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