parent
f97183cfee
commit
a24b568419
|
|
@ -0,0 +1,74 @@
|
|||
package com.bonus.core.notice.notice.v2.controller;
|
||||
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.core.common.page.PageVO;
|
||||
import com.bonus.core.notice.notice.v2.dto.InformHistoryAppletPageDTO;
|
||||
import com.bonus.core.notice.notice.v2.dto.InformRangeUpdateWhetherDTO;
|
||||
import com.bonus.core.notice.notice.v2.service.InformHistoryService;
|
||||
import com.bonus.core.notice.notice.v2.service.InformRangeService;
|
||||
import com.bonus.core.notice.notice.v2.vo.InformHistoryAppletPageVO;
|
||||
import com.bonus.encrypt.RequiresGuest;
|
||||
import com.bonus.utils.LeRequest;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@Api(
|
||||
value = "用户获取临时消息",
|
||||
tags = {"用户获取临时消息"}
|
||||
)
|
||||
@RequestMapping({"/api/v2/applet/inform"})
|
||||
public class AppletInformController extends BaseController {
|
||||
@Resource
|
||||
@Lazy
|
||||
private InformHistoryService informHistoryService;
|
||||
@Resource
|
||||
@Lazy
|
||||
private InformRangeService informRangeService;
|
||||
|
||||
@PostMapping({"/queryUserInform"})
|
||||
@RequiresGuest
|
||||
@ApiOperation("用户获取通知消息")
|
||||
public PageVO<InformHistoryAppletPageVO> queryUserInform(@RequestBody InformHistoryAppletPageDTO dto) {
|
||||
PageMethod.startPage(dto);
|
||||
List<InformHistoryAppletPageVO> historyList = this.informHistoryService.queryAppletPageList(dto);
|
||||
return PageVO.of(historyList);
|
||||
}
|
||||
|
||||
@PostMapping({"/queryUnreadInformNum"})
|
||||
@RequiresGuest
|
||||
@ApiOperation("获取未读消息数量")
|
||||
public AjaxResult queryUnreadInformNum(@RequestBody InformHistoryAppletPageDTO dto) {
|
||||
try {
|
||||
return AjaxResult.success(this.informRangeService.queryUnreadInformNum(dto.getCustId()));
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("获取未读消息数量失败");
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping({"/updateStatus"})
|
||||
@RequiresGuest
|
||||
@ApiOperation("修改通知状态")
|
||||
public AjaxResult updateWhether(@RequestBody @Valid InformRangeUpdateWhetherDTO dto) {
|
||||
try {
|
||||
int count = this.informRangeService.updateWhether(dto);
|
||||
if (count == 0) {
|
||||
return AjaxResult.error("修改通知状态失败");
|
||||
}
|
||||
return AjaxResult.success("修改通知状态成功");
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("修改通知状态失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.bonus.core.notice.notice.v2.dto;
|
||||
|
||||
import com.bonus.core.common.page.PageDTO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
public class InformHistoryAppletPageDTO extends PageDTO {
|
||||
@ApiModelProperty("用户id")
|
||||
private @NotNull(
|
||||
message = "{notice_inform_his_query_null_cust_id_exception}"
|
||||
) Long custId;
|
||||
|
||||
public Long getCustId() {
|
||||
return this.custId;
|
||||
}
|
||||
|
||||
public void setCustId(final Long custId) {
|
||||
this.custId = custId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.bonus.core.notice.notice.v2.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
public class InformRangeUpdateWhetherDTO {
|
||||
@ApiModelProperty("通知记录id")
|
||||
private @NotNull(
|
||||
message = "{notice_null_id_exception}"
|
||||
) Long informhisId;
|
||||
@ApiModelProperty("通知人员id")
|
||||
private @NotNull(
|
||||
message = "{notice_inform_his_query_null_cust_id_exception}"
|
||||
) Long custId;
|
||||
|
||||
public Long getInformhisId() {
|
||||
return this.informhisId;
|
||||
}
|
||||
|
||||
public Long getCustId() {
|
||||
return this.custId;
|
||||
}
|
||||
|
||||
public void setInformhisId(final Long informhisId) {
|
||||
this.informhisId = informhisId;
|
||||
}
|
||||
|
||||
public void setCustId(final Long custId) {
|
||||
this.custId = custId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.bonus.core.notice.notice.v2.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bonus.core.notice.notice.v2.dto.InformHistoryAppletPageDTO;
|
||||
import com.bonus.core.notice.notice.v2.model.InformHistory;
|
||||
import com.bonus.core.notice.notice.v2.vo.InformHistoryAppletPageVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface InformHistoryMapper extends BaseMapper<InformHistory> {
|
||||
|
||||
List<InformHistoryAppletPageVO> queryApplietPageList(@Param("content") InformHistoryAppletPageDTO content);
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.bonus.core.notice.notice.v2.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bonus.core.notice.notice.v2.model.InformRange;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface InformRangeMapper extends BaseMapper<InformRange> {
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
package com.bonus.core.notice.notice.v2.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@TableName("inform_history")
|
||||
@ApiModel("通知记录 ")
|
||||
public class InformHistory implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId
|
||||
@ApiModelProperty("主键自增")
|
||||
private Long id;
|
||||
@ApiModelProperty("通知记录id")
|
||||
private Long informhisId;
|
||||
@ApiModelProperty("通知方式 2:公众号,999:临时通知")
|
||||
private Integer informType;
|
||||
@ApiModelProperty("通知时间")
|
||||
private LocalDateTime informStatime;
|
||||
@ApiModelProperty("通知名称")
|
||||
private String noticeName;
|
||||
@ApiModelProperty("通知内容")
|
||||
private String informContent;
|
||||
@ApiModelProperty("通知人员类型 日常活跃用户:1,30天内未下单用户:2,三个月未下单用户:3")
|
||||
private Integer noticeUserType;
|
||||
@ApiModelProperty("创建人")
|
||||
private String crby;
|
||||
@ApiModelProperty("创建时间")
|
||||
private LocalDateTime crtime;
|
||||
@ApiModelProperty("更新人")
|
||||
private String upby;
|
||||
@ApiModelProperty("更新时间")
|
||||
private LocalDateTime uptime;
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Long getInformhisId() {
|
||||
return this.informhisId;
|
||||
}
|
||||
|
||||
public Integer getInformType() {
|
||||
return this.informType;
|
||||
}
|
||||
|
||||
public LocalDateTime getInformStatime() {
|
||||
return this.informStatime;
|
||||
}
|
||||
|
||||
public String getNoticeName() {
|
||||
return this.noticeName;
|
||||
}
|
||||
|
||||
public String getInformContent() {
|
||||
return this.informContent;
|
||||
}
|
||||
|
||||
public Integer getNoticeUserType() {
|
||||
return this.noticeUserType;
|
||||
}
|
||||
|
||||
public String getCrby() {
|
||||
return this.crby;
|
||||
}
|
||||
|
||||
public LocalDateTime getCrtime() {
|
||||
return this.crtime;
|
||||
}
|
||||
|
||||
public String getUpby() {
|
||||
return this.upby;
|
||||
}
|
||||
|
||||
public LocalDateTime getUptime() {
|
||||
return this.uptime;
|
||||
}
|
||||
|
||||
public void setId(final Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setInformhisId(final Long informhisId) {
|
||||
this.informhisId = informhisId;
|
||||
}
|
||||
|
||||
public void setInformType(final Integer informType) {
|
||||
this.informType = informType;
|
||||
}
|
||||
|
||||
public void setInformStatime(final LocalDateTime informStatime) {
|
||||
this.informStatime = informStatime;
|
||||
}
|
||||
|
||||
public void setNoticeName(final String noticeName) {
|
||||
this.noticeName = noticeName;
|
||||
}
|
||||
|
||||
public void setInformContent(final String informContent) {
|
||||
this.informContent = informContent;
|
||||
}
|
||||
|
||||
public void setNoticeUserType(final Integer noticeUserType) {
|
||||
this.noticeUserType = noticeUserType;
|
||||
}
|
||||
|
||||
public void setCrby(final String crby) {
|
||||
this.crby = crby;
|
||||
}
|
||||
|
||||
public void setCrtime(final LocalDateTime crtime) {
|
||||
this.crtime = crtime;
|
||||
}
|
||||
|
||||
public void setUpby(final String upby) {
|
||||
this.upby = upby;
|
||||
}
|
||||
|
||||
public void setUptime(final LocalDateTime uptime) {
|
||||
this.uptime = uptime;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
package com.bonus.core.notice.notice.v2.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@TableName("inform_range")
|
||||
@ApiModel("通知人群 ")
|
||||
public class InformRange implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId
|
||||
@ApiModelProperty("主键自增")
|
||||
private Long id;
|
||||
@ApiModelProperty("通知记录id")
|
||||
private Long informhisId;
|
||||
@ApiModelProperty("通知人员id")
|
||||
private Long custId;
|
||||
@ApiModelProperty("是否通知成功")
|
||||
private Integer whether;
|
||||
@ApiModelProperty("创建人")
|
||||
private String crby;
|
||||
@ApiModelProperty("创建时间")
|
||||
private LocalDateTime crtime;
|
||||
@ApiModelProperty("更新人")
|
||||
private String upby;
|
||||
@ApiModelProperty("更新时间")
|
||||
private LocalDateTime uptime;
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Long getInformhisId() {
|
||||
return this.informhisId;
|
||||
}
|
||||
|
||||
public Long getCustId() {
|
||||
return this.custId;
|
||||
}
|
||||
|
||||
public Integer getWhether() {
|
||||
return this.whether;
|
||||
}
|
||||
|
||||
public String getCrby() {
|
||||
return this.crby;
|
||||
}
|
||||
|
||||
public LocalDateTime getCrtime() {
|
||||
return this.crtime;
|
||||
}
|
||||
|
||||
public String getUpby() {
|
||||
return this.upby;
|
||||
}
|
||||
|
||||
public LocalDateTime getUptime() {
|
||||
return this.uptime;
|
||||
}
|
||||
|
||||
public void setId(final Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setInformhisId(final Long informhisId) {
|
||||
this.informhisId = informhisId;
|
||||
}
|
||||
|
||||
public void setCustId(final Long custId) {
|
||||
this.custId = custId;
|
||||
}
|
||||
|
||||
public void setWhether(final Integer whether) {
|
||||
this.whether = whether;
|
||||
}
|
||||
|
||||
public void setCrby(final String crby) {
|
||||
this.crby = crby;
|
||||
}
|
||||
|
||||
public void setCrtime(final LocalDateTime crtime) {
|
||||
this.crtime = crtime;
|
||||
}
|
||||
|
||||
public void setUpby(final String upby) {
|
||||
this.upby = upby;
|
||||
}
|
||||
|
||||
public void setUptime(final LocalDateTime uptime) {
|
||||
this.uptime = uptime;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.bonus.core.notice.notice.v2.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bonus.core.notice.notice.v2.dto.InformHistoryAppletPageDTO;
|
||||
import com.bonus.core.notice.notice.v2.model.InformHistory;
|
||||
import com.bonus.core.notice.notice.v2.vo.InformHistoryAppletPageVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface InformHistoryService extends IService<InformHistory> {
|
||||
|
||||
List<InformHistoryAppletPageVO> queryAppletPageList(InformHistoryAppletPageDTO content);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.bonus.core.notice.notice.v2.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bonus.core.notice.notice.v2.dto.InformRangeUpdateWhetherDTO;
|
||||
import com.bonus.core.notice.notice.v2.model.InformRange;
|
||||
|
||||
|
||||
public interface InformRangeService extends IService<InformRange> {
|
||||
|
||||
Long queryUnreadInformNum(Long custId);
|
||||
|
||||
int updateWhether(InformRangeUpdateWhetherDTO content);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.bonus.core.notice.notice.v2.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bonus.constant.LeConstants;
|
||||
import com.bonus.core.notice.notice.v2.dto.InformHistoryAppletPageDTO;
|
||||
import com.bonus.core.notice.notice.v2.mapper.InformHistoryMapper;
|
||||
import com.bonus.core.notice.notice.v2.model.InformHistory;
|
||||
import com.bonus.core.notice.notice.v2.model.InformRange;
|
||||
import com.bonus.core.notice.notice.v2.service.InformHistoryService;
|
||||
import com.bonus.core.notice.notice.v2.service.InformRangeService;
|
||||
import com.bonus.core.notice.notice.v2.vo.InformHistoryAppletPageVO;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class InformHistoryServiceImpl extends ServiceImpl<InformHistoryMapper, InformHistory> implements InformHistoryService {
|
||||
private static final Logger log = LoggerFactory.getLogger(InformHistoryServiceImpl.class);
|
||||
@Resource
|
||||
@Lazy
|
||||
private InformRangeService informRangeService;
|
||||
|
||||
|
||||
@Override
|
||||
public List<InformHistoryAppletPageVO> queryAppletPageList(InformHistoryAppletPageDTO content) {
|
||||
List<InformHistoryAppletPageVO> historyList = ((InformHistoryMapper)this.baseMapper).queryApplietPageList(content);
|
||||
if (ObjectUtil.isNotEmpty(historyList)) {
|
||||
this.informRangeService.update(Wrappers.lambdaUpdate(InformRange.class)
|
||||
.set(InformRange::getWhether, LeConstants.COMMON_YES)
|
||||
.eq(InformRange::getCustId, content.getCustId())
|
||||
.eq(InformRange::getWhether, LeConstants.COMMON_NO));
|
||||
}
|
||||
|
||||
return historyList;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package com.bonus.core.notice.notice.v2.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bonus.constant.LeConstants;
|
||||
import com.bonus.core.notice.notice.v2.dto.InformRangeUpdateWhetherDTO;
|
||||
import com.bonus.core.notice.notice.v2.mapper.InformRangeMapper;
|
||||
import com.bonus.core.notice.notice.v2.model.InformRange;
|
||||
import com.bonus.core.notice.notice.v2.service.InformRangeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@Service
|
||||
public class InformRangeServiceImpl extends ServiceImpl<InformRangeMapper, InformRange> implements InformRangeService {
|
||||
|
||||
@Override
|
||||
public Long queryUnreadInformNum(Long custId) {
|
||||
return ((InformRangeMapper)this.baseMapper).selectCount(Wrappers.lambdaQuery(InformRange.class)
|
||||
.eq(InformRange::getCustId, custId)
|
||||
.eq(InformRange::getWhether, LeConstants.COMMON_NO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateWhether(InformRangeUpdateWhetherDTO content) {
|
||||
return ((InformRangeMapper)this.baseMapper).update(null,Wrappers.lambdaUpdate(InformRange.class)
|
||||
.set(InformRange::getWhether, LeConstants.COMMON_YES)
|
||||
.eq(InformRange::getCustId, content.getCustId())
|
||||
.eq(InformRange::getInformhisId, content.getInformhisId()));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.bonus.core.notice.notice.v2.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class InformHistoryAppletPageVO {
|
||||
@ApiModelProperty("通知记录id")
|
||||
private Long informhisId;
|
||||
@ApiModelProperty("通知方式")
|
||||
private Integer informType;
|
||||
@ApiModelProperty("通知时间")
|
||||
private LocalDateTime informStatime;
|
||||
@ApiModelProperty("通知内容")
|
||||
private String informContent;
|
||||
|
||||
public Long getInformhisId() {
|
||||
return this.informhisId;
|
||||
}
|
||||
|
||||
public Integer getInformType() {
|
||||
return this.informType;
|
||||
}
|
||||
|
||||
public LocalDateTime getInformStatime() {
|
||||
return this.informStatime;
|
||||
}
|
||||
|
||||
public String getInformContent() {
|
||||
return this.informContent;
|
||||
}
|
||||
|
||||
public void setInformhisId(final Long informhisId) {
|
||||
this.informhisId = informhisId;
|
||||
}
|
||||
|
||||
public void setInformType(final Integer informType) {
|
||||
this.informType = informType;
|
||||
}
|
||||
|
||||
public void setInformStatime(final LocalDateTime informStatime) {
|
||||
this.informStatime = informStatime;
|
||||
}
|
||||
|
||||
public void setInformContent(final String informContent) {
|
||||
this.informContent = informContent;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.bonus.core.notice.notice.v2.mapper.InformHistoryMapper">
|
||||
|
||||
<select id="queryApplietPageList" resultType="com.bonus.core.notice.notice.v2.vo.InformHistoryAppletPageVO">
|
||||
SELECT t1.informhis_id,
|
||||
t1.inform_type,
|
||||
t1.inform_statime,
|
||||
t1.inform_content
|
||||
FROM inform_history t1
|
||||
WHERE EXISTS(SELECT NULL
|
||||
FROM inform_range t2
|
||||
WHERE t1.informhis_id = t2.informhis_id
|
||||
AND t2.cust_id =
|
||||
#{content.custId})
|
||||
ORDER BY t1.inform_statime DESC
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.bonus.core.notice.notice.v2.mapper.InformRangeMapper">
|
||||
</mapper>
|
||||
Reference in New Issue