From 5a739be44dddf7a112941aaf800f7269316594b6 Mon Sep 17 00:00:00 2001 From: "Stormeye.Wu" Date: Thu, 27 Sep 2018 14:39:44 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BC=9A=E5=91=98=E5=88=97=E8=A1=A8=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E4=BF=AE=E6=94=B9][=E4=BF=AE=E5=A4=8D]:=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E6=97=B6=E6=89=8B=E6=9C=BA=E5=8F=B7=E5=81=9A=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=EF=BC=8C=E9=98=B2=E6=AD=A2=E6=89=8B=E6=9C=BA=E5=8F=B7?= =?UTF-8?q?=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WxCUserBasicInfoController.java | 18 ++++++++++++++++-- .../service/WxCUserBasicInfoService.java | 7 +++++++ .../impl/WxCUserBasicInfoServiceImpl.java | 5 +++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WxCUserBasicInfoController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WxCUserBasicInfoController.java index 0642188b2..f0b754b2b 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/WxCUserBasicInfoController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WxCUserBasicInfoController.java @@ -3,6 +3,7 @@ package com.iformall.controller; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageInfo; +import com.iformall.common.ErrorCode; import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.domain.po.*; @@ -98,14 +99,27 @@ public class WxCUserBasicInfoController extends BaseController { // 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更新接口") @PostMapping("update") 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()); if (StringUtils.isNotBlank(wxCUserBasicInfo.getTagIds())) { WxCUserTags record = new WxCUserTags(); - record.setUserId(info.getId()); + record.setUserId(oldInfo.getId()); record.setTenantId(getTenantId()); PageInfo page = wxCUserTagsService.listAsPage(record, 1, 1); if (page.getSize() > 0) { diff --git a/mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java b/mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java index da15a4028..31aaf3b9e 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java @@ -22,6 +22,13 @@ public interface WxCUserBasicInfoService { */ PageInfo listAsPage(WxCUserBasicInfo record, Integer pageIndex, Integer pageSize); + /** + * 根据实体查询列表 + * @param record + * @return + */ + int cntUserList(WxCUserBasicInfo record); + /** * 根据Id获得实体 * diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java index 99a2608f2..e593e9787 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java @@ -68,6 +68,11 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserBasicInfoMapper.findList(record)); } + @Override + public int cntUserList(WxCUserBasicInfo record) { + return wxCUserBasicInfoMapper.selectCount(record); + } + @Override public List findByPhone(String tenantId, String phone) { WxCUserBasicInfo basicQ = new WxCUserBasicInfo();