|
|
|
package ${packageName}.controller;
|
|
|
|
package ${packageName}.${modlePath}.controller.${moduleName};
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import com.ruoyi.common.annotation.DataSource;
|
|
|
|
import com.ruoyi.common.enums.DataSourceType;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
...
|
...
|
@@ -16,9 +20,10 @@ import com.ruoyi.common.annotation.Log; |
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
|
|
import ${packageName}.domain.${ClassName};
|
|
|
|
import ${packageName}.service.I${ClassName}Service;
|
|
|
|
import com.zhonglai.luhui.dao.service.PublicTemplateService;
|
|
|
|
import ${packageName}.domain.${moduleName}.${ClassName};
|
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
|
|
|
|
|
#if($table.crud || $table.sub)
|
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
|
#elseif($table.tree)
|
|
...
|
...
|
@@ -30,86 +35,91 @@ import com.ruoyi.common.core.page.TableDataInfo; |
|
|
|
* @author ${author}
|
|
|
|
* @date ${datetime}
|
|
|
|
*/
|
|
|
|
@Api(tags = "${functionName}")
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/${moduleName}/${businessName}")
|
|
|
|
@RequestMapping("/${modlePath}/${moduleName}/${businessName}")
|
|
|
|
public class ${ClassName}Controller extends BaseController
|
|
|
|
{
|
|
|
|
@Autowired
|
|
|
|
private I${ClassName}Service ${className}Service;
|
|
|
|
private PublicTemplateService publicTemplateService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询${functionName}列表
|
|
|
|
*/
|
|
|
|
@ApiOperation(value ="查询${functionName}列表",notes="\n" +
|
|
|
|
"公共参数描述:\n" +
|
|
|
|
"条件参数:\n" +
|
|
|
|
"timeMap; //时间条件(如:{\"create_time\":[开始时间,结束时间]})\n" +
|
|
|
|
"keyValue; //模糊匹配的关键字(如:[\"value\",\"name,no\"])\n" +
|
|
|
|
"queryParams; //字段对应的比较符号(如:{\"id\":\"EQ\"})\n" +
|
|
|
|
"orderBy; //排序(如:\"id desc,name asc\")\n" +
|
|
|
|
"\n" +
|
|
|
|
"分页参数:\n" +
|
|
|
|
"pageNum; //当前记录起始索引,从1开始\n" +
|
|
|
|
"pageSize; //每页显示记录数")
|
|
|
|
@DataSource(DataSourceType.SLAVE)
|
|
|
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
|
|
|
|
@GetMapping("/list")
|
|
|
|
#if($table.crud || $table.sub)
|
|
|
|
public TableDataInfo list(${ClassName} ${className})
|
|
|
|
{
|
|
|
|
startPage();
|
|
|
|
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
|
|
|
List<${ClassName}> list = publicTemplateService.selectTList(${className});
|
|
|
|
return getDataTable(list);
|
|
|
|
}
|
|
|
|
#elseif($table.tree)
|
|
|
|
public AjaxResult list(${ClassName} ${className})
|
|
|
|
{
|
|
|
|
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
|
|
|
List<${ClassName}> list = publicTemplateService.selectTList(${className});
|
|
|
|
return success(list);
|
|
|
|
}
|
|
|
|
#end
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 导出${functionName}列表
|
|
|
|
*/
|
|
|
|
@ApiOperation("导出${functionName}列表")
|
|
|
|
@DataSource(DataSourceType.SLAVE)
|
|
|
|
@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});
|
|
|
|
List<${ClassName}> list = publicTemplateService.selectTList(${className});
|
|
|
|
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
|
|
|
|
util.exportExcel(response, list, "${functionName}数据");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取${functionName}详细信息
|
|
|
|
*/
|
|
|
|
@ApiOperation("获取${functionName}详细信息")
|
|
|
|
@DataSource(DataSourceType.SLAVE)
|
|
|
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
|
|
|
|
@GetMapping(value = "/{${pkColumn.javaField}}")
|
|
|
|
public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
|
|
|
|
{
|
|
|
|
return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
|
|
|
|
return success(publicTemplateService.getTById(${pkColumn.javaField}, ${ClassName}.class));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 新增${functionName}
|
|
|
|
*/
|
|
|
|
@ApiOperation("新增${functionName}")
|
|
|
|
@DataSource(DataSourceType.SLAVE)
|
|
|
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
|
|
|
|
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
|
|
|
|
@PostMapping
|
|
|
|
public AjaxResult add(@RequestBody ${ClassName} ${className})
|
|
|
|
{
|
|
|
|
return toAjax(${className}Service.insert${ClassName}(${className}));
|
|
|
|
return toAjax(publicTemplateService.add(${className}));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 修改${functionName}
|
|
|
|
*/
|
|
|
|
@ApiOperation("修改${functionName}")
|
|
|
|
@DataSource(DataSourceType.SLAVE)
|
|
|
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
|
|
|
|
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
|
|
|
|
@PutMapping
|
|
|
|
public AjaxResult edit(@RequestBody ${ClassName} ${className})
|
|
|
|
{
|
|
|
|
return toAjax(${className}Service.update${ClassName}(${className}));
|
|
|
|
return toAjax(publicTemplateService.edit((${className})));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 删除${functionName}
|
|
|
|
*/
|
|
|
|
@ApiOperation("删除${functionName}")
|
|
|
|
@DataSource(DataSourceType.SLAVE)
|
|
|
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
|
|
|
|
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
|
|
|
|
@DeleteMapping("/{${pkColumn.javaField}s}")
|
|
|
|
public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
|
|
|
{
|
|
|
|
return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s));
|
|
|
|
return toAjax(publicTemplateService.removeByIds(${ClassName}.class,${pkColumn.javaField}s));
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|