|
|
@@ -18,10 +18,13 @@ import com.goafanti.common.bo.Result;
|
|
|
import com.goafanti.common.constant.ErrorConstants;
|
|
|
import com.goafanti.common.controller.BaseApiController;
|
|
|
import com.goafanti.common.enums.AttachmentType;
|
|
|
+import com.goafanti.common.enums.LectureDynamicType;
|
|
|
+import com.goafanti.common.enums.LectureHotType;
|
|
|
import com.goafanti.common.enums.PatentInfoFields;
|
|
|
import com.goafanti.common.model.Lecture;
|
|
|
import com.goafanti.lecture.bo.InputLecture;
|
|
|
import com.goafanti.lecture.service.LectureService;
|
|
|
+import com.goafanti.user.service.UserService;
|
|
|
|
|
|
/**
|
|
|
* 科技讲堂
|
|
|
@@ -30,7 +33,54 @@ import com.goafanti.lecture.service.LectureService;
|
|
|
@RequestMapping(value = "/api/admin/lecture")
|
|
|
public class AdminLectureApiController extends BaseApiController {
|
|
|
@Resource
|
|
|
- private LectureService lectureService;
|
|
|
+ private LectureService lectureService;
|
|
|
+ @Resource
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
+ private static final Integer HOT_MAX_NUM = 4;
|
|
|
+
|
|
|
+ private static final Integer DYNAMIC_MAX_NUM = 9;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 大咖说页面展示列表
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/hotList", method = RequestMethod.GET)
|
|
|
+ public Result hotList() {
|
|
|
+ Result res = new Result();
|
|
|
+ res.setData(lectureService.listHot());
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 科技明星页面展示列表
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/dynamic", method = RequestMethod.GET)
|
|
|
+ public Result dynamic(){
|
|
|
+ Result res = new Result();
|
|
|
+ res.setData(lectureService.listDynamic());
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 专家及明星列表
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/starAndExpertList", method = RequestMethod.GET)
|
|
|
+ public Result starAndExpertList(Integer number, String engagedField, String username, String professionalTitle,
|
|
|
+ String workUnit, String pageNo, String pageSize) {
|
|
|
+ Result res = new Result();
|
|
|
+ Integer pNo = 1;
|
|
|
+ Integer pSize = 10;
|
|
|
+ if (StringUtils.isNumeric(pageSize)) {
|
|
|
+ pSize = Integer.parseInt(pageSize);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNumeric(pageNo)) {
|
|
|
+ pNo = Integer.parseInt(pageNo);
|
|
|
+ }
|
|
|
+ res.setData(
|
|
|
+ userService.listStarAndExpert(number, engagedField, username, professionalTitle, workUnit, pNo, pSize));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 新增
|
|
|
@@ -44,20 +94,10 @@ public class AdminLectureApiController extends BaseApiController {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
- if (StringUtils.isBlank(il.getUid())) {
|
|
|
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "讲堂开展人ID"));
|
|
|
+ if (!disposeLecture(res, il, lectureTimeFormattedDate).getError().isEmpty()) {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
- if (StringUtils.isBlank(il.getName())) {
|
|
|
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "讲堂名称"));
|
|
|
- return res;
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isBlank(lectureTimeFormattedDate)) {
|
|
|
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "讲堂开展时间"));
|
|
|
- return res;
|
|
|
- }
|
|
|
Lecture l = new Lecture();
|
|
|
BeanUtils.copyProperties(il, l);
|
|
|
lectureService.save(l, lectureTimeFormattedDate);
|
|
|
@@ -81,20 +121,10 @@ public class AdminLectureApiController extends BaseApiController {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
- if (StringUtils.isBlank(il.getUid())) {
|
|
|
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "讲堂开展人ID"));
|
|
|
- return res;
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isBlank(il.getName())) {
|
|
|
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "讲堂名称"));
|
|
|
+ if (!disposeLecture(res, il, lectureTimeFormattedDate).getError().isEmpty()) {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
- if (StringUtils.isBlank(lectureTimeFormattedDate)) {
|
|
|
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "讲堂开展时间"));
|
|
|
- return res;
|
|
|
- }
|
|
|
Lecture l = new Lecture();
|
|
|
BeanUtils.copyProperties(il, l);
|
|
|
lectureService.update(l, lectureTimeFormattedDate);
|
|
|
@@ -153,4 +183,48 @@ public class AdminLectureApiController extends BaseApiController {
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
+ private Result disposeLecture(Result res, InputLecture il, String lectureTimeFormattedDate) {
|
|
|
+ if (StringUtils.isBlank(il.getUid())) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "讲堂开展人ID"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(il.getName())) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "讲堂名称"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(lectureTimeFormattedDate)) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "讲堂开展时间"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null == il.getHot()) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "是否展示在大咖说页面标记"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null == il.getDynamic()) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "是否展示在科技明星页面标记"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (LectureDynamicType.DYNAMIC.getCode().equals(il.getDynamic())) {
|
|
|
+ Integer dynamicNum = lectureService.countDynamicNum();
|
|
|
+ if (null != dynamicNum && DYNAMIC_MAX_NUM == dynamicNum) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "展示在科技明星页面数量"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (LectureHotType.HOT.getCode().equals(il.getHot())) {
|
|
|
+ Integer hotNum = lectureService.countHotNum();
|
|
|
+ if (null != hotNum && HOT_MAX_NUM == hotNum) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "展示在大咖说页面数量"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
}
|