content: package com.cn.xmf.job.admin.prize.controller;
  
  import com.alibaba.fastjson.JSON;
  import com.alibaba.fastjson.JSONObject;
  import com.cn.xmf.base.model.Partion;
  import com.cn.xmf.job.admin.prize.rpc.WinnersListService;
  import com.cn.xmf.job.core.biz.model.ReturnT;
  import com.cn.xmf.model.wx.WinnersList;
  import com.cn.xmf.util.StringUtil;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.ResponseBody;
  
  import javax.servlet.http.HttpServletRequest;
  import java.util.List;
  
  /**
   * WinnersListController(获奖名单)
   *
   * @author rufei.cn
   * @version 2020-01-02
   */
  @Controller
  @RequestMapping("/winnersList")
  @SuppressWarnings("all")
  public class WinnersListController {
  
      private static Logger logger = LoggerFactory.getLogger(WinnersListController.class);
      @Autowired
      private WinnersListService winnersListService;
  
      @RequestMapping
      public String index() {
          return "prize/winnersList-index";
      }
  
      /**
       * getList:(获取获奖名单分页查询接口)
       *
       * @param request
       * @return
       * @Author rufei.cn
       */
      @RequestMapping("pageList")
      @ResponseBody
      public JSONObject getList(HttpServletRequest request) {
          JSONObject retJon = new JSONObject();
          JSONObject param = null;
          String type = request.getParameter("type");
          String name = request.getParameter("name");
          String userId = request.getParameter("userId");
          String startStr = request.getParameter("start");
          String length = request.getParameter("length");
          int pageSize = 10;
          int pageNo = 1;
          int start = 0;
          if (StringUtil.isNotBlank(startStr)) {
              start = StringUtil.stringToInt(startStr);
          }
          if (StringUtil.isNotBlank(length)) {
              pageSize = StringUtil.stringToInt(length);
          }
          if (start > 0) {
              pageNo = (start / pageSize) + 1;
          }
          param = StringUtil.getPageJSONObject(pageNo, pageSize);
          logger.info("getList:(获取获奖名单分页查询接口) 开始  param={}", param);
  
          param.put("type", type);
          param.put("name", name);
          param.put("userId", userId);
          Partion pt = winnersListService.getList(param);
          List<WinnersList> list = null;
          int totalCount = 0;
          //long totalCount = 0;
          if (pt != null) {
              list = (List<WinnersList>) pt.getList();
              totalCount = pt.getTotalCount();
          }
          retJon.put("data", list);
          retJon.put("recordsTotal", totalCount);
          retJon.put("recordsFiltered", totalCount);
          logger.info("getList:(获取获奖名单分页查询接口) 结束");
          return retJon;
      }
  
      /**
       * delete:(逻辑删除获奖名单数据接口)
       *
       * @param request
       * @param parms
       * @return
       * @Author rufei.cn
       */
      @RequestMapping("delete")
      @ResponseBody
      public ReturnT<String> delete(HttpServletRequest request) {
          ReturnT<String> returnT = new ReturnT<>(ReturnT.FAIL_CODE, "删除失败");
          String ids = null;
          ids = request.getParameter("id");
          int id = StringUtil.stringToInt(ids);
          logger.info("delete 开始============>" + id);
          if (id <= 0) {
              returnT.setMsg("参数错误");
              return returnT;
          }
          long newId = id;
          boolean ret = winnersListService.delete(newId);
          if (ret) {
              returnT.setCode(ReturnT.SUCCESS_CODE);
              returnT.setMsg("成功");
          }
          logger.info("delete 结束============>" + JSON.toJSONString(returnT));
          return returnT;
      }
  
      /**
       * save:(保存获奖名单数据接口)
       *
       * @param request
       * @param parms
       * @return
       * @Author rufei.cn
       */
      @RequestMapping(value = "save")
      @ResponseBody
      public ReturnT<String> save(WinnersList winnersList) {
          ReturnT<String> returnT = new ReturnT<>(ReturnT.FAIL_CODE, "保存数据失败");
          String parms = JSON.toJSONString(winnersList);
          logger.info("save:(保存获奖名单数据接口) 开始  parms={}", parms);
          if (winnersList == null) {
              returnT.setMsg("参数为空");
              return returnT;
          }
          if (winnersList == null) {
              returnT.setMsg("参数错误");
              return returnT;
          }
          WinnersList ret = winnersListService.save(winnersList);
          if (ret == null) {
              returnT.setMsg("保存数据失败");
              return returnT;
          }
          returnT.setCode(ReturnT.SUCCESS_CODE);
          returnT.setMsg("成功");
          logger.info("save 结束============>" + JSON.toJSONString(returnT));
          return returnT;
      }
  
  }