master:通知公告功能完善;

pull/1121/head
liujiang 2025-06-06 11:05:00 +08:00
parent 4792a2105c
commit dd25d08717
21 changed files with 431 additions and 385 deletions

View File

@ -1,19 +1,10 @@
package com.ruoyi.web.controller.xkt;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.XktBaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.xkt.domain.UserNoticeSetting;
import com.ruoyi.xkt.service.IUserNoticeSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Controller
@ -27,65 +18,4 @@ public class UserNoticeSettingController extends XktBaseController {
@Autowired
private IUserNoticeSettingService userNoticeSettingService;
/**
*
*/
// @PreAuthorize("@ss.hasPermi('system:setting:list')")
@GetMapping("/list")
public TableDataInfo list(UserNoticeSetting userNoticeSetting) {
startPage();
List<UserNoticeSetting> list = userNoticeSettingService.selectUserNoticeSettingList(userNoticeSetting);
return getDataTable(list);
}
/**
*
*/
// @PreAuthorize("@ss.hasPermi('system:setting:export')")
@Log(title = "用户通知接收设置", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, UserNoticeSetting userNoticeSetting) {
List<UserNoticeSetting> list = userNoticeSettingService.selectUserNoticeSettingList(userNoticeSetting);
ExcelUtil<UserNoticeSetting> util = new ExcelUtil<UserNoticeSetting>(UserNoticeSetting.class);
util.exportExcel(response, list, "用户通知接收设置数据");
}
/**
*
*/
// @PreAuthorize("@ss.hasPermi('system:setting:query')")
@GetMapping(value = "/{userNoticeSetId}")
public R getInfo(@PathVariable("userNoticeSetId") Long userNoticeSetId) {
return success(userNoticeSettingService.selectUserNoticeSettingByUserNoticeSetId(userNoticeSetId));
}
/**
*
*/
// @PreAuthorize("@ss.hasPermi('system:setting:add')")
@Log(title = "用户通知接收设置", businessType = BusinessType.INSERT)
@PostMapping
public R add(@RequestBody UserNoticeSetting userNoticeSetting) {
return success(userNoticeSettingService.insertUserNoticeSetting(userNoticeSetting));
}
/**
*
*/
// @PreAuthorize("@ss.hasPermi('system:setting:edit')")
@Log(title = "用户通知接收设置", businessType = BusinessType.UPDATE)
@PutMapping
public R edit(@RequestBody UserNoticeSetting userNoticeSetting) {
return success(userNoticeSettingService.updateUserNoticeSetting(userNoticeSetting));
}
/**
*
*/
// @PreAuthorize("@ss.hasPermi('system:setting:remove')")
@Log(title = "用户通知接收设置", businessType = BusinessType.DELETE)
@DeleteMapping("/{userNoticeSetIds}")
public R remove(@PathVariable Long[] userNoticeSetIds) {
return success(userNoticeSettingService.deleteUserNoticeSettingByUserNoticeSetIds(userNoticeSetIds));
}
}

View File

@ -16,6 +16,9 @@ import java.util.List;
@Data
public class StoreProdStatusVO {
@NotNull(message = "档口ID不能为空!")
@ApiModelProperty(value = "档口ID", required = true)
private Long storeId;
@NotNull(message = "档口商品ID不能为空!")
@ApiModelProperty(value = "档口商品ID", required = true)
private List<Long> storeProdIdList;

View File

@ -253,5 +253,9 @@ public class CacheConstants {
* 20
*/
public static final String SEARCH_HOT_KEY = "search_hot_key";
/**
* 广
*/
public static final String ADVERT_KEY = "advert:";
}

View File

@ -541,7 +541,7 @@ public class XktTask {
}
/**
* 12:00:01storereidis
* 12:00:01storeredis
*/
public void saveStoreToRedis() {
List<Store> storeList = this.storeMapper.selectList(new LambdaQueryWrapper<Store>()
@ -554,6 +554,19 @@ public class XktTask {
});
}
/**
* 12:45:00 advertredis
*/
public void saveAdvertToRedis() {
List<Advert> advertList = this.advertMapper.selectList(new LambdaQueryWrapper<Advert>()
.eq(Advert::getDelFlag, Constants.UNDELETED));
if (CollectionUtils.isEmpty(advertList)) {
return;
}
advertList.forEach(advert ->
redisCache.setCacheObject(CacheConstants.ADVERT_KEY + advert.getId(), advert, 1, TimeUnit.DAYS));
}
/**
* 00:00:30symbolredis
*/
@ -576,6 +589,8 @@ public class XktTask {
// 搜图服务同步
// sync2ImgSearchServer(storeProd.getId(), storeProdDTO.getFileList());
// 新增档口商品动态、关注档口用户 通知公告
}
/**

View File

@ -3,8 +3,10 @@ package com.ruoyi.xkt.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.domain.XktBaseEntity;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
@ -16,6 +18,7 @@ import java.util.Date;
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
public class UserNotice extends XktBaseEntity {
private static final long serialVersionUID = 1L;
@ -36,6 +39,11 @@ public class UserNotice extends XktBaseEntity {
*/
private Long userId;
/**
*
*/
private Integer targetNoticeType;
/**
* 0 1
*/

View File

@ -5,8 +5,6 @@ import com.ruoyi.common.core.domain.XktBaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* user_notice_setting
*
@ -43,25 +41,5 @@ public class UserNoticeSetting extends XktBaseEntity {
* [] 0 1
*/
private Integer favoriteNotice;
/**
* []广 0 1
*/
private Integer advertNotice;
/**
* [] 0 1
*/
private Integer prodNotice;
/**
* [] 0 1
*/
private Integer smsNotice;
/**
* [] yyyy-MM-dd HH:mm
*/
private Date smsNoticeStart;
/**
* [] yyyy-MM-dd HH:mm
*/
private Date smsNoticeEnd;
}

View File

@ -15,6 +15,8 @@ import java.util.List;
@Data
public class StoreProdStatusDTO {
@ApiModelProperty(value = "档口ID")
private Long storeId;
@ApiModelProperty("档口商品名称")
private List<Long> storeProdIdList;
@ApiModelProperty("档口商品状态")

View File

@ -6,7 +6,7 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 广
*
*
* @author liujiang
* @date 2025-04-02 23:42
@ -32,6 +32,6 @@ public enum NoticeReadType {
return e;
}
}
throw new ServiceException("营销推广展示类型不存在!", HttpStatus.ERROR);
throw new ServiceException("通知公告阅读类型不存在!", HttpStatus.ERROR);
}
}

