| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- package com.izouma.awesomeadmin.web;
- import java.util.*;
- import com.izouma.awesomeadmin.util.ExportExcelUtil;
- import org.apache.commons.lang.StringUtils;
- import org.apache.shiro.authz.annotation.RequiresAuthentication;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.*;
- import com.izouma.awesomeadmin.constant.AppConstant;
- import com.izouma.awesomeadmin.dto.Page;
- import com.izouma.awesomeadmin.dto.Result;
- import com.izouma.awesomeadmin.model.ChannelInfo;
- import com.izouma.awesomeadmin.service.ChannelInfoService;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- @Controller
- @RequestMapping("/channelInfo")
- public class ChannelInfoController {
- /*generatedStart*/
- @Autowired
- private ChannelInfoService channelInfoService;
- /*generatedEnd*/
- /*generatedStart*/
- @RequiresAuthentication
- @RequestMapping(value = "/all", method = RequestMethod.GET)
- @ResponseBody
- public Result all(ChannelInfo record) {
- List<ChannelInfo> pp = channelInfoService.getChannelInfoList(record);
- return new Result(true, pp);
- }
- @RequestMapping(value = "/getChannelInfo", method = RequestMethod.GET)
- @ResponseBody
- public Result getChannelInfo(@RequestParam(required = false, value = "id") String id) {
- ChannelInfo data = channelInfoService.getChannelInfoById(id);
- return new Result(true, data);
- }
- @RequestMapping(value = "/getOne", method = RequestMethod.GET)
- @ResponseBody
- public Result getOne(ChannelInfo record) {
- ChannelInfo data = channelInfoService.getChannelInfo(record);
- return new Result(true, data);
- }
- @RequestMapping(value = "/page", method = RequestMethod.GET)
- @ResponseBody
- public Result page(Page page, ChannelInfo record) {
- Map<String, Object> result = new HashMap<>();
- List<ChannelInfo> pp =channelInfoService.getChannelInfoByPage(page, record);
- result.put(AppConstant.PAGE, page);
- result.put("pp", pp);
- return new Result(true, result);
- }
- @RequestMapping(value = "/save", method = RequestMethod.POST)
- @ResponseBody
- public Result save(ChannelInfo record) {
- boolean num = channelInfoService.createChannelInfo(record);
- if (num) {
- return new Result(true, record.getId());
- }
- return new Result(false, "保存异常");
- }
- @RequestMapping(value = "/update", method = RequestMethod.POST)
- @ResponseBody
- public Result updateChannelInfo(ChannelInfo record) {
- boolean num = channelInfoService.updateChannelInfo(record);
- if (num) {
- return new Result(true, "保存成功");
- }
- return new Result(false, "保存异常");
- }
- @RequestMapping(value = "/del", method = RequestMethod.POST)
- @ResponseBody
- public Result deleteChannelInfo(ChannelInfo record) {
- boolean num = channelInfoService.deleteChannelInfo(record);
- if (num) {
- return new Result(true, "删除成功");
- }
- return new Result(false, "删除异常");
- }
- @RequestMapping(value = "/exportExcel", method = RequestMethod.GET)
- @ResponseBody
- public void exportExcel(HttpServletRequest request, HttpServletResponse response, ChannelInfo record) throws Exception {
- List<ChannelInfo> channelInfos = channelInfoService.getChannelInfoList(record);
- String sheetName = "channel_info";
- String titleName = "渠道信息数据表";
- String fileName = "渠道信息表";
- int columnNumber = 12;
- int[] columnWidth = { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 };
- String[] columnName = { "ID" , "删除标识" , "更新时间" , "更新人" , "创建时间" , "创建人" , "名称" , "版本号" , "地址" , "备注" , "比率" , "二级比率" };
- String[][] dataList = new String[channelInfos.size()][12];
- for (int i = 0; i < channelInfos.size(); i++) {
- dataList[i][0] = String.valueOf(channelInfos.get(i).getId());
- dataList[i][1] = String.valueOf(channelInfos.get(i).getDelFlag());
- dataList[i][2] = String.valueOf(channelInfos.get(i).getUpdateTime());
- dataList[i][3] = String.valueOf(channelInfos.get(i).getUpdateUser());
- dataList[i][4] = String.valueOf(channelInfos.get(i).getCreateTime());
- dataList[i][5] = String.valueOf(channelInfos.get(i).getCreateUser());
- dataList[i][6] = String.valueOf(channelInfos.get(i).getName());
- dataList[i][7] = String.valueOf(channelInfos.get(i).getVersionNo());
- dataList[i][8] = String.valueOf(channelInfos.get(i).getUrl());
- dataList[i][9] = String.valueOf(channelInfos.get(i).getRemark());
- dataList[i][10] = String.valueOf(channelInfos.get(i).getRatio());
- dataList[i][11] = String.valueOf(channelInfos.get(i).getRatio2());
- }
- ExportExcelUtil.ExportWithResponse(sheetName, titleName, fileName,
- columnNumber, columnWidth, columnName, dataList, response);
- }
- /*generatedEnd*/
- }
|