admin
2021-01-04 aa6ef62aef83e277d4171df1d9f0803f91738216
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package com.newvideo.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.newvideo.domain.entity.ReturnResult;
import com.newvideo.domain.shop.ShopGoodsItem;
import com.newvideo.service.imp.shop.ShopService;
import com.newvideo.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);
        }
    }
 
}