当前位置: 首页 > news >正文

网站开发上海工资淘宝店铺怎么推广和引流

网站开发上海工资,淘宝店铺怎么推广和引流,自己做的网站会被黑吗,台州建设网站文章目录 1、updateInviteCodeStatus2、handleLock3、InviteCodeController4、InviteCodeService5、CrudRepository 点击锁定按钮,锁定按钮要变成解锁按钮,然后状态要从待绑定变成 已锁定:https://blog.csdn.net/m0_65152767/article/details…

文章目录

  • 1、updateInviteCodeStatus
  • 2、handleLock
  • 3、InviteCodeController
  • 4、InviteCodeService
  • 5、CrudRepository

点击锁定按钮,锁定按钮要变成解锁按钮,然后状态要从待绑定变成 已锁定:https://blog.csdn.net/m0_65152767/article/details/144810693

这篇博客中的内容,有一个bug,那就是我刷新页面,解锁按钮还是会变成锁定按钮,最后检查发现锁定按钮有一个字段是和后端关联的,我没有更新后端这个字段的值,所以也就造成我们只是临时的更改锁定按钮的状态,并没有持久化更改。


1、updateInviteCodeStatus

// 修改接口参数类型
export const updateInviteCodeStatus = (data: {inviteCodeId: number;statusName: string;isLocked: number; // 新增 isLocked 字段}) =>request({url: '/api/invite-codes/updateStatus',method: 'put',params: data, // params 中包含 isLocked 参数});

2、handleLock

  private async handleLock(row: any) {const newIsLocked = row.isLocked === 0 ? 1 : 0const newStatus = newIsLocked === 0? InviteCodeStatus.EFFECTIVE.name: InviteCodeStatus.LOCKED.namethis.$confirm(`确定要${row.isLocked === 0 ? '锁定' : '解锁'}该邀请码吗?`,'提示',{confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(async() => {try {console.log('请求参数:', {inviteCodeId: row.id,statusName: newStatus,isLocked: newIsLocked, // 添加 isLocked 参数})// 调用后端的更新状态接口const response = await updateInviteCodeStatus({inviteCodeId: row.id,statusName: newStatus,isLocked: newIsLocked, // 添加 isLocked 参数})console.log('response.data:', response.data)console.log('typeof response.data', typeof response.data)if (response && response.data && typeof response.data === 'object' && 'status' in response.data) {const status = response.data.statusconst isLocked = response.data.isLocked// 调试步骤 1:打印状态值console.log('状态值:', status)console.log('后端返回的isLocked值:',isLocked)// 调试步骤 2:检查状态映射let statusObjtry {statusObj = InviteCodeStatus.fromValue(status)console.log('映射后的状态:', statusObj)} catch (e) {console.error('状态映射错误:', e)this.$message.error('状态映射错误,请联系管理员')return}// 更新本地数据const index = this.tableData.findIndex(item => item.id === row.id)if (index !== -1) {this.$set(this.tableData, index, {...this.tableData[index],// isLocked: newIsLocked,status: status, // 使用后端返回的 status 值isLocked: isLocked, // 使用后端返回的isLocked})console.log('更新后的行数据:', this.tableData[index])}this.$message.success(`${newIsLocked === 0 ? '解锁' : '锁定'}成功`)// 选择性地重新拉取数据,根据实际需求// await this.fetchInviteCodeList();} else {this.$message.error('更新失败')}} catch (error) {console.error('更新邀请码状态失败:', error)console.error('错误详情:', error.response || error.message)this.$message.error('更新邀请码状态失败:未知错误')}}).catch(() => { })}

3、InviteCodeController

    @PutMapping("/updateStatus")public BaseResult updateInviteCodeStatus(@RequestParam Integer inviteCodeId,@RequestParam String statusName,@RequestParam Integer isLocked) {  // 添加 isLocked 参数try {// 获取 InviteCodeStatus 枚举值InviteCodeStatus status = InviteCodeStatus.fromName(statusName);// 调用service层更新状态的方法inviteCodeService.updateInviteCodeStatus(inviteCodeId, status.getValue(),isLocked);// 更新 isLocked// 获取更新后的邀请码数据Optional<InviteCode>  updatedInviteCodeOptional = inviteCodeService.getInviteCodeById(inviteCodeId);if(updatedInviteCodeOptional.isPresent()){InviteCode updatedInviteCode =  updatedInviteCodeOptional.get();// 构建返回数据Map<String,Object> data = new HashMap<>();data.put("status", updatedInviteCode.getStatus());data.put("isLocked", updatedInviteCode.getIsLocked()); // 添加 isLocked 字段return BaseResult.success("状态更新成功",data);}else {return BaseResult.success("状态更新成功");}} catch (IllegalArgumentException e) {return BaseResult.failure(BaseResult.PARAMETER_ERROR, e.getMessage());} catch (Exception e) {e.printStackTrace();return BaseResult.failure(500, "服务器内部错误" + e.getMessage());}}

4、InviteCodeService

    @Transactionalpublic void updateInviteCodeStatus(Integer inviteCodeId, Integer status, Integer isLocked) {Optional<InviteCode> inviteCodeOptional = inviteCodeRepository.findById(inviteCodeId);if (inviteCodeOptional.isPresent()) {InviteCode inviteCode = inviteCodeOptional.get();inviteCode.setStatus(status);inviteCode.setLastModifiedDate(LocalDateTime.now());// 更新最后修改时间inviteCode.setIsLocked(isLocked);inviteCodeRepository.save(inviteCode);} else {throw new IllegalArgumentException("Invalid inviteCode ID: " + inviteCodeId);}}public Optional<InviteCode> getInviteCodeById(Integer inviteCodeId) {return inviteCodeRepository.findById(inviteCodeId);}

5、CrudRepository

public interface CrudRepository<T, ID> extends Repository<T, ID> {Optional<T> findById(ID var1);<S extends T> S save(S var1);
}

在这里插入图片描述

http://www.hkea.cn/news/818005/

相关文章:

  • 泉州网站建设工作室谷歌seo价格
  • 国建设委员会网站百度推广一天烧几千
  • 做网站 花园路国贸营销推广方案包括哪些内容
  • 做商城网站哪里买口碑营销属于什么营销
  • 鞋子 东莞网站建设真正的免费建站在这里
  • 网站上微信的链接怎么做项目平台
  • 做网站后有人抢注关键词网络营销方案策划论文
  • 苏州网站建设网站seo优化的方法
  • 设计网装修seo顾问服
  • 网站ip拦截免费网站搭建平台
  • 深圳企业网站建设公司快速申请免费个人网站
  • 唯品会 一家专门做特卖的网站沈阳seo按天计费
  • 聊城手机网站建设郑州seo服务技术
  • 个人定做衣服店江门seo推广公司
  • 网站开发与网站建设山东济南seo整站优化费用
  • 香港疫情最新消息今天深圳seo教程
  • 维护一个网站难吗免费发布外链
  • 南安市网站建设成都今天重大新闻事件
  • 网站后台补丁如何做软文有哪几种类型
  • 网站建设的费用包括哪些内容资讯门户类网站有哪些
  • 一站式服务图片制作网页的基本步骤
  • 个人网站建设网站网络网站推广
  • asp做的药店网站模板北京百度快照推广公司
  • 网站建设泉州效率网络seo的优化策略有哪些
  • 页网站无锡网站制作推广
  • 一流的龙岗网站建设目前最靠谱的推广平台
  • 企业营销型网站费用短视频推广引流
  • 化妆品可做的团购网站有哪些seo研究中心南宁线下
  • 网站空间域名是什么做电商必备的几个软件
  • 软件公司运营是做什么的seo公司运营