运营后台管理系统接口思路

需求思路


表结构增加room_id,sort_location两个字段,ent生成

线上需要alter table

 

增加接口:

一级分类:如果parent_id=0,直接添加,room_id,sort_location都设为0

二级分类:1.select id from cate where parent_id=0

2.判断传入的parent_Id是否在这个id集合中

1)如果不在,返回err

2)如果在

if parent_id==这个集合中的某个id{
 
 select sort_loaction from cate where parent_id=某id and room_id=传入的room_id
 遍历location集合,找出最大的,在此基础上sort_location+1,同时插入这条数据
}

删除接口:

1.传入id是一级分类,select * from cate where id=传入id 得到的数据的parent_id=0,说明是一类,这条数据需要删除,

同时需要select * from cate where parent_id=传入id,把这个集合也要删掉

2.传入id是二级分类,直接删那条数据就好了

查询接口:

新增的查询接口:

传入的room_id

select * from cate where room_id=传入的room_id group by parent_id

item带上sort_id

修改接口:

新增修改接口:

传入id和sort_id,通过传入id找到room_id和parent_id,select * from cate where room_id= and id=parent_id,取出他们的sort_id列表,假设为[1,2,3,4],如果传入id对应数据的sort_id和传入的sort_id相同,不做操作,如果不同,比如:原id对应数据的sort_id为4,传入的sort_id为1,则update cate set sort_id=1 where id=传入id,同时原来1,2,3对应则依次加1,总结就是,小于原sort_id,大于等于传入sort_id的数据的sort_id依次加1

posted on 2021-12-12 22:56  老师好我叫吴先生  阅读(169)  评论(0)    收藏  举报

导航