首页>代码>基于Spring Boot+Spring Data Jpa+apache shiro+easyui+bootstrap开发的电影推酷网站源码>/src/main/java/com/java1234/controller/admin/LinkAdminController.java
package com.java1234.controller.admin;

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

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.java1234.entity.Link;
import com.java1234.init.InitSystem;
import com.java1234.service.LinkService;


/**
 * 友情链接Controller类
 * @author Administrator
 *
 */
@RestController
@RequestMapping(value = "/admin/link")
public class LinkAdminController {

	@Resource
	private LinkService linkService;
	
	@Resource
	private InitSystem initSystem;
	
	/**
	 * 分页查询友情链接
	 * @param page
	 * @param rows
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping("/list")
	public Map<String,Object> list(@RequestParam(value="page",required=false)Integer page,@RequestParam(value="rows",required=false)Integer rows)throws Exception{
		List<Link> linkList=linkService.list(page-1,rows);
		Long total=linkService.getCount();
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("rows", linkList);
		resultMap.put("total", total);
		return resultMap;
	}
	
	/**
	 * 添加或者修改友情链接
	 * @param link
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping("/save")
	public Map<String,Object> save(Link link,HttpServletRequest request)throws Exception{
		Map<String, Object> resultMap = new HashMap<>();
		linkService.save(link);
		initSystem.loadData(request.getServletContext());
		resultMap.put("success", true);
		return resultMap;
	}
	
	/**
	 * 删除友情链接信息
	 * @param ids
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping("/delete")
	public Map<String,Object> delete(@RequestParam(value="ids")String ids,HttpServletRequest request)throws Exception{
		String []idsStr=ids.split(",");
		Map<String, Object> resultMap = new HashMap<>();
		for(int i=0;i<idsStr.length;i++){
			linkService.delete(Integer.parseInt(idsStr[i]));				
		}
		initSystem.loadData(request.getServletContext());
		resultMap.put("success", true);
		return resultMap;
	}
	
}
最近下载更多
admin_z  LV22 2023年12月26日
huyuxin  LV3 2023年12月10日
chj173  LV1 2023年5月30日
qiangmin1223  LV12 2023年4月22日
计算机暴龙战士  LV19 2023年4月2日
admin115  LV6 2022年11月19日
1025490081  LV2 2022年11月7日
testuser1234567  LV24 2022年6月30日
877549024  LV8 2022年4月21日
AlanLi  LV19 2022年4月8日
最近浏览更多
yyhrhv  LV8 2024年9月3日
wyyz5211314  LV4 2024年4月23日
暂无贡献等级
微信网友_6927932988952576  LV12 2024年3月31日
Denck1111 2024年3月27日
暂无贡献等级
zolscy  LV24 2024年3月24日
ming_123_9715  LV23 2024年3月8日
暂无贡献等级
fzlzxc  LV10 2024年1月23日
小草12345 2023年12月26日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友