更改返回标签

This commit is contained in:
cyk
2023-07-10 10:16:57 +08:00
parent f816d065e6
commit 4bd10efebd
2 changed files with 8 additions and 7 deletions

View File

@@ -131,18 +131,19 @@ public class UserDao {
String sql = "select searchHistory from user where userName=? and isValid = 1";
userEntity = runner.query(conn, sql, new BeanHandler<>(userEntity.class),name);
l = userEntity.getSearchHistory().split(";");
for(int i=0;i<l.length;i++)
List<String> sss= new ArrayList<>(Arrays.asList(l));
for(int i=0;i<sss.size();i++)
{
if(l[i].equals(str))
if(sss.get(i).equals(str))
{
l[i]="";
sss.remove(i);
break;
}
}
label = String.join(";",l)+";";
if(l.length == 1)
if(sss.size()!=0)
{
label = String.join(";",sss)+";";
}else{
label="";
}
sql="UPDATE user SET searchHistory = ? WHERE userName= ?";

View File

@@ -44,7 +44,7 @@ public class selectUserLabelServlet extends HttpServlet {
String name = userEntity.getUserName();
List<String> stringList = userService.selectLabel(name);
if(stringList.get(0).equals("无搜索历史")){
writer.println(jsonString);
writer.println("null");
}
else{
jsonString = JSONObject.toJSONString(stringList);