/**
|
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
* <p>
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
* you may not use this file except in compliance with the License.
|
* You may obtain a copy of the License at
|
* <p>
|
* http://www.apache.org/licenses/LICENSE-2.0
|
* <p>
|
* Unless required by applicable law or agreed to in writing, software
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* See the License for the specific language governing permissions and
|
* limitations under the License.
|
*/
|
package org.springblade.modules.water.controller;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.AllArgsConstructor;
|
import org.springblade.core.boot.ctrl.BladeController;
|
import org.springblade.core.log.annotation.ApiLog;
|
import org.springblade.core.mp.support.Condition;
|
import org.springblade.core.mp.support.Query;
|
import org.springblade.core.tool.api.R;
|
import org.springblade.core.tool.utils.Func;
|
import org.springblade.modules.water.entity.water;
|
import org.springblade.modules.water.service.WaterService;
|
import org.springblade.modules.water.vo.WaterVO;
|
import org.springblade.modules.water.wrapper.WaterWrapper;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.multipart.MultipartFile;
|
import springfox.documentation.annotations.ApiIgnore;
|
|
import javax.validation.Valid;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 控制器
|
*
|
* @author Blade
|
* @since 2019-11-07
|
*/
|
@RestController
|
@AllArgsConstructor
|
@RequestMapping("/water")
|
@Api(value = "", tags = "接口")
|
public class WaterController extends BladeController {
|
|
private WaterService waterService;
|
|
/**
|
* 详情
|
*/
|
@ApiLog("详情")
|
@GetMapping("/detail")
|
@ApiOperationSupport(order = 1)
|
@ApiOperation(value = "详情", notes = "传入tmpR")
|
public R<WaterVO> detail(water waterLine) {
|
water detail = waterService.getOne(Condition.getQueryWrapper(waterLine));
|
return R.data(WaterWrapper.build().entityVO(detail));
|
}
|
|
|
/**
|
* 新增
|
*/
|
@ApiLog("新增")
|
@PostMapping("/save")
|
@ApiOperationSupport(order = 4)
|
@ApiOperation(value = "新增", notes = "")
|
public R save(@Valid @RequestBody water waterLine) {
|
return R.status(waterService.save(waterLine));
|
}
|
|
/**
|
* 修改
|
*/
|
@ApiLog("修改")
|
@PostMapping("/update")
|
@ApiOperationSupport(order = 5)
|
@ApiOperation(value = "修改", notes = "传入tmpR")
|
public R update(@Valid @RequestBody water waterLine) {
|
return R.status(waterService.updateById(waterLine));
|
}
|
|
/**
|
* 新增或修改
|
*/
|
@PostMapping("/submit")
|
@ApiOperationSupport(order = 6)
|
@ApiOperation(value = "新增或修改", notes = "")
|
public R submit(@Valid @RequestBody water waterLine) {
|
return R.status(waterService.saveOrUpdate(waterLine));
|
}
|
|
/**
|
* 删除
|
* @param ids
|
* @return
|
*/
|
@PostMapping("/remove")
|
@ApiOperationSupport(order = 8)
|
public R remove(@RequestParam String ids) {
|
return R.status(waterService.removeByIds(Func.toLongList(ids)));
|
}
|
|
/**
|
* 子列表
|
*/
|
@GetMapping("/child-list")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "code", value = "字典编号", paramType = "query", dataType = "string"),
|
@ApiImplicitParam(name = "dictValue", value = "字典名称", paramType = "query", dataType = "string"),
|
@ApiImplicitParam(name = "parentId", value = "字典名称", paramType = "query", dataType = "string")
|
})
|
@ApiOperationSupport(order = 9)
|
@ApiOperation(value = "列表", notes = "传入dict")
|
public R<IPage<WaterVO>> childList(@ApiIgnore @RequestParam Map<String, Object> dict, @RequestParam(required = false, defaultValue = "-1") Long parentId, Query query) {
|
return R.data(waterService.childList(dict, parentId, query));
|
}
|
|
/**
|
* 分页
|
*/
|
@GetMapping("/childpage")
|
@ApiOperation(value = "分页", notes = "传入tmpR")
|
public R<IPage<WaterVO>> childpage(@ApiIgnore @RequestParam Map<String, Object> water, Query query) {
|
IPage<water> pages = waterService.page(Condition.getPage(query), Condition.getQueryWrapper(water,water.class).orderByAsc("origin"));
|
return R.data(WaterWrapper.build().pageVO(pages));
|
}
|
|
/**
|
* 模糊查询
|
*/
|
@PostMapping("/queryList")
|
@ApiOperationSupport(order =10)
|
@ApiOperation(value = "模糊查询", notes = "")
|
public R queryList(String pid, String loc) {
|
return R.data(waterService.queryList(pid,loc));
|
}
|
|
@RequestMapping(value = "/saveFile",method = RequestMethod.POST)
|
@ResponseBody
|
public R saveFile(@RequestParam("file") MultipartFile file) {
|
waterService.upLoadFile(file);
|
return R.success("成功");
|
}
|
|
|
|
/**
|
* 河道断面
|
*/
|
@PostMapping("/selectInfoh")
|
@ApiOperation(value = "模糊查询", notes = "")
|
public R selectInfoh(String stcd) {
|
Map<String, Object> map = new HashMap<>(16);
|
List<Map<String, Object>> lists = new ArrayList<>();
|
List<Map<String, Object>> list = waterService.selectInfoh(stcd);
|
List<Map<String, String>> selectZ = waterService.selectZ(stcd);
|
List<Map<String, String>> maps = waterService.selectJ(stcd);
|
if (maps.size() == 0){
|
map.put("List",list);
|
map.put("wrz",0);
|
map.put("z",selectZ.get(0).get("Z"));
|
map.put("obhtz",0);
|
map.put("hlz",0);
|
}
|
else {
|
map.put("List",list);
|
map.put("z",selectZ.get(0).get("Z"));
|
map.put("wrz",maps.get(0).get("WRZ"));
|
map.put("obhtz",maps.get(0).get("OBHTZ"));
|
map.put("hlz",maps.get(0).get("HLZ"));
|
}
|
lists.add(map);
|
return R.data(lists);
|
}
|
|
}
|