| | |
| | | * 保存项目介绍密码配置 |
| | | */ |
| | | @PostMapping("/project-introduction-password") |
| | | public ApiResponse<Void> savePasswordConfig(@Valid @RequestBody ProjectIntroductionPasswordRequest req) { |
| | | public ApiResponse<Boolean> savePasswordConfig(@Valid @RequestBody ProjectIntroductionPasswordRequest req) { |
| | | passwordService.savePasswordConfig(req); |
| | | return ApiResponse.ok(null); |
| | | return ApiResponse.ok(true); |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.tcm.training.admin.live.entity.ProjectIntroductionPassword; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Update; |
| | | |
| | | @Mapper |
| | | public interface ProjectIntroductionPasswordMapper extends BaseMapper<ProjectIntroductionPassword> { |
| | | |
| | | /** |
| | | * 更新密码配置(支持将密码设置为null) |
| | | */ |
| | | @Update("UPDATE tcm_project_introduction_password SET password_enabled = #{passwordEnabled}, password = #{password}, updated_at = NOW() WHERE id = #{id}") |
| | | int updatePasswordConfig(@Param("id") Long id, @Param("passwordEnabled") Integer passwordEnabled, @Param("password") String password); |
| | | } |
| | |
| | | } |
| | | passwordMapper.insert(config); |
| | | } else { |
| | | // 更新 |
| | | config.setPasswordEnabled(req.getPasswordEnabled()); |
| | | // 更新 - 使用自定义SQL支持设置为null |
| | | String encodedPassword = null; |
| | | if (req.getPasswordEnabled() == 1 && StrUtil.isNotBlank(req.getPassword())) { |
| | | config.setPassword(passwordEncoder.encode(req.getPassword())); |
| | | } else { |
| | | // 不启用密码时,清空密码 |
| | | config.setPassword(null); |
| | | encodedPassword = passwordEncoder.encode(req.getPassword()); |
| | | } |
| | | passwordMapper.updateById(config); |
| | | passwordMapper.updatePasswordConfig(config.getId(), req.getPasswordEnabled(), encodedPassword); |
| | | } |
| | | } |
| | | |
| | |
| | | password: values.passwordEnabled ? values.password : undefined, |
| | | }; |
| | | |
| | | const res = await saveProjectIntroductionPassword(data); |
| | | if (res.code === 200) { |
| | | await saveProjectIntroductionPassword(data); |
| | | message.success('保存成功'); |
| | | loadConfig(); |
| | | } else { |
| | | message.error(res.message || '保存失败'); |
| | | } |
| | | } catch (error) { |
| | | message.error('保存失败'); |
| | | console.error('保存失败:', error); |
| | | } finally { |
| | | setSubmitting(false); |