Commit ccb42772 authored by jiaorz's avatar jiaorz

Merge branch 'jrz_dev' into base-modify

parents 22693ca9 0a18d50b
......@@ -20,4 +20,14 @@ public class RandomListDto {
*/
private Integer location;
/**
* 新闻类型
*/
private Integer newsType;
/**
* 新闻id
*/
private Integer newsId;
}
......@@ -44,7 +44,7 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
*/
public PageInfo getArticleList(Integer page, Integer limit, Integer type) {
PageHelper.startPage(page, limit);
List articleList = mapper.getArticleList(type,null);
List articleList = mapper.getArticleList(type,null,null);
return PageInfo.of(articleList);
}
......@@ -71,21 +71,24 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
/**
* 随机获取三条连续的文章
*
*
*
* @param type
* @param id
* @return
*/
public List getThree(Integer type) {
List<Article> articleList = mapper.getArticleList(type,null);
public List getThree( Integer type, Integer number, Integer id) {
number = number == null ? RANDOM_NUMBER : number;
List<Article> articleList = mapper.getArticleList(type,null,id);
if (!Objects.isNull(articleList)) {
int size = articleList.size();
if (RANDOM_NUMBER >= size) {
if (number >= size) {
return articleList;
} else {
Random random = new Random();
int r = random.nextInt(size - RANDOM_NUMBER + 1);
int r = random.nextInt(size - number + 1);
List<Article> result = new ArrayList<>();
for (int i = 0; i < RANDOM_NUMBER.intValue(); i++) {
for (int i = 0; i < number.intValue(); i++) {
int index = i + r;
result.add(articleList.get(index));
}
......@@ -103,7 +106,7 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
* @return
*/
public List getHomePageArticle(Integer type) {
List<Article> articleList = mapper.getArticleList(type,HOME_PAGE_NUMBER);
List<Article> articleList = mapper.getArticleList(type,HOME_PAGE_NUMBER,null);
// if (Objects.isNull(articleList)) {
// return new ArrayList();
// } else {
......
......@@ -37,7 +37,7 @@ public class RandomListBiz {
* @param number 随机数,默认是2
* @return
*/
public ObjectRestResponse getRandomList(Integer type, Integer number, Integer location) {
public ObjectRestResponse getRandomList(Integer type, Integer number, Integer location, Integer id, Integer newsType) {
if(type != null) {
number = number == null ? 2 : number;
switch (TypeEnum.getByValue(type)) {
......@@ -50,7 +50,7 @@ public class RandomListBiz {
case ACTIVITY:
return ObjectRestResponse.succ(summitActivityBiz.getHostWithSummitActivity(number, location));
case NEWS:
return ObjectRestResponse.succ(articleBiz.getThree(type, number, id));
}
}
return ObjectRestResponse.succ();
......
......@@ -11,9 +11,11 @@ import java.util.List;
*/
public interface ArticleMapper extends Mapper<Article> {
/**
* 根据网站类型查询文章
* 获取获取文章信息
* @param type
* @param limit 已使用分业插件传null值即可,不要重复传
* @param id 当前文章id ,无就传null
* @return
*/
List<Article> getArticleList(@Param("type") Integer type,@Param( "limit") Integer limit);
List<Article> getArticleList(@Param("type") Integer type,@Param( "limit") Integer limit,@Param("id") Integer id);
}
......@@ -36,11 +36,16 @@ public class ArticleController extends BaseController<ArticleBiz, Article> {
return ObjectRestResponse.succ(baseBiz.getOne(id,urlType));
}
@GetMapping("/app/unauth/three/{type}")
/**
*
* @param type
* @param id 当前文章id
* @return
*/
@GetMapping("/app/unauth/three/{type}/{id}")
@ApiOperation(value = "随机获取三条数据")
public ObjectRestResponse randomAccessToThreeData(@PathVariable Integer type){
return ObjectRestResponse.succ(baseBiz.getThree(type));
public ObjectRestResponse randomAccessToThreeData(@PathVariable Integer type,@PathVariable Integer id){
return ObjectRestResponse.succ(baseBiz.getThree(type,id));
}
@GetMapping("/app/unauth/homePage/{type}")
......
......@@ -19,7 +19,7 @@ public class RandomListController {
if(randomListDto == null) {
return ObjectRestResponse.paramIsEmpty();
}
return randomListBiz.getRandomList(randomListDto.getType(), randomListDto.getNumber(), randomListDto.getLocation());
return randomListBiz.getRandomList(randomListDto.getType(), randomListDto.getNumber(), randomListDto.getLocation(), randomListDto.getNewsId(), randomListDto.getNewsType());
}
}
......@@ -47,9 +47,11 @@ public class VehicleModelController extends CommonBaseController {
@RequestMapping(value = "/detail/{name}", method = RequestMethod.GET)
@IgnoreUserToken
public ObjectRestResponse<VModelDetailVO> detail(@PathVariable("name") @ApiParam("车型名称") String name) {
return vehicleFeign.detailByParam(BeanUtil.beanToMap(new VehicleModel(){{
ObjectRestResponse<VModelDetailVO> objectRestResponse = vehicleFeign.detailByParam(BeanUtil.beanToMap(new VehicleModel(){{
setName(name);
}}, false, true));
objectRestResponse.getData().setUccnCataList(initUccnCataCollect(objectRestResponse.getData().getConfig()));
return objectRestResponse;
}
/**
......@@ -65,11 +67,18 @@ public class VehicleModelController extends CommonBaseController {
ObjectRestResponse<PageDataVO<VehicleModelVo>> objectRestResponse = vehicleFeign.findVehicleModelPageUnauthfind(vmqc);
PageDataVO<VehicleModelVo> pageDataVOs = objectRestResponse.getData();
pageDataVOs.getData().forEach( v -> {
List<VehiclePlatCata> vehiclePlatCataList = vehicleFeign.getCatasByIds(v.getConfig()).getData();
StrUtil.splitToInt("14,7,11", ",");
v.setUccnCataList(vehiclePlatCataList.parallelStream().filter(v1 -> {return ArrayUtil.contains(StrUtil.splitToInt("14,7,11", ","), v1.getParentId());}).sorted(Comparator.comparing(VehiclePlatCata::getParentId, (x, y) -> {
int xx = 0,yy = 0;
v.setUccnCataList(initUccnCataCollect(v.getConfig()));
});
return objectRestResponse;
}
private List<VehiclePlatCata> initUccnCataCollect(String modelConfig) {
List<VehiclePlatCata> vehiclePlatCataList = vehicleFeign.getCatasByIds(modelConfig).getData();
int[] array = StrUtil.splitToInt("14,7,11", ",");
return vehiclePlatCataList.parallelStream()
.filter(v1 -> {return ArrayUtil.contains(array, v1.getParentId());})
.sorted(Comparator.comparing(VehiclePlatCata::getParentId, (x, y) -> {
int xx = 0,yy = 0;
for(int i = 0; i < array.length; i++) {
if(x == array[i]) {
xx = i;
......@@ -78,8 +87,6 @@ public class VehicleModelController extends CommonBaseController {
}
}
return (xx - yy);
})).collect(Collectors.toList()));
});
return objectRestResponse;
})).collect(Collectors.toList());
}
}
......@@ -8,12 +8,18 @@
where
is_del=0
and status=1
<if test="id != null">
and id != #{id}
</if>
and (type=#{type} or type=0)
order by
weight ASC ,add_time DESC
<if test="limit != null">
limit #{limit}
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -19,4 +19,9 @@ public class VModelDetailVO extends VehicleModel {
@ApiModelProperty("会员列表")
List<BaseUserMemberLevel> userMemberLevel;
/**
* 官网需要显示的配置列表
*/
List<VehiclePlatCata> UccnCataList;
}
\ No newline at end of file
......@@ -48,6 +48,9 @@ public class VehicleModelVo extends VehicleModel implements Serializable {
@ApiModelProperty(value = "品牌")
private String brandName;
/**
* 官网需要显示的配置列表
*/
List<VehiclePlatCata> UccnCataList;
}
......@@ -677,6 +677,8 @@
and v.is_del = 0
and v.status != 3
and v.use_type = 1
and bc.is_del = 0
and bc.is_show = 1
</where>
</sql>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment