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