新增 用户通知偏好设置

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);
}
}

View File

@@ -0,0 +1,121 @@
<?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.vetti.hotake.mapper.HotakeNotificationPreferencesMapper">
<resultMap type="HotakeNotificationPreferences" id="HotakeNotificationPreferencesResult">
<result property="id" column="id" />
<result property="emailJobAlerts" column="email_job_alerts" />
<result property="emailApplicationUpdates" column="email_application_updates" />
<result property="emailAiMatchSuggestions" column="email_ai_match_suggestions" />
<result property="emailNewsletter" column="email_newsletter" />
<result property="pushNewMessages" column="push_new_messages" />
<result property="pushInterviewReminders" column="push_interview_reminders" />
<result property="mailMarketingEmails" column="mail_marketing_emails" />
<result property="mailPartnerOffers" column="mail_partner_offers" />
<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" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectHotakeNotificationPreferencesVo">
select id, email_job_alerts, email_application_updates, email_ai_match_suggestions,
email_newsletter, push_new_messages, push_interview_reminders,
mail_marketing_emails, mail_partner_offers,
del_flag, create_by, create_time, update_by, update_time, remark
from hotake_notification_preferences
</sql>
<select id="selectHotakeNotificationPreferencesList" parameterType="HotakeNotificationPreferences" resultMap="HotakeNotificationPreferencesResult">
<include refid="selectHotakeNotificationPreferencesVo"/>
<where>
<if test="emailJobAlerts != null"> and email_job_alerts = #{emailJobAlerts}</if>
<if test="emailApplicationUpdates != null"> and email_application_updates = #{emailApplicationUpdates}</if>
<if test="emailAiMatchSuggestions != null"> and email_ai_match_suggestions = #{emailAiMatchSuggestions}</if>
<if test="emailNewsletter != null"> and email_newsletter = #{emailNewsletter}</if>
<if test="pushNewMessages != null"> and push_new_messages = #{pushNewMessages}</if>
<if test="pushInterviewReminders != null"> and push_interview_reminders = #{pushInterviewReminders}</if>
<if test="mailMarketingEmails != null"> and mail_marketing_emails = #{mailMarketingEmails}</if>
<if test="mailPartnerOffers != null"> and mail_partner_offers = #{mailPartnerOffers}</if>
<if test="delFlag != null and delFlag != ''"> and del_flag = #{delFlag}</if>
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
</where>
</select>
<select id="selectHotakeNotificationPreferencesById" parameterType="Long" resultMap="HotakeNotificationPreferencesResult">
<include refid="selectHotakeNotificationPreferencesVo"/>
where id = #{id}
</select>
<insert id="insertHotakeNotificationPreferences" parameterType="HotakeNotificationPreferences" useGeneratedKeys="true" keyProperty="id">
insert into hotake_notification_preferences
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="emailJobAlerts != null">email_job_alerts,</if>
<if test="emailApplicationUpdates != null">email_application_updates,</if>
<if test="emailAiMatchSuggestions != null">email_ai_match_suggestions,</if>
<if test="emailNewsletter != null">email_newsletter,</if>
<if test="pushNewMessages != null">push_new_messages,</if>
<if test="pushInterviewReminders != null">push_interview_reminders,</if>
<if test="mailMarketingEmails != null">mail_marketing_emails,</if>
<if test="mailPartnerOffers != null">mail_partner_offers,</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>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="emailJobAlerts != null">#{emailJobAlerts},</if>
<if test="emailApplicationUpdates != null">#{emailApplicationUpdates},</if>
<if test="emailAiMatchSuggestions != null">#{emailAiMatchSuggestions},</if>
<if test="emailNewsletter != null">#{emailNewsletter},</if>
<if test="pushNewMessages != null">#{pushNewMessages},</if>
<if test="pushInterviewReminders != null">#{pushInterviewReminders},</if>
<if test="mailMarketingEmails != null">#{mailMarketingEmails},</if>
<if test="mailPartnerOffers != null">#{mailPartnerOffers},</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>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateHotakeNotificationPreferences" parameterType="HotakeNotificationPreferences">
update hotake_notification_preferences
<trim prefix="SET" suffixOverrides=",">
<if test="emailJobAlerts != null">email_job_alerts = #{emailJobAlerts},</if>
<if test="emailApplicationUpdates != null">email_application_updates = #{emailApplicationUpdates},</if>
<if test="emailAiMatchSuggestions != null">email_ai_match_suggestions = #{emailAiMatchSuggestions},</if>
<if test="emailNewsletter != null">email_newsletter = #{emailNewsletter},</if>
<if test="pushNewMessages != null">push_new_messages = #{pushNewMessages},</if>
<if test="pushInterviewReminders != null">push_interview_reminders = #{pushInterviewReminders},</if>
<if test="mailMarketingEmails != null">mail_marketing_emails = #{mailMarketingEmails},</if>
<if test="mailPartnerOffers != null">mail_partner_offers = #{mailPartnerOffers},</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>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteHotakeNotificationPreferencesById" parameterType="Long">
delete from hotake_notification_preferences where id = #{id}
</delete>
<delete id="deleteHotakeNotificationPreferencesByIds" parameterType="String">
delete from hotake_notification_preferences where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>