117 lines
4.3 KiB
Plaintext
117 lines
4.3 KiB
Plaintext
package ${packageName}.controller;
|
|
import java.util.List;
|
|
import javax.annotation.Resource;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import io.swagger.annotations.Api;
|
|
import com.jg.common.utils.poi.ExcelUtil;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import com.jg.common.utils.QueryPage;
|
|
import com.jg.framework.aspectj.lang.annotation.Log;
|
|
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;
|
|
import com.jg.framework.web.controller.BaseController;
|
|
import ${packageName}.domain.${ClassName};
|
|
import ${packageName}.service.I${ClassName}Service;
|
|
import com.jg.framework.web.domain.R;
|
|
#if($table.crud || $table.sub)
|
|
#elseif($table.tree)
|
|
#end
|
|
|
|
/**
|
|
* ${functionName}Controller
|
|
*
|
|
* @author ${author}
|
|
* @date ${datetime}
|
|
*/
|
|
@Slf4j
|
|
@Api(tags = "${functionName}")
|
|
@RestController
|
|
@RequestMapping("/${moduleName}")
|
|
public class ${ClassName}Controller extends BaseController{
|
|
|
|
@Resource
|
|
private I${ClassName}Service ${className}Service;
|
|
|
|
/**
|
|
* ${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);
|
|
}
|
|
/**
|
|
* ${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);
|
|
}
|
|
|
|
/**
|
|
* ${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}新增信息")
|
|
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
|
|
@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}修改信息")
|
|
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
|
|
@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}删除信息")
|
|
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
|
|
@PostMapping("/remove")
|
|
public R<Boolean> remove(Long id) {
|
|
boolean res = ${className}Service.removeById(id);
|
|
return R.ok(res);
|
|
}
|
|
|
|
/**
|
|
* 导出${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}数据");
|
|
}
|
|
}
|