package org.springblade.modules.equipage.controller;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiParam;
|
import lombok.AllArgsConstructor;
|
import org.springblade.common.utils.arg;
|
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.equipage.entity.Gun;
|
import org.springblade.modules.equipage.service.GunService;
|
import org.springblade.modules.equipage.vo.GunVo;
|
import org.springframework.web.bind.annotation.*;
|
|
/**
|
* @author zhongrj
|
* @time 2021-07-06
|
* @desc 枪支控制层
|
*/
|
@RestController
|
@AllArgsConstructor
|
@RequestMapping("/gun")
|
public class GunController {
|
|
private final GunService gunService;
|
|
/**
|
* 自定义分页
|
* @param query page,size
|
* @param gun 枪支信息对象
|
*/
|
@GetMapping("/page")
|
public R<IPage<GunVo>> page(GunVo gun, Query query) {
|
IPage<GunVo> pages = gunService.selectGunPage(Condition.getPage(query), gun);
|
return R.data(pages);
|
}
|
|
/**
|
* 新增
|
* @param gun 枪支信息对象
|
*/
|
@PostMapping("/save")
|
@ApiOperation(value = "新增", notes = "传入gun")
|
public R save(@RequestBody Gun gun) {
|
return R.status(gunService.save(gun));
|
}
|
|
/**
|
* 修改
|
* @param gun 枪支信息对象
|
*/
|
@PostMapping("/update")
|
public R update(@RequestBody Gun gun) {
|
return R.status(gunService.updateById(gun));
|
}
|
|
/**
|
* 新增或修改
|
* @param gun 枪支信息对象
|
*/
|
@PostMapping("/submit")
|
public R submit(@RequestBody Gun gun) throws Exception {
|
if (gun.getId()==null){
|
arg arg = new arg();
|
arg.test01(arg.url+"/gun/save",gun);
|
}
|
return R.status(gunService.saveOrUpdate(gun));
|
}
|
|
/**
|
* 删除
|
* @param ids 枪支信息ids 数组
|
*/
|
@PostMapping("/remove")
|
public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
|
return R.status(gunService.removeByIds(Func.toLongList(ids)));
|
}
|
|
/**
|
* 详情
|
* @param gun 枪支信息对象
|
*/
|
@GetMapping("/detail")
|
@ApiOperation(value = "详情", notes = "传入gun")
|
public R<GunVo> detail(Gun gun) {
|
GunVo detail = gunService.selectGunInfo(gun);
|
return R.data(detail);
|
}
|
|
}
|