首页展示用户公开网站
This commit is contained in:
parent
165170af97
commit
b8b2e03585
@ -182,6 +182,100 @@ public class UrlAndCateController {
|
|||||||
}
|
}
|
||||||
return JSONObject.toJSONString(result);
|
return JSONObject.toJSONString(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/disposeBookmarkExhibitedToJson")
|
||||||
|
public String disposeBookmarkExhibitedToJson()
|
||||||
|
{
|
||||||
|
|
||||||
|
List<UrlList> urlLists = urlListService.selectUrListByNeedLogin();
|
||||||
|
List<CateAndUrl> cateAndUrlList = new ArrayList<>();
|
||||||
|
Set<String> parentSet = new HashSet<>();
|
||||||
|
for( int i = 0 ; i < urlLists.size() ; i++)
|
||||||
|
{
|
||||||
|
CateAndUrl cateAndUrl = new CateAndUrl();
|
||||||
|
cateAndUrl.setFloder("false");
|
||||||
|
cateAndUrl.setName(urlLists.get(i).getName());
|
||||||
|
cateAndUrl.setParentId(urlLists.get(i).getCateId());
|
||||||
|
cateAndUrl.setUrlId(urlLists.get(i).getId());
|
||||||
|
cateAndUrlList.add(cateAndUrl);
|
||||||
|
String parentString = urlCateListService.selectUrListCateByUrlCateId(urlLists.get(i).getCateId());
|
||||||
|
String [] parentList = parentString.split(",");
|
||||||
|
for(String parent : parentList)
|
||||||
|
{
|
||||||
|
if(parent.equals("0")){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
parentSet.add(parent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String str : parentSet) {
|
||||||
|
UrlCateList urlCateList =urlCateListService.selectByPrimaryKey(Integer.valueOf(str));
|
||||||
|
CateAndUrl cateAndUrl = new CateAndUrl();
|
||||||
|
cateAndUrl.setFloder("true");
|
||||||
|
cateAndUrl.setName(urlCateList.getName());
|
||||||
|
cateAndUrl.setParentId(urlCateList.getRootCateId());
|
||||||
|
cateAndUrl.setCateId(urlCateList.getId());
|
||||||
|
cateAndUrlList.add(cateAndUrl);
|
||||||
|
}
|
||||||
|
Collections.reverse(cateAndUrlList);
|
||||||
|
|
||||||
|
List<CateAndUrl> parentsList = new ArrayList<>();
|
||||||
|
//声明返回集合
|
||||||
|
List<CateAndUrl> resultList = new ArrayList<>();
|
||||||
|
//对全部数据进行遍历
|
||||||
|
for (CateAndUrl disease : cateAndUrlList) {
|
||||||
|
//判断是否是第一梯队,或者说是树的根节点,如果是根节点就加入到父类集合与返回集合
|
||||||
|
if (disease.getParentId() == 0) {
|
||||||
|
parentsList.add(disease);
|
||||||
|
resultList.add(disease);
|
||||||
|
} else {
|
||||||
|
//对于不是第一梯队的数据进行遍历
|
||||||
|
for (CateAndUrl parent : parentsList) {
|
||||||
|
//对数据的pid与父类集合中的父节点进行配对,如果配对成功,就把数据加入到父节点中的子节点集合
|
||||||
|
|
||||||
|
if (parent.getFloder().equals("true") ) {
|
||||||
|
if( parent.getCateId() == disease.getParentId())
|
||||||
|
{
|
||||||
|
parent.getChildUC().add(disease);
|
||||||
|
//当前数据有可能是别的数据的父节点,加到父类容器
|
||||||
|
parentsList.add(disease);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (parent.getFloder().equals("false") ) {
|
||||||
|
if(parent.getUrlId() == disease.getParentId())
|
||||||
|
{
|
||||||
|
parent.getChildUC().add(disease);
|
||||||
|
//当前数据有可能是别的数据的父节点,加到父类容器
|
||||||
|
parentsList.add(disease);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
String Json;
|
||||||
|
HashMap<String, Object> result = new HashMap<>();
|
||||||
|
// java对象转换为json字符换
|
||||||
|
try {
|
||||||
|
Json = mapper.writeValueAsString(resultList);
|
||||||
|
result.put("code", 200);
|
||||||
|
result.put("msg", "处理成功");
|
||||||
|
result.put("data", resultList);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return JSONObject.toJSONString(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String setResult(Integer code, String msg) {
|
public String setResult(Integer code, String msg) {
|
||||||
HashMap<String, Object> result = new HashMap<>();
|
HashMap<String, Object> result = new HashMap<>();
|
||||||
result.put("code", code);
|
result.put("code", code);
|
||||||
|
@ -30,4 +30,5 @@ public interface UrlCateListDao {
|
|||||||
|
|
||||||
|
|
||||||
public List<UrlCateList> selectUrListByUserId(Integer userId);
|
public List<UrlCateList> selectUrListByUserId(Integer userId);
|
||||||
|
public String selectUrListCateByUrlCateId(Integer cateId);
|
||||||
}
|
}
|
@ -29,5 +29,7 @@ public interface UrlListDao {
|
|||||||
|
|
||||||
public UrlList selectUrlListByUrlId(Long urlId);
|
public UrlList selectUrlListByUrlId(Long urlId);
|
||||||
|
|
||||||
|
public List<UrlList> selectUrListByNeedLogin();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -14,4 +14,7 @@ public interface UrlCateListService {
|
|||||||
public String countCateContainUrlNumber(String userId);
|
public String countCateContainUrlNumber(String userId);
|
||||||
|
|
||||||
public JSONArray getUrl(String userId);
|
public JSONArray getUrl(String userId);
|
||||||
|
public String selectUrListCateByUrlCateId(Integer cateId);
|
||||||
|
public UrlCateList selectByPrimaryKey(Integer id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,5 +13,5 @@ public interface UrlListService {
|
|||||||
|
|
||||||
public int updateUrlStatusListById(UrlList urlList);
|
public int updateUrlStatusListById(UrlList urlList);
|
||||||
|
|
||||||
|
public List<UrlList> selectUrListByNeedLogin();
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,14 @@ public class UrlCateListServiceImpl implements UrlCateListService {
|
|||||||
return urlCateListDao.selectUrListByUserId(userId);
|
return urlCateListDao.selectUrListByUserId(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String selectUrListCateByUrlCateId(Integer cateId){
|
||||||
|
return urlCateListDao.selectUrListCateByUrlCateId(cateId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UrlCateList selectByPrimaryKey(Integer id)
|
||||||
|
{
|
||||||
|
return urlCateListDao.selectByPrimaryKey(id);
|
||||||
|
}
|
||||||
|
|
||||||
public String countCateContainUrlNumber(String email){
|
public String countCateContainUrlNumber(String email){
|
||||||
User user = userDao.selectByEmail(email);
|
User user = userDao.selectByEmail(email);
|
||||||
|
@ -49,6 +49,13 @@ public class UrlLiserServiceImpl implements UrlListService {
|
|||||||
return urlListDao.selectUrList();
|
return urlListDao.selectUrList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<UrlList> selectUrListByNeedLogin(){
|
||||||
|
return urlListDao.selectUrListByNeedLogin();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public UrlList selectUrListByInput(String input)
|
public UrlList selectUrListByInput(String input)
|
||||||
{
|
{
|
||||||
return urlListDao.selectUrListByInput(input);
|
return urlListDao.selectUrListByInput(input);
|
||||||
|
@ -13,6 +13,10 @@
|
|||||||
<result column="root_cate_id" jdbcType="INTEGER" property="rootCateId" />
|
<result column="root_cate_id" jdbcType="INTEGER" property="rootCateId" />
|
||||||
<result column="ico" jdbcType="VARCHAR" property="ico" />
|
<result column="ico" jdbcType="VARCHAR" property="ico" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, `name`, createtime, url_number, weigh, `status`, need_login, user_id, root_cate_id,
|
id, `name`, createtime, url_number, weigh, `status`, need_login, user_id, root_cate_id,
|
||||||
ico
|
ico
|
||||||
@ -38,6 +42,16 @@
|
|||||||
where name = #{name ,jdbcType=VARCHAR} and user_id = #{userId,jdbcType=INTEGER}
|
where name = #{name ,jdbcType=VARCHAR} and user_id = #{userId,jdbcType=INTEGER}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectUrListCateByUrlCateId" parameterType="java.lang.Integer" resultType="java.lang.String">
|
||||||
|
SELECT t3.isparent
|
||||||
|
FROM(SELECT t1.*,
|
||||||
|
IF (FIND_IN_SET(id, @ids) > 0,@ids := CONCAT( root_cate_id,',', @ids),'0') AS isparent
|
||||||
|
FROM(SELECT t.id,t.root_cate_id,t.name
|
||||||
|
FROM ln_url_cate_list AS t
|
||||||
|
ORDER BY t.id DESC) t1,
|
||||||
|
(SELECT @ids := #{cateId ,jdbcType=INTEGER}) t2) t3
|
||||||
|
WHERE t3.isparent != '0' and t3.id =#{cateId ,jdbcType=INTEGER}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||||
|
@ -37,6 +37,13 @@
|
|||||||
from ln_url_list
|
from ln_url_list
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectUrListByNeedLogin" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
from ln_url_list
|
||||||
|
where need_login = 1
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectUrListByInput" parameterType="java.lang.String" resultMap="BaseResultMap">
|
<select id="selectUrListByInput" parameterType="java.lang.String" resultMap="BaseResultMap">
|
||||||
select
|
select
|
||||||
<include refid="Base_Column_List" />
|
<include refid="Base_Column_List" />
|
||||||
|
Loading…
Reference in New Issue
Block a user