View File

@ -0,0 +1,37 @@
package com.ruoyi.xkt.enums;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.exception.ServiceException;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
*
*
* @author liujiang
* @date 2025-04-02 23:42
*/
@Getter
@AllArgsConstructor
public enum NoticeReceiveType {
// 不接收
UN_RECEIVE(0, "不接收"),
// 接收
RECEIVE(1, "接收"),
;
private final Integer value;
private final String label;
public static NoticeReceiveType of(Integer value) {
for (NoticeReceiveType e : NoticeReceiveType.values()) {
if (e.getValue().equals(value)) {
return e;
}
}
throw new ServiceException("通知公告接收类型不存在!", HttpStatus.ERROR);
}
}

View File

@ -0,0 +1,37 @@
package com.ruoyi.xkt.enums;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.exception.ServiceException;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
*
*
* @author liujiang
* @date 2025-04-02 23:42
*/
@Getter
@AllArgsConstructor
public enum NoticeType {
// 通知
NOTICE(1, "通知"),
// 公告
ANNOUNCEMENT(2, "公告"),
;
private final Integer value;
private final String label;
public static NoticeType of(Integer value) {
for (NoticeType e : NoticeType.values()) {
if (e.getValue().equals(value)) {
return e;
}
}
throw new ServiceException("通知公告类型不存在!", HttpStatus.ERROR);
}
}

View File

@ -0,0 +1,44 @@
package com.ruoyi.xkt.enums;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.exception.ServiceException;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
*
*
* @author liujiang
* @date 2025-04-02 23:42
*/
@Getter
@AllArgsConstructor
public enum UserNoticeType {
// 系统消息
SYSTEM_MSG(1, "系统消息"),
// 代发订单
DELIVERY_ORDER(2, "代发订单"),
// 关注档口
FOCUS_STORE(3, "关注档口"),
// 收藏商品
FAVORITE_PRODUCT(4, "收藏商品"),
// 推广营销
ADVERT(5, "推广营销"),
// 商品动态
PRODUCT_DYNAMIC(6, "商品动态"),
;
private final Integer value;
private final String label;
public static UserNoticeType of(Integer value) {
for (UserNoticeType e : UserNoticeType.values()) {
if (e.getValue().equals(value)) {
return e;
}
}
throw new ServiceException("通知公告类型不存在!", HttpStatus.ERROR);
}
}

View File

@ -12,51 +12,5 @@ import java.util.List;
* @date 2025-03-26
*/
public interface UserNoticeSettingMapper extends BaseMapper<UserNoticeSetting> {
/**
*
*
* @param id
* @return
*/
public UserNoticeSetting selectUserNoticeSettingByUserNoticeSetId(Long id);
/**
*
*
* @param userNoticeSetting
* @return
*/
public List<UserNoticeSetting> selectUserNoticeSettingList(UserNoticeSetting userNoticeSetting);
/**
*
*
* @param userNoticeSetting
* @return
*/
public int insertUserNoticeSetting(UserNoticeSetting userNoticeSetting);
/**
*
*
* @param userNoticeSetting
* @return
*/
public int updateUserNoticeSetting(UserNoticeSetting userNoticeSetting);
/**
*
*
* @param id
* @return
*/
public int deleteUserNoticeSettingByUserNoticeSetId(Long id);
/**
*
*
* @param userNoticeSetIds
* @return
*/
public int deleteUserNoticeSettingByUserNoticeSetIds(Long[] userNoticeSetIds);
}

View File

@ -49,4 +49,19 @@ public interface INoticeService {
* @return Page<NoticeResDTO>
*/
Page<NoticeResDTO> page(NoticePageDTO pageDTO);
/**
*
*
* @param userId userId
* @param title
* @param noticeType NoticeType
* @param ownerType NoticeOwnerType
* @param storeId ID
* @param targetNoticeType
* @param content
* @return
*/
Integer createSingleNotice(Long userId, String title, Integer noticeType, Integer ownerType,
Long storeId, Integer targetNoticeType, String content);
}

View File

@ -1,9 +1,5 @@
package com.ruoyi.xkt.service;
import com.ruoyi.xkt.domain.UserNoticeSetting;
import java.util.List;
/**
* Service
*
@ -11,51 +7,5 @@ import java.util.List;
* @date 2025-03-26
*/
public interface IUserNoticeSettingService {
/**
*
*
* @param userNoticeSetId
* @return
*/
public UserNoticeSetting selectUserNoticeSettingByUserNoticeSetId(Long userNoticeSetId);
/**
*
*
* @param userNoticeSetting
* @return
*/
public List<UserNoticeSetting> selectUserNoticeSettingList(UserNoticeSetting userNoticeSetting);
/**
*
*
* @param userNoticeSetting
* @return
*/
public int insertUserNoticeSetting(UserNoticeSetting userNoticeSetting);
/**
*
*
* @param userNoticeSetting
* @return
*/
public int updateUserNoticeSetting(UserNoticeSetting userNoticeSetting);
/**
*
*
* @param userNoticeSetIds
* @return
*/
public int deleteUserNoticeSettingByUserNoticeSetIds(Long[] userNoticeSetIds);
/**
*
*
* @param userNoticeSetId
* @return
*/
public int deleteUserNoticeSettingByUserNoticeSetId(Long userNoticeSetId);
}

View File

