package ${packageName}.controller;

import java.util.List;

import lombok.RequiredArgsConstructor;
import ValidList;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import SwitchStatusEntity;
import org.springframework.web.bind.annotation.*;
import com.shkj.common.annotation.Log;
import com.shkj.common.enums.BusinessType;
import com.shkj.common.core.controller.BaseController;
import com.shkj.common.core.domain.Result;
import ${packageName}.vo.${ClassName}Vo;
import ${packageName}.bo.${ClassName}QueryBo;
import ${packageName}.bo.${ClassName}AddBo;
import ${packageName}.bo.${ClassName}EditBo;
import ${packageName}.service.I${ClassName}Service;
import com.shkj.common.core.page.TableDataInfo;
import com.shkj.common.utils.poi.ExcelUtil;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * ${functionName}Controller
 *
 * @menu ${functionName}管理
 * @author ${author}
 * @date ${datetime}
 */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/${moduleName}/${businessName}")
public class ${ClassName}Controller extends BaseController {

    private final I${ClassName}Service i${ClassName}Service;

    /**
     * 查询${functionName}列表
     */
    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
    @GetMapping("/list")
    public TableDataInfo<${ClassName}Vo> list(${ClassName}QueryBo bo) {
        startPage();
        List<${ClassName}Vo> list = i${ClassName}Service.queryList(bo);
        return getDataTable(list);
    }

    /**
     * 导出${functionName}列表
     */
    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
    @GetMapping("/export")
    public void export(HttpServletResponse response, ${ClassName}QueryBo bo) {
        List<${ClassName}Vo> list = i${ClassName}Service.queryList(bo);
        ExcelUtil<${ClassName}Vo> util = new ExcelUtil<${ClassName}Vo>(${ClassName}Vo.class);
        util.exportExcel(response, list, "${functionName}数据");
    }

    /**
     * 获取${functionName}详细信息
     */
    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
    @GetMapping("/{${pkColumn.javaField}}")
    public Result<${ClassName}Vo> getInfo(@PathVariable("${pkColumn.javaField}" ) ${pkColumn.javaType} ${pkColumn.javaField}) {
        return i${ClassName}Service.queryById(${pkColumn.javaField});
    }

    /**
     * 新增${functionName}
     */
    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
    @Log(title = "${functionName}", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public Result<Boolean> add(@Valid @RequestBody ${ClassName}AddBo bo) {
        return i${ClassName}Service.insertByAddBo(bo);
    }

    /**
     * 修改${functionName}
     */
    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
    @Log(title = "${functionName}", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public Result<Boolean> edit(@Valid @RequestBody ${ClassName}EditBo bo) {
        return i${ClassName}Service.updateByEditBo(bo);
    }

    /**
     * 删除${functionName}
     */
    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
    @Log(title = "${functionName}" , businessType = BusinessType.DELETE)
    @DeleteMapping("/remove")
    public Result<Boolean> remove(@Valid @RequestBody ValidList<Long> ids) {
        return i${ClassName}Service.deleteWithValidById(ids, true);
    }


}
