package ${package}.${moduleName}.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.plugins.Page;
import com.pig4cloud.pigx.common.core.util.Query;

import ${package}.${moduleName}.entity.${className};
import ${package}.${moduleName}.service.${className}Service;
import com.pig4cloud.pigx.common.core.util.R;
import java.util.Map;


/**
 * ${comments}
 *
 * @author ${author}
 * @date ${datetime}
 */
@RestController
@RequestMapping("/${pathName}")
public class ${className}Controller {
    @Autowired
    private ${className}Service ${classname}Service;


    /**
    *  列表
    * @param params
    * @return
    */
    @GetMapping("/page")
    public Page page(@RequestParam Map<String, Object> params) {
      return  ${classname}Service.selectPage(new Query<>(params), new EntityWrapper<>());
    }


    /**
     * 信息
     * @param ${pk.lowerAttrName}
     * @return R
     */
    @GetMapping("/{${pk.lowerAttrName}}")
    public R info(@PathVariable("${pk.lowerAttrName}") ${pk.attrType} ${pk.lowerAttrName}){
			${className} ${classname} = ${classname}Service.selectById(${pk.lowerAttrName});
			return new R<>(${classname});
    }

    /**
     * 保存
     * @param ${classname}
     * @return R
     */
    @PostMapping
    public R save(@RequestBody ${className} ${classname}){
			return new R<>(${classname}Service.insert(${classname}));
    }

    /**
     * 修改
     * @param ${classname}
     * @return R
     */
    @PutMapping
    public R update(@RequestBody ${className} ${classname}){
			${classname}Service.updateById(${classname});
      return new R<>(Boolean.TRUE);
    }

    /**
     * 删除
     * @param ${pk.lowerAttrName}
     * @return R
     */
    @DeleteMapping("/{${pk.lowerAttrName}}")
    public R delete(@PathVariable ${pk.attrType} ${pk.lowerAttrName}){
      return new R<>(${classname}Service.deleteById(${pk.lowerAttrName}));
    }

}
