|
@@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.rf.check.base.rest.BaseController;
|
|
import com.rf.check.base.rest.BaseController;
|
|
import com.rf.check.picture.dao.model.PictureEntity;
|
|
import com.rf.check.picture.dao.model.PictureEntity;
|
|
import com.rf.check.picture.service.PictureService;
|
|
import com.rf.check.picture.service.PictureService;
|
|
|
|
+import com.rf.check.utils.Constant;
|
|
|
|
+import com.rf.check.utils.DateUtil;
|
|
import com.rf.check.utils.LunarCalendarFestivalUtils;
|
|
import com.rf.check.utils.LunarCalendarFestivalUtils;
|
|
import com.rf.check.utils.Result;
|
|
import com.rf.check.utils.Result;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
@@ -32,10 +34,10 @@ public class PictureController extends BaseController {
|
|
private PictureService pictureService;
|
|
private PictureService pictureService;
|
|
|
|
|
|
@GetMapping("/findPictureList")
|
|
@GetMapping("/findPictureList")
|
|
- @ApiOperation(value = "背景图片列表查询", notes = "参数包括:beginNum:页码,pageSize:每页条数,category:图片分类(四季-1;风景-2;旅行-3;生活-4;宠物-5;卡通-6;其他-7)")
|
|
|
|
|
|
+ @ApiOperation(value = "背景图片列表查询", notes = "参数包括:beginNum:页码,pageSize:每页条数,category:图片分类(问安-1;风景-2;趣味-3;生活-4;宠物-5;卡通-6;心情-7)")
|
|
public Result findPictureList(String category, int beginNum, int pageSize) {
|
|
public Result findPictureList(String category, int beginNum, int pageSize) {
|
|
Page<PictureEntity> pictureEntities = null;
|
|
Page<PictureEntity> pictureEntities = null;
|
|
- if (category.equals("7")) {
|
|
|
|
|
|
+ if (category.equals("0")) {
|
|
pictureEntities = this.pictureService.findPictureOtherList(beginNum, pageSize);
|
|
pictureEntities = this.pictureService.findPictureOtherList(beginNum, pageSize);
|
|
}else {
|
|
}else {
|
|
pictureEntities = this.pictureService.findPictureList(category, beginNum, pageSize);
|
|
pictureEntities = this.pictureService.findPictureList(category, beginNum, pageSize);
|
|
@@ -71,10 +73,53 @@ public class PictureController extends BaseController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (pictureEntities.size() == 0) {
|
|
if (pictureEntities.size() == 0) {
|
|
- PictureEntity pictureEntitie = this.pictureService.recommendPicture();
|
|
|
|
- pictureEntities.add(pictureEntitie);
|
|
|
|
|
|
+ List<PictureEntity> pictureEntitieList = this.pictureService.recommendPicture(Integer.parseInt(Constant.MAGIC_NUM_3));
|
|
|
|
+ pictureEntities.addAll(pictureEntitieList);
|
|
|
|
+ }else if (pictureEntities.size() == 1) {
|
|
|
|
+ List<PictureEntity> pictureEntitieList = this.pictureService.recommendPicture(Integer.parseInt(Constant.MAGIC_NUM_2));
|
|
|
|
+ pictureEntities.addAll(pictureEntitieList);
|
|
|
|
+ }else if (pictureEntities.size() == 2) {
|
|
|
|
+ List<PictureEntity> pictureEntitieList = this.pictureService.recommendPicture(Integer.parseInt(Constant.MAGIC_NUM_1));
|
|
|
|
+ pictureEntities.addAll(pictureEntitieList);
|
|
}
|
|
}
|
|
return success(pictureEntities);
|
|
return success(pictureEntities);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @GetMapping("/share")
|
|
|
|
+ @ApiOperation(value = "分享成功", notes = "参数包括:pictureId:图片ID")
|
|
|
|
+ public Result share(String pictureId) {
|
|
|
|
+ PictureEntity pictureEntity = this.pictureService.findById(pictureId);
|
|
|
|
+ if (pictureEntity != null){
|
|
|
|
+ pictureEntity.setShareNum(pictureEntity.getShareNum() + 1);
|
|
|
|
+ pictureEntity.setUpdateTime(DateUtil.getNowTime());
|
|
|
|
+ this.pictureService.save(pictureEntity);
|
|
|
|
+ }else {
|
|
|
|
+ return fail("图片不存在");
|
|
|
|
+ }
|
|
|
|
+ return success("分享成功");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/festival")
|
|
|
|
+ @ApiOperation(value = "获取节日信息", notes = "")
|
|
|
|
+ public Result festival() {
|
|
|
|
+ JSONObject festival = new JSONObject();
|
|
|
|
+ festival.put("lunarTerm","");
|
|
|
|
+ festival.put("lunarFestival","");
|
|
|
|
+ festival.put("solarFestival","");
|
|
|
|
+ JSONObject jsonObject = LunarCalendarFestivalUtils.isSpecialDate();
|
|
|
|
+ //判断当日是否为某个节气
|
|
|
|
+ if (jsonObject.containsKey("lunarTerm")) {
|
|
|
|
+ festival.put("lunarTerm",jsonObject.getString("lunarTerm"));
|
|
|
|
+ }
|
|
|
|
+ //判断当日是否为某个农历节日
|
|
|
|
+ if (jsonObject.containsKey("lunarFestival")) {
|
|
|
|
+ festival.put("lunarFestival",jsonObject.getString("lunarFestival"));
|
|
|
|
+ }
|
|
|
|
+ //判断当日是否为某个公立节日
|
|
|
|
+ if (jsonObject.containsKey("solarFestival")) {
|
|
|
|
+ festival.put("solarFestival",jsonObject.getString("solarFestival"));
|
|
|
|
+ }
|
|
|
|
+ return success(festival);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|