package com.sxl.controller.admin; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import com.sxl.controller.MyController; @Controller("bkController") @RequestMapping(value = "/admin/bk") public class BkController extends MyController { @RequestMapping(value = "/frame") public String frame(Model model, HttpServletRequest request,String flag)throws Exception { return "/admin/bk/frame"; } @RequestMapping(value = "/list") public String list(Model model, HttpServletRequest request,String flag,String bkName)throws Exception { String sql="select a.* from t_bk a where 1=1"; if(bkName!=null&&!"".equals(bkName)){ sql+=" and bkName like '%"+bkName+"%'"; } sql+=" order by id desc"; List list = db.queryForList(sql); request.setAttribute("list", list); return "/admin/bk/list"; } @RequestMapping(value = "/editSave") public ResponseEntity<String> editSave(Model model,HttpServletRequest request,Long id,String flag ,String bkName) throws Exception{ int result = 0; if(id!=null){ String sql="update t_bk set bkName=? where id=?"; result = db.update(sql, new Object[]{bkName,id}); }else{ String sql="insert into t_bk(bkName) values(?)"; result = db.update(sql, new Object[]{bkName}); } if(result==1){ return renderData(true,"操作成功",null); }else{ return renderData(false,"操作失败",null); } } @RequestMapping(value = "/editDelete") public ResponseEntity<String> editDelete(Model model,HttpServletRequest request,Long id,String flag) throws Exception { String sql="delete from t_bk where id=?"; int result = db.update(sql, new Object[]{id}); if(result==1){ return renderData(true,"操作成功",null); }else{ return renderData(false,"操作失败",null); } } @RequestMapping(value = "/edit") public String edit(Model model, HttpServletRequest request,Long id,String flag)throws Exception { if(id!=null){ //修改 String sql="select * from t_bk where id=?"; Map map = db.queryForMap(sql,new Object[]{id}); model.addAttribute("map", map); }String sql=""; return "/admin/bk/edit"; } }