mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-09 10:56:50 +08:00
二期移动端接口
This commit is contained in:
@@ -68,7 +68,28 @@ public class Course extends BaseEntity {
|
||||
this.publishTime=publishTime;
|
||||
this.isTop=isTop;
|
||||
}
|
||||
|
||||
|
||||
public Course(String id,Integer type,String name,String coverImg, Float score,Integer studys,Integer comments,Integer shares,Integer praises,Integer favorites
|
||||
,String forUsers,String value,String summary,LocalDateTime publishTime,Boolean isTop,String sysType1,String sysType2,String sysType3) {
|
||||
this.setId(id);
|
||||
this.setType(type);
|
||||
this.setName(name);
|
||||
this.setCoverImg(coverImg);
|
||||
this.setScore(score);
|
||||
this.setComments(comments);
|
||||
this.setStudys(studys);
|
||||
this.setShares(shares);
|
||||
this.setPraises(praises);
|
||||
this.setFavorites(praises);
|
||||
this.forUsers=forUsers;
|
||||
this.value=value;
|
||||
this.summary=summary;
|
||||
this.publishTime=publishTime;
|
||||
this.isTop=isTop;
|
||||
this.sysType1=sysType1;
|
||||
this.sysType2=sysType2;
|
||||
this.sysType3=sysType3;
|
||||
}
|
||||
@Column(name = "kid")
|
||||
private String kid;
|
||||
|
||||
|
||||
@@ -115,6 +115,12 @@ public interface ICourseService {
|
||||
*/
|
||||
List<Course> findSimpleList(int pageIndex,String currentAid,CourseQueryDto dto);
|
||||
|
||||
|
||||
/**
|
||||
* 移动端首页
|
||||
* */
|
||||
List<Course> mobileList(int num,String aid,CourseQueryDto dto);
|
||||
|
||||
|
||||
/**
|
||||
* 添加课程
|
||||
|
||||
@@ -375,6 +375,51 @@ public class CourseServiceImpl implements ICourseService {
|
||||
return rs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Course> mobileList(int num, String aid,CourseQueryDto dto) {
|
||||
|
||||
List<IFieldFilter> filters = createFilters(dto);
|
||||
//自动添加过滤已删除
|
||||
filters.add(FieldFilters.eq("deleted",false));
|
||||
filters.add(FieldFilters.eq("enabled",true));
|
||||
//返回的结果
|
||||
|
||||
|
||||
QueryBuilder query=QueryBuilder.from(Course.class).addFilters(filters);
|
||||
|
||||
if(dto.getTopOrder()!=null) {
|
||||
if(dto.getTopOrder()){
|
||||
query.addOrder(OrderCondition.desc("isTop"));
|
||||
query.addOrder(OrderCondition.desc("topTime"));
|
||||
}
|
||||
}
|
||||
OrderCondition oc=null;
|
||||
if(StringUtils.isNotBlank(dto.getOrderField())) {
|
||||
if(dto.getOrderAsc()==null || dto.getOrderAsc()) {
|
||||
oc=OrderCondition.asc(dto.getOrderField());
|
||||
}else {
|
||||
oc=OrderCondition.desc(dto.getOrderField());
|
||||
}
|
||||
}else {
|
||||
//oc=OrderCondition.desc("id");
|
||||
//默认按发布时间排序
|
||||
oc=OrderCondition.desc("publishTime");
|
||||
}
|
||||
query.addOrder(oc);
|
||||
|
||||
List<Course> courses = this.userHobbyList(aid, dto.getOrderField(), dto.getOrderAsc());
|
||||
if(courses!=null && !courses.isEmpty()){
|
||||
num=num-courses.size();
|
||||
//重复的不包括
|
||||
List<String> courseIds = courses.stream().map(Course::getId).collect(Collectors.toList());
|
||||
query.addFilter(FieldFilters.notIn("id",courseIds));
|
||||
}
|
||||
query.setPageSize(num);
|
||||
query.addFields("new Course(id,type,name,coverImg,score,studys,comments,shares,praises,favorites,forUsers,value,summary,publishTime,isTop,sysType1,sysType2,sysType3)");
|
||||
List<Course> courseList = courseDao.findList(query.builder());
|
||||
return courseList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(Course course) {
|
||||
course.setComments(0);
|
||||
|
||||
@@ -7,10 +7,7 @@ import java.util.stream.Collectors;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.common.Pagination;
|
||||
@@ -212,5 +209,40 @@ public class PortalIndexApi extends ApiBaseController{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 移动端首页课程列表
|
||||
* 返回内容分类
|
||||
* */
|
||||
@GetMapping("/mobile-courseindex")
|
||||
public JsonResponse<List<Course>> mobileCourseIndex(Integer num,CourseQueryDto dto){
|
||||
if(num==null){
|
||||
num=5;
|
||||
}
|
||||
dto.setPublish(true);
|
||||
dto.setYearFilter(true);
|
||||
String aid = this.getCurrent().getAccountId();
|
||||
List<Course> courses = courseService.mobileList(num, aid, dto);
|
||||
//提取教师信息
|
||||
List<String> ids=new ArrayList<String>();
|
||||
|
||||
|
||||
for(Course c :courses) {
|
||||
ids.add(c.getId());
|
||||
}
|
||||
List<CourseTeacher> teachers = courseService.findTeachersByCourseIds(ids);
|
||||
//注意对于多个教师的情况,这里只是设置第一个教师
|
||||
for(Course c :courses) {
|
||||
for(CourseTeacher ct : teachers) {
|
||||
if(ct.getCourseId().equals(c.getId())) {
|
||||
c.setSysCreateAid(ct.getTeacherId());
|
||||
c.setSysCreateBy(ct.getTeacherName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return success(courses);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.xboe.system.user.api;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@@ -123,5 +124,38 @@ public class MessageApi extends ApiBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动端
|
||||
* 消息页面,按用户分组返回
|
||||
*
|
||||
* */
|
||||
@GetMapping("/mess-group")
|
||||
public JsonResponse<Map<String,Object>> messGroup(){
|
||||
String aid = this.getCurrent().getAccountId();
|
||||
if(StringUtil.isBlank(aid)){
|
||||
return badRequest("参数异常");
|
||||
}
|
||||
Map<String, Object> map = service.messGroup(aid);
|
||||
return success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动端
|
||||
* 按用户删除消息
|
||||
* */
|
||||
@GetMapping("/remove")
|
||||
public JsonResponse<Boolean> remove(String aid){
|
||||
if(StringUtil.isBlank(aid)){
|
||||
return badRequest("参数异常");
|
||||
}
|
||||
try {
|
||||
service.remove(aid);
|
||||
return success(true);
|
||||
} catch (Exception e) {
|
||||
return error("参数异常",e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.xboe.system.user.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.system.user.entity.Message;
|
||||
@@ -39,5 +40,15 @@ public interface IMessageService {
|
||||
* */
|
||||
void updateIsRead(List<String> ids);
|
||||
|
||||
/**
|
||||
* 移动端针对用户消息列表
|
||||
* */
|
||||
Map<String,Object> messGroup(String aid);
|
||||
|
||||
/**
|
||||
* 根据用户移除消息
|
||||
* */
|
||||
void remove(String aid);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.xboe.system.user.service.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@@ -76,4 +78,24 @@ public class MessageServiceImpl implements IMessageService {
|
||||
.builder());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> messGroup(String aid) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
QueryBuilder builder = QueryBuilder.from(Message.class);
|
||||
builder.addFilter(FieldFilters.eq("acceptId",aid));
|
||||
builder.addGroupBy("acceptId");
|
||||
List<Message> list = dao.findList(builder.builder());
|
||||
map.put("mess",list);
|
||||
//在查出未读消息数
|
||||
String sql="select count(1) from boe_message where is_read=false and acceptId=?1";
|
||||
int count = dao.sqlCount(sql, aid);
|
||||
map.put("count",count);
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(String aid) {
|
||||
dao.deleteByFilter(FieldFilters.eq("acceptId",aid));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user