百战商城(五)-CMS系统

一.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)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值