package com.ideabobo.action;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import com.google.gson.Gson;
import com.ideabobo.model.Bill;
import com.ideabobo.service.BaseService;
import com.ideabobo.service.BillService;
import com.ideabobo.util.IdeaAction;
import com.ideabobo.util.Page;
@Controller
public class BillAction extends IdeaAction {
@Resource
private BillService billService;
@Resource
private BaseService baseService;
private static final long serialVersionUID = -3218238026025256103L;
private Bill bill;
public Bill getBill() {
return bill;
}
public void setBill(Bill bill) {
this.bill = bill;
}
public String bill(){
return SUCCESS;
}
public void getList(){
String billname = request.getParameter("sgname");
String sort = request.getParameter("sort");
String order = request.getParameter("order");
Page page = new Page();
Map paramsMap = new HashMap();
String roletype = (String) session.get("roletype");
if(roletype.equals("3")){
String sid = (String) session.get("sid");
paramsMap.put("sid",sid);
}
paramsMap.put("billname", billname);
paramsMap.put("sort", "order by "+sort+" "+order);
String pageNo = (String) this.request.getParameter("page");
String pageSizes = (String) this.request.getParameter("rows");
if (pageNo == null) {
page.setPageSize(10);
page.setPageNo(1);
} else {
page.setPageSize(Integer.parseInt(pageSizes));
page.setPageNo(Integer.parseInt(pageNo));
}
page = billService.findByPage(page, paramsMap);
Gson json = new Gson();
Map<String, Object> map = new HashMap<String, Object>();
map.put("total", page.getTotal());
map.put("rows", page.getList());
render(json.toJson(map));
}
public void add(){
String action = request.getParameter("action");
if(bill != null){
if(action.equals("add")){
billService.save(bill);
render("操作成功!");
}else {
String id = request.getParameter("id");
bill.setId(Integer.parseInt(id));
billService.update(bill);
render("操作成功!");
}
}
}
public void deleteItem(){
String id = request.getParameter("id");
billService.delete(Integer.parseInt(id));
render("操作成功");
}
public void jiaohao(){
String bid = request.getParameter("bid");
String statecn = request.getParameter("statecn");
Bill b = (Bill) baseService.find(Integer.parseInt(bid), Bill.class);
b.setStatecn(statecn);
baseService.update(b);
render("success");
}
}
如需定做或者获取更多资料,请联系QQ:375279829