@ -12,12 +12,14 @@ import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.enums.AdType;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.xkt.domain.*;
import com.ruoyi.xkt.dto.advertRound.*;
import com.ruoyi.xkt.enums.*;
import com.ruoyi.xkt.mapper.*;
import com.ruoyi.xkt.service.IAdvertRoundService;
import com.ruoyi.xkt.service.IAssetService;
import com.ruoyi.xkt.service.INoticeService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
@ -61,6 +63,8 @@ public class AdvertRoundServiceImpl implements IAdvertRoundService {
final StoreProductMapper storeProdMapper;
final SysFileMapper fileMapper;
final IAssetService assetService;
final INoticeService noticeService;
// 推广营销位锁 keysymbol + roundId 或者 symbol + roundId + position 。value都是new Object()
public static Map<String, Object> advertLockMap = new ConcurrentHashMap<>();
@ -330,7 +334,8 @@ public class AdvertRoundServiceImpl implements IAdvertRoundService {
if (DateUtils.getTime().compareTo(this.getDeadline(createDTO.getSymbol())) > 0) {
throw new ServiceException("竞价失败,已经有档口出价更高了噢!", HttpStatus.ERROR);
}
if (ObjectUtils.isEmpty(redisCache.getCacheObject(CacheConstants.STORE_KEY + createDTO.getStoreId()))) {
Store store = redisCache.getCacheObject(CacheConstants.STORE_KEY + createDTO.getStoreId());
if (ObjectUtils.isEmpty(store)) {
throw new ServiceException("档口不存在!", HttpStatus.ERROR);
}
// 如果是位置枚举的推广位则需要传position
@ -366,12 +371,20 @@ public class AdvertRoundServiceImpl implements IAdvertRoundService {
if (createDTO.getPayPrice().compareTo(ObjectUtils.defaultIfNull(minPriceAdvert.getPayPrice(), BigDecimal.ZERO)) <= 0) {
throw new ServiceException("已经有档口出价更高了噢,请重新出价!", HttpStatus.ERROR);
}
Advert advert = redisCache.getCacheObject(CacheConstants.ADVERT_KEY + createDTO.getAdvertId());
final String position = Objects.equals(minPriceAdvert.getShowType(), AdShowType.TIME_RANGE.getValue()) ? "" : minPriceAdvert.getPosition();
// storeId不为空表明之前有其他的档口竞价
if (ObjectUtils.isNotEmpty(minPriceAdvert.getStoreId())) {
// 将推广费退至原档口余额
assetService.refundAdvertFee(minPriceAdvert.getStoreId(), minPriceAdvert.getPayPrice());
// 记录竞价失败的档口推广营销
this.record(minPriceAdvert);
final String failTitle = ObjectUtils.isNotEmpty(advert) ? AdType.of(advert.getTypeId()).getLabel() : "" + position + "被抢占!";
final String failContent = "您抢购的 " + (ObjectUtils.isNotEmpty(advert) ? AdType.of(advert.getTypeId()).getLabel() : "") + position +
" 被其它档口抢拍,订购金额已退回余额!您可在抢购结束前加价抢回噢!";
// 新增竞价失败档口消息通知
this.noticeService.createSingleNotice(SecurityUtils.getUserId(), failTitle, NoticeType.NOTICE.getValue(), NoticeOwnerType.SYSTEM.getValue(),
minPriceAdvert.getStoreId(), UserNoticeType.ADVERT.getValue(), failContent);
}
// 更新广告位数据
minPriceAdvert
@ -385,6 +398,13 @@ public class AdvertRoundServiceImpl implements IAdvertRoundService {
.setPicAuditStatus(this.hasPic(minPriceAdvert.getDisplayType()) ? AdPicAuditStatus.UN_AUDIT.getValue() : null)
.setProdIdStr(createDTO.getProdIdStr());
this.advertRoundMapper.updateById(minPriceAdvert);
final String successTitle = ObjectUtils.isNotEmpty(advert) ? AdType.of(advert.getTypeId()).getLabel() : "" + position + "订购成功!";
final String successContent = ObjectUtils.isNotEmpty(store) ? store.getStoreName() : "" + " ,恭喜您!您成功订购 "
+ (ObjectUtils.isNotEmpty(advert) ? AdType.of(advert.getTypeId()).getLabel() : "") + position +
"播放时间段为" + minPriceAdvert.getStartTime() + "至" + minPriceAdvert.getEndTime() + ",请确保推广设置正确噢!";
// 新增订购成功的消息通知
this.noticeService.createSingleNotice(SecurityUtils.getUserId(), successTitle, NoticeType.NOTICE.getValue(), NoticeOwnerType.SYSTEM.getValue(),
minPriceAdvert.getStoreId(), UserNoticeType.ADVERT.getValue(), successContent);
// 扣除推广费
assetService.payAdvertFee(createDTO.getStoreId(), createDTO.getPayPrice(), createDTO.getTransactionPassword());
}
@ -392,7 +412,6 @@ public class AdvertRoundServiceImpl implements IAdvertRoundService {
}
/**
* 广
*
@ -555,7 +574,6 @@ public class AdvertRoundServiceImpl implements IAdvertRoundService {
}
/**
* @param picDTO 广
* @return Integer
@ -850,6 +868,7 @@ public class AdvertRoundServiceImpl implements IAdvertRoundService {
/**
* 广 广
*
* @param displayType 广
* @return true false
*/

View File

@ -6,20 +6,19 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.Page;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.xkt.domain.Notice;
import com.ruoyi.xkt.domain.UserNotice;
import com.ruoyi.xkt.domain.UserNoticeSetting;
import com.ruoyi.xkt.dto.notice.*;
import com.ruoyi.xkt.enums.NoticeOwnerType;
import com.ruoyi.xkt.enums.NoticeReadType;
import com.ruoyi.xkt.mapper.NoticeMapper;
import com.ruoyi.xkt.mapper.UserFavoritesMapper;
import com.ruoyi.xkt.mapper.UserNoticeMapper;
import com.ruoyi.xkt.mapper.UserSubscriptionsMapper;
import com.ruoyi.xkt.enums.NoticeReceiveType;
import com.ruoyi.xkt.enums.UserNoticeType;
import com.ruoyi.xkt.mapper.*;
import com.ruoyi.xkt.service.INoticeService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
@ -49,6 +48,7 @@ public class NoticeServiceImpl implements INoticeService {
final UserFavoritesMapper userFavMapper;
final UserNoticeMapper userNoticeMapper;
final SysUserMapper userMapper;
final UserNoticeSettingMapper userNoticeSetMapper;
/**
*
@ -68,20 +68,19 @@ public class NoticeServiceImpl implements INoticeService {
// 档口发的公告,则发送给关注档口用户
? this.userSubMapper.selectUserFocusList(notice.getStoreId())
// 系统发的公告,则发送给所有用户
: this.userMapper.selectList(new LambdaQueryWrapper<SysUser>().eq(SysUser::getDelFlag, Constants.UNDELETED))
.stream().map(SysUser::getUserId).distinct().collect(Collectors.toList());
: this.userNoticeSetMapper.selectList(new LambdaQueryWrapper<UserNoticeSetting>()
.eq(UserNoticeSetting::getSysMsgNotice, NoticeReceiveType.RECEIVE.getValue())
.eq(UserNoticeSetting::getDelFlag, Constants.UNDELETED)).stream()
.map(UserNoticeSetting::getUserId)
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(userIdList)) {
return 0;
}
// 往user_notice表插入数据
List<UserNotice> userNoticeList = userIdList.stream().map(userId -> {
UserNotice userNotice = new UserNotice();
userNotice.setNoticeId(notice.getId());
userNotice.setUserId(userId);
userNotice.setReadStatus(NoticeReadType.UN_READ.getValue());
userNotice.setVoucherDate(voucherDate);
return userNotice;
})
List<UserNotice> userNoticeList = userIdList.stream().map(userId -> new UserNotice().setNoticeId(notice.getId())
.setUserId(userId).setReadStatus(NoticeReadType.UN_READ.getValue()).setVoucherDate(voucherDate)
.setTargetNoticeType(Objects.equals(createDTO.getOwnerType(), NoticeOwnerType.STORE.getValue())
? UserNoticeType.FOCUS_STORE.getValue() : UserNoticeType.SYSTEM_MSG.getValue()))
.collect(Collectors.toList());
this.userNoticeMapper.insert(userNoticeList);
return count;
@ -187,5 +186,25 @@ public class NoticeServiceImpl implements INoticeService {
}
}
/**
*
*
* @param userId userId
* @param title
* @param noticeType NoticeType
* @param ownerType NoticeOwnerType
* @param storeId ID
* @param targetNoticeType
* @param content
* @return
*/
public Integer createSingleNotice(Long userId, String title, Integer noticeType, Integer ownerType, Long storeId, Integer targetNoticeType, String content) {
Notice notice = new Notice().setNoticeTitle(title).setNoticeType(noticeType).setOwnerType(ownerType)
.setStoreId(storeId).setUserId(userId).setPerpetuity(1).setNoticeContent(content);
this.noticeMapper.insert(notice);
return this.userNoticeMapper.insert(new UserNotice().setNoticeId(notice.getId()).setUserId(userId).setReadStatus(NoticeReadType.UN_READ.getValue())
.setVoucherDate(java.sql.Date.valueOf(LocalDate.now())).setTargetNoticeType(targetNoticeType));
}
}

View File

@ -42,10 +42,7 @@ import com.ruoyi.xkt.dto.storeProductFile.StoreProdFileDTO;
import com.ruoyi.xkt.dto.storeProductFile.StoreProdFileResDTO;
import com.ruoyi.xkt.dto.storeProductFile.StoreProdMainPicDTO;
import com.ruoyi.xkt.dto.userBrowsingHistory.UserBrowsingHisDTO;
import com.ruoyi.xkt.enums.EProductStatus;
import com.ruoyi.xkt.enums.FileType;
import com.ruoyi.xkt.enums.ListingType;
import com.ruoyi.xkt.enums.ProductSizeStatus;
import com.ruoyi.xkt.enums.*;
import com.ruoyi.xkt.mapper.*;
import com.ruoyi.xkt.service.IPictureService;
import com.ruoyi.xkt.service.IStoreProductService;
@ -59,6 +56,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
@ -100,7 +98,9 @@ public class StoreProductServiceImpl implements IStoreProductService {
final StoreProductStatisticsMapper storeProductStatisticsMapper;
final StoreHomepageMapper storeHomepageMapper;
final RedisCache redisCache;
final NoticeMapper noticeMapper;
final UserNoticeSettingMapper userNoticeSetMapper;
final UserNoticeMapper userNoticeMapper;
/**
*
@ -234,6 +234,8 @@ public class StoreProductServiceImpl implements IStoreProductService {
this.createESDoc(storeProd, storeProdDTO);
// 搜图服务同步
sync2ImgSearchServer(storeProd.getId(), storeProdDTO.getFileList());
// 新增档口商品动态、关注档口通知公告
this.createNotice(storeProd, storeProdDTO.getStoreName());
}
return count;
}
@ -290,6 +292,8 @@ public class StoreProductServiceImpl implements IStoreProductService {
this.updateESDoc(storeProd, storeProdDTO);
// 搜图服务同步
sync2ImgSearchServer(storeProd.getId(), storeProdDTO.getFileList());
// 更新档口商品动态、关注档口、收藏商品通知公告
this.updateNotice(storeProd, storeProdDTO.getStoreName());
}
return count;
}
@ -451,9 +455,12 @@ public class StoreProductServiceImpl implements IStoreProductService {
this.storeProdMapper.updateById(storeProdList);
// 筛选商品状态为已下架则删除ES文档
if (Objects.equals(prodStatusDTO.getProdStatus(), EProductStatus.OFF_SALE.getValue())) {
// 删除ES中商品
this.deleteESDoc(prodStatusDTO.getStoreProdIdList());
// 搜图服务同步
prodStatusDTO.getStoreProdIdList().forEach(spId -> sync2ImgSearchServer(spId, ListUtil.empty()));
// 新增消息通知
this.offSaleOrReSaleProd(storeProdList, Boolean.TRUE, prodStatusDTO.getStoreId());
}
// 已下架的商品重新上架
if (CollectionUtils.isNotEmpty(reSaleList)) {
@ -466,9 +473,12 @@ public class StoreProductServiceImpl implements IStoreProductService {
Collectors.mapping(StoreProdMainPicDTO::getFileUrl, Collectors.toList())));
prodStatusDTO.getStoreProdIdList()
.forEach(spId -> sync2ImgSearchServer(spId, picKeyGroupMap.get(spId), true));
// 新增消息通知
this.offSaleOrReSaleProd(storeProdList, Boolean.FALSE, prodStatusDTO.getStoreId());
}
}
/**
* ID
*
@ -995,5 +1005,114 @@ public class StoreProductServiceImpl implements IStoreProductService {
this.redisCache.setCacheObject(CacheConstants.USER_BROWSING_HISTORY + SecurityUtils.getUserId(), browsingList);
}
/**
*
*
* @param storeProd
* @param storeName
*/
private void createNotice(StoreProduct storeProd, String storeName) {
// 新增档口 商品动态 通知公告
Long userId = SecurityUtils.getUserId();
// 新增一条档口消息通知
Notice notice = new Notice().setNoticeTitle(storeName + "商品上新啦!").setNoticeType(NoticeType.NOTICE.getValue())
.setNoticeContent(storeName + "上新了货号为: " + storeProd.getProdArtNum() + " 的商品!请及时关注!")
.setOwnerType(NoticeOwnerType.STORE.getValue()).setStoreId(storeProd.getStoreId())
.setUserId(userId).setPerpetuity(1);
this.noticeMapper.insert(notice);
final Date voucherDate = java.sql.Date.valueOf(LocalDate.now());
// 新增消息通知列表
List<UserNotice> userNoticeList = new ArrayList<>();
// 新增档口商品动态
userNoticeList.add(new UserNotice().setNoticeId(notice.getId())
.setUserId(userId).setReadStatus(NoticeReadType.UN_READ.getValue()).setVoucherDate(voucherDate)
.setTargetNoticeType(UserNoticeType.PRODUCT_DYNAMIC.getValue()));
List<UserNoticeSetting> focusList = this.userNoticeSetMapper.selectList(new LambdaQueryWrapper<UserNoticeSetting>()
.isNotNull(UserNoticeSetting::getFocusNotice));
if (CollectionUtils.isNotEmpty(focusList)) {
focusList.forEach(x -> userNoticeList.add(new UserNotice().setNoticeId(notice.getId())
.setUserId(x.getUserId()).setReadStatus(NoticeReadType.UN_READ.getValue()).setVoucherDate(voucherDate)
.setTargetNoticeType(UserNoticeType.FOCUS_STORE.getValue())));
}
if (CollectionUtils.isEmpty(userNoticeList)) {
return;
}
this.userNoticeMapper.insert(userNoticeList);
}
/**
*
*
* @param storeProd
* @param storeName
*/
private void updateNotice(StoreProduct storeProd, String storeName) {
// 新增档口 商品动态 通知公告
Long userId = SecurityUtils.getUserId();
// 新增一条档口消息通知
Notice notice = new Notice().setNoticeTitle(storeName + "商品更新啦!").setNoticeType(NoticeType.NOTICE.getValue())
.setNoticeContent(storeName + "更新了货号为: " + storeProd.getProdArtNum() + " 的商品!请及时关注!")
.setOwnerType(NoticeOwnerType.STORE.getValue()).setStoreId(storeProd.getStoreId())
.setUserId(userId).setPerpetuity(1);
this.noticeMapper.insert(notice);
final Date voucherDate = java.sql.Date.valueOf(LocalDate.now());
// 新增消息通知列表
List<UserNotice> userNoticeList = new ArrayList<>();
userNoticeList.add(new UserNotice().setNoticeId(notice.getId())
.setUserId(userId).setReadStatus(NoticeReadType.UN_READ.getValue()).setVoucherDate(voucherDate)
.setTargetNoticeType(UserNoticeType.PRODUCT_DYNAMIC.getValue()));
// 关注档口或者收藏商品的用户
List<UserNoticeSetting> targetList = this.userNoticeSetMapper.selectList(new LambdaQueryWrapper<UserNoticeSetting>()
.isNotNull(UserNoticeSetting::getFocusNotice).or().isNotNull(UserNoticeSetting::getFavoriteNotice));
if (CollectionUtils.isNotEmpty(targetList)) {
targetList.forEach(x -> userNoticeList.add(new UserNotice().setNoticeId(notice.getId())
.setUserId(x.getUserId()).setReadStatus(NoticeReadType.UN_READ.getValue()).setVoucherDate(voucherDate)
.setTargetNoticeType(Objects.equals(x.getFocusNotice(), NoticeReceiveType.RECEIVE.getValue())
? UserNoticeType.FOCUS_STORE.getValue() : UserNoticeType.FAVORITE_PRODUCT.getValue())));
}
if (CollectionUtils.isEmpty(userNoticeList)) {
return;
}
this.userNoticeMapper.insert(userNoticeList);
}
/**
*
*
* @param storeProdList
* @param offSale true false
* @param storeId ID
*/
private void offSaleOrReSaleProd(List<StoreProduct> storeProdList, Boolean offSale, Long storeId) {
// 新增档口 商品动态 通知公告
Long userId = SecurityUtils.getUserId();
Store store = redisCache.getCacheObject(CacheConstants.STORE_KEY + storeId);
// 新增消息通知列表
List<UserNotice> userNoticeList = new ArrayList<>();
final Date voucherDate = java.sql.Date.valueOf(LocalDate.now());
storeProdList.forEach(storeProd -> {
// 新增一条档口消息通知
Notice notice = new Notice().setNoticeType(NoticeType.NOTICE.getValue()).setUserId(userId).setPerpetuity(1)
.setOwnerType(NoticeOwnerType.STORE.getValue()).setStoreId(storeProd.getStoreId())
.setNoticeTitle(ObjectUtils.isNotEmpty(store) ? store.getStoreName() : "" + "商品" + (offSale ? "下架" : "重新上架") + "啦!")
.setNoticeContent(ObjectUtils.isNotEmpty(store) ? store.getStoreName() : "" + (offSale ? "下架" : "重新上架")
+ "了货号为: " + storeProd.getProdArtNum() + " 的商品!请及时关注!");
this.noticeMapper.insert(notice);
// 关注档口或者收藏商品的用户
List<UserNoticeSetting> targetList = this.userNoticeSetMapper.selectList(new LambdaQueryWrapper<UserNoticeSetting>()
.isNotNull(UserNoticeSetting::getFocusNotice).or().isNotNull(UserNoticeSetting::getFavoriteNotice));
if (CollectionUtils.isNotEmpty(targetList)) {
targetList.forEach(x -> userNoticeList.add(new UserNotice().setNoticeId(notice.getId())
.setUserId(x.getUserId()).setReadStatus(NoticeReadType.UN_READ.getValue()).setVoucherDate(voucherDate)
.setTargetNoticeType(Objects.equals(x.getFocusNotice(), NoticeReceiveType.RECEIVE.getValue())
? UserNoticeType.FOCUS_STORE.getValue() : UserNoticeType.FAVORITE_PRODUCT.getValue())));
}
});
if (CollectionUtils.isEmpty(userNoticeList)) {
return;
}
this.userNoticeMapper.insert(userNoticeList);
}
}

View File

@ -13,9 +13,9 @@ import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.xkt.domain.*;
import com.ruoyi.xkt.dto.storeProductFile.StoreProdMainPicDTO;
import com.ruoyi.xkt.dto.userFavorite.*;
import com.ruoyi.xkt.enums.FileType;
import com.ruoyi.xkt.enums.ProductSizeStatus;
import com.ruoyi.xkt.enums.*;
import com.ruoyi.xkt.mapper.*;
import com.ruoyi.xkt.service.INoticeService;
import com.ruoyi.xkt.service.IUserFavoritesService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
@ -48,6 +48,10 @@ public class UserFavoritesServiceImpl implements IUserFavoritesService {
final StoreProductColorPriceMapper prodColorPriceMapper;
final StoreProductColorMapper prodColorMapper;
final ShoppingCartDetailMapper shopCartDetailMapper;
final StoreMapper storeMapper;
final INoticeService noticeService;
final StoreProductMapper storeProdMapper;
/**
*
@ -73,7 +77,26 @@ public class UserFavoritesServiceImpl implements IUserFavoritesService {
.filter(x -> CollectionUtils.isNotEmpty(existStoreProdIdList) ? !existStoreProdIdList.contains(x.getStoreProdId()) : Boolean.TRUE)
.map(x -> BeanUtil.toBean(x, UserFavorites.class).setUserId(loginUser.getUserId()))
.collect(Collectors.toList());
return this.userFavMapper.insert(list).size();
int count = this.userFavMapper.insert(list).size();
Map<Long, Store> storeMap = this.storeMapper.selectList(new LambdaQueryWrapper<Store>()
.in(Store::getId, list.stream().map(UserFavorites::getStoreId).collect(Collectors.toList()))
.eq(Store::getDelFlag, Constants.UNDELETED)).stream()
.collect(Collectors.toMap(Store::getId, Function.identity()));
Map<Long, StoreProduct> storeProdMap = this.storeProdMapper.selectList(new LambdaQueryWrapper<StoreProduct>()
.in(StoreProduct::getId, list.stream().map(UserFavorites::getStoreProdId).collect(Collectors.toList()))
.eq(StoreProduct::getDelFlag, Constants.UNDELETED)).stream()
.collect(Collectors.toMap(StoreProduct::getId, Function.identity()));
// 新增用户收藏商品通知
list.forEach(userFav -> {
StoreProduct storeProd = storeProdMap.get(userFav.getStoreProdId());
Store store = storeMap.get(userFav.getStoreId());
// 新增用户收藏商品消息通知
this.noticeService.createSingleNotice(SecurityUtils.getUserId(), "收藏商品成功!", NoticeType.NOTICE.getValue(), NoticeOwnerType.SYSTEM.getValue(),
userFav.getStoreId(), UserNoticeType.FAVORITE_PRODUCT.getValue(),
"恭喜您,收藏" + (ObjectUtils.isNotEmpty(store) ? store.getStoreName() : "") + " 家商品: " +
(ObjectUtils.isNotEmpty(storeProd) ? storeProd.getProdArtNum() : "") + "成功!");
});
return count;
}
/**
@ -206,7 +229,26 @@ public class UserFavoritesServiceImpl implements IUserFavoritesService {
return 0;
}
favoriteList.forEach(x -> x.setDelFlag(Constants.DELETED));
return this.userFavMapper.updateById(favoriteList).size();
int count = this.userFavMapper.updateById(favoriteList).size();
Map<Long, Store> storeMap = this.storeMapper.selectList(new LambdaQueryWrapper<Store>()
.in(Store::getId, favoriteList.stream().map(UserFavorites::getStoreId).collect(Collectors.toList()))
.eq(Store::getDelFlag, Constants.UNDELETED)).stream()
.collect(Collectors.toMap(Store::getId, Function.identity()));
Map<Long, StoreProduct> storeProdMap = this.storeProdMapper.selectList(new LambdaQueryWrapper<StoreProduct>()
.in(StoreProduct::getId, favoriteList.stream().map(UserFavorites::getStoreProdId).collect(Collectors.toList()))
.eq(StoreProduct::getDelFlag, Constants.UNDELETED)).stream()
.collect(Collectors.toMap(StoreProduct::getId, Function.identity()));
// 新增用户取消收藏商品通知
favoriteList.forEach(userFav -> {
StoreProduct storeProd = storeProdMap.get(userFav.getStoreProdId());
Store store = storeMap.get(userFav.getStoreId());
// 新增用户取消收藏商品消息通知
this.noticeService.createSingleNotice(SecurityUtils.getUserId(), "取消收藏商品!", NoticeType.NOTICE.getValue(), NoticeOwnerType.SYSTEM.getValue(),
userFav.getStoreId(), UserNoticeType.FAVORITE_PRODUCT.getValue(),
"您已取消收藏" + (ObjectUtils.isNotEmpty(store) ? store.getStoreName() : "") + " 家商品: " +
(ObjectUtils.isNotEmpty(storeProd) ? storeProd.getProdArtNum() : "") + "!");
});
return count;
}

View File

@ -1,14 +1,9 @@
package com.ruoyi.xkt.service.impl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.xkt.domain.UserNoticeSetting;
import com.ruoyi.xkt.mapper.UserNoticeSettingMapper;
import com.ruoyi.xkt.service.IUserNoticeSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* Service
@ -18,76 +13,9 @@ import java.util.List;
*/
@Service
public class UserNoticeSettingServiceImpl implements IUserNoticeSettingService {
@Autowired
private UserNoticeSettingMapper userNoticeSettingMapper;
/**
*
*
* @param userNoticeSetId
* @return
*/
@Override
public UserNoticeSetting selectUserNoticeSettingByUserNoticeSetId(Long userNoticeSetId) {
return userNoticeSettingMapper.selectUserNoticeSettingByUserNoticeSetId(userNoticeSetId);
}
/**
*
*
* @param userNoticeSetting
* @return
*/
@Override
public List<UserNoticeSetting> selectUserNoticeSettingList(UserNoticeSetting userNoticeSetting) {
return userNoticeSettingMapper.selectUserNoticeSettingList(userNoticeSetting);
}
/**
*
*
* @param userNoticeSetting
* @return
*/
@Override
@Transactional
public int insertUserNoticeSetting(UserNoticeSetting userNoticeSetting) {
userNoticeSetting.setCreateTime(DateUtils.getNowDate());
return userNoticeSettingMapper.insertUserNoticeSetting(userNoticeSetting);
}
/**
*
*
* @param userNoticeSetting
* @return
*/
@Override
@Transactional
public int updateUserNoticeSetting(UserNoticeSetting userNoticeSetting) {
userNoticeSetting.setUpdateTime(DateUtils.getNowDate());
return userNoticeSettingMapper.updateUserNoticeSetting(userNoticeSetting);
}
/**
*
*
* @param userNoticeSetIds
* @return
*/
@Override
public int deleteUserNoticeSettingByUserNoticeSetIds(Long[] userNoticeSetIds) {
return userNoticeSettingMapper.deleteUserNoticeSettingByUserNoticeSetIds(userNoticeSetIds);
}
/**
*
*
* @param userNoticeSetId
* @return
*/
@Override
public int deleteUserNoticeSettingByUserNoticeSetId(Long userNoticeSetId) {
return userNoticeSettingMapper.deleteUserNoticeSettingByUserNoticeSetId(userNoticeSetId);
}
}

View File

@ -9,6 +9,7 @@ import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.Page;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.xkt.domain.Store;
import com.ruoyi.xkt.domain.StoreProduct;
import com.ruoyi.xkt.domain.StoreSale;
import com.ruoyi.xkt.domain.UserSubscriptions;
@ -16,9 +17,14 @@ import com.ruoyi.xkt.dto.userSubscriptions.UserSubscDTO;
import com.ruoyi.xkt.dto.userSubscriptions.UserSubscDeleteDTO;
import com.ruoyi.xkt.dto.userSubscriptions.UserSubscPageDTO;
import com.ruoyi.xkt.dto.userSubscriptions.UserSubscPageResDTO;
import com.ruoyi.xkt.enums.NoticeOwnerType;
import com.ruoyi.xkt.enums.NoticeType;
import com.ruoyi.xkt.enums.UserNoticeType;
import com.ruoyi.xkt.mapper.StoreMapper;
import com.ruoyi.xkt.mapper.StoreProductMapper;
import com.ruoyi.xkt.mapper.StoreSaleMapper;
import com.ruoyi.xkt.mapper.UserSubscriptionsMapper;
import com.ruoyi.xkt.service.INoticeService;
import com.ruoyi.xkt.service.IUserSubscriptionsService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
@ -31,6 +37,7 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@ -43,9 +50,11 @@ import java.util.stream.Collectors;
@Service
public class UserSubscriptionsServiceImpl implements IUserSubscriptionsService {
final UserSubscriptionsMapper userSubscMapper;
final UserSubscriptionsMapper userSubMapper;
final StoreSaleMapper saleMapper;
final StoreProductMapper storeProdMapper;
final INoticeService noticeService;
final StoreMapper storeMapper;
/**
@ -60,7 +69,7 @@ public class UserSubscriptionsServiceImpl implements IUserSubscriptionsService {
// 获取当前登录用户
LoginUser loginUser = SecurityUtils.getLoginUser();
// 判断是否已关注过
UserSubscriptions exist = this.userSubscMapper.selectOne(new LambdaQueryWrapper<UserSubscriptions>()
UserSubscriptions exist = this.userSubMapper.selectOne(new LambdaQueryWrapper<UserSubscriptions>()
.eq(UserSubscriptions::getUserId, loginUser.getUserId()).eq(UserSubscriptions::getStoreId, subscDTO.getStoreId())
.eq(UserSubscriptions::getDelFlag, Constants.UNDELETED));
if (ObjectUtils.isNotEmpty(exist)) {
@ -69,7 +78,14 @@ public class UserSubscriptionsServiceImpl implements IUserSubscriptionsService {
UserSubscriptions userSubscriptions = new UserSubscriptions();
userSubscriptions.setUserId(loginUser.getUserId());
userSubscriptions.setStoreId(subscDTO.getStoreId());
return this.userSubscMapper.insert(userSubscriptions);
int count = this.userSubMapper.insert(userSubscriptions);
Store store = Optional.ofNullable(this.storeMapper.selectOne(new LambdaQueryWrapper<Store>()
.eq(Store::getId, subscDTO.getStoreId()).eq(Store::getDelFlag, Constants.UNDELETED)))
.orElseThrow(() -> new ServiceException("档口不存在!", HttpStatus.ERROR));
// 新增用户关注档口消息通知
this.noticeService.createSingleNotice(SecurityUtils.getUserId(), "关注档口成功!", NoticeType.NOTICE.getValue(), NoticeOwnerType.SYSTEM.getValue(),
subscDTO.getStoreId(), UserNoticeType.FOCUS_STORE.getValue(), "恭喜您,关注档口: " + store.getStoreName() + "成功!");
return count;
}
/**
@ -83,13 +99,23 @@ public class UserSubscriptionsServiceImpl implements IUserSubscriptionsService {
public Integer delete(UserSubscDeleteDTO deleteDTO) {
// 获取当前登录用户
LoginUser loginUser = SecurityUtils.getLoginUser();
List<UserSubscriptions> list = Optional.ofNullable(this.userSubscMapper.selectList(new LambdaQueryWrapper<UserSubscriptions>()
List<UserSubscriptions> list = Optional.ofNullable(this.userSubMapper.selectList(new LambdaQueryWrapper<UserSubscriptions>()
.eq(UserSubscriptions::getUserId, loginUser.getUserId())
.in(UserSubscriptions::getStoreId, deleteDTO.getStoreIdList())
.eq(UserSubscriptions::getDelFlag, Constants.UNDELETED)))
.orElseThrow(() -> new ServiceException("用户关注档口不存在!", HttpStatus.ERROR));
list.forEach(x -> x.setDelFlag(Constants.DELETED));
return this.userSubscMapper.updateById(list).size();
int count = this.userSubMapper.updateById(list).size();
Map<Long, Store> storeMap = this.storeMapper.selectList(new LambdaQueryWrapper<Store>()
.in(Store::getId, deleteDTO.getStoreIdList()).eq(Store::getDelFlag, Constants.UNDELETED)).stream()
.collect(Collectors.toMap(Store::getId, Function.identity()));
list.forEach(x -> {
Store store = storeMap.get(x.getStoreId());
// 用户取消关注档口消息通知
this.noticeService.createSingleNotice(SecurityUtils.getUserId(), "取消关注档口!", NoticeType.NOTICE.getValue(), NoticeOwnerType.SYSTEM.getValue(),
store.getId(), UserNoticeType.FOCUS_STORE.getValue(), "您已取消关注档口: " + store.getStoreName() + " !");
});
return count;
}
/**
@ -104,7 +130,7 @@ public class UserSubscriptionsServiceImpl implements IUserSubscriptionsService {
// 获取当前登录用户
LoginUser loginUser = SecurityUtils.getLoginUser();
PageHelper.startPage(pageDTO.getPageNum(), pageDTO.getPageSize());
List<UserSubscPageResDTO> list = this.userSubscMapper.selectUserSubscPage(loginUser.getUserId(), pageDTO.getStoreName());
List<UserSubscPageResDTO> list = this.userSubMapper.selectUserSubscPage(loginUser.getUserId(), pageDTO.getStoreName());
if (CollectionUtils.isEmpty(list)) {
return Page.empty(pageDTO.getPageNum(), pageDTO.getPageSize());
}

View File

@ -1,91 +1,7 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.xkt.mapper.UserNoticeSettingMapper">
<resultMap type="UserNoticeSetting" id="UserNoticeSettingResult">
<result property="id" column="id" />
<result property="userId" column="user_id" />
<result property="noticeType" column="notice_type" />
<result property="allow" column="allow" />
<result property="version" column="version" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectUserNoticeSettingVo">
select id, user_id, notice_type, allow, version, del_flag, create_by, create_time, update_by, update_time from user_notice_setting
</sql>
<select id="selectUserNoticeSettingList" parameterType="UserNoticeSetting" resultMap="UserNoticeSettingResult">
<include refid="selectUserNoticeSettingVo"/>
<where>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="noticeType != null and noticeType != ''"> and notice_type = #{noticeType}</if>
<if test="allow != null and allow != ''"> and allow = #{allow}</if>
<if test="version != null "> and version = #{version}</if>
</where>
</select>
<select id="selectUserNoticeSettingByUserNoticeSetId" parameterType="Long" resultMap="UserNoticeSettingResult">
<include refid="selectUserNoticeSettingVo"/>
where id = #{id}
</select>
<insert id="insertUserNoticeSetting" parameterType="UserNoticeSetting" useGeneratedKeys="true" keyProperty="userNoticeSetId">
insert into user_notice_setting
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">user_id,</if>
<if test="noticeType != null">notice_type,</if>
<if test="allow != null">allow,</if>
<if test="version != null">version,</if>
<if test="delFlag != null">del_flag,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">#{userId},</if>
<if test="noticeType != null">#{noticeType},</if>
<if test="allow != null">#{allow},</if>
<if test="version != null">#{version},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateUserNoticeSetting" parameterType="UserNoticeSetting">
update user_notice_setting
<trim prefix="SET" suffixOverrides=",">
<if test="userId != null">user_id = #{userId},</if>
<if test="noticeType != null">notice_type = #{noticeType},</if>
<if test="allow != null">allow = #{allow},</if>
<if test="version != null">version = #{version},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteUserNoticeSettingByUserNoticeSetId" parameterType="Long">
delete from user_notice_setting where id = #{id}
</delete>
<delete id="deleteUserNoticeSettingByUserNoticeSetIds" parameterType="String">
delete from user_notice_setting where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>