AppController.java 2.77 KB
Newer Older
zhangxiaoyan committed
1 2 3 4
package common.controller;

import common.model.AppInfo;
import common.service.AppService;
zhangxiaoyan committed
5
import dic.OperateObjectTypeEnum;
zhangxiaoyan committed
6 7 8 9 10 11 12 13 14
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
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 util.ResultModel;
import util.StringUtil;
zhangxiaoyan committed
15 16 17
import util.UserLogThread;

import javax.servlet.http.HttpServletRequest;
zhangxiaoyan committed
18

zhangxiaoyan committed
19 20 21 22 23 24
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;

zhangxiaoyan committed
25 26 27 28 29 30 31 32 33
/**
 * Created by zxy on 2017/12/27.
 */
@Controller
@RequestMapping("applist")
public class AppController
{
    @Autowired AppService appService;

zhangxiaoyan committed
34
    ///api/applist/find?reyun=&location=%E5%8C%97%E4%BA%AC&firstCate=&secondCate=&pageNum=0&pageSize=20&sortString=pkgName&isASC=1
zhangxiaoyan committed
35 36 37
    @RequestMapping(value = "find", method = RequestMethod.GET)
    @ResponseBody
    public ResultModel findAll(@RequestParam Integer reyun, @RequestParam String location, @RequestParam String firstCate, @RequestParam String secondCate,
zhangxiaoyan committed
38 39
    @RequestParam int pageNum, @RequestParam int pageSize, @RequestParam String sortString, @RequestParam Integer isASC, @RequestParam String searchString,
            @RequestParam String startDate, @RequestParam String endDate) {
zhangxiaoyan committed
40 41 42 43 44
        AppInfo app = new AppInfo();
        app.setLocation(location);
        app.setFirstCate(firstCate);
        app.setSecondCate(secondCate);
        app.setReyun(reyun);
zhangxiaoyan committed
45 46 47 48 49 50 51 52 53 54 55
        Map result = new HashMap();
        try {
            result = appService.findAppList(app, pageNum, pageSize, sortString, isASC, searchString, startDate, endDate);
        }
        catch (ExecutionException e) {
            e.printStackTrace();
        }
        catch (InterruptedException e) {
            e.printStackTrace();
        }
        return ResultModel.OK(result);
zhangxiaoyan committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
    }

    ///api/applist/category/1
    @RequestMapping(value="category/{level}", method = RequestMethod.GET)
    @ResponseBody
    public ResultModel findCategory(@PathVariable int level) {
        return ResultModel.OK(appService.findAllCategoryByLevel(level));
    }

    ///api/applist/city
    @RequestMapping(value = "city", method = RequestMethod.GET)
    @ResponseBody
    public ResultModel findCity() {
        return ResultModel.OK(appService.findCity());
    }
zhangxiaoyan committed
71 72 73 74 75 76

    @RequestMapping(value = "data", method = RequestMethod.GET)
    @ResponseBody
    public ResultModel findDeviceData() {
        return ResultModel.OK(appService.findAppDataList("2017-12-22", "2017-12-22", null, 0, 0, 20));
    }
zhangxiaoyan committed
77
}