From 8988856570dfca92e31b05524797285233a8ff56 Mon Sep 17 00:00:00 2001 From: 199901012 Date: Fri, 12 Mar 2021 21:36:14 +0800 Subject: [PATCH] =?UTF-8?q?'=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bweb/controller/HighCouponController.java | 57 +++++++++ .../controller/HighMerchantController.java | 117 ++++++++++++------ .../com/hai/service/HighCouponService.java | 7 ++ .../com/hai/service/HighMerchantService.java | 17 ++- .../java/com/hai/service/SecUserService.java | 50 +------- .../service/impl/HighCouponServiceImpl.java | 21 ++++ .../service/impl/HighMerchantServiceImpl.java | 61 ++++++--- .../impl/HighMerchantStoreServiceImpl.java | 1 + .../hai/service/impl/SecUserServiceImpl.java | 42 +------ 9 files changed, 235 insertions(+), 138 deletions(-) diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java index 0c6902e1..803416f9 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java @@ -108,4 +108,61 @@ public class HighCouponController { } } + + @RequestMapping(value="/updateCoupon",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "修改卡卷") + public ResponseData updateCoupon(@RequestBody HighCouponModel highCoupon, HttpServletRequest request) { + try { + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + if (highCoupon.getId() == null + || highCoupon.getMerchantId() == null + || StringUtils.isNotBlank(highCoupon.getCouponKey()) + || StringUtils.isNotBlank(highCoupon.getCouponName()) + || StringUtils.isNotBlank(highCoupon.getCouponValue()) + || StringUtils.isNotBlank(highCoupon.getCouponImg()) + || highCoupon.getIsPresent() == null + || highCoupon.getCouponPrice() == null) { + log.error("HighCouponController -> updateCoupon() error!","参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + // 是否赠送卡卷 + if (highCoupon.getIsPresent() == true) { + if (highCoupon.getHandselCouponList() == null || highCoupon.getHandselCouponList().size() == 0) { + log.error("HighCouponController -> updateCoupon() error!","请选择赠送卡卷名单"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.SELECT_HANDSEL_COUPON_ERROR, ""); + } + for (HighCouponHandsel handsel : highCoupon.getHandselCouponList()) { + // 如果没有id 就是需要增加的 + if (handsel.getId() == null) { + handsel.setCreateTime(new Date()); + handsel.setStatus(1); // 状态 0:删除 1:正常 + handsel.setOperatorId(userInfoModel.getSecUser().getId()); + handsel.setOperatorName(userInfoModel.getSecUser().getUserName()); + } + } + } + + // 查询商户 + HighMerchant merchant = highMerchantService.getMerchantById(highCoupon.getCompanyId()); + if (merchant == null) { + log.error("HighCouponController -> updateCoupon() error!","未找到商户"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOF_FOUND, ""); + } + + highCoupon.setCompanyId(merchant.getCompanyId()); + highCoupon.setOperatorId(userInfoModel.getSecUser().getId()); + highCoupon.setOperatorName(userInfoModel.getSecUser().getUserName()); + highCoupon.setUpdateTime(new Date()); + highCouponService.updateCoupon(highCoupon); + + return ResponseMsgUtil.success(highCoupon); + } catch (Exception e) { + log.error("HighCouponController -> updateCoupon() error!",e); + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java b/hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java index 5b056ab2..eddbe7b7 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java @@ -57,10 +57,10 @@ public class HighMerchantController { @Resource private SecUserService secUserService; - @RequestMapping(value="/editMerchant",method = RequestMethod.POST) + @RequestMapping(value="/insertMerchant",method = RequestMethod.POST) @ResponseBody - @ApiOperation(value = "编辑商户") - public ResponseData editMerchant(@RequestBody HighMerchantModel highMerchant, HttpServletRequest request) { + @ApiOperation(value = "增加商户") + public ResponseData insertMerchant(@RequestBody HighMerchantModel highMerchant, HttpServletRequest request) { try { SessionObject sessionObject = userCenter.getSessionObject(request); UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); @@ -69,49 +69,93 @@ public class HighMerchantController { || StringUtils.isBlank(highMerchant.getMerchantName()) || StringUtils.isBlank(highMerchant.getTelephone()) || StringUtils.isBlank(highMerchant.getAddress()) + || StringUtils.isBlank(highMerchant.getSecUser().getPassword()) + || StringUtils.isBlank(highMerchant.getSecUser().getTelephone()) ) { - log.error("HighMerchantController -> editMerchant() error!","参数错误"); + log.error("HighMerchantController -> insertMerchant() error!","参数错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - // id为空 就是增加商户,需要校验账号是否填写 - if (highMerchant.getId() == null) { - if (StringUtils.isBlank(highMerchant.getSecUser().getPassword()) || StringUtils.isBlank(highMerchant.getSecUser().getTelephone())) { - log.error("HighMerchantController -> editMerchant() error!","参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - // 校验账户手机号 - if (!MemberValidateUtil.validatePhone(highMerchant.getSecUser().getTelephone())) { - log.error("BsStudentController --> addStudent() error!", "请输入正确的电话号码"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_IS_ERROR, ""); - } - - // 校验账号手机号是否存在 - if (secUserService.findByPhone(highMerchant.getSecUser().getTelephone()) != null) { - log.error("BsStudentController --> addStudent() error!", "电话号码已被使用"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_EXISTED, ""); - } - - highMerchant.setStatus(1); // 状态:0:不可用,1:可用 - highMerchant.setCreateTime(new Date()); - highMerchant.setUpdateTime(new Date()); - - } else { - if (highMerchantService.getMerchantById(highMerchant.getId()) == null) { - log.error("HighMerchantController -> editMerchant() error!","未找到商户"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOF_FOUND, ""); - } - highMerchant.setUpdateTime(new Date()); + // 校验账户手机号 + if (!MemberValidateUtil.validatePhone(highMerchant.getSecUser().getTelephone())) { + log.error("BsStudentController --> insertMerchant() error!", "请输入正确的电话号码"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_IS_ERROR, ""); } + // 校验账号手机号是否存在 + if (secUserService.findByPhone(highMerchant.getSecUser().getTelephone()) != null) { + log.error("BsStudentController --> insertMerchant() error!", "电话号码已被使用"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_EXISTED, ""); + } + + highMerchant.setStatus(1); // 状态:0:不可用,1:可用 + highMerchant.setCreateTime(new Date()); + highMerchant.setUpdateTime(new Date()); highMerchant.setOperatorId(userInfoModel.getSecUser().getId()); highMerchant.setOperatorName(userInfoModel.getSecUser().getUserName()); - highMerchantService.editMerchant(highMerchant); + highMerchantService.insertMerchant(highMerchant); return ResponseMsgUtil.success(highMerchant); } catch (Exception e) { - log.error("HighMerchantController -> editMerchant() error!",e); + log.error("HighMerchantController -> insertMerchant() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value="/updateMerchant",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "修改商户") + public ResponseData updateMerchant(@RequestBody HighMerchantModel highMerchant, HttpServletRequest request) { + try { + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + if (highMerchant.getId() == null + || highMerchant.getCompanyId() == null + || StringUtils.isBlank(highMerchant.getMerchantKey()) + || StringUtils.isBlank(highMerchant.getMerchantName()) + || StringUtils.isBlank(highMerchant.getTelephone()) + || StringUtils.isBlank(highMerchant.getAddress()) + || StringUtils.isBlank(highMerchant.getTelephone()) + ) { + log.error("HighMerchantController -> updateMerchant() error!","参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + // 查询商户 + HighMerchantModel merchant = highMerchantService.getMerchantById(highMerchant.getId()); + if (merchant == null) { + log.error("HighMerchantController -> updateMerchant() error!","未找到商户"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOF_FOUND, ""); + } + + // 商户主账号 + if (merchant.getSecUser() == null) { + log.error("HighMerchantController -> updateMerchant() error!","主账号异常"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPANY_ADMIN_USER_ERROR, ""); + } + + // 校验账户手机号 + if (MemberValidateUtil.validatePhone(highMerchant.getSecUser().getTelephone())) { + log.error("BsStudentController --> updateMerchant() error!", "请输入正确的电话号码"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_IS_ERROR, ""); + } + + // 校验账号手机号是否存在 + if (!merchant.getSecUser().getTelephone().equals(highMerchant.getSecUser().getTelephone()) + && secUserService.findByPhone(highMerchant.getSecUser().getTelephone()) != null) { + log.error("BsStudentController --> updateMerchant() error!", "电话号码已被使用"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_EXISTED, ""); + } + + highMerchant.setUpdateTime(new Date()); + highMerchant.setOperatorId(userInfoModel.getSecUser().getId()); + highMerchant.setOperatorName(userInfoModel.getSecUser().getUserName()); + highMerchantService.updateMerchant(highMerchant); + + return ResponseMsgUtil.success(highMerchant); + } catch (Exception e) { + log.error("HighMerchantController -> updateMerchant() error!",e); return ResponseMsgUtil.exception(e); } } @@ -123,6 +167,7 @@ public class HighMerchantController { try { return ResponseMsgUtil.success(highMerchantService.getMerchantById(id)); + } catch (Exception e) { log.error("HighMerchantController -> getMerchantById() error!",e); return ResponseMsgUtil.exception(e); @@ -135,6 +180,7 @@ public class HighMerchantController { public ResponseData getMerchantList(@RequestParam(name = "merchantKey", required = false) String merchantKey, @RequestParam(name = "merchantName", required = false) String merchantName, @RequestParam(name = "telephone", required = false) String telephone, + @RequestParam(name = "status", required = false) Integer status, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { @@ -150,6 +196,7 @@ public class HighMerchantController { map.put("merchantKey", merchantKey); map.put("merchantName", merchantName); map.put("telephone", telephone); + map.put("status", status); PageHelper.startPage(pageNum, pageSize); return ResponseMsgUtil.success(new PageInfo<>(highMerchantService.getMerchantList(map))); diff --git a/hai-service/src/main/java/com/hai/service/HighCouponService.java b/hai-service/src/main/java/com/hai/service/HighCouponService.java index 651b5d14..01661c65 100644 --- a/hai-service/src/main/java/com/hai/service/HighCouponService.java +++ b/hai-service/src/main/java/com/hai/service/HighCouponService.java @@ -17,4 +17,11 @@ public interface HighCouponService { **/ void insertCoupon(HighCouponModel highCouponModel); + /** + * @Author 胡锐 + * @Description 修改 + * @Date 2021/3/12 20:41 + **/ + void updateCoupon(HighCouponModel highCouponModel); + } diff --git a/hai-service/src/main/java/com/hai/service/HighMerchantService.java b/hai-service/src/main/java/com/hai/service/HighMerchantService.java index 2deda497..6ab88e7f 100644 --- a/hai-service/src/main/java/com/hai/service/HighMerchantService.java +++ b/hai-service/src/main/java/com/hai/service/HighMerchantService.java @@ -12,16 +12,25 @@ import java.util.Map; public interface HighMerchantService { /** - * 编辑 - */ - void editMerchant(HighMerchantModel highMerchant) throws Exception; + * @Author 胡锐 + * @Description 增加 + * @Date 2021/3/12 21:24 + **/ + void insertMerchant(HighMerchantModel highMerchant) throws Exception; + + /** + * @Author 胡锐 + * @Description 修改 + * @Date 2021/3/12 21:24 + **/ + void updateMerchant(HighMerchantModel highMerchant) throws Exception; /** * 根据id查询 * @param id * @return */ - HighMerchant getMerchantById(Long id); + HighMerchantModel getMerchantById(Long id); /** * 查询列表 diff --git a/hai-service/src/main/java/com/hai/service/SecUserService.java b/hai-service/src/main/java/com/hai/service/SecUserService.java index 12e9f4e0..2790940b 100644 --- a/hai-service/src/main/java/com/hai/service/SecUserService.java +++ b/hai-service/src/main/java/com/hai/service/SecUserService.java @@ -133,52 +133,12 @@ public interface SecUserService { void modifyUser(SecUser user); /** - * - * @Title: findAgencyUser - * @Description: 查询机构用户 - * @author: 杜江 - * @Date: 2020/7/28 16:05 - * @param: [agencyId] - * @return: com.shinwoten.train.entity.SecUser - * @throws - */ - SecUser findAgencyUser(Long agencyId); - - /** - * - * @Title: findAgencyWorker - * @Description: 查询机构工作人员 - * @author: 袁野 - * @Date: 2020/10/08 16:05 - * @param: [workerId] - * @return: com.shinwoten.train.entity.SecUser - * @throws - */ - SecUser findAgencyWorker(Long workerId); - - /** - * - * @Title: findTeacherUser - * @Description: 查询教师账号 - * @author: 杜江 - * @Date: 2020/7/30 14:48 - * @param: [teacherId] - * @return: com.shinwoten.train.entity.SecUser - * @throws - */ - SecUser findTeacherUser(Long teacherId); + * @Author 胡锐 + * @Description 查询主账号 + * @Date 2021/3/12 21:05 + **/ + SecUser getMainAccount(Integer objectType,Long objectId); - /** - * - * @Title: findTeacherUser - * @Description: 查询工作人员账号 - * @author: 袁野 - * @Date: 2020/09/29 14:48 - * @param: [workId] - * @return: com.shinwoten.train.entity.SecUser - * @throws - */ - SecUser findWorkerUser(Long workId); /** * * @Title: findUserList diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java index 558b5775..d5cde4d8 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java @@ -37,8 +37,29 @@ public class HighCouponServiceImpl implements HighCouponService { if (highCouponModel.getHandselCouponList() != null && highCouponModel.getHandselCouponList().size() > 0) { for (HighCouponHandselModel handsel : highCouponModel.getHandselCouponList()) { handsel.setCouponId(highCouponModel.getId()); + highCouponHandselMapper.insert(handsel); } } + } + + @Override + @Transactional + public void updateCoupon(HighCouponModel highCouponModel) { + highCouponMapper.updateByPrimaryKey(highCouponModel); + // 赠送卡卷 + if (highCouponModel.getHandselCouponList() != null && highCouponModel.getHandselCouponList().size() > 0) { + for (HighCouponHandselModel handsel : highCouponModel.getHandselCouponList()) { + // 状态标记为删除的,进行删除操作 + if (handsel.getStatus() == 0) { + highCouponHandselMapper.deleteByPrimaryKey(handsel.getId()); + } + // id为空的,进行增加操作 + if (handsel.getId() == null) { + handsel.setCouponId(highCouponModel.getId()); + highCouponHandselMapper.insert(handsel); + } + } + } } } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighMerchantServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighMerchantServiceImpl.java index 3927729a..7350158b 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighMerchantServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighMerchantServiceImpl.java @@ -1,5 +1,8 @@ package com.hai.service.impl; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; import com.hai.common.utils.MD5Util; import com.hai.dao.HighMerchantMapper; import com.hai.entity.HighMerchant; @@ -10,6 +13,7 @@ import com.hai.service.HighMerchantService; import com.hai.service.SecUserService; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -29,29 +33,48 @@ public class HighMerchantServiceImpl implements HighMerchantService { @Override @Transactional - public void editMerchant(HighMerchantModel highMerchant) throws Exception { - if (highMerchant.getId() == null) { - highMerchantMapper.insert(highMerchant); + public void insertMerchant(HighMerchantModel highMerchant) throws Exception { + highMerchantMapper.insert(highMerchant); - highMerchant.getSecUser().setUserName(highMerchant.getMerchantName()); - highMerchant.getSecUser().setLoginName(highMerchant.getSecUser().getTelephone()); + highMerchant.getSecUser().setUserName(highMerchant.getMerchantName()); + highMerchant.getSecUser().setLoginName(highMerchant.getSecUser().getTelephone()); + highMerchant.getSecUser().setPassword(MD5Util.encode(highMerchant.getSecUser().getPassword().getBytes())); + highMerchant.getSecUser().setAdminFlag(1); + highMerchant.getSecUser().setStatus(1); + highMerchant.getSecUser().setRoleId(2L); + highMerchant.getSecUser().setObjectType(2); + highMerchant.getSecUser().setObjectId(highMerchant.getId()); + highMerchant.getSecUser().setCreateTime(new Date()); + highMerchant.getSecUser().setUpdateTime(new Date()); + secUserService.addUser(highMerchant.getSecUser()); + } + + @Override + @Transactional + public void updateMerchant(HighMerchantModel highMerchant) throws Exception { + highMerchantMapper.updateByPrimaryKey(highMerchant); + + if (StringUtils.isNotBlank(highMerchant.getSecUser().getPassword())) { highMerchant.getSecUser().setPassword(MD5Util.encode(highMerchant.getSecUser().getPassword().getBytes())); - highMerchant.getSecUser().setStatus(1); - highMerchant.getSecUser().setRoleId(2L); - highMerchant.getSecUser().setObjectType(2); - highMerchant.getSecUser().setObjectId(highMerchant.getId()); - highMerchant.getSecUser().setCreateTime(new Date()); - highMerchant.getSecUser().setUpdateTime(new Date()); - secUserService.addUser(highMerchant.getSecUser()); - - } else { - highMerchantMapper.updateByPrimaryKey(highMerchant); } + secUserService.updateUser(highMerchant.getSecUser()); } @Override - public HighMerchant getMerchantById(Long id) { - return highMerchantMapper.selectByPrimaryKey(id); + public HighMerchantModel getMerchantById(Long id) { + HighMerchant merchant = highMerchantMapper.selectByPrimaryKey(id); + if (merchant == null) { + return null; + } + HighMerchantModel merchantModel = new HighMerchantModel(); + BeanUtils.copyProperties(merchant, merchantModel); + + // 查询商户主账号 + SecUser mainAccount = secUserService.getMainAccount(2, merchant.getId()); + if (mainAccount != null) { + merchantModel.setSecUser(mainAccount); + } + return merchantModel; } @Override @@ -75,6 +98,10 @@ public class HighMerchantServiceImpl implements HighMerchantService { criteria.andTelephoneEqualTo(MapUtils.getString(map, "telephone")); } + if (StringUtils.isNotBlank(MapUtils.getString(map, "status"))) { + criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); + } + example.setOrderByClause("create_time desc"); return highMerchantMapper.selectByExample(example); } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java index 8d732497..fa962240 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java @@ -41,6 +41,7 @@ public class HighMerchantStoreServiceImpl implements HighMerchantStoreService { highMerchantStore.getSecUser().setUserName(highMerchantStore.getStoreName()); highMerchantStore.getSecUser().setLoginName(highMerchantStore.getSecUser().getTelephone()); highMerchantStore.getSecUser().setPassword(MD5Util.encode(highMerchantStore.getSecUser().getPassword().getBytes())); + highMerchantStore.getSecUser().setAdminFlag(1); highMerchantStore.getSecUser().setStatus(1); highMerchantStore.getSecUser().setRoleId(3L); highMerchantStore.getSecUser().setObjectType(3); diff --git a/hai-service/src/main/java/com/hai/service/impl/SecUserServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/SecUserServiceImpl.java index dd10bf59..0c732993 100644 --- a/hai-service/src/main/java/com/hai/service/impl/SecUserServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/SecUserServiceImpl.java @@ -176,45 +176,13 @@ public class SecUserServiceImpl implements SecUserService { } @Override - public SecUser findAgencyUser(Long agencyId) { + public SecUser getMainAccount(Integer objectType, Long objectId) { SecUserExample example = new SecUserExample(); - example.createCriteria().andObjectTypeEqualTo(2).andObjectIdEqualTo(agencyId).andStatusEqualTo(1); - List secUsers = secUserMapper.selectByExample(example); - if (secUsers != null && secUsers.size() != 0) { - return secUsers.get(0); - } - return null; - } - - @Override - public SecUser findAgencyWorker(Long workerId) { - SecUserExample example = new SecUserExample(); - example.createCriteria().andObjectTypeEqualTo(4).andObjectIdEqualTo(workerId).andStatusEqualTo(1); - List secUsers = secUserMapper.selectByExample(example); - if (secUsers != null && secUsers.size() != 0) { - return secUsers.get(0); - } - return null; - } + example.createCriteria().andAdminFlagEqualTo(1).andObjectTypeEqualTo(objectType).andObjectIdEqualTo(objectId); - @Override - public SecUser findTeacherUser(Long teacherId) { - SecUserExample example = new SecUserExample(); - example.createCriteria().andObjectTypeEqualTo(3).andObjectIdEqualTo(teacherId).andStatusEqualTo(1); - List secUsers = secUserMapper.selectByExample(example); - if (secUsers != null && secUsers.size() != 0) { - return secUsers.get(0); - } - return null; - } - - @Override - public SecUser findWorkerUser(Long workId) { - SecUserExample example = new SecUserExample(); - example.createCriteria().andObjectTypeEqualTo(4).andObjectIdEqualTo(workId).andStatusEqualTo(1); - List secUsers = secUserMapper.selectByExample(example); - if (secUsers != null && secUsers.size() != 0) { - return secUsers.get(0); + List list = secUserMapper.selectByExample(example); + if (list != null && list.size() > 0) { + return list.get(0); } return null; }