103 lines
3.8 KiB
Plaintext
103 lines
3.8 KiB
Plaintext
package ${package}.${moduleName}.controller;
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.hccake.ballcat.common.core.result.R;
|
|
import com.hccake.ballcat.commom.log.operation.annotation.OperationLogging;
|
|
import ${package}.${moduleName}.model.entity.${className};
|
|
import ${package}.${moduleName}.model.qo.${className}QO;
|
|
import ${package}.${moduleName}.model.vo.${className}VO;
|
|
import ${package}.${moduleName}.service.${className}Service;
|
|
import com.hccake.ballcat.common.core.result.BaseResultCode;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
/**
|
|
* ${comments}
|
|
*
|
|
* @author ${author}
|
|
* @date ${datetime}
|
|
*/
|
|
@RestController
|
|
@RequiredArgsConstructor
|
|
@RequestMapping("/${moduleName}/${pathName}" )
|
|
@Api(value = "${pathName}", tags = "${comments}管理")
|
|
public class ${className}Controller {
|
|
|
|
private final ${className}Service ${classname}Service;
|
|
|
|
/**
|
|
* 分页查询
|
|
* @param page 分页对象
|
|
* @param ${classname}QO ${comments}
|
|
* @return R
|
|
*/
|
|
@ApiOperation(value = "分页查询", notes = "分页查询")
|
|
@GetMapping("/page" )
|
|
@PreAuthorize("@per.hasPermission('${moduleName}:${pathName}:read')" )
|
|
public R<IPage<${className}VO>> get${className}Page(
|
|
Page<?> page, ${className}QO ${classname}QO) {
|
|
return R.ok(${classname}Service.selectPageVo(page, ${classname}QO));
|
|
}
|
|
|
|
|
|
/**
|
|
* 通过id查询${comments}
|
|
* @param ${pk.lowerAttrName} id
|
|
* @return R
|
|
*/
|
|
@ApiOperation(value = "通过id查询", notes = "通过id查询")
|
|
@GetMapping("/{${pk.lowerAttrName}}" )
|
|
@PreAuthorize("@per.hasPermission('${moduleName}:${pathName}:read')" )
|
|
public R<${className}> getById(@PathVariable("${pk.lowerAttrName}" ) ${pk.attrType} ${pk.lowerAttrName}) {
|
|
return R.ok(${classname}Service.getById(${pk.lowerAttrName}));
|
|
}
|
|
|
|
/**
|
|
* 新增${comments}
|
|
* @param ${classname} ${comments}
|
|
* @return R
|
|
*/
|
|
@ApiOperation(value = "新增${comments}", notes = "新增${comments}")
|
|
@CreateOperationLogging(msg = "新增${comments}" )
|
|
@PostMapping
|
|
@PreAuthorize("@per.hasPermission('${moduleName}:${pathName}:add')" )
|
|
public R save(@RequestBody ${className} ${classname}) {
|
|
return ${classname}Service.save(${classname}) ?
|
|
R.ok() : R.failed(BaseResultCode.UPDATE_DATABASE_ERROR, "新增${comments}失败");
|
|
}
|
|
|
|
/**
|
|
* 修改${comments}
|
|
* @param ${classname} ${comments}
|
|
* @return R
|
|
*/
|
|
@ApiOperation(value = "修改${comments}", notes = "修改${comments}")
|
|
@UpdateOperationLogging(msg = "修改${comments}" )
|
|
@PutMapping
|
|
@PreAuthorize("@per.hasPermission('${moduleName}:${pathName}:edit')" )
|
|
public R updateById(@RequestBody ${className} ${classname}) {
|
|
return ${classname}Service.updateById(${classname}) ?
|
|
R.ok() : R.failed(BaseResultCode.UPDATE_DATABASE_ERROR, "修改${comments}失败");
|
|
}
|
|
|
|
/**
|
|
* 通过id删除${comments}
|
|
* @param ${pk.lowerAttrName} id
|
|
* @return R
|
|
*/
|
|
@ApiOperation(value = "通过id删除${comments}", notes = "通过id删除${comments}")
|
|
@DeleteOperationLogging(msg = "通过id删除${comments}" )
|
|
@DeleteMapping("/{${pk.lowerAttrName}}" )
|
|
@PreAuthorize("@per.hasPermission('${moduleName}:${pathName}:del')" )
|
|
public R removeById(@PathVariable ${pk.attrType} ${pk.lowerAttrName}) {
|
|
return ${classname}Service.removeById(${pk.lowerAttrName}) ?
|
|
R.ok() : R.failed(BaseResultCode.UPDATE_DATABASE_ERROR, "通过id删除${comments}失败");
|
|
}
|
|
|
|
}
|