python222网站实战(SpringBoot+SpringSecurity+MybatisPlus+thymeleaf+layui)-友情链接管理实现

锋哥原创的Springboot+Layui python222网站实战:

python222网站实战课程视频教程(SpringBoot+Python爬虫实战) ( 火爆连载更新中... )_哔哩哔哩_bilibilipython222网站实战课程视频教程(SpringBoot+Python爬虫实战) ( 火爆连载更新中... )共计23条视频,包括:python222网站实战课程视频教程(SpringBoot+Python爬虫实战) ( 火爆连载更新中... )、第2讲 架构搭建实现、第3讲 页面系统属性动态化设计实现等,UP主更多精彩视频,请关注UP账号。icon-default.png?t=N7T8https://www.bilibili.com/video/BV1yX4y1a7qM/python222网站实战(SpringBoot+SpringSecurity+MybatisPlus+thymeleaf+layui)-友情链接管理实现_第1张图片

后端:

package com.python222.controller.admin;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.python222.entity.Link;
import com.python222.entity.PageBean;
import com.python222.service.LinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 管理员-友情链接控制器
 * @author Administrator
 *
 */
@RestController
@RequestMapping(value = "/admin/link")
public class LinkAdminController {

   @Autowired
   private LinkService linkService;

   /**
    * 根据条件分页查询友情链接
    * @param page
    * @param limit
    * @return
    * @throws Exception
    */
   @RequestMapping(value = "/list")
   public Map list(@RequestParam(value="page",required=false)Integer page,@RequestParam(value="limit",required=false)Integer limit)throws Exception{
      Map resultMap = new HashMap<>();
      PageBean pageBean=new PageBean(page,limit);
      Page linkPage = linkService.page(new Page<>(pageBean.getPage(), pageBean.getPageSize()));
      resultMap.put("code", 0);
      resultMap.put("count", linkPage.getTotal());
      resultMap.put("data", linkPage.getRecords());
      return resultMap;
   }

   /**
    * 添加或者修改友情链接
    * @param link
    * @return
    */
   @RequestMapping("/save")
   public Map save(Link link){
      if(link.getId()==null){
         linkService.save(link);
      }else{
         linkService.updateById(link);
      }
      Map resultMap = new HashMap<>();
      resultMap.put("success", true);
      return resultMap;
   }

   /**
    * 删除友情链接
    * @param id
    * @return
    * @throws Exception
    */
   @RequestMapping("/delete")
   public Map delete(Integer id)throws Exception{
      Map resultMap = new HashMap<>();
      linkService.removeById(id);
      resultMap.put("success", true);
      return resultMap;
   }

   /**
    * 根据id查询友情链接实体
    * @param id
    * @return
    * @throws Exception
    */
   @RequestMapping("/findById")
   public Map findById(Integer id)throws Exception{
      Map resultMap = new HashMap<>();
      Link link=linkService.getById(id);
      resultMap.put("link", link);
      resultMap.put("success", true);
      return resultMap;
   }
}

前端linkManage.html





友情链接管理






   


   
   


saveLink.html





添加或者修改友情链接




友情链接名称:
友情链接地址:
友情链接描述:
排列序号:   (根据数值从小到大排序)

你可能感兴趣的:(java,spring,boot,layui,java)