91 lines
2.4 KiB
Plaintext
91 lines
2.4 KiB
Plaintext
package ${package}.controller.${moduleName};
|
|
|
|
import java.util.Arrays;
|
|
import java.util.Map;
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import ${package}.entity.${moduleName}.${className}Entity;
|
|
import ${package}.service.${moduleName}.${className}Service;
|
|
import ${mainPath}.common.utils.PageUtils;
|
|
import ${mainPath}.common.utils.R;
|
|
|
|
|
|
|
|
/**
|
|
* ${comments}
|
|
*
|
|
* @author ${author}
|
|
* @email ${email}
|
|
* @date ${datetime}
|
|
*/
|
|
@RestController
|
|
@RequestMapping("${moduleName}/${pathName}")
|
|
public class ${className}Controller {
|
|
@Autowired
|
|
private ${className}Service ${classname}Service;
|
|
|
|
/**
|
|
* 列表
|
|
*/
|
|
@RequestMapping("/list")
|
|
@RequiresPermissions("${moduleName}:${pathName}:list")
|
|
public R list(@RequestParam Map<String, Object> params){
|
|
PageUtils page = ${classname}Service.queryPage(params);
|
|
|
|
return R.ok().put("page", page);
|
|
}
|
|
|
|
|
|
/**
|
|
* 信息
|
|
*/
|
|
@RequestMapping("/info/{${pk.attrname}}")
|
|
@RequiresPermissions("${moduleName}:${pathName}:info")
|
|
public R info(@PathVariable("${pk.attrname}") ${pk.attrType} ${pk.attrname}){
|
|
${className}Entity ${classname} = ${classname}Service.selectById(${pk.attrname});
|
|
|
|
return R.ok().put("${classname}", ${classname});
|
|
}
|
|
|
|
/**
|
|
* 保存
|
|
*/
|
|
@RequestMapping("/save")
|
|
@RequiresPermissions("${moduleName}:${pathName}:save")
|
|
public R save(@RequestBody ${className}Entity ${classname}){
|
|
${classname}Service.insert(${classname});
|
|
|
|
return R.ok();
|
|
}
|
|
|
|
/**
|
|
* 修改
|
|
*/
|
|
@RequestMapping("/update")
|
|
@RequiresPermissions("${moduleName}:${pathName}:update")
|
|
public R update(@RequestBody ${className}Entity ${classname}){
|
|
${classname}Service.updateById(${classname});
|
|
|
|
return R.ok();
|
|
}
|
|
|
|
/**
|
|
* 删除
|
|
*/
|
|
@RequestMapping("/delete")
|
|
@RequiresPermissions("${moduleName}:${pathName}:delete")
|
|
public R delete(@RequestBody ${pk.attrType}[] ${pk.attrname}s){
|
|
${classname}Service.deleteBatchIds(Arrays.asList(${pk.attrname}s));
|
|
|
|
return R.ok();
|
|
}
|
|
|
|
}
|