package ${package}.${pkgName}.controller;

import java.util.Map;

import io.swagger.annotations.Api;
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 org.springframework.security.access.prepost.PreAuthorize;
import org.shoulder.core.dto.response.PageResult;
import org.shoulder.core.dto.response.RestResult;

import ${package}.${pkgName}.entity.${className};
import ${package}.${pkgName}.service.${className}Service;

/**
 * ${comments}
 *
 * @author ${author}
 * @date ${datetime}
 */
@RestController
@RequestMapping("${pathName}")
@Api(tags = "${comments}")
public class ${className}Controller {

    @Autowired
    private ${className}Service ${lowClassName}Service;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @PreAuthorize("hasAnyAuthority('${tableName}:${pathName}:list')")
    public PageResult list(@RequestParam Map<String, Object> params){
        PageResult pageResult = ${lowClassName}Service.findAll(params);
        return pageResult;
    }


    /**
     * 保存
     */
    @RequestMapping("/save")
    @PreAuthorize("hasAnyAuthority('generator:sysroleuser:save')")
    public Result save(@RequestBody ${className} ${lowClassName}){
			${lowClassName}Service.save(${lowClassName});

        return Result.succeed("保存成功");
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @PreAuthorize("hasAnyAuthority('generator:sysroleuser:update')")
    public Result update(@RequestBody ${className} ${lowClassName}){
			${lowClassName}Service.update(${lowClassName});

        return Result.succeed("修改成功");
    }

    /**
     * 删除
     */
    @RequestMapping("/delete/{id}")
    @PreAuthorize("hasAnyAuthority('generator:sysroleuser:delete')")
    public Result delete(@PathVariable Long  ${pk.attrname}){
			${lowClassName}Service.delete(${pk.attrname});
        return Result.succeed("删除成功");
    }

}
