首页>代码>SSM+bootstrap+jquery+maven编写的进存销后台管理系统>/HBtest/src/main/java/org/shop/controller/FenLeiController.java
package org.shop.controller;

import java.util.List;

import org.shop.pojo.FenLei;
import org.shop.service.FenLeiService;
import org.shop.utils.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Controller
@RequestMapping("/fenlei")
public class FenLeiController {
	
	@Autowired
	FenLeiService fenLeiService;

	@RequestMapping("/top.do")
	public String top() {
		return "/fenlei/top";
	}
	
	@RequestMapping("/base.do")
	public String base() {
		return "/fenlei/base";
	}
	
	@RequestMapping("/seebase.do")
	public String seebase() {
		return "/fenlei/seebase";
	}
	
	@RequestMapping("/addbase.do")
	public String addbase() {
		return "/fenlei/addbase";
	}
	
	@ResponseBody
	@RequestMapping("/getFenleiXinXi.do")
	public Msg getFenleiXinXi(int pn) {
		//开启分页
		PageHelper.startPage(pn, 5);
		List<FenLei> list = fenLeiService.selectAll();
		PageInfo pageInfo = new PageInfo(list,5);
		return Msg.success().add("pageInfo", pageInfo);
	}
	
	@ResponseBody
	@RequestMapping("/select.do")
	public Msg getselect(FenLei fenlei) {
		System.out.println("---------------------------------->:"+fenlei);
		PageHelper.startPage(1, 5);
		List<FenLei> list = fenLeiService.selectOne(fenlei);
		System.out.println(list.size());
		PageInfo pageInfo = new PageInfo(list,5);
		if(list.size()!=0) {
			return Msg.success().add("pageInfo", pageInfo);
		}else {
			return Msg.file();
		}
	//	PageInfo pageInfo = new PageInfo(list,5);
	//	return Msg.success().add("pageInfo", pageInfo);
	}
	
	//添加数据
	@ResponseBody
	@RequestMapping("/insert.do")
	public Msg getinsert(FenLei fenlei) {
		System.out.println("---------------------------->:"+fenlei);
		//首先要查询数据库中是否已经有改编号的数据了
		int deptId = fenLeiService.selectByKey(fenlei);
	//	System.out.println("++++++++++++++++"+deptest);
		if(deptId!=0) {
			return Msg.idCFfile();
		}
		int deptName = fenLeiService.selectByNameKey(fenlei);
		if(deptName!=0) {
			return Msg.nameCFfile();
		}
		int dept = fenLeiService.insert(fenlei);
		if(dept==1) {
			return Msg.success();
		}else {
			return Msg.file();
		}
	}
	//修改数据
	@ResponseBody
	@RequestMapping("/update.do")
	public Msg getupdate(FenLei fenlei) {
		System.out.println("------------------------->:"+fenlei);
		int dept = fenLeiService.update(fenlei);
		if(dept==1) {
			return Msg.success();
		}else {
			return Msg.file();
		}
	}
	//删除数据
	@ResponseBody
	@RequestMapping("/delete.do")
	public Msg getdelete(int sortId) {
		System.out.println("-------------------------->:"+sortId);
		int dept = fenLeiService.delete(sortId);
		if(dept==1) {
			return Msg.success();
		}else {
			return Msg.file();
		}
	}
}
最近下载更多
飞翔的面包片  LV12 2023年2月15日
184445428  LV6 2022年11月29日
微信网友_6164511365238784  LV7 2022年10月10日
wuying8208  LV15 2022年6月7日
*  LV4 2022年5月17日
wanglinddad  LV54 2022年3月9日
暖茶1234  LV8 2021年9月14日
2105175744  LV1 2021年7月16日
862960632  LV14 2021年6月16日
浅陌  LV7 2021年6月7日
最近浏览更多
sunlea  LV17 3月21日
black8angel  LV4 2023年12月22日
shuangfu  LV25 2023年12月2日
uni-code_0123  LV1 2023年11月27日
阳光男孩阿葵 2023年7月14日
暂无贡献等级
c469893928  LV2 2023年6月10日
刘春涛  LV2 2023年6月2日
哇塞塞哈哈哈  LV8 2023年5月5日
cuberbread  LV6 2023年3月23日
飞翔的面包片  LV12 2023年2月15日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友