删除网站分类
This commit is contained in:
parent
74df52c3aa
commit
6fdbb36e6b
@ -7,6 +7,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.lovenav.dao.UserDao;
|
||||
import com.lovenav.entity.UrlCateList;
|
||||
import com.lovenav.entity.UrlList;
|
||||
import com.lovenav.service.UrlCateListService;
|
||||
@ -48,8 +49,8 @@ public class UrlAndCateController {
|
||||
|
||||
@Autowired
|
||||
UrlListService urlListService;
|
||||
|
||||
|
||||
@Autowired
|
||||
UserDao userDao;
|
||||
//处理JSON
|
||||
@RequestMapping("/disposeJson")
|
||||
public String disposeJson(@RequestBody String data2 ,String email)
|
||||
@ -605,18 +606,31 @@ public class UrlAndCateController {
|
||||
}
|
||||
|
||||
@RequestMapping("/deleteCateByCateId")
|
||||
public String deleteCateByCateId(String cateId)
|
||||
public String deleteCateByCateId(Integer Id,String userId)
|
||||
{
|
||||
int flag = 0;
|
||||
HashMap<String, Object> result = new HashMap<>();
|
||||
if(flag == 1)
|
||||
{
|
||||
Set<Integer> parentList = new HashSet<>();
|
||||
parentList.add(Integer.valueOf(Id));
|
||||
|
||||
List<String> stringList = urlCateListService.selectChildrenByCateId(Id);
|
||||
|
||||
String childrenString= String.join(",", stringList);
|
||||
String [] strings = childrenString.split(",");
|
||||
Set<String> set = new HashSet<>(Arrays.asList(strings));
|
||||
for(String child : set){
|
||||
if(child.equals("")) {
|
||||
urlListService.deleteByCateId(Long.valueOf(Id));
|
||||
urlCateListService.deleteByPrimaryKey(Id);
|
||||
}else{
|
||||
urlListService.deleteByCateId(Long.valueOf(child));
|
||||
urlCateListService.deleteByPrimaryKey(Integer.valueOf(child));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
urlCateListService.countCateContainUrlNumber(userDao.selectByPrimaryKey(Integer.valueOf(userId)).getUserEmail());
|
||||
result.put("code", 200);
|
||||
result.put("msg", "处理成功");
|
||||
}else{
|
||||
result.put("code", 500);
|
||||
result.put("msg", "处理失败");
|
||||
}
|
||||
return JSONObject.toJSONString(result);
|
||||
}
|
||||
|
||||
|
@ -31,4 +31,7 @@ public interface UrlCateListDao {
|
||||
|
||||
public List<UrlCateList> selectUrListByUserId(Integer userId);
|
||||
public String selectUrListCateByUrlCateId(Integer cateId);
|
||||
|
||||
public List<String> selectChildrenByCateId(Integer id);
|
||||
|
||||
}
|
@ -31,5 +31,5 @@ public interface UrlListDao {
|
||||
|
||||
public List<UrlList> selectUrListByNeedLogin();
|
||||
|
||||
|
||||
public int deleteByCateId(Long id);
|
||||
}
|
@ -20,4 +20,9 @@ public interface UrlCateListService {
|
||||
public int insertSelective(UrlCateList urlCateList);
|
||||
public int updateByUrlCateList(UrlCateList urlCateList);
|
||||
|
||||
|
||||
public List<String> selectChildrenByCateId(Integer id);
|
||||
|
||||
public int deleteByPrimaryKey(Integer id);
|
||||
|
||||
}
|
||||
|
@ -15,4 +15,7 @@ public interface UrlListService {
|
||||
|
||||
public List<UrlList> selectUrListByNeedLogin();
|
||||
public int insertUrlByUser(UrlList urlList);
|
||||
public int deleteByPrimaryKey(Long id);
|
||||
|
||||
public int deleteByCateId(Long id);
|
||||
}
|
||||
|
@ -72,6 +72,14 @@ public class UrlCateListServiceImpl implements UrlCateListService {
|
||||
{
|
||||
return urlCateListDao.updateByPrimaryKeySelective(urlCateList);
|
||||
}
|
||||
|
||||
public List<String> selectChildrenByCateId(Integer id)
|
||||
{
|
||||
return urlCateListDao.selectChildrenByCateId(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public UrlCateList selectByPrimaryKey(Integer id)
|
||||
{
|
||||
return urlCateListDao.selectByPrimaryKey(id);
|
||||
@ -145,4 +153,8 @@ public class UrlCateListServiceImpl implements UrlCateListService {
|
||||
}
|
||||
return jsonArray;
|
||||
}
|
||||
|
||||
public int deleteByPrimaryKey(Integer id){
|
||||
return urlCateListDao.deleteByPrimaryKey(id);
|
||||
}
|
||||
}
|
||||
|
@ -79,4 +79,12 @@ public class UrlLiserServiceImpl implements UrlListService {
|
||||
}
|
||||
|
||||
}
|
||||
public int deleteByPrimaryKey(Long id){
|
||||
return urlListDao.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int deleteByCateId(Long id)
|
||||
{
|
||||
return urlListDao.deleteByCateId(id);
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,19 @@
|
||||
WHERE t3.isparent != '0' and t3.id =#{cateId ,jdbcType=INTEGER}
|
||||
</select>
|
||||
|
||||
<select id="selectChildrenByCateId" parameterType="java.lang.Integer" resultType="java.lang.String">
|
||||
SELECT t3.ischild
|
||||
FROM(SELECT t1.*,
|
||||
IF (FIND_IN_SET(root_cate_id, @pids) > 0,@pids := CONCAT(@pids, ',', id),'0') AS ischild
|
||||
FROM(SELECT t.id,t.root_cate_id
|
||||
FROM ln_url_cate_list AS t
|
||||
ORDER BY t.id ASC) t1,
|
||||
(SELECT @pids := #{id ,jdbcType=INTEGER}) t2) t3
|
||||
WHERE ischild != '0'
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
delete from ln_url_cate_list
|
||||
|
@ -64,6 +64,14 @@
|
||||
delete from ln_url_list
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByCateId" parameterType="java.lang.Long">
|
||||
delete from ln_url_list
|
||||
where cate_id = #{id,jdbcType=BIGINT}
|
||||
</delete>
|
||||
|
||||
|
||||
|
||||
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.lovenav.entity.UrlList" useGeneratedKeys="true">
|
||||
insert into ln_url_list (`name`, icon, cate_id,
|
||||
url, createtime, views,
|
||||
|
Loading…
Reference in New Issue
Block a user