同步建立账户

This commit is contained in:
sxu 2025-04-07 16:24:32 +08:00
parent 09f1423d82
commit 1c6c29484c
5 changed files with 53 additions and 17 deletions

View File

@ -3,21 +3,17 @@ package com.bonus.canteen.core.account.controller;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.bonus.common.log.enums.OperaType; import com.bonus.common.log.enums.OperaType;
import com.bonus.canteen.core.common.annotation.PreventRepeatSubmit;
import com.bonus.system.api.domain.SysUser; import com.bonus.system.api.domain.SysUser;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; 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.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.bonus.common.log.annotation.SysLog; import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.security.annotation.RequiresPermissions;
import com.bonus.canteen.core.account.domain.AccInfo; import com.bonus.canteen.core.account.domain.AccInfo;
import com.bonus.canteen.core.account.service.IAccInfoService; import com.bonus.canteen.core.account.service.IAccInfoService;
import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.controller.BaseController;
@ -133,4 +129,25 @@ public class AccInfoController extends BaseController {
public AjaxResult remove(@PathVariable Long[] ids) { public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(accInfoService.deleteAccInfoByIds(ids)); return toAjax(accInfoService.deleteAccInfoByIds(ids));
} }
/**
* 删除账户资料
*/
// @ApiOperation(value = "删除账户资料")
// //@PreventRepeatSubmit
// //@RequiresPermissions("account:info:remove")
// @SysLog(title = "账户资料", businessType = OperaType.DELETE, logType = 1,module = "账户管理->删除账户资料")
// @PostMapping("/delete/{userIds}")
// public AjaxResult deleteAccInfoByUserIds(@PathVariable("userIds") Long[] userIds) {
// return toAjax(accInfoService.deleteAccInfoByUserIds(userIds));
// }
@ApiOperation(value = "删除账户资料")
//@PreventRepeatSubmit
//@RequiresPermissions("account:info:remove")
@SysLog(title = "账户资料", businessType = OperaType.DELETE, logType = 1,module = "账户管理->删除账户资料")
@PostMapping("/deleteAccInfoByUserIds")
public AjaxResult deleteAccInfoByUserIds(@RequestBody List<SysUser> users) {
return toAjax(accInfoService.deleteAccInfoByUserIds(users));
}
} }

View File

@ -48,7 +48,7 @@ public interface AccInfoMapper {
* @param id 账户资料主键 * @param id 账户资料主键
* @return 结果 * @return 结果
*/ */
public int deleteAccInfoById(Long id); public int deleteAccInfoByUserId(Long id);
/** /**
* 批量删除账户资料 * 批量删除账户资料

View File

@ -54,10 +54,12 @@ public interface IAccInfoService {
/** /**
* 删除账户资料信息 * 删除账户资料信息
* *
* @param id 账户资料主键 * @param userIds 账户资料主键
* @return 结果 * @return 结果
*/ */
public int deleteAccInfoById(Long id); public int deleteAccInfoByUserIds(Long[] userIds);
public int deleteAccInfoByUserIds(List<SysUser> users);
public int syncAccInfo(SysUser sysUser); public int syncAccInfo(SysUser sysUser);
} }

View File

@ -1,7 +1,6 @@
package com.bonus.canteen.core.account.service.impl; package com.bonus.canteen.core.account.service.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import com.bonus.canteen.core.account.domain.AccWalletInfo; import com.bonus.canteen.core.account.domain.AccWalletInfo;
@ -10,9 +9,6 @@ import com.bonus.canteen.core.account.enums.AccWalletIdEnum;
import com.bonus.canteen.core.account.service.IAccWalletInfoService; import com.bonus.canteen.core.account.service.IAccWalletInfoService;
import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.houqin.mq.constant.LeMqConstant;
import com.bonus.common.houqin.mq.util.MqUtil;
import com.bonus.common.houqin.utils.id.Id;
import com.bonus.system.api.domain.SysUser; import com.bonus.system.api.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -102,12 +98,33 @@ public class AccInfoServiceImpl implements IAccInfoService {
/** /**
* 删除账户资料信息 * 删除账户资料信息
* *
* @param id 账户资料主键 * @param userIds 账户资料主键
* @return 结果 * @return 结果
*/ */
@Override @Transactional(
public int deleteAccInfoById(Long id) { rollbackFor = {Exception.class}
return accInfoMapper.deleteAccInfoById(id); )
public int deleteAccInfoByUserIds(Long[] userIds) {
int count = 0;
for (int i = 0; i < userIds.length; i++) {
accWalletInfoService.deleteAccWalletInfoByUserId(userIds[i]);
//MqUtil.sendDataChange(userId, LeMqConstant.DataChangeType.REMOVE, LeMqConstant.Topic.DATA_CHANGE_CUSTOMER);
count += accInfoMapper.deleteAccInfoByUserId(userIds[i]);
}
return count;
}
@Transactional(
rollbackFor = {Exception.class}
)
public int deleteAccInfoByUserIds(List<SysUser> users) {
int count = 0;
for (int i = 0; i < users.size(); i++) {
accWalletInfoService.deleteAccWalletInfoByUserId(users.get(i).getUserId());
//MqUtil.sendDataChange(userId, LeMqConstant.DataChangeType.REMOVE, LeMqConstant.Topic.DATA_CHANGE_CUSTOMER);
count += accInfoMapper.deleteAccInfoByUserId(users.get(i).getUserId());
}
return count;
} }
@Transactional( @Transactional(

View File

@ -296,8 +296,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id} where id = #{id}
</update> </update>
<delete id="deleteAccInfoById" parameterType="Long"> <delete id="deleteAccInfoByUserId" parameterType="Long">
delete from acc_info where id = #{id} delete from acc_info where user_id = #{userId}
</delete> </delete>
<delete id="deleteAccInfoByIds" parameterType="String"> <delete id="deleteAccInfoByIds" parameterType="String">