新增 用户通知偏好设置

This commit is contained in:
2026-02-01 19:08:16 +08:00
parent 86b683aafd
commit 01291e61a6
6 changed files with 559 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
package com.vetti.hotake.domain;
import com.vetti.common.annotation.Excel;
import com.vetti.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 用户通知偏好设置对象 hotake_notification_preferences
*
* @author vetti
* @date 2026-02-01
*/
@Data
@Accessors(chain = true)
public class HotakeNotificationPreferences extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键ID */
@ApiModelProperty("主键ID")
private Long id;
/** 职位提醒:新职位机会通知 (0-关闭, 1-开启) */
@ApiModelProperty("职位提醒:新职位机会通知 (0-关闭, 1-开启)")
@Excel(name = "职位提醒")
private Integer emailJobAlerts;
/** 申请更新:职位申请状态更新 (0-关闭, 1-开启) */
@ApiModelProperty("申请更新:职位申请状态更新 (0-关闭, 1-开启)")
@Excel(name = "申请更新")
private Integer emailApplicationUpdates;
/** AI匹配建议基于个人资料的强匹配职位推荐 (0-关闭, 1-开启) */
@ApiModelProperty("AI匹配建议基于个人资料的强匹配职位推荐 (0-关闭, 1-开启)")
@Excel(name = "AI匹配建议")
private Integer emailAiMatchSuggestions;
/** 新闻简报:每周职业技巧和行业新闻 (0-关闭, 1-开启) */
@ApiModelProperty("新闻简报:每周职业技巧和行业新闻 (0-关闭, 1-开启)")
@Excel(name = "新闻简报")
private Integer emailNewsletter;
/** 新消息:收到新消息时通知 (0-关闭, 1-开启) */
@ApiModelProperty("新消息:收到新消息时通知 (0-关闭, 1-开启)")
@Excel(name = "新消息")
private Integer pushNewMessages;
/** 面试提醒:即将到来的面试提醒 (0-关闭, 1-开启) */
@ApiModelProperty("面试提醒:即将到来的面试提醒 (0-关闭, 1-开启)")
@Excel(name = "面试提醒")
private Integer pushInterviewReminders;
/** 营销邮件:促销内容和特别优惠 (0-关闭, 1-开启) */
@ApiModelProperty("营销邮件:促销内容和特别优惠 (0-关闭, 1-开启)")
@Excel(name = "营销邮件")
private Integer mailMarketingEmails;
/** 合作伙伴优惠:来自可信合作伙伴的机会 (0-关闭, 1-开启) */
@ApiModelProperty("合作伙伴优惠:来自可信合作伙伴的机会 (0-关闭, 1-开启)")
@Excel(name = "合作伙伴优惠")
private Integer mailPartnerOffers;
}

View File

