ruoyi/target/classes/vm/java/controller.java.vm

117 lines
4.3 KiB
Plaintext
Raw Normal View History

2024-04-22 08:45:46 +08:00
package ${packageName}.controller;
import java.util.List;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import io.swagger.annotations.Api;
2024-04-24 15:05:28 +08:00
import com.jg.common.utils.poi.ExcelUtil;
2024-04-22 08:45:46 +08:00
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
2024-04-23 10:23:51 +08:00
import com.jg.common.utils.QueryPage;
2024-04-24 15:05:28 +08:00
import com.jg.framework.aspectj.lang.annotation.Log;
2024-04-22 08:45:46 +08:00
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
2024-04-23 08:39:01 +08:00
import com.jg.framework.web.controller.BaseController;
2024-04-22 08:45:46 +08:00
import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service;
2024-04-23 09:01:15 +08:00
import com.jg.framework.web.domain.R;
2024-04-22 08:45:46 +08:00
#if($table.crud || $table.sub)
#elseif($table.tree)
#end
/**
* ${functionName}Controller
*
* @author ${author}
* @date ${datetime}
*/
@Slf4j
@Api(tags = "${functionName}")
@RestController
@RequestMapping("/${moduleName}")
2024-04-23 08:39:01 +08:00
public class ${ClassName}Controller extends BaseController{
2024-04-24 15:05:28 +08:00
2024-04-22 08:45:46 +08:00
@Resource
private I${ClassName}Service ${className}Service;
2024-04-23 08:39:01 +08:00
/**
* ${functionName}分页列表
*/
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:listPage')")
@ApiOperation(value = "${functionName}分页列表", notes = "${functionName}分页列表信息")
@PostMapping("/listPage")
public R listPage(QueryPage queryPage,${ClassName} ${className}) {
startPage();
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
return R.page(queryPage.getPageNum(),queryPage.getPageSize(),list.size(),list);
}
2024-04-22 08:45:46 +08:00
/**
* ${functionName}列表
*/
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
@ApiOperation(value = "${functionName}列表", notes = "${functionName}列表信息")
@GetMapping("/list")
public R<List<${ClassName}>> list() {
List<${ClassName}> list = ${className}Service.list();
return R.ok(list);
}
2024-04-24 15:05:28 +08:00
2024-04-22 08:45:46 +08:00
/**
* ${functionName}id详细信息
*/
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
@ApiOperation(value = "${functionName}id详细信息", notes = "${functionName}id详细信息")
@GetMapping("/query")
public R<${ClassName}> query(Long id) {
${ClassName} queryinfo = ${className}Service.getById(id);
return R.ok(queryinfo);
}
/**
* ${functionName}新增信息
*/
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
@ApiOperation(value = "${functionName}新增信息", notes = "${functionName}新增信息")
2024-04-24 15:05:28 +08:00
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
2024-04-22 08:45:46 +08:00
@PostMapping("/add")
public R<Boolean> add(${ClassName} ${className}) {
boolean res = ${className}Service.save(${className});
return R.ok(res);
}
/**
* ${functionName}修改信息
*/
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
@ApiOperation(value = "${functionName}修改信息", notes = "${functionName}修改信息")
2024-04-24 15:05:28 +08:00
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
2024-04-22 08:45:46 +08:00
@PostMapping("/edit")
public R<Boolean> edit(${ClassName} ${className}) {
boolean res = ${className}Service.updateById(${className});
return R.ok(res);
}
/**
* ${functionName}删除信息
*/
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
@ApiOperation(value = "${functionName}删除信息", notes = "${functionName}删除信息")
2024-04-24 15:05:28 +08:00
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
2024-04-22 08:45:46 +08:00
@PostMapping("/remove")
public R<Boolean> remove(Long id) {
boolean res = ${className}Service.removeById(id);
return R.ok(res);
}
2024-04-24 15:05:28 +08:00
/**
* 导出${functionName}列表
*/
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ${ClassName} ${className})
{
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
util.exportExcel(response, list, "${functionName}数据");
}
2024-04-22 08:45:46 +08:00
}