package com.dian.controller;

import com.dian.domain.Leixing; import com.dian.service.LeixingService; import com.dian.type.ResponseType; import com.dian.util.FastjsonUtils; import com.dian.vo.ResponseVo; import com.github.pagehelper.Page; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody;

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

/**

  • @Author www.lifedian.com */ @Controller @RequestMapping(value = '/leixing', produces = {'application/json;charset=UTF-8'}) public class LeixingController extends BaseController { @Resource private LeixingService leixingService;

    @RequestMapping(value = '/page/add') public String addPage() { return '/leixing/leixing_add'; } //查询 @RequestMapping(value = '/query') public String query(HttpServletRequest request, @RequestParam(required = false, defaultValue = '1') int startId, @RequestParam(required = false, defaultValue = '1') int pageIndex, @RequestParam(required = false, defaultValue = '10') int pageSize, ModelMap modelMap) { Page result = leixingService.selectByPage(startId, pageIndex, pageSize); modelMap.put('leixingList', result.getResult()); modelMap.put('page', getPageInfo(result).getHtml()); return '/leixing/leixing_list'; } //添加 @RequestMapping(value = '/add', method = RequestMethod.POST) @ResponseBody public String editTiku(HttpServletRequest request, Leixing leixing, ModelMap modelMap) { if (leixing.getId() == null) { modelMap.put('result', new ResponseVo(leixingService.insertSelective(leixing) ? ResponseType.ADD_SUCCESS : ResponseType.ADD_FAIL)); } return FastjsonUtils.serialize(modelMap); } //删除 @RequestMapping(value = '/del/{id}') @ResponseBody public String del(@PathVariable Integer id, ModelMap modelMap) { Leixing leixing = new Leixing(); leixing.setId(id); //直接删除 boolean result = leixingService.deleteByPrimaryKey(id); //更新删除 modelMap.put('result', new ResponseVo(result ? ResponseType.DEL_SUCCESS : ResponseType.DEL_FAIL)); return FastjsonUtils.serialize(modelMap); } //编辑 @RequestMapping(value = '/edit', method = RequestMethod.POST) @ResponseBody public String edit(HttpServletRequest request, Leixing leixing, ModelMap modelMap) { modelMap.put('result', new ResponseVo(leixingService.updateByPrimaryKeySelective(leixing) ? ResponseType.EDIT_SUCCESS : ResponseType.EDIT_FAIL)); return FastjsonUtils.serialize(modelMap); }

    @RequestMapping(value = '/page/edit/{id}') public String editTiku(@PathVariable Integer id, ModelMap modelMap) { Leixing result = leixingService.selectByPrimaryKey(id); modelMap.put('result', result); return '/leixing/leixing_edit'; } }

Leixing 管理系统 - 添加、查询、删除、编辑 Leixing

原文地址: https://www.cveoy.top/t/topic/kLw3 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录