@@ -0,0 +1,61 @@
package com.vetti.hotake.mapper;
import java.util.List;
import com.vetti.hotake.domain.HotakeNotificationPreferences;
/**
* 用户通知偏好设置Mapper接口
*
* @author vetti
* @date 2026-02-01
*/
public interface HotakeNotificationPreferencesMapper
{
/**
* 查询用户通知偏好设置
*
* @param id 用户通知偏好设置主键
* @return 用户通知偏好设置
*/
public HotakeNotificationPreferences selectHotakeNotificationPreferencesById(Long id);
/**
* 查询用户通知偏好设置列表
*
* @param hotakeNotificationPreferences 用户通知偏好设置
* @return 用户通知偏好设置集合
*/
public List<HotakeNotificationPreferences> selectHotakeNotificationPreferencesList(HotakeNotificationPreferences hotakeNotificationPreferences);
/**
* 新增用户通知偏好设置
*
* @param hotakeNotificationPreferences 用户通知偏好设置
* @return 结果
*/
public int insertHotakeNotificationPreferences(HotakeNotificationPreferences hotakeNotificationPreferences);
/**
* 修改用户通知偏好设置
*
* @param hotakeNotificationPreferences 用户通知偏好设置
* @return 结果
*/
public int updateHotakeNotificationPreferences(HotakeNotificationPreferences hotakeNotificationPreferences);
/**
* 删除用户通知偏好设置
*
* @param id 用户通知偏好设置主键
* @return 结果
*/
public int deleteHotakeNotificationPreferencesById(Long id);
/**
* 批量删除用户通知偏好设置
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteHotakeNotificationPreferencesByIds(Long[] ids);
}

View File

@@ -0,0 +1,70 @@
package com.vetti.hotake.service;
import java.util.List;
import com.vetti.hotake.domain.HotakeNotificationPreferences;
/**
* 用户通知偏好设置Service接口
*
* @author vetti
* @date 2026-02-01
*/
public interface IHotakeNotificationPreferencesService
{
/**
* 查询用户通知偏好设置
*
* @param id 用户通知偏好设置主键
* @return 用户通知偏好设置
*/
public HotakeNotificationPreferences selectHotakeNotificationPreferencesById(Long id);
/**
* 查询用户通知偏好设置列表
*
* @param hotakeNotificationPreferences 用户通知偏好设置
* @return 用户通知偏好设置集合
*/
public List<HotakeNotificationPreferences> selectHotakeNotificationPreferencesList(HotakeNotificationPreferences hotakeNotificationPreferences);
/**
* 新增用户通知偏好设置
*
* @param hotakeNotificationPreferences 用户通知偏好设置
* @return 结果
*/
public HotakeNotificationPreferences insertHotakeNotificationPreferences(HotakeNotificationPreferences hotakeNotificationPreferences);
/**
* 修改用户通知偏好设置
*
* @param hotakeNotificationPreferences 用户通知偏好设置
* @return 结果
*/
public HotakeNotificationPreferences updateHotakeNotificationPreferences(HotakeNotificationPreferences hotakeNotificationPreferences);
/**
* 批量删除用户通知偏好设置
*
* @param ids 需要删除的用户通知偏好设置主键集合
* @return 结果
*/
public int deleteHotakeNotificationPreferencesByIds(Long[] ids);
/**
* 删除用户通知偏好设置信息
*
* @param id 用户通知偏好设置主键
* @return 结果
*/
public int deleteHotakeNotificationPreferencesById(Long id);
/**
* 获取当前登录用户的通知偏好设置
* 如果不存在则自动创建默认设置
*
* @param username 用户名
* @return 用户通知偏好设置
*/
public HotakeNotificationPreferences getCurrentUserPreferences(String username);
}

View File

@@ -0,0 +1,137 @@
package com.vetti.hotake.service.impl;
import com.vetti.common.core.service.BaseServiceImpl;
import com.vetti.common.enums.FillTypeEnum;
import com.vetti.hotake.domain.HotakeNotificationPreferences;
import com.vetti.hotake.mapper.HotakeNotificationPreferencesMapper;
import com.vetti.hotake.service.IHotakeNotificationPreferencesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 用户通知偏好设置Service业务层处理
*
* @author vetti
* @date 2026-02-01
*/
@Service
public class HotakeNotificationPreferencesServiceImpl extends BaseServiceImpl implements IHotakeNotificationPreferencesService {
@Autowired
private HotakeNotificationPreferencesMapper hotakeNotificationPreferencesMapper;
/**
* 查询用户通知偏好设置
*
* @param id 用户通知偏好设置主键
* @return 用户通知偏好设置
*/
@Transactional(readOnly = true)
@Override
public HotakeNotificationPreferences selectHotakeNotificationPreferencesById(Long id) {
return hotakeNotificationPreferencesMapper.selectHotakeNotificationPreferencesById(id);
}
/**
* 查询用户通知偏好设置列表
*
* @param hotakeNotificationPreferences 用户通知偏好设置
* @return 用户通知偏好设置
*/
@Transactional(readOnly = true)
@Override
public List<HotakeNotificationPreferences> selectHotakeNotificationPreferencesList(HotakeNotificationPreferences hotakeNotificationPreferences) {
return hotakeNotificationPreferencesMapper.selectHotakeNotificationPreferencesList(hotakeNotificationPreferences);
}
/**
* 新增用户通知偏好设置
*
* @param hotakeNotificationPreferences 用户通知偏好设置
* @return 结果
*/
@Transactional(rollbackFor = Exception.class)
@Override
public HotakeNotificationPreferences insertHotakeNotificationPreferences(HotakeNotificationPreferences hotakeNotificationPreferences) {
fill(FillTypeEnum.INSERT.getCode(), hotakeNotificationPreferences);
hotakeNotificationPreferencesMapper.insertHotakeNotificationPreferences(hotakeNotificationPreferences);
return hotakeNotificationPreferences;
}
/**
* 修改用户通知偏好设置
*
* @param hotakeNotificationPreferences 用户通知偏好设置
* @return 结果
*/
@Transactional(rollbackFor = Exception.class)
@Override
public HotakeNotificationPreferences updateHotakeNotificationPreferences(HotakeNotificationPreferences hotakeNotificationPreferences) {
fill(FillTypeEnum.UPDATE.getCode(), hotakeNotificationPreferences);
hotakeNotificationPreferencesMapper.updateHotakeNotificationPreferences(hotakeNotificationPreferences);
return hotakeNotificationPreferences;
}
/**
* 批量删除用户通知偏好设置
*
* @param ids 需要删除的用户通知偏好设置主键
* @return 结果
*/
@Transactional(rollbackFor = Exception.class)
@Override
public int deleteHotakeNotificationPreferencesByIds(Long[] ids) {
return hotakeNotificationPreferencesMapper.deleteHotakeNotificationPreferencesByIds(ids);
}
/**
* 删除用户通知偏好设置信息
*
* @param id 用户通知偏好设置主键
* @return 结果
*/
@Transactional(rollbackFor = Exception.class)
@Override
public int deleteHotakeNotificationPreferencesById(Long id) {
return hotakeNotificationPreferencesMapper.deleteHotakeNotificationPreferencesById(id);
}
/**
* 获取当前登录用户的通知偏好设置
* 如果不存在则自动创建默认设置
*
* @param username 用户名
* @return 用户通知偏好设置
*/
@Transactional(rollbackFor = Exception.class)
@Override
public HotakeNotificationPreferences getCurrentUserPreferences(String username) {
// 查询当前用户的设置
HotakeNotificationPreferences query = new HotakeNotificationPreferences();
query.setCreateBy(username);
List<HotakeNotificationPreferences> list = hotakeNotificationPreferencesMapper.selectHotakeNotificationPreferencesList(query);
// 如果存在,返回第一条
if (list != null && !list.isEmpty()) {
return list.get(0);
}
// 如果不存在,创建默认设置
HotakeNotificationPreferences defaultPreferences = new HotakeNotificationPreferences();
// 设置默认值(根据数据库表定义)
defaultPreferences.setEmailJobAlerts(1); // 默认开启
defaultPreferences.setEmailApplicationUpdates(1); // 默认开启
defaultPreferences.setEmailAiMatchSuggestions(0); // 默认关闭
defaultPreferences.setEmailNewsletter(0); // 默认关闭
defaultPreferences.setPushNewMessages(1); // 默认开启
defaultPreferences.setPushInterviewReminders(1); // 默认开启
defaultPreferences.setMailMarketingEmails(0); // 默认关闭
defaultPreferences.setMailPartnerOffers(0); // 默认关闭
// 保存并返回
return insertHotakeNotificationPreferences(defaultPreferences);
}
}