package ${packageName}.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.*;
import com.yccrc.common.utils.PageUtils;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
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.RestController;
import com.yccrc.common.annotation.Log;
import com.yccrc.common.core.controller.BaseController;
import com.yccrc.common.vo.*;
import io.swagger.annotations.*;
import com.yccrc.common.enums.BusinessType;
import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service;
import com.yccrc.common.utils.poi.ExcelUtil;


/**
 * ${functionName}Controller
 * 
 * @author ${author}
 * @date ${datetime}
 */
@Api(tags = "${functionName}")
@RestController
@RequestMapping("/${moduleName}/${businessName}")
public class ${ClassName}Controller extends BaseController
{
    @Autowired
    private I${ClassName}Service ${className}Service;

    
    @ApiOperation(value = "查询${functionName}列表")
    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
    @GetMapping("/list")
    public Result<Page<${ClassName}>> list(${ClassName} ${className})
    {
       return new Result<Page<${ClassName}>>().ok(${className}Service.page(PageUtils.initPage(), new QueryWrapper<>(${className})));
     
    }

    @ApiOperation(value = "导出${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.list(new QueryWrapper<${ClassName}>(${className}));
        ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
        util.exportExcel(response, list, "${functionName}数据");
    }

    @ApiOperation(value = "获取${functionName}详细信息")
    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
    @GetMapping(value = "/{${pkColumn.javaField}}")
    public Result<${ClassName}> getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
    {
        return new Result<${ClassName}>().ok(${className}Service.getById(${pkColumn.javaField}));
    }

    @ApiOperation(value = "新增${functionName}")
    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
    @Log(title = "${functionName}", businessType = BusinessType.INSERT)
    @PostMapping
    public Result<Boolean> add(@RequestBody ${ClassName} ${className})
    {
        return new Result<Boolean>().ok(${className}Service.save(${className}));
    }

    @ApiOperation(value = "修改${functionName}")
    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
    @Log(title = "${functionName}", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result<Boolean> edit(@RequestBody ${ClassName} ${className})
    {
        return new Result<Boolean>().ok(${className}Service.updateById(${className}));
    }

    @ApiOperation(value = "删除${functionName}")
    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
    @Log(title = "${functionName}", businessType = BusinessType.DELETE)
	@DeleteMapping("/{${pkColumn.javaField}s}")
    public Result<Boolean> remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
    {
        return new Result<Boolean>().ok(${className}Service.removeBatchByIds(Arrays.asList(${pkColumn.javaField}s)));
    }
}
