Browse Source

[会员列表编辑修改][修复]:编辑时手机号做检查,防止手机号重复

release_toaliyun_real
Stormeye.Wu 7 years ago
parent
commit
5a739be44d
3 changed files with 28 additions and 2 deletions
  1. +16
    -2
      mallinkAdmin/src/main/java/com/iformall/controller/WxCUserBasicInfoController.java
  2. +7
    -0
      mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java
  3. +5
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java

+ 16
- 2
mallinkAdmin/src/main/java/com/iformall/controller/WxCUserBasicInfoController.java View File

@@ -3,6 +3,7 @@ package com.iformall.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result; import com.iformall.common.Result;
import com.iformall.common.ResultData; import com.iformall.common.ResultData;
import com.iformall.domain.po.*; import com.iformall.domain.po.*;
@@ -98,14 +99,27 @@ public class WxCUserBasicInfoController extends BaseController {
// return new ResultData(); // return new ResultData();
// } // }


private int checkUniquePhone(String phone, String tenantId) {
WxCUserBasicInfo baseInfoQ = new WxCUserBasicInfo();
baseInfoQ.setPhone(phone);
baseInfoQ.setTenantId(tenantId);
return wxCUserBasicInfoService.cntUserList(baseInfoQ);
}

@ApiOperation("根据id更新接口") @ApiOperation("根据id更新接口")
@PostMapping("update") @PostMapping("update")
public ResultData update(@RequestBody WxCUserBasicInfo wxCUserBasicInfo) { public ResultData update(@RequestBody WxCUserBasicInfo wxCUserBasicInfo) {
WxCUserBasicInfo info = wxCUserBasicInfoService.getById(wxCUserBasicInfo.getId());
MallUserInfo currentUser = getUser();
WxCUserBasicInfo oldInfo = wxCUserBasicInfoService.getById(wxCUserBasicInfo.getId());
if (!oldInfo.getPhone().equals(wxCUserBasicInfo.getPhone())) {
if(checkUniquePhone(wxCUserBasicInfo.getPhone(), currentUser.getTenantId()) > 0){
return new ResultData(ErrorCode.USER_PHONE_IS_FOUND.getCode(),"手机号已存在");
}
}
wxCUserBasicInfo.setTenantId(getTenantId()); wxCUserBasicInfo.setTenantId(getTenantId());
if (StringUtils.isNotBlank(wxCUserBasicInfo.getTagIds())) { if (StringUtils.isNotBlank(wxCUserBasicInfo.getTagIds())) {
WxCUserTags record = new WxCUserTags(); WxCUserTags record = new WxCUserTags();
record.setUserId(info.getId());
record.setUserId(oldInfo.getId());
record.setTenantId(getTenantId()); record.setTenantId(getTenantId());
PageInfo<WxCUserTags> page = wxCUserTagsService.listAsPage(record, 1, 1); PageInfo<WxCUserTags> page = wxCUserTagsService.listAsPage(record, 1, 1);
if (page.getSize() > 0) { if (page.getSize() > 0) {


+ 7
- 0
mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java View File

@@ -22,6 +22,13 @@ public interface WxCUserBasicInfoService {
*/ */
PageInfo<WxCUserBasicInfo> listAsPage(WxCUserBasicInfo record, Integer pageIndex, Integer pageSize); PageInfo<WxCUserBasicInfo> listAsPage(WxCUserBasicInfo record, Integer pageIndex, Integer pageSize);


/**
* 根据实体查询列表
* @param record
* @return
*/
int cntUserList(WxCUserBasicInfo record);

/** /**
* 根据Id获得实体 * 根据Id获得实体
* *


+ 5
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java View File

@@ -68,6 +68,11 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserBasicInfoMapper.findList(record)); return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserBasicInfoMapper.findList(record));
} }


@Override
public int cntUserList(WxCUserBasicInfo record) {
return wxCUserBasicInfoMapper.selectCount(record);
}

@Override @Override
public List<WxCUserBasicInfo> findByPhone(String tenantId, String phone) { public List<WxCUserBasicInfo> findByPhone(String tenantId, String phone) {
WxCUserBasicInfo basicQ = new WxCUserBasicInfo(); WxCUserBasicInfo basicQ = new WxCUserBasicInfo();


Loading…
Cancel
Save