You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tcZz-java/ruoyi-admin/src/main/java/com/ruoyi/tcZz/controller/TcMapController.java

142 lines
4.2 KiB

2 years ago
package com.ruoyi.tcZz.controller;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
2 years ago
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
2 years ago
import com.ruoyi.tcZz.domain.TcMap;
import com.ruoyi.tcZz.service.ITcMapService;
2 years ago
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
2 years ago
/**
* Controller
2 years ago
*
2 years ago
* @author ruoyi
* @date 2023-10-12
*/
@RestController
2 years ago
@Api(tags = "地图统计")
2 years ago
@RequestMapping("/tcZz/networkSecurity/map")
2 years ago
public class TcMapController extends BaseController {
2 years ago
@Autowired
private ITcMapService tcMapService;
/**
*
*/
2 years ago
@ApiOperation(value = "查询地图统计列表", response = TcMap.class)
2 years ago
@GetMapping("/list")
2 years ago
public TableDataInfo list(TcMap tcMap) {
2 years ago
startPage();
List<TcMap> list = tcMapService.selectTcMapList(tcMap);
return getDataTable(list);
}
/**
*
*/
2 years ago
@ApiOperation(value = "导出地图统计列表")
2 years ago
@PostMapping("/export")
2 years ago
public void export(HttpServletResponse response, TcMap tcMap) {
2 years ago
List<TcMap> list = tcMapService.selectTcMapList(tcMap);
ExcelUtil<TcMap> util = new ExcelUtil<TcMap>(TcMap.class);
util.exportExcel(response, list, "地图统计数据");
}
/**
*
*/
2 years ago
@ApiOperation(value = "获取地图统计详细信息")
2 years ago
@GetMapping(value = "/{id}")
2 years ago
public AjaxResult getInfo(@PathVariable("id") Long id) {
2 years ago
return success(tcMapService.selectTcMapById(id));
}
/**
*
*/
2 years ago
@ApiOperation(value = "新增地图统计")
2 years ago
@PostMapping
2 years ago
public AjaxResult add(@RequestBody TcMap tcMap) {
2 years ago
//根据Name判断如果已存在则调修改
2 years ago
TcMap newtcMap = new TcMap();
2 years ago
newtcMap.setName(tcMap.getName());
List<TcMap> list = tcMapService.selectTcMapList(newtcMap);
2 years ago
if (!list.isEmpty()) {
for (TcMap a : list) {
2 years ago
tcMap.setId(a.getId());
tcMapService.updateTcMap(tcMap);
}
2 years ago
} else {
2 years ago
tcMapService.insertTcMap(tcMap);
}
return AjaxResult.success();
2 years ago
}
/**
*
*/
2 years ago
@ApiOperation(value = "修改地图统计")
2 years ago
@PutMapping
2 years ago
public AjaxResult edit(@RequestBody TcMap tcMap) {
2 years ago
return toAjax(tcMapService.updateTcMap(tcMap));
}
/**
*
*/
2 years ago
@ApiOperation(value = "根据id删除地图统计")
2 years ago
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
2 years ago
return toAjax(tcMapService.deleteTcMapByIds(ids));
}
2 years ago
2 years ago
/**
*
*/
@ApiOperation(value = "删除地图统计")
@PostMapping("/deleteAll")
public AjaxResult deleteAll() {
return AjaxResult.success(tcMapService.deleteTcMap());
}
2 years ago
/**
*
*/
@ApiOperation("通用导入excel信息")
@PostMapping("/common/importExcel")
public AjaxResult importExcel(MultipartFile file) throws Exception {
ExcelUtil<TcMap> util = new ExcelUtil<TcMap>(TcMap.class);
List<TcMap> tcMapList = util.importExcel(file.getInputStream());
tcMapService.importUser(tcMapList);
return AjaxResult.success();
}
/**
*
*
* @param isStatus
* @return
*/
@ApiOperation("批量启用禁用")
@GetMapping("/isStatus")
public AjaxResult isStatus(@RequestParam("isStatus") Integer isStatus, @RequestParam("ids") List<String> ids) {
2 years ago
tcMapService.updateByisStatus(isStatus, ids);
return AjaxResult.success();
}
2 years ago
@ApiOperation("通用下载excel模板")
@PostMapping("/importTemplate")
2 years ago
public void importTemplate(HttpServletResponse response) {
2 years ago
ExcelUtil<TcMap> util = new ExcelUtil<TcMap>(TcMap.class);
util.importTemplateExcel(response, " 地图统计");
}
2 years ago
}