一.CMS
1.CMS, Content Management System, 内容管理系统. 用于对前台系统中的内容进行管理, 例如广告信息的管理, 公告管理, 楼层管理, 活动信息管理…
2.实际开发中, CMS应该是一个独立的系统. 百战商城中, CMS被嵌入到后台管理系统中.内容管理局限于大广告信息管理.
3.涉及到的数据库表格
a)tb_content_category, 内容类目表.
b)tb_content, 内容表
二.内容类目管理
1.内容类目列表查询
1.1页面分析
content-category.jsp
1.2控制器
@RestController
@RequestMapping("/content/category")
public class ContentCatController {
@Autowired
private ContentCatService contentCatService;
/**
* 根据父id查询内容类目列表
*
* @param pid
* @return
*/
@GetMapping("/list")
public List<EasyTreeNode> contentCatList(
@RequestParam(value = "id", defaultValue = "0") long pid) {
return contentCatService.contentCatList(pid);
}
}
1.3后台系统服务代码
public interface ContentCatService {
/**
* 内容类目列表查询
*
* @param pid
* @return
*/
List<EasyTreeNode> contentCatList(long pid);
}
@Service
public class ContentCatServiceImpl implements ContentCatService {
@Autowired
private RpcContentCatService rpcContentCatService;
@Override
public List<EasyTreeNode> contentCatList(long pid) {
// 准备要返回的结果对象
List<EasyTreeNode> list = new ArrayList<>();
try {
// 远程调用获取结果
RpcResult<List<ContentCategory>> result =
rpcContentCatService.contentCatListByPid(pid);
// 判断结果状态, 进行类型转换
if(result.getStatus() == 200) {
// 获取数据
List<ContentCategory> data = result.getData();
for (ContentCategory category : data) {
EasyTreeNode node = new EasyTreeNode();
node.setId(category.getId());
node.setText(category.getName());
node.setState(category.getIsParent() ? "closed" : "open");
list.add(node);
}
}
} catch (Exception e) {
e.printStackTrace();
}
// 返回结果
return list;
}
}
1.4RPC系统服务代码
public interface RpcContentCatService {
/**
* 根据父类目id查询类目列表信息
*
* @param pid
* @return
*/
RpcResult<List<ContentCategory>> contentCatListByPid(long pid)