利用OssListDto实体类接收多个参数,同时利用@RequestParam参数接收单个参数
@Api(tags="bs_file_store") @RestController @RequestMapping("/test/bsFileStore") @Slf4j public class BsFileStoreController extends JeecgController<BsFileStore, IBsFileStoreService> { @Autowired private IBsFileStoreService bsFileStoreService; /** * 分页列表查询 * * @param ossListDto * @param pageNo * @param pageSize * @param req * @return */ @AutoLog(value = "bs_file_store-分页列表查询") @ApiOperation(value="bs_file_store-分页列表查询", notes="bs_file_store-分页列表查询") @GetMapping(value = "/list") public Result<?> queryOssList(OssListDto ossListDto, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) { log.info(pageNo.toString()); log.info(pageSize.toString()); return Result.OK(bsFileStoreService.queryOssList(ossListDto,pageNo,pageSize)); } }
(1)service接口
public interface IBsFileStoreService extends IService<BsFileStore> { /** * 存储列表 * @param ossListDto * @param pageNo * @param pageSize * @return */ IPage<OssListDto> queryOssList(OssListDto ossListDto, Integer pageNo, Integer pageSize); }
(2)实现类
@Service @DS("multi-datasource1") @Slf4j public class BsFileStoreServiceImpl extends ServiceImpl<BsFileStoreMapper, BsFileStore> implements IBsFileStoreService { @Autowired private BsFileStoreMapper bsFileStoreMapper; @Override public IPage<OssListDto> queryOssList(OssListDto ossListDto, Integer pageNo, Integer pageSize) { Page<OssListDto> page=new Page<>(pageNo,pageSize); List<OssListDto> ossList=bsFileStoreMapper.queryOssList(ossListDto); log.info("hell0"); return null; } }
public interface BsFileStoreMapper extends BaseMapper<BsFileStore> { /** * oss存储列表 * @param ossListDto * @return */ List<OssListDto> queryOssList(OssListDto ossListDto); }
对应的xml文件:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.jeecg.modules.mapper.BsFileStoreMapper"> <!--多表关联查询,推荐直接用传统 mybatis xml--> <select id="queryOssList" resultType="org.jeecg.modules.dto.OssListDto"> select id,os_name as osName,IFNULL(NULL,1) storeType,endpoint_first as storePath from pm_os_info <where> <if test="osName!=null"> os_name=#{osName} </if> </where> </select> </mapper>
#{osName}是拿取BsFileStoreMapper接口中queryOssList方法所传递的实体类OssListDto中的osName成员变量,将其作为where条件的参数
id="queryOssList"
postman模拟前端:
后端debug界面: