package com.javaweb.geo.controller; import java.util.List; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import com.javaweb.common.annotation.Log; import com.javaweb.common.enums.BusinessType; import com.javaweb.geo.domain.DataSource; import com.javaweb.geo.service.IDataSourceService; import com.javaweb.common.core.controller.BaseController; import com.javaweb.common.core.domain.AjaxResult; import com.javaweb.common.utils.poi.ExcelUtil; import com.javaweb.common.core.page.TableDataInfo; /** * 数据来源Controller * * @author cxy * @date 2022-12-30 */ @Controller @RequestMapping("/geo/source") public class DataSourceController extends BaseController { private String prefix = "geo/source"; @Autowired private IDataSourceService dataSourceService; @RequiresPermissions("geo:source:view") @GetMapping() public String source() { return prefix + "/source"; } /** * 查询数据来源列表 */ @RequiresPermissions("geo:source:list") @PostMapping("/list") @ResponseBody public TableDataInfo list(DataSource dataSource) { startPage(); List list = dataSourceService.selectDataSourceList(dataSource); return getDataTable(list); } /** * 导出数据来源列表 */ @RequiresPermissions("geo:source:export") @Log(title = "数据来源", businessType = BusinessType.EXPORT) @PostMapping("/export") @ResponseBody public AjaxResult export(DataSource dataSource) { List list = dataSourceService.selectDataSourceList(dataSource); ExcelUtil util = new ExcelUtil(DataSource.class); return util.exportExcel(list, "source"); } /** * 新增数据来源 */ @GetMapping("/add") public String add() { return prefix + "/add"; } /** * 新增保存数据来源 */ @RequiresPermissions("geo:source:add") @Log(title = "数据来源", businessType = BusinessType.INSERT) @PostMapping("/add") @ResponseBody public AjaxResult addSave(DataSource dataSource) { return toAjax(dataSourceService.insertDataSource(dataSource)); } /** * 修改数据来源 */ @GetMapping("/edit/{ids}") public String edit(@PathVariable("ids") String ids, ModelMap mmap) { DataSource dataSource = dataSourceService.selectDataSourceById(ids); mmap.put("dataSource", dataSource); return prefix + "/edit"; } /** * 修改保存数据来源 */ @RequiresPermissions("geo:source:edit") @Log(title = "数据来源", businessType = BusinessType.UPDATE) @PostMapping("/edit") @ResponseBody public AjaxResult editSave(DataSource dataSource) { return toAjax(dataSourceService.updateDataSource(dataSource)); } /** * 删除数据来源 */ @RequiresPermissions("geo:source:remove") @Log(title = "数据来源", businessType = BusinessType.DELETE) @PostMapping( "/remove") @ResponseBody public AjaxResult remove(String ids) { return toAjax(dataSourceService.deleteDataSourceByIds(ids)); } }