2026-01-14 09:37:49 +08:00
|
|
|
package ${package.Controller};
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
#if(${restControllerStyle})
|
|
|
|
|
#else
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
#if(${superControllerClassPackage})
|
|
|
|
|
import ${superControllerClassPackage};
|
|
|
|
|
#end
|
|
|
|
|
#if(${swagger2})
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
|
|
#end
|
|
|
|
|
#if(${entityLombokModel})
|
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
import $!{package.Entity}.$!{entity};
|
|
|
|
|
import $!{package.Service}.$!{table.serviceName};
|
|
|
|
|
import result.pojo.com.zhangy.skyeye.common.Result;
|
|
|
|
|
import param.pojo.com.zhangy.skyeye.common.IdParam;
|
2026-01-19 10:38:16 +08:00
|
|
|
import com.zhangy.skyeye.db.utils.MPUtil;
|
|
|
|
|
import com.zhangy.skyeye.db.pojo.page.PageParam;
|
2026-01-14 09:37:49 +08:00
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* $!{table.comment} 前端控制器
|
|
|
|
|
*
|
|
|
|
|
* @author ${author}
|
|
|
|
|
* @since ${date}
|
|
|
|
|
*/
|
|
|
|
|
#if(${restControllerStyle})
|
|
|
|
|
@RestController
|
|
|
|
|
#else
|
|
|
|
|
@Controller
|
|
|
|
|
#end
|
|
|
|
|
@AllArgsConstructor
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Api(value = "$!{table.comment}", tags = "$!{table.comment}接口")
|
|
|
|
|
@RequestMapping("#if(${controllerMappingHyphenStyle})${controllerMappingHyphen}#else${table.entityPath}#end")
|
|
|
|
|
#if(${superControllerClass})
|
|
|
|
|
public class ${table.controllerName} extends ${superControllerClass} {
|
|
|
|
|
#else
|
|
|
|
|
public class ${table.controllerName} {
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
private $!{table.serviceName} $!{table.entityPath}Service;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/save")
|
|
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
|
|
@ApiOperation(value = "新增", notes = "传入$!{table.entityPath}")
|
|
|
|
|
public Result save(@RequestBody $!{entity} $!{table.entityPath}) {
|
|
|
|
|
if($!{table.entityPath} == null){
|
|
|
|
|
return Result.error("参数异常");
|
|
|
|
|
}
|
|
|
|
|
return Result.status($!{table.entityPath}Service.save($!{table.entityPath}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改 $!{table.comment}
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/update")
|
|
|
|
|
@ApiOperationSupport(order = 2)
|
|
|
|
|
@ApiOperation(value = "修改", notes = "传入$!{table.entityPath}")
|
|
|
|
|
public Result update(@RequestBody $!{entity} $!{table.entityPath}) {
|
|
|
|
|
if($!{table.entityPath} == null){
|
|
|
|
|
return Result.error("参数异常");
|
|
|
|
|
}
|
|
|
|
|
return Result.status($!{table.entityPath}Service.updateById($!{table.entityPath}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除 $!{table.comment}
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/remove")
|
|
|
|
|
@ApiOperationSupport(order = 3)
|
|
|
|
|
@ApiOperation(value = "删除", notes = "传入ids")
|
|
|
|
|
public Result remove(@RequestBody IdParam<Long> idParam) {
|
|
|
|
|
if(idParam == null){
|
|
|
|
|
return Result.error("参数异常!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Result.status($!{table.entityPath}Service.removeByIds(idParam.getIds()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 详情
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/detail")
|
|
|
|
|
@ApiOperationSupport(order = 4)
|
|
|
|
|
@ApiOperation(value = "详情", notes = "传入id")
|
|
|
|
|
public Result<$!{entity}> detail(Long id) {
|
|
|
|
|
if(id == null){
|
|
|
|
|
return Result.error("参数异常");
|
|
|
|
|
}
|
|
|
|
|
$!{entity} detail = $!{table.entityPath}Service.getById(id);
|
|
|
|
|
return Result.successData(detail);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询 $!{table.comment}
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/list")
|
|
|
|
|
@ApiOperationSupport(order = 5)
|
|
|
|
|
@ApiOperation(value = "查询", notes = "传入$!{table.entityPath}")
|
|
|
|
|
public Result<List<$!{entity}>> list(PageParam pageParam, $!{entity} $!{table.entityPath}) {
|
|
|
|
|
List<$!{entity}> list = $!{table.entityPath}Service.list($!{table.entityPath}Service.getQueryWrapper(pageParam, $!{table.entityPath}));
|
|
|
|
|
return Result.successData(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分页 $!{table.comment}
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/page")
|
|
|
|
|
@ApiOperationSupport(order = 6)
|
|
|
|
|
@ApiOperation(value = "分页", notes = "传入$!{table.entityPath}")
|
|
|
|
|
public Result<IPage<$!{entity}>> page(PageParam pageParam, $!{entity} $!{table.entityPath}) {
|
|
|
|
|
IPage<$!{entity}> pages = $!{table.entityPath}Service.page(
|
|
|
|
|
MPUtil.getPage(pageParam),
|
|
|
|
|
$!{table.entityPath}Service.getQueryWrapper(null, $!{table.entityPath})
|
|
|
|
|
);
|
|
|
|
|
return Result.successData(pages);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|