package cn.gistack.sm.patrol.controller;
|
|
import java.util.Arrays;
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
|
import cn.gistack.sm.patrol.entity.PatrolType;
|
import cn.gistack.sm.patrol.service.IPatrolTypeService;
|
import lombok.AllArgsConstructor;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
import org.springblade.core.mp.support.Condition;
|
import org.springblade.core.tool.api.R;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.servlet.ModelAndView;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.springblade.core.mp.support.Query;
|
|
/**
|
* @Description: 巡查类型
|
*/
|
@Slf4j
|
@Api(tags="巡查类型")
|
@RestController
|
@RequestMapping("/patrol/patrolType")
|
@AllArgsConstructor
|
public class PatrolTypeController extends BladeController {
|
private IPatrolTypeService patrolTypeService;
|
|
/**
|
* 分页列表查询
|
*
|
* @param patrolType
|
* @return
|
*/
|
@ApiOperation(value="巡查类型-分页列表查询", notes="巡查类型-分页列表查询")
|
@GetMapping(value = "/list")
|
public R queryPageList(PatrolType patrolType,Query query) {
|
// IPage<PatrolType> pageList = patrolTypeService.selectPatrolType(Condition.getPage(query),patrolType);
|
IPage<PatrolType> pageList = patrolTypeService.page(Condition.getPage(query), Condition.getQueryWrapper(patrolType));
|
return R.data(pageList);
|
}
|
|
/**
|
* 添加
|
*
|
* @param patrolType
|
* @return
|
*/
|
@ApiOperation(value="巡查类型-添加", notes="巡查类型-添加")
|
@PostMapping(value = "/add")
|
public R add(@RequestBody PatrolType patrolType) {
|
return R.data(patrolTypeService.save(patrolType));
|
}
|
|
/**
|
* 编辑
|
*
|
* @param patrolType
|
* @return
|
*/
|
@ApiOperation(value="巡查类型-编辑", notes="巡查类型-编辑")
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
public R edit(@RequestBody PatrolType patrolType) {
|
return R.data(patrolTypeService.updateById(patrolType));
|
}
|
|
/**
|
* 通过id删除
|
*
|
* @param id
|
* @return
|
*/
|
@ApiOperation(value="巡查类型-通过id删除", notes="巡查类型-通过id删除")
|
@DeleteMapping(value = "/delete")
|
public R delete(@RequestParam(name="id",required=true) String id) {
|
return R.data(patrolTypeService.removeById(id));
|
}
|
|
/**
|
* 批量删除
|
*
|
* @param ids
|
* @return
|
*/
|
@ApiOperation(value="巡查类型-批量删除", notes="巡查类型-批量删除")
|
@DeleteMapping(value = "/deleteBatch")
|
public R deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
return R.data(patrolTypeService.removeByIds(Arrays.asList(ids.split(","))));
|
}
|
|
/**
|
* 通过id查询
|
*
|
* @param id
|
* @return
|
*/
|
@ApiOperation(value="巡查类型-通过id查询", notes="巡查类型-通过id查询")
|
@GetMapping(value = "/queryById")
|
public R queryById(@RequestParam(name="id",required=true) String id) {
|
PatrolType patrolType = patrolTypeService.getById(id);
|
return R.data(patrolType);
|
}
|
|
|
}
|