diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/controller/AppletInformController.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/controller/AppletInformController.java new file mode 100644 index 00000000..2236224e --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/controller/AppletInformController.java @@ -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 queryUserInform(@RequestBody InformHistoryAppletPageDTO dto) { + PageMethod.startPage(dto); + List 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("修改通知状态失败"); + } + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/dto/InformHistoryAppletPageDTO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/dto/InformHistoryAppletPageDTO.java new file mode 100644 index 00000000..29f29e51 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/dto/InformHistoryAppletPageDTO.java @@ -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; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/dto/InformRangeUpdateWhetherDTO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/dto/InformRangeUpdateWhetherDTO.java new file mode 100644 index 00000000..7b402969 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/dto/InformRangeUpdateWhetherDTO.java @@ -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; + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/mapper/InformHistoryMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/mapper/InformHistoryMapper.java new file mode 100644 index 00000000..271baa45 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/mapper/InformHistoryMapper.java @@ -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 { + + List queryApplietPageList(@Param("content") InformHistoryAppletPageDTO content); +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/mapper/InformRangeMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/mapper/InformRangeMapper.java new file mode 100644 index 00000000..75276887 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/mapper/InformRangeMapper.java @@ -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 { +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/model/InformHistory.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/model/InformHistory.java new file mode 100644 index 00000000..89486577 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/model/InformHistory.java @@ -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; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/model/InformRange.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/model/InformRange.java new file mode 100644 index 00000000..753ef6fd --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/model/InformRange.java @@ -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; + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/service/InformHistoryService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/service/InformHistoryService.java new file mode 100644 index 00000000..0f0fa569 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/service/InformHistoryService.java @@ -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 { + + List queryAppletPageList(InformHistoryAppletPageDTO content); + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/service/InformRangeService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/service/InformRangeService.java new file mode 100644 index 00000000..c53507e9 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/service/InformRangeService.java @@ -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 { + + Long queryUnreadInformNum(Long custId); + + int updateWhether(InformRangeUpdateWhetherDTO content); + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/service/impl/InformHistoryServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/service/impl/InformHistoryServiceImpl.java new file mode 100644 index 00000000..ab9e199e --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/service/impl/InformHistoryServiceImpl.java @@ -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 implements InformHistoryService { + private static final Logger log = LoggerFactory.getLogger(InformHistoryServiceImpl.class); + @Resource + @Lazy + private InformRangeService informRangeService; + + + @Override + public List queryAppletPageList(InformHistoryAppletPageDTO content) { + List 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; + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/service/impl/InformRangeServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/service/impl/InformRangeServiceImpl.java new file mode 100644 index 00000000..4af3acfb --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/service/impl/InformRangeServiceImpl.java @@ -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 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())); + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/vo/InformHistoryAppletPageVO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/vo/InformHistoryAppletPageVO.java new file mode 100644 index 00000000..b8771137 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/notice/notice/v2/vo/InformHistoryAppletPageVO.java @@ -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; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/notice/InformHistoryMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/notice/InformHistoryMapper.xml new file mode 100644 index 00000000..c9ef6257 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/notice/InformHistoryMapper.xml @@ -0,0 +1,19 @@ + + + + + + + diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/notice/InformRangeMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/notice/InformRangeMapper.xml new file mode 100644 index 00000000..d6ec3d87 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/notice/InformRangeMapper.xml @@ -0,0 +1,5 @@ + + + + +