package com.yeshi.buwan.controller.admin.api;
|
|
import java.io.PrintWriter;
|
import java.util.List;
|
|
import javax.annotation.Resource;
|
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import com.google.gson.Gson;
|
import com.google.gson.GsonBuilder;
|
import com.yeshi.buwan.domain.entity.ReturnResult;
|
import com.yeshi.buwan.domain.shop.ShopGoodsItem;
|
import com.yeshi.buwan.service.imp.shop.ShopService;
|
import com.yeshi.buwan.web.tag.PageEntity;
|
|
import net.sf.json.JSONObject;
|
|
@Controller
|
@RequestMapping("admin/new/api/found")
|
public class FoundController {
|
|
@Resource
|
private ShopService shopService;
|
|
@RequestMapping(value = "/shop/itemlist", method = RequestMethod.POST)
|
public void itemList(int page, int show, String key, PrintWriter out) {
|
System.out.println(key);
|
ReturnResult ss = shopService.getGoodsListAdmin(page, key, show);
|
List<ShopGoodsItem> list = (List<ShopGoodsItem>) ss.getResult();
|
long count = ss.getCode();
|
PageEntity entity = new PageEntity();
|
entity.setPageIndex(page);
|
entity.setPageSize(20);
|
entity.setTotalCount((int) count);
|
Gson gson = new GsonBuilder().create();
|
JSONObject data = new JSONObject();
|
data.put("data", gson.toJson(list));
|
data.put("pageEntity", entity);
|
|
JSONObject object = new JSONObject();
|
object.put("code", 0);
|
object.put("data", data);
|
out.print(object);
|
}
|
|
@RequestMapping(value = "/shop/updateitem", method = RequestMethod.POST)
|
public void updateitem(long id, String title, int show, int orderby, PrintWriter out) {
|
if (shopService.updateGoodsItem(id, show, orderby, title)) {
|
JSONObject object = new JSONObject();
|
object.put("code", 0);
|
object.put("msg", "更改成功");
|
out.print(object);
|
} else {
|
JSONObject object = new JSONObject();
|
object.put("code", 1);
|
object.put("msg", "更改失败");
|
out.print(object);
|
}
|
}
|
|
@RequestMapping(value = "/shop/deleteitem", method = RequestMethod.POST)
|
public void updateitem(long id, PrintWriter out) {
|
if (shopService.deleteGoodsItem(id)) {
|
JSONObject object = new JSONObject();
|
object.put("code", 0);
|
object.put("msg", "删除成功");
|
out.print(object);
|
} else {
|
JSONObject object = new JSONObject();
|
object.put("code", 1);
|
object.put("msg", "删除失败");
|
out.print(object);
|
}
|
}
|
|
}
|