添加修改默认银行卡接口

main
hansha 2 years ago
parent 97d11709e5
commit d777d78b75

@ -1,25 +1,19 @@
package com.ruoyi.szxc.controller; package com.ruoyi.szxc.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.szxc.domain.SzxcBankcardInfo; import com.ruoyi.szxc.domain.SzxcBankcardInfo;
import com.ruoyi.szxc.service.ISzxcBankcardInfoService; import com.ruoyi.szxc.service.ISzxcBankcardInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil; import org.springframework.beans.factory.annotation.Autowired;
import com.ruoyi.common.core.page.TableDataInfo; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/** /**
* Controller * Controller
@ -90,6 +84,16 @@ public class SzxcBankcardInfoController extends BaseController
{ {
return toAjax(szxcBankcardInfoService.updateSzxcBankcardInfo(szxcBankcardInfo)); return toAjax(szxcBankcardInfoService.updateSzxcBankcardInfo(szxcBankcardInfo));
} }
/**
*
*/
@PreAuthorize("@ss.hasPermi('szxc:bankinfo:edit')")
@Log(title = "银行卡信息", businessType = BusinessType.UPDATE)
@PutMapping("/editDefault")
public AjaxResult editDefault(@RequestBody SzxcBankcardInfo szxcBankcardInfo)
{
return toAjax(szxcBankcardInfoService.updateSzxcBankcardInfo2(szxcBankcardInfo));
}
/** /**
* *

@ -1,8 +1,9 @@
package com.ruoyi.szxc.mapper; package com.ruoyi.szxc.mapper;
import java.util.List;
import com.ruoyi.szxc.domain.SzxcBankcardInfo; import com.ruoyi.szxc.domain.SzxcBankcardInfo;
import java.util.List;
/** /**
* Mapper * Mapper
* *
@ -58,4 +59,6 @@ public interface SzxcBankcardInfoMapper
* @return * @return
*/ */
public int deleteSzxcBankcardInfoByIds(Long[] ids); public int deleteSzxcBankcardInfoByIds(Long[] ids);
void updateSzxcBankcardInfo2(SzxcBankcardInfo param);
} }

@ -1,8 +1,9 @@
package com.ruoyi.szxc.service; package com.ruoyi.szxc.service;
import java.util.List;
import com.ruoyi.szxc.domain.SzxcBankcardInfo; import com.ruoyi.szxc.domain.SzxcBankcardInfo;
import java.util.List;
/** /**
* Service * Service
* *
@ -58,4 +59,6 @@ public interface ISzxcBankcardInfoService
* @return * @return
*/ */
public int deleteSzxcBankcardInfoById(Long id); public int deleteSzxcBankcardInfoById(Long id);
int updateSzxcBankcardInfo2(SzxcBankcardInfo szxcBankcardInfo);
} }

@ -1,12 +1,14 @@
package com.ruoyi.szxc.service.impl; package com.ruoyi.szxc.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.szxc.mapper.SzxcBankcardInfoMapper;
import com.ruoyi.szxc.domain.SzxcBankcardInfo; import com.ruoyi.szxc.domain.SzxcBankcardInfo;
import com.ruoyi.szxc.mapper.SzxcBankcardInfoMapper;
import com.ruoyi.szxc.service.ISzxcBankcardInfoService; import com.ruoyi.szxc.service.ISzxcBankcardInfoService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
/** /**
* Service * Service
@ -17,7 +19,7 @@ import com.ruoyi.szxc.service.ISzxcBankcardInfoService;
@Service @Service
public class SzxcBankcardInfoServiceImpl implements ISzxcBankcardInfoService public class SzxcBankcardInfoServiceImpl implements ISzxcBankcardInfoService
{ {
@Autowired @Resource
private SzxcBankcardInfoMapper szxcBankcardInfoMapper; private SzxcBankcardInfoMapper szxcBankcardInfoMapper;
/** /**
@ -70,6 +72,29 @@ public class SzxcBankcardInfoServiceImpl implements ISzxcBankcardInfoService
return szxcBankcardInfoMapper.updateSzxcBankcardInfo(szxcBankcardInfo); return szxcBankcardInfoMapper.updateSzxcBankcardInfo(szxcBankcardInfo);
} }
/**
*
* @param szxcBankcardInfo
* @return
*/
@Override
@Transactional
public int updateSzxcBankcardInfo2(SzxcBankcardInfo szxcBankcardInfo) {
szxcBankcardInfo.setUpdateTime(DateUtils.getNowDate());
//修改所有ownerid=jmid的银行卡 修改银行卡默认为否
if(szxcBankcardInfo.getDefaultCard()!=null&&szxcBankcardInfo.getDefaultCard().equals("0")){
SzxcBankcardInfo param=new SzxcBankcardInfo();
param.setOwnerId(szxcBankcardInfo.getOwnerId());
param.setDefaultCard("1");//1代表设置为非默认卡
try {
szxcBankcardInfoMapper.updateSzxcBankcardInfo2(param);
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
return szxcBankcardInfoMapper.updateSzxcBankcardInfo(szxcBankcardInfo);
}
/** /**
* *
* *
@ -93,4 +118,5 @@ public class SzxcBankcardInfoServiceImpl implements ISzxcBankcardInfoService
{ {
return szxcBankcardInfoMapper.deleteSzxcBankcardInfoById(id); return szxcBankcardInfoMapper.deleteSzxcBankcardInfoById(id);
} }
} }

@ -108,6 +108,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
<!--修改默认银行卡专属方法-->
<update id="updateSzxcBankcardInfo2" parameterType="SzxcBankcardInfo">
update szxc_bankcard_info
<trim prefix="SET" suffixOverrides=",">
<if test="ownerId != null">owner_id = #{ownerId},</if>
<if test="defaultCard != null and defaultCard != ''">default_card = #{defaultCard},</if>
</trim>
</update>
<delete id="deleteSzxcBankcardInfoById" parameterType="Long"> <delete id="deleteSzxcBankcardInfoById" parameterType="Long">
delete from szxc_bankcard_info where id = #{id} delete from szxc_bankcard_info where id = #{id}

Loading…
Cancel
Save