调整 mapper 命名,避免可能的冲突

This commit is contained in:
YunaiV 2023-09-02 19:23:09 +08:00
parent 891ed3d055
commit 9148170926
10 changed files with 64 additions and 64 deletions

View File

@ -8,7 +8,7 @@ import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface AddressMapper extends BaseMapperX<MemberAddressDO> {
public interface MemberAddressMapper extends BaseMapperX<MemberAddressDO> {
default MemberAddressDO selectByIdAndUserId(Long id, Long userId) {
return selectOne(MemberAddressDO::getId, id, MemberAddressDO::getUserId, userId);

View File

@ -5,7 +5,7 @@ import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressCreate
import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressUpdateReqVO;
import cn.iocoder.yudao.module.member.convert.address.AddressConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO;
import cn.iocoder.yudao.module.member.dal.mysql.address.AddressMapper;
import cn.iocoder.yudao.module.member.dal.mysql.address.MemberAddressMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
@ -26,21 +26,21 @@ import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.ADDRESS_NO
public class AddressServiceImpl implements AddressService {
@Resource
private AddressMapper addressMapper;
private MemberAddressMapper memberAddressMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public Long createAddress(Long userId, AppAddressCreateReqVO createReqVO) {
// 如果添加的是默认收件地址则将原默认地址修改为非默认
if (Boolean.TRUE.equals(createReqVO.getDefaultStatus())) {
List<MemberAddressDO> addresses = addressMapper.selectListByUserIdAndDefaulted(userId, true);
addresses.forEach(address -> addressMapper.updateById(new MemberAddressDO().setId(address.getId()).setDefaultStatus(false)));
List<MemberAddressDO> addresses = memberAddressMapper.selectListByUserIdAndDefaulted(userId, true);
addresses.forEach(address -> memberAddressMapper.updateById(new MemberAddressDO().setId(address.getId()).setDefaultStatus(false)));
}
// 插入
MemberAddressDO address = AddressConvert.INSTANCE.convert(createReqVO);
address.setUserId(userId);
addressMapper.insert(address);
memberAddressMapper.insert(address);
// 返回
return address.getId();
}
@ -53,14 +53,14 @@ public class AddressServiceImpl implements AddressService {
// 如果修改的是默认收件地址则将原默认地址修改为非默认
if (Boolean.TRUE.equals(updateReqVO.getDefaultStatus())) {
List<MemberAddressDO> addresses = addressMapper.selectListByUserIdAndDefaulted(userId, true);
List<MemberAddressDO> addresses = memberAddressMapper.selectListByUserIdAndDefaulted(userId, true);
addresses.stream().filter(u -> !u.getId().equals(updateReqVO.getId())) // 排除自己
.forEach(address -> addressMapper.updateById(new MemberAddressDO().setId(address.getId()).setDefaultStatus(false)));
.forEach(address -> memberAddressMapper.updateById(new MemberAddressDO().setId(address.getId()).setDefaultStatus(false)));
}
// 更新
MemberAddressDO updateObj = AddressConvert.INSTANCE.convert(updateReqVO);
addressMapper.updateById(updateObj);
memberAddressMapper.updateById(updateObj);
}
@Override
@ -68,7 +68,7 @@ public class AddressServiceImpl implements AddressService {
// 校验存在,校验是否能够操作
validAddressExists(userId, id);
// 删除
addressMapper.deleteById(id);
memberAddressMapper.deleteById(id);
}
private void validAddressExists(Long userId, Long id) {
@ -80,17 +80,17 @@ public class AddressServiceImpl implements AddressService {
@Override
public MemberAddressDO getAddress(Long userId, Long id) {
return addressMapper.selectByIdAndUserId(id, userId);
return memberAddressMapper.selectByIdAndUserId(id, userId);
}
@Override
public List<MemberAddressDO> getAddressList(Long userId) {
return addressMapper.selectListByUserIdAndDefaulted(userId, null);
return memberAddressMapper.selectListByUserIdAndDefaulted(userId, null);
}
@Override
public MemberAddressDO getDefaultUserAddress(Long userId) {
List<MemberAddressDO> addresses = addressMapper.selectListByUserIdAndDefaulted(userId, true);
List<MemberAddressDO> addresses = memberAddressMapper.selectListByUserIdAndDefaulted(userId, true);
return CollUtil.getFirst(addresses);
}

View File

@ -31,7 +31,7 @@ import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.GROUP_NOT_
public class MemberGroupServiceImpl implements MemberGroupService {
@Resource
private MemberGroupMapper groupMapper;
private MemberGroupMapper memberGroupMapper;
@Resource
private MemberUserService memberUserService;
@ -39,7 +39,7 @@ public class MemberGroupServiceImpl implements MemberGroupService {
public Long createGroup(MemberGroupCreateReqVO createReqVO) {
// 插入
MemberGroupDO group = MemberGroupConvert.INSTANCE.convert(createReqVO);
groupMapper.insert(group);
memberGroupMapper.insert(group);
// 返回
return group.getId();
}
@ -50,7 +50,7 @@ public class MemberGroupServiceImpl implements MemberGroupService {
validateGroupExists(updateReqVO.getId());
// 更新
MemberGroupDO updateObj = MemberGroupConvert.INSTANCE.convert(updateReqVO);
groupMapper.updateById(updateObj);
memberGroupMapper.updateById(updateObj);
}
@Override
@ -60,11 +60,11 @@ public class MemberGroupServiceImpl implements MemberGroupService {
// 校验分组下是否有用户
validateGroupHasUser(id);
// 删除
groupMapper.deleteById(id);
memberGroupMapper.deleteById(id);
}
void validateGroupExists(Long id) {
if (groupMapper.selectById(id) == null) {
if (memberGroupMapper.selectById(id) == null) {
throw exception(GROUP_NOT_EXISTS);
}
}
@ -78,7 +78,7 @@ public class MemberGroupServiceImpl implements MemberGroupService {
@Override
public MemberGroupDO getGroup(Long id) {
return groupMapper.selectById(id);
return memberGroupMapper.selectById(id);
}
@Override
@ -86,17 +86,17 @@ public class MemberGroupServiceImpl implements MemberGroupService {
if (CollUtil.isEmpty(ids)) {
return ListUtil.empty();
}
return groupMapper.selectBatchIds(ids);
return memberGroupMapper.selectBatchIds(ids);
}
@Override
public PageResult<MemberGroupDO> getGroupPage(MemberGroupPageReqVO pageReqVO) {
return groupMapper.selectPage(pageReqVO);
return memberGroupMapper.selectPage(pageReqVO);
}
@Override
public List<MemberGroupDO> getGroupListByStatus(Integer status) {
return groupMapper.selectListByStatus(status);
return memberGroupMapper.selectListByStatus(status);
}
}

View File

@ -42,7 +42,7 @@ import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
public class MemberLevelServiceImpl implements MemberLevelService {
@Resource
private MemberLevelMapper levelMapper;
private MemberLevelMapper memberLevelMapper;
@Resource
private MemberLevelRecordService memberLevelRecordService;
@Resource
@ -57,7 +57,7 @@ public class MemberLevelServiceImpl implements MemberLevelService {
// 插入
MemberLevelDO level = MemberLevelConvert.INSTANCE.convert(createReqVO);
levelMapper.insert(level);
memberLevelMapper.insert(level);
// 返回
return level.getId();
}
@ -71,7 +71,7 @@ public class MemberLevelServiceImpl implements MemberLevelService {
// 更新
MemberLevelDO updateObj = MemberLevelConvert.INSTANCE.convert(updateReqVO);
levelMapper.updateById(updateObj);
memberLevelMapper.updateById(updateObj);
}
@Override
@ -81,12 +81,12 @@ public class MemberLevelServiceImpl implements MemberLevelService {
// 校验分组下是否有用户
validateLevelHasUser(id);
// 删除
levelMapper.deleteById(id);
memberLevelMapper.deleteById(id);
}
@VisibleForTesting
MemberLevelDO validateLevelExists(Long id) {
MemberLevelDO levelDO = levelMapper.selectById(id);
MemberLevelDO levelDO = memberLevelMapper.selectById(id);
if (levelDO == null) {
throw exception(LEVEL_NOT_EXISTS);
}
@ -141,7 +141,7 @@ public class MemberLevelServiceImpl implements MemberLevelService {
@VisibleForTesting
void validateConfigValid(Long id, String name, Integer level, Integer experience) {
List<MemberLevelDO> list = levelMapper.selectList();
List<MemberLevelDO> list = memberLevelMapper.selectList();
// 校验名称唯一
validateNameUnique(list, id, name);
// 校验等级唯一
@ -160,7 +160,7 @@ public class MemberLevelServiceImpl implements MemberLevelService {
@Override
public MemberLevelDO getLevel(Long id) {
return id != null && id > 0 ? levelMapper.selectById(id) : null;
return id != null && id > 0 ? memberLevelMapper.selectById(id) : null;
}
@Override
@ -168,17 +168,17 @@ public class MemberLevelServiceImpl implements MemberLevelService {
if (CollUtil.isEmpty(ids)) {
return Collections.emptyList();
}
return levelMapper.selectBatchIds(ids);
return memberLevelMapper.selectBatchIds(ids);
}
@Override
public List<MemberLevelDO> getLevelList(MemberLevelListReqVO listReqVO) {
return levelMapper.selectList(listReqVO);
return memberLevelMapper.selectList(listReqVO);
}
@Override
public List<MemberLevelDO> getLevelListByStatus(Integer status) {
return levelMapper.selectListByStatus(status);
return memberLevelMapper.selectListByStatus(status);
}
@Override

View File

@ -21,23 +21,23 @@ import java.util.List;
public class MemberPointConfigServiceImpl implements MemberPointConfigService {
@Resource
private MemberPointConfigMapper pointConfigMapper;
private MemberPointConfigMapper memberPointConfigMapper;
@Override
public void savePointConfig(MemberPointConfigSaveReqVO saveReqVO) {
// 存在则进行更新
MemberPointConfigDO dbConfig = getPointConfig();
if (dbConfig != null) {
pointConfigMapper.updateById(MemberPointConfigConvert.INSTANCE.convert(saveReqVO).setId(dbConfig.getId()));
memberPointConfigMapper.updateById(MemberPointConfigConvert.INSTANCE.convert(saveReqVO).setId(dbConfig.getId()));
return;
}
// 不存在则进行插入
pointConfigMapper.insert(MemberPointConfigConvert.INSTANCE.convert(saveReqVO));
memberPointConfigMapper.insert(MemberPointConfigConvert.INSTANCE.convert(saveReqVO));
}
@Override
public MemberPointConfigDO getPointConfig() {
List<MemberPointConfigDO> list = pointConfigMapper.selectList();
List<MemberPointConfigDO> list = memberPointConfigMapper.selectList();
return CollectionUtils.getFirst(list);
}

View File

@ -35,7 +35,7 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
public class MemberPointRecordServiceImpl implements MemberPointRecordService {
@Resource
private MemberPointRecordMapper recordMapper;
private MemberPointRecordMapper memberPointRecordMapper;
@Resource
private MemberPointConfigService memberPointConfigService;
@ -55,12 +55,12 @@ public class MemberPointRecordServiceImpl implements MemberPointRecordService {
userIds = convertSet(users, MemberUserDO::getId);
}
// 执行查询
return recordMapper.selectPage(pageReqVO, userIds);
return memberPointRecordMapper.selectPage(pageReqVO, userIds);
}
@Override
public PageResult<MemberPointRecordDO> getPointRecordPage(Long userId, PageParam pageVO) {
return recordMapper.selectPage(userId, pageVO);
return memberPointRecordMapper.selectPage(userId, pageVO);
}
@Override
@ -86,7 +86,7 @@ public class MemberPointRecordServiceImpl implements MemberPointRecordService {
.setUserId(userId).setBizId(bizId).setBizType(bizType.getType())
.setTitle(bizType.getName()).setDescription(StrUtil.format(bizType.getDescription(), point))
.setPoint(point).setTotalPoint(totalPoint);
recordMapper.insert(record);
memberPointRecordMapper.insert(record);
// 3. 更新用户积分
memberUserService.updateUserPoint(userId, totalPoint);

View File

@ -26,7 +26,7 @@ import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.SIGN_IN_CO
public class MemberSignInConfigServiceImpl implements MemberSignInConfigService {
@Resource
private MemberSignInConfigMapper signInConfigMapper;
private MemberSignInConfigMapper memberSignInConfigMapper;
@Override
public Long createSignInConfig(MemberSignInConfigCreateReqVO createReqVO) {
@ -35,7 +35,7 @@ public class MemberSignInConfigServiceImpl implements MemberSignInConfigService
// 插入
MemberSignInConfigDO signInConfig = MemberSignInConfigConvert.INSTANCE.convert(createReqVO);
signInConfigMapper.insert(signInConfig);
memberSignInConfigMapper.insert(signInConfig);
// 返回
return signInConfig.getId();
}
@ -49,7 +49,7 @@ public class MemberSignInConfigServiceImpl implements MemberSignInConfigService
// 判断更新
MemberSignInConfigDO updateObj = MemberSignInConfigConvert.INSTANCE.convert(updateReqVO);
signInConfigMapper.updateById(updateObj);
memberSignInConfigMapper.updateById(updateObj);
}
@Override
@ -57,11 +57,11 @@ public class MemberSignInConfigServiceImpl implements MemberSignInConfigService
// 校验存在
validateSignInConfigExists(id);
// 删除
signInConfigMapper.deleteById(id);
memberSignInConfigMapper.deleteById(id);
}
private void validateSignInConfigExists(Long id) {
if (signInConfigMapper.selectById(id) == null) {
if (memberSignInConfigMapper.selectById(id) == null) {
throw exception(SIGN_IN_CONFIG_NOT_EXISTS);
}
}
@ -73,7 +73,7 @@ public class MemberSignInConfigServiceImpl implements MemberSignInConfigService
* @param id 编号只有更新的时候会传递
*/
private void validateSignInConfigDayDuplicate(Integer day, Long id) {
MemberSignInConfigDO config = signInConfigMapper.selectByDay(day);
MemberSignInConfigDO config = memberSignInConfigMapper.selectByDay(day);
// 1. 新增时config 非空则说明重复
if (id == null && config != null) {
throw exception(SIGN_IN_CONFIG_EXISTS);
@ -86,19 +86,19 @@ public class MemberSignInConfigServiceImpl implements MemberSignInConfigService
@Override
public MemberSignInConfigDO getSignInConfig(Long id) {
return signInConfigMapper.selectById(id);
return memberSignInConfigMapper.selectById(id);
}
@Override
public List <MemberSignInConfigDO> getSignInConfigList() {
List<MemberSignInConfigDO> list = signInConfigMapper.selectList();
List<MemberSignInConfigDO> list = memberSignInConfigMapper.selectList();
list.sort(Comparator.comparing(MemberSignInConfigDO::getDay));
return list;
}
@Override
public List<MemberSignInConfigDO> getSignInConfigList(Integer status) {
List<MemberSignInConfigDO> list = signInConfigMapper.selectListByStatus(status);
List<MemberSignInConfigDO> list = memberSignInConfigMapper.selectListByStatus(status);
list.sort(Comparator.comparing(MemberSignInConfigDO::getDay));
return list;
}

View File

@ -28,7 +28,7 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
public class MemberSignInRecordServiceImpl implements MemberSignInRecordService {
@Resource
private MemberSignInRecordMapper signInRecordMapper;
private MemberSignInRecordMapper memberSignInRecordMapper;
@Resource
private MemberUserApi memberUserApi;
@ -46,12 +46,12 @@ public class MemberSignInRecordServiceImpl implements MemberSignInRecordService
userIds = convertSet(users, MemberUserRespDTO::getId);
}
// 分页查询
return signInRecordMapper.selectPage(pageReqVO, userIds);
return memberSignInRecordMapper.selectPage(pageReqVO, userIds);
}
@Override
public PageResult<MemberSignInRecordDO> getSignRecordPage(Long userId, PageParam pageParam) {
return signInRecordMapper.selectPage(userId, pageParam);
return memberSignInRecordMapper.selectPage(userId, pageParam);
}
}

View File

@ -31,7 +31,7 @@ import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
public class MemberTagServiceImpl implements MemberTagService {
@Resource
private MemberTagMapper tagMapper;
private MemberTagMapper memberTagMapper;
@Resource
private MemberUserService memberUserService;
@ -41,7 +41,7 @@ public class MemberTagServiceImpl implements MemberTagService {
validateTagNameUnique(null, createReqVO.getName());
// 插入
MemberTagDO tag = MemberTagConvert.INSTANCE.convert(createReqVO);
tagMapper.insert(tag);
memberTagMapper.insert(tag);
// 返回
return tag.getId();
}
@ -54,7 +54,7 @@ public class MemberTagServiceImpl implements MemberTagService {
validateTagNameUnique(updateReqVO.getId(), updateReqVO.getName());
// 更新
MemberTagDO updateObj = MemberTagConvert.INSTANCE.convert(updateReqVO);
tagMapper.updateById(updateObj);
memberTagMapper.updateById(updateObj);
}
@Override
@ -64,11 +64,11 @@ public class MemberTagServiceImpl implements MemberTagService {
// 校验标签下是否有用户
validateTagHasUser(id);
// 删除
tagMapper.deleteById(id);
memberTagMapper.deleteById(id);
}
private void validateTagExists(Long id) {
if (tagMapper.selectById(id) == null) {
if (memberTagMapper.selectById(id) == null) {
throw exception(TAG_NOT_EXISTS);
}
}
@ -77,7 +77,7 @@ public class MemberTagServiceImpl implements MemberTagService {
if (StrUtil.isBlank(name)) {
return;
}
MemberTagDO tag = tagMapper.selelctByName(name);
MemberTagDO tag = memberTagMapper.selelctByName(name);
if (tag == null) {
return;
}
@ -100,7 +100,7 @@ public class MemberTagServiceImpl implements MemberTagService {
@Override
public MemberTagDO getTag(Long id) {
return tagMapper.selectById(id);
return memberTagMapper.selectById(id);
}
@Override
@ -108,17 +108,17 @@ public class MemberTagServiceImpl implements MemberTagService {
if (CollUtil.isEmpty(ids)) {
return ListUtil.empty();
}
return tagMapper.selectBatchIds(ids);
return memberTagMapper.selectBatchIds(ids);
}
@Override
public PageResult<MemberTagDO> getTagPage(MemberTagPageReqVO pageReqVO) {
return tagMapper.selectPage(pageReqVO);
return memberTagMapper.selectPage(pageReqVO);
}
@Override
public List<MemberTagDO> getTagList() {
return tagMapper.selectList();
return memberTagMapper.selectList();
}
}

View File

@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressCreateReqVO;
import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressUpdateReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO;
import cn.iocoder.yudao.module.member.dal.mysql.address.AddressMapper;
import cn.iocoder.yudao.module.member.dal.mysql.address.MemberAddressMapper;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import;
@ -30,7 +30,7 @@ public class AddressServiceImplTest extends BaseDbUnitTest {
private AddressServiceImpl addressService;
@Resource
private AddressMapper addressMapper;
private MemberAddressMapper addressMapper;
@Test
public void testCreateAddress_success() {