package ${entity.controllerPackage};

import cn.exrick.xboot.core.base.XbootBaseController;
import cn.exrick.xboot.core.common.utils.PageUtil;
import cn.exrick.xboot.core.common.utils.ResultUtil;
import cn.exrick.xboot.core.common.vo.PageVo;
import cn.exrick.xboot.core.common.vo.Result;
import cn.exrick.xboot.core.common.vo.SearchVo;
import ${entity.entityPackage}.${entity.className};
import ${entity.servicePackage}.${entity.className}Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author ${entity.author}
 */
@Slf4j
@RestController
@Api(description = "${entity.description}管理接口")
@RequestMapping("/xboot/${entity.classNameLowerCase}")
@Transactional
public class ${entity.className}Controller extends XbootBaseController<${entity.className}, ${entity.primaryKeyType}> {

    @Autowired
    private ${entity.className}Service ${entity.classNameLowerCase}Service;

    @Override
    public ${entity.className}Service getService() {
        return ${entity.classNameLowerCase}Service;
    }

    @RequestMapping(value = "/getByCondition", method = RequestMethod.GET)
    @ApiOperation(value = "多条件分页获取")
    public Result<Page<${entity.className}>> getByCondition(${entity.className} ${entity.classNameLowerCase},
                                                            SearchVo searchVo,
                                                            PageVo pageVo){

        Page<${entity.className}> page = ${entity.classNameLowerCase}Service.findByCondition(${entity.classNameLowerCase}, searchVo, PageUtil.initPage(pageVo));
        return new ResultUtil<Page<${entity.className}>>().setData(page);
    }
}
