mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-13 12:56:48 +08:00
提交修改
This commit is contained in:
@@ -22,7 +22,7 @@ public class PopupApi extends ApiBaseController {
|
||||
/**
|
||||
* 前端查询,只是查询出对于当前用户来说需要弹出的
|
||||
* */
|
||||
@PostMapping("/user")
|
||||
@GetMapping("/user")
|
||||
public JsonResponse<List<Popup>> userList(){
|
||||
String aid=getCurrent().getAccountId();
|
||||
List<Popup> list = service.findForUser(aid);
|
||||
@@ -38,6 +38,15 @@ public class PopupApi extends ApiBaseController {
|
||||
List<Popup> list = service.list(popup);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public JsonResponse<Boolean> list(String popupId){
|
||||
String aid=getCurrent().getAccountId();
|
||||
service.addUser(aid, popupId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/find-user")
|
||||
public JsonResponse<List<Popup>> findForUser(String aid){
|
||||
|
||||
@@ -43,4 +43,10 @@ public interface IPopupService {
|
||||
* 删除
|
||||
* */
|
||||
void delete(String id);
|
||||
|
||||
/**
|
||||
* 添加弹出了的用户
|
||||
* @param popupId
|
||||
*/
|
||||
void addUser(String aid,String popupId);
|
||||
}
|
||||
|
||||
@@ -81,25 +81,31 @@ public class PopupServiceImpl implements IPopupService {
|
||||
|
||||
@Override
|
||||
public List<Popup> findForUser(String aid) {
|
||||
//根据时间查询,在时间内的。
|
||||
//根据时间查询,查询出时间内需要弹出的内容
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
List<Popup> list=popupDao.findList(FieldFilters.le("p.startTime",now),FieldFilters.ge("p.endTime",now));
|
||||
List<Popup> rslist=new ArrayList<Popup>();
|
||||
for(Popup p: list) {
|
||||
if(p.getOnce()!=null && p.getOnce()) {
|
||||
//只是查询一次
|
||||
List<PopupUser> pu = popupUserDao.findList(FieldFilters.eq("aid",aid),FieldFilters.eq("popupId",p.getId()));
|
||||
if(pu.isEmpty()) {
|
||||
rslist.add(p);
|
||||
}
|
||||
}else {
|
||||
rslist.add(p);
|
||||
}
|
||||
}
|
||||
return rslist;
|
||||
}
|
||||
|
||||
String from ="Popup p,PopupUser pu";
|
||||
QueryBuilder builder = QueryBuilder.from(from);
|
||||
builder.addFilter(FieldFilters.eqField("p.id","pu.popupId"));
|
||||
//当前时间在时间内的
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
builder.addFilter(FieldFilters.ge("p.startTime",now));
|
||||
builder.addFilter(FieldFilters.lt("p.endTime",now));
|
||||
if(StringUtil.isNotBlank(aid)){
|
||||
builder.addFilter(FieldFilters.eq("pu.aid",aid));
|
||||
}
|
||||
builder.addFilter(FieldFilters.eq("pu.status",false));
|
||||
// builder.addFilter(FieldFilters.eq("p.once",true));
|
||||
builder.addFields("p");
|
||||
List<Popup> list = popupDao.findList(builder.builder());
|
||||
|
||||
//如果一个用户只弹一次,还要结合 PopupUser 查询,
|
||||
return list;
|
||||
@Override
|
||||
public void addUser(String aid,String popupId) {
|
||||
PopupUser pu=new PopupUser();
|
||||
pu.setAid(aid);
|
||||
pu.setPopupId(popupId);
|
||||
pu.setStatus(true);
|
||||
popupUserDao.save(pu);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user