Browse Source

loginByWxCode、loginByPassword接口修改,删除customer_user相关代码

dev_shibei_match
yinzuomei 6 years ago
parent
commit
391ad82af0
  1. 17
      epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java
  2. 9
      epmet-auth/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java
  3. 100
      epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java
  4. 127
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerUserDTO.java
  5. 5
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/OperUserDTO.java
  6. 2
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PasswordLoginUserInfoFormDTO.java
  7. 138
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerUserController.java
  8. 73
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserController.java
  9. 88
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerUserDao.java
  10. 80
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserDao.java
  11. 15
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserWechatDao.java
  12. 96
      epmet-user/epmet-user-server/src/main/java/com/epmet/entity/CustomerUserEntity.java
  13. 5
      epmet-user/epmet-user-server/src/main/java/com/epmet/entity/OperUserEntity.java
  14. 86
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/CustomerUserExcel.java
  15. 47
      epmet-user/epmet-user-server/src/main/java/com/epmet/redis/CustomerUserRedis.java
  16. 127
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerUserService.java
  17. 77
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserService.java
  18. 203
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerUserServiceImpl.java
  19. 92
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java
  20. 80
      epmet-user/epmet-user-server/src/main/resources/mapper/CustomerUserDao.xml
  21. 24
      epmet-user/epmet-user-server/src/main/resources/mapper/UserDao.xml
  22. 80
      epmet-user/epmet-user-server/src/main/resources/mapper/UserWechatDao.xml

17
epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java

@ -2,7 +2,8 @@ package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerUserDTO; import com.epmet.dto.UserDTO;
import com.epmet.dto.UserWechatDTO;
import com.epmet.dto.form.PasswordLoginUserInfoFormDTO; import com.epmet.dto.form.PasswordLoginUserInfoFormDTO;
import com.epmet.dto.form.WxLoginUserInfoFormDTO; import com.epmet.dto.form.WxLoginUserInfoFormDTO;
import com.epmet.dto.result.PasswordLoginUserInfoResultDTO; import com.epmet.dto.result.PasswordLoginUserInfoResultDTO;
@ -28,19 +29,19 @@ public interface EpmetUserFeignClient {
* @author yinzuomei * @author yinzuomei
* @date 2020/3/16 14:48 * @date 2020/3/16 14:48
*/ */
@PostMapping(value = "epmetuser/customeruser/selecWxLoginUserInfo", consumes = MediaType.APPLICATION_JSON_VALUE) @PostMapping(value = "epmetuser/user/selecWxLoginUserInfo", consumes = MediaType.APPLICATION_JSON_VALUE)
Result selecWxLoginUserInfo(WxLoginUserInfoFormDTO loginUserInfoFormDTO); Result<UserDTO> selecWxLoginUserInfo(@RequestBody WxLoginUserInfoFormDTO loginUserInfoFormDTO);
/** /**
* 获取居民微信信息保存到customer_user,返回主键 * 获取居民微信信息保存到user_wechat,返回主键
* *
* @param customerUserDTO * @param userWechatDTO
* @return java.lang.String * @return java.lang.String
* @author yinzuomei * @author yinzuomei
* @date 2020/3/16 14:48 * @date 2020/3/16 14:48
*/ */
@PostMapping(value = "epmetuser/customeruser/saveOrUpdateCustomerUser", consumes = MediaType.APPLICATION_JSON_VALUE) @PostMapping(value = "epmetuser/user/saveOrUpdateUserWechatDTO", consumes = MediaType.APPLICATION_JSON_VALUE)
Result saveOrUpdateCustomerUser(CustomerUserDTO customerUserDTO); Result<UserDTO> saveOrUpdateUserWechatDTO(@RequestBody UserWechatDTO userWechatDTO);
/** /**
* @param passwordLoginUserInfoFormDTO * @param passwordLoginUserInfoFormDTO
@ -49,6 +50,6 @@ public interface EpmetUserFeignClient {
* @Description 根据手机号查询用户信息 * @Description 根据手机号查询用户信息
* @Date 2020/3/16 16:14 * @Date 2020/3/16 16:14
**/ **/
@PostMapping(value = "epmetuser/customeruser/selectLoginUserInfoByPassword", consumes = MediaType.APPLICATION_JSON_VALUE) @PostMapping(value = "epmetuser/user/selectLoginUserInfoByPassword", consumes = MediaType.APPLICATION_JSON_VALUE)
Result<PasswordLoginUserInfoResultDTO> selectLoginUserInfoByPassword(@RequestBody PasswordLoginUserInfoFormDTO passwordLoginUserInfoFormDTO); Result<PasswordLoginUserInfoResultDTO> selectLoginUserInfoByPassword(@RequestBody PasswordLoginUserInfoFormDTO passwordLoginUserInfoFormDTO);
} }

9
epmet-auth/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java

@ -3,7 +3,8 @@ package com.epmet.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerUserDTO; import com.epmet.dto.UserDTO;
import com.epmet.dto.UserWechatDTO;
import com.epmet.dto.form.PasswordLoginUserInfoFormDTO; import com.epmet.dto.form.PasswordLoginUserInfoFormDTO;
import com.epmet.dto.form.WxLoginUserInfoFormDTO; import com.epmet.dto.form.WxLoginUserInfoFormDTO;
import com.epmet.dto.result.PasswordLoginUserInfoResultDTO; import com.epmet.dto.result.PasswordLoginUserInfoResultDTO;
@ -19,13 +20,13 @@ import org.springframework.stereotype.Component;
public class EpmetUserFeignClientFallback implements EpmetUserFeignClient { public class EpmetUserFeignClientFallback implements EpmetUserFeignClient {
@Override @Override
public Result<String> selecWxLoginUserInfo(WxLoginUserInfoFormDTO loginUserInfoFormDTO) { public Result<UserDTO> selecWxLoginUserInfo(WxLoginUserInfoFormDTO loginUserInfoFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "selecWxLoginUserInfo", loginUserInfoFormDTO); return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "selecWxLoginUserInfo", loginUserInfoFormDTO);
} }
@Override @Override
public Result saveOrUpdateCustomerUser(CustomerUserDTO customerUserDTO) { public Result<UserDTO> saveOrUpdateUserWechatDTO(UserWechatDTO userWechatDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "saveOrUpdateCustomerUser", customerUserDTO); return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "saveOrUpdateUserWechatDTO", userWechatDTO);
} }
@Override @Override

100
epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java

@ -12,7 +12,8 @@ import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.security.password.PasswordUtils; import com.epmet.commons.tools.security.password.PasswordUtils;
import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.commons.tools.utils.CpUserDetailRedis;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerUserDTO; import com.epmet.dto.UserDTO;
import com.epmet.dto.UserWechatDTO;
import com.epmet.dto.form.PasswordLoginUserInfoFormDTO; import com.epmet.dto.form.PasswordLoginUserInfoFormDTO;
import com.epmet.dto.form.WxLoginUserInfoFormDTO; import com.epmet.dto.form.WxLoginUserInfoFormDTO;
import com.epmet.dto.result.PasswordLoginUserInfoResultDTO; import com.epmet.dto.result.PasswordLoginUserInfoResultDTO;
@ -128,19 +129,21 @@ public class LoginServiceImpl implements LoginService {
wxLoginUserInfoFormDTO.setApp(formDTO.getApp()); wxLoginUserInfoFormDTO.setApp(formDTO.getApp());
wxLoginUserInfoFormDTO.setOpenId(wxMaJscode2SessionResult.getOpenid()); wxLoginUserInfoFormDTO.setOpenId(wxMaJscode2SessionResult.getOpenid());
//1、先根据app、client、openId查询 //1、先根据app、client、openId查询
Result<String> userResult = epmetUserFeignClient.selecWxLoginUserInfo(wxLoginUserInfoFormDTO); Result<UserDTO> userResult = epmetUserFeignClient.selecWxLoginUserInfo(wxLoginUserInfoFormDTO);
String userId = ""; String userId = "";
if (!userResult.success()) { if (!userResult.success()) {
throw new RenException("获取用户信息失败" + userResult.getMsg()); throw new RenException("获取用户信息失败" + userResult.getMsg());
} }
userId = userResult.getData(); if(null!=userResult.getData()&&StringUtils.isNotBlank(userResult.getData().getId())){
userId = userResult.getData().getId();
}
//2、如果已经存在userId,则更新微信信息 //2、如果已经存在userId,则更新微信信息
if (StringUtils.isNotBlank(userId) && StringUtils.isNotBlank(formDTO.getEncryptedData()) && StringUtils.isNotBlank(formDTO.getIv())) { if (StringUtils.isNotBlank(userId) && StringUtils.isNotBlank(formDTO.getEncryptedData()) && StringUtils.isNotBlank(formDTO.getIv())) {
this.updateWxInfO(userId,formDTO,wxMaJscode2SessionResult); this.updateWxInfO(userId,formDTO,wxMaJscode2SessionResult);
} }
//3、数据库不存在此用户则创建此用户 //3、数据库不存在此用户则创建此用户
if (StringUtils.isBlank(userId)) { if (StringUtils.isBlank(userId)) {
userId = createEpmtUser(formDTO, wxMaJscode2SessionResult); userId = createUser(formDTO, wxMaJscode2SessionResult);
} }
return userId; return userId;
} }
@ -156,21 +159,13 @@ public class LoginServiceImpl implements LoginService {
private Result updateWxInfO(String userId, private Result updateWxInfO(String userId,
LoginByWxCodeFormDTO formDTO, LoginByWxCodeFormDTO formDTO,
WxMaJscode2SessionResult wxMaJscode2SessionResult) { WxMaJscode2SessionResult wxMaJscode2SessionResult) {
if (LoginConstant.APP_GOV.equals(formDTO.getApp())) { WxMaUserInfo wxMaUserInfo = wxMaServiceUtils.resiWxMaService().getUserService()
//查询customer_staff待完善 .getUserInfo(wxMaJscode2SessionResult.getSessionKey(),
formDTO.getEncryptedData(),
} else if (LoginConstant.APP_OPER.equals(formDTO.getApp())) { formDTO.getIv());
//查询oper_user待完善 UserWechatDTO userWechatDTO = this.packageCustomerUserDTO(wxMaUserInfo);
userWechatDTO.setUserId(userId);
} else if (LoginConstant.APP_RESI.equals(formDTO.getApp())) { Result<UserDTO> updateUserDtoResult=epmetUserFeignClient.saveOrUpdateUserWechatDTO(userWechatDTO);
WxMaUserInfo wxMaUserInfo = wxMaServiceUtils.resiWxMaService().getUserService()
.getUserInfo(wxMaJscode2SessionResult.getSessionKey(),
formDTO.getEncryptedData(),
formDTO.getIv());
CustomerUserDTO customerUserDTO = this.packageCustomerUserDTO(wxMaUserInfo);
customerUserDTO.setId(userId);
epmetUserFeignClient.saveOrUpdateCustomerUser(customerUserDTO);
}
return new Result(); return new Result();
} }
@ -182,52 +177,46 @@ public class LoginServiceImpl implements LoginService {
* @Description 陌生人首次授权创建用户信息 * @Description 陌生人首次授权创建用户信息
* @Date 2020/3/20 19:42 * @Date 2020/3/20 19:42
**/ **/
private String createEpmtUser(LoginByWxCodeFormDTO formDTO, WxMaJscode2SessionResult wxMaJscode2SessionResult) { private String createUser(LoginByWxCodeFormDTO formDTO, WxMaJscode2SessionResult wxMaJscode2SessionResult) {
String userId = ""; String userId = "";
if (LoginConstant.APP_GOV.equals(formDTO.getApp())) { //查询customer_user
//查询customer_staff待完善 UserWechatDTO userWechatDTO = new UserWechatDTO();
} else if (LoginConstant.APP_OPER.equals(formDTO.getApp())) { if (StringUtils.isNotBlank(formDTO.getIv()) && StringUtils.isNotBlank(formDTO.getEncryptedData())) {
//查询oper_user待完善 WxMaUserInfo wxMaUserInfo = wxMaServiceUtils.resiWxMaService().getUserService()
} else if (LoginConstant.APP_RESI.equals(formDTO.getApp())) { .getUserInfo(wxMaJscode2SessionResult.getSessionKey(),
//查询customer_user formDTO.getEncryptedData(),
CustomerUserDTO customerUserDTO = new CustomerUserDTO(); formDTO.getIv());
if (StringUtils.isNotBlank(formDTO.getIv()) && StringUtils.isNotBlank(formDTO.getEncryptedData())) { userWechatDTO = this.packageCustomerUserDTO(wxMaUserInfo);
WxMaUserInfo wxMaUserInfo = wxMaServiceUtils.resiWxMaService().getUserService() } else {
.getUserInfo(wxMaJscode2SessionResult.getSessionKey(), userWechatDTO.setWxOpenId(wxMaJscode2SessionResult.getOpenid());
formDTO.getEncryptedData(), userWechatDTO.setUnionId(wxMaJscode2SessionResult.getUnionid());
formDTO.getIv());
customerUserDTO = this.packageCustomerUserDTO(wxMaUserInfo);
} else {
customerUserDTO.setWxOpenId(wxMaJscode2SessionResult.getOpenid());
customerUserDTO.setUnionId(wxMaJscode2SessionResult.getUnionid());
}
Result<String> saveCustomerUserResult = epmetUserFeignClient.saveOrUpdateCustomerUser(customerUserDTO);
if (!saveCustomerUserResult.success()) {
throw new RenException("创建用户失败" + saveCustomerUserResult.getMsg());
}
userId = saveCustomerUserResult.getData();
} }
Result<UserDTO> saveUserWechatResult = epmetUserFeignClient.saveOrUpdateUserWechatDTO(userWechatDTO);
if (!saveUserWechatResult.success()||null==saveUserWechatResult.getData()) {
throw new RenException("创建用户失败" + saveUserWechatResult.getMsg());
}
userId = saveUserWechatResult.getData().getId();
return userId; return userId;
} }
/** /**
* @param wxMaUserInfo * @param wxMaUserInfo
* @return com.epmet.dto.CustomerUserDTO * @return com.epmet.dto.UserWechatDTO
* @Author yinzuomei * @Author yinzuomei
* @Description 微信信息封装为customer_user记录 * @Description 微信信息封装为customer_user记录
* @Date 2020/3/17 18:22 * @Date 2020/3/17 18:22
**/ **/
private CustomerUserDTO packageCustomerUserDTO(WxMaUserInfo wxMaUserInfo) { private UserWechatDTO packageCustomerUserDTO(WxMaUserInfo wxMaUserInfo) {
CustomerUserDTO customerUserDTO = new CustomerUserDTO(); UserWechatDTO userWechatDTO = new UserWechatDTO();
customerUserDTO.setCity(wxMaUserInfo.getCity()); userWechatDTO.setCity(wxMaUserInfo.getCity());
customerUserDTO.setWxOpenId(wxMaUserInfo.getOpenId()); userWechatDTO.setWxOpenId(wxMaUserInfo.getOpenId());
customerUserDTO.setNickname(wxMaUserInfo.getNickName()); userWechatDTO.setUnionId(wxMaUserInfo.getUnionId());
customerUserDTO.setCountry(wxMaUserInfo.getCountry()); userWechatDTO.setNickname(wxMaUserInfo.getNickName());
customerUserDTO.setHeadImgUrl(wxMaUserInfo.getAvatarUrl()); userWechatDTO.setCountry(wxMaUserInfo.getCountry());
customerUserDTO.setCountry(wxMaUserInfo.getCountry()); userWechatDTO.setHeadImgUrl(wxMaUserInfo.getAvatarUrl());
customerUserDTO.setProvince(wxMaUserInfo.getProvince()); userWechatDTO.setProvince(wxMaUserInfo.getProvince());
customerUserDTO.setSex(Integer.valueOf(wxMaUserInfo.getGender())); userWechatDTO.setSex(Integer.valueOf(wxMaUserInfo.getGender()));
return customerUserDTO; return userWechatDTO;
} }
/** /**
@ -277,6 +266,9 @@ public class LoginServiceImpl implements LoginService {
*/ */
@Override @Override
public Result<UserTokenResultDTO> loginByPassword(LoginByPassWordFormDTO formDTO) { public Result<UserTokenResultDTO> loginByPassword(LoginByPassWordFormDTO formDTO) {
if(LoginConstant.APP_RESI.equals(formDTO.getApp())){
return new Result<UserTokenResultDTO>().error("居民端请使用微信登录");
}
//1、验证码是否正确 //1、验证码是否正确
boolean flag = captchaService.validate(formDTO.getUuid(), formDTO.getCaptcha()); boolean flag = captchaService.validate(formDTO.getUuid(), formDTO.getCaptcha());
if (!flag) { if (!flag) {

127
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerUserDTO.java

@ -1,127 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 居民用户信息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-16
*/
@Data
public class CustomerUserDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 唯一标识
*/
private String id;
/**
* 客户Id
*/
private String customerId;
/**
* 微信openId
*/
private String wxOpenId;
/**
* 微信unionId
*/
private String unionId;
/**
* 手机号
*/
private String mobile;
/**
* 昵称
*/
private String nickname;
/**
* 性别:0.未知 1.男性2女性
*/
private Integer sex;
/**
* 头像
*/
private String headImgUrl;
/**
* 国家
*/
private String country;
/**
* 省份
*/
private String province;
/**
* 城市
*/
private String city;
/**
* 语言
*/
private String language;
/**
* 删除标识0.未删除 1.已删除
*/
private String delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

5
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/OperUserDTO.java

@ -75,11 +75,6 @@ public class OperUserDTO implements Serializable {
*/ */
private String phone; private String phone;
/**
* 微信openId
*/
private String wxOpenId;
/** /**
* 部门ID * 部门ID
*/ */

2
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PasswordLoginUserInfoFormDTO.java

@ -14,7 +14,7 @@ import java.io.Serializable;
public class PasswordLoginUserInfoFormDTO implements Serializable { public class PasswordLoginUserInfoFormDTO implements Serializable {
private static final long serialVersionUID = -6653010297552029277L; private static final long serialVersionUID = -6653010297552029277L;
@NotBlank(message = "app1111不能为空") @NotBlank(message = "app不能为空")
private String app; private String app;
@NotBlank(message = "手机号不能为空") @NotBlank(message = "手机号不能为空")

138
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerUserController.java

@ -1,138 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.controller;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.CustomerUserDTO;
import com.epmet.dto.form.PasswordLoginUserInfoFormDTO;
import com.epmet.dto.form.WxLoginUserInfoFormDTO;
import com.epmet.dto.result.PasswordLoginUserInfoResultDTO;
import com.epmet.excel.CustomerUserExcel;
import com.epmet.service.CustomerUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 居民用户信息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-16
*/
@RestController
@RequestMapping("customeruser")
public class CustomerUserController {
@Autowired
private CustomerUserService customerUserService;
@GetMapping("page")
public Result<PageData<CustomerUserDTO>> page(@RequestParam Map<String, Object> params){
PageData<CustomerUserDTO> page = customerUserService.page(params);
return new Result<PageData<CustomerUserDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<CustomerUserDTO> get(@PathVariable("id") String id){
CustomerUserDTO data = customerUserService.get(id);
return new Result<CustomerUserDTO>().ok(data);
}
@PostMapping
public Result save(@RequestBody CustomerUserDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
customerUserService.save(dto);
return new Result();
}
@PutMapping
public Result update(@RequestBody CustomerUserDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
customerUserService.update(dto);
return new Result();
}
@DeleteMapping
public Result delete(@RequestBody String[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
customerUserService.delete(ids);
return new Result();
}
@GetMapping("export")
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<CustomerUserDTO> list = customerUserService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, CustomerUserExcel.class);
}
/**
* @param formDTO
* @return com.epmet.commons.tools.utils.Result
* @Author yinzuomei
* @Description 根据openIdapp查询对应终端用户信息
* @Date 2020/3/16 16:15
**/
@PostMapping("selecWxLoginUserInfo")
public Result<String> selecWxLoginUserInfo(@RequestBody WxLoginUserInfoFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO);
return customerUserService.selecWxLoginUserInfo(formDTO);
}
/**
* @param customerUserDTO
* @return 将获取到的居民微信信息保存到customer_user表,返回主键
* @Author yinzuomei
* @Description
* @Date 2020/3/16 15:49
**/
@PostMapping("saveOrUpdateCustomerUser")
public Result<String> saveOrUpdateCustomerUser(@RequestBody CustomerUserDTO customerUserDTO) {
//效验数据
ValidatorUtils.validateEntity(customerUserDTO, AddGroup.class, DefaultGroup.class);
return customerUserService.saveOrUpdateCustomerUser(customerUserDTO);
}
/**
* @param passwordLoginUserInfoFormDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.PasswordLoginUserInfoResultDTO>
* @Author yinzuomei
* @Description 根据手机号app获取对应终端用户信息
* @Date 2020/3/16 16:15
**/
@PostMapping("selectLoginUserInfoByPassword")
public Result<PasswordLoginUserInfoResultDTO> selectLoginUserInfoByPassword(@RequestBody PasswordLoginUserInfoFormDTO passwordLoginUserInfoFormDTO) {
//效验数据
ValidatorUtils.validateEntity(passwordLoginUserInfoFormDTO);
Result<PasswordLoginUserInfoResultDTO> result= customerUserService.selectLoginUserInfoByPassword(passwordLoginUserInfoFormDTO);
return result;
}
}

73
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserController.java

@ -0,0 +1,73 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.dto.UserDTO;
import com.epmet.dto.UserWechatDTO;
import com.epmet.dto.form.PasswordLoginUserInfoFormDTO;
import com.epmet.dto.form.WxLoginUserInfoFormDTO;
import com.epmet.dto.result.PasswordLoginUserInfoResultDTO;
import com.epmet.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Description
* @Author yinzuomei
* @Date 2020/3/30 12:42
*/
@RestController
@RequestMapping("user")
public class UserController {
@Autowired
private UserService userService;
/**
* @param formDTO
* @return com.epmet.commons.tools.utils.Result
* @Author yinzuomei
* @Description 根据openIdapp查询对应终端用户信息
* @Date 2020/3/16 16:15
**/
@PostMapping("selecWxLoginUserInfo")
public Result<UserDTO> selecWxLoginUserInfo(@RequestBody WxLoginUserInfoFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO);
return userService.selecWxLoginUserInfo(formDTO);
}
/**
* @param userWechatDTO
* @return 将获取到的居民微信信息保存到user_wechat表,返回主键
* @Author yinzuomei
* @Description
* @Date 2020/3/16 15:49
**/
@PostMapping("saveOrUpdateUserWechatDTO")
public Result<UserDTO> saveOrUpdateUserWechatDTO(@RequestBody UserWechatDTO userWechatDTO) {
//效验数据
ValidatorUtils.validateEntity(userWechatDTO, AddGroup.class, DefaultGroup.class);
return userService.saveOrUpdateUserWechatDTO(userWechatDTO);
}
/**
* @param passwordLoginUserInfoFormDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.PasswordLoginUserInfoResultDTO>
* @Author yinzuomei
* @Description 根据手机号app获取对应终端用户信息
* @Date 2020/3/16 16:15
**/
@PostMapping("selectLoginUserInfoByPassword")
public Result<PasswordLoginUserInfoResultDTO> selectLoginUserInfoByPassword(@RequestBody PasswordLoginUserInfoFormDTO passwordLoginUserInfoFormDTO) {
//效验数据
ValidatorUtils.validateEntity(passwordLoginUserInfoFormDTO);
Result<PasswordLoginUserInfoResultDTO> result= userService.selectLoginUserInfoByPassword(passwordLoginUserInfoFormDTO);
return result;
}
}

88
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerUserDao.java

@ -1,88 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.result.PasswordLoginUserInfoResultDTO;
import com.epmet.entity.CustomerUserEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 居民用户信息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-16
*/
@Mapper
public interface CustomerUserDao extends BaseDao<CustomerUserEntity> {
/**
* @param openId
* @return userId
* @Author yinzuomei
* @Description 根据openId查询居民用户信息
* @Date 2020/3/14 20:45
**/
String selectCustomerIdByOpenId(String openId);
/**
* @param openId
* @return userId
* @Author yinzuomei
* @Description 根据openId查询政府工作人员信息
* @Date 2020/3/14 20:45
**/
String selectCustomerStaffId(String openId);
/**
* @param openId
* @return userId
* @Author yinzuomei
* @Description 根据openId查询运营人员信息
* @Date 2020/3/14 20:45
**/
String selectOperUserId(String openId);
/**
* @param phone
* @return com.epmet.dto.result.PasswordLoginUserInfoResultDTO
* @Author yinzuomei
* @Description 根据手机号查询政府工作人员信息
* @Date 2020/3/17 11:01
**/
PasswordLoginUserInfoResultDTO selectCustomerStaffByPhone(String phone);
/**
* @param phone
* @return com.epmet.dto.result.PasswordLoginUserInfoResultDTO
* @Author yinzuomei
* @Description 根据手机号查询运营人员信息
* @Date 2020/3/17 11:01
**/
PasswordLoginUserInfoResultDTO selectOperUserByPhone(String phone);
/**
* @param phone
* @return com.epmet.dto.result.PasswordLoginUserInfoResultDTO
* @Author yinzuomei
* @Description 根据手机号查询居民信息
* @Date 2020/3/17 11:01
**/
PasswordLoginUserInfoResultDTO selectCustomerUserByPhone(String phone);
}

80
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserDao.java

@ -1,15 +1,10 @@
package com.epmet.dao; package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.commons.tools.page.PageData; import com.epmet.dto.result.PasswordLoginUserInfoResultDTO;
import com.epmet.dto.UserDTO;
import com.epmet.dto.UserWechatDTO;
import com.epmet.entity.UserEntity; import com.epmet.entity.UserEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
/** /**
* @Description 用户DAO * @Description 用户DAO
* @IntefaceName UserDao * @IntefaceName UserDao
@ -18,68 +13,23 @@ import java.util.Map;
*/ */
@Mapper @Mapper
public interface UserDao extends BaseDao<UserEntity> { public interface UserDao extends BaseDao<UserEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<UserWechatDTO>
* @author generator
* @date 2020-03-18
*/
PageData<UserWechatDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<UserWechatDTO>
* @author generator
* @date 2020-03-18
*/
List<UserWechatDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return UserWechatDTO
* @author generator
* @date 2020-03-18
*/
UserDTO get(String id);
/** /**
* 默认保存 * @param phone
* * @return com.epmet.dto.result.PasswordLoginUserInfoResultDTO
* @param dto * @Author yinzuomei
* @return void * @Description 根据手机号查询政府工作人员信息
* @author generator * @Date 2020/3/17 11:01
* @date 2020-03-18 **/
*/ PasswordLoginUserInfoResultDTO selectCustomerStaffByPhone(String phone);
void save(UserWechatDTO dto);
/** /**
* 默认更新 * @param phone
* * @return com.epmet.dto.result.PasswordLoginUserInfoResultDTO
* @param dto * @Author yinzuomei
* @return void * @Description 根据手机号查询运营人员信息
* @author generator * @Date 2020/3/17 11:01
* @date 2020-03-18 **/
*/ PasswordLoginUserInfoResultDTO selectOperUserByPhone(String phone);
void update(UserWechatDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2020-03-18
*/
void delete(String[] ids);
} }

15
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserWechatDao.java

@ -1,7 +1,9 @@
package com.epmet.dao; package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.UserDTO;
import com.epmet.dto.UserWechatDTO; import com.epmet.dto.UserWechatDTO;
import com.epmet.dto.form.WxLoginUserInfoFormDTO;
import com.epmet.entity.UserWechatEntity; import com.epmet.entity.UserWechatEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -24,12 +26,11 @@ public interface UserWechatDao extends BaseDao<UserWechatEntity>{
int updateByUserId(UserWechatDTO userWechatDTO); int updateByUserId(UserWechatDTO userWechatDTO);
/** /**
* @Description 根据openId查询系统下用户信息不区分用户政府端运营端 * @return com.epmet.dto.UserDTO
* @Param openId * @param formDTO
* @return userId * @Author yinzuomei
* @Author wangc * @Description 根据appopenId查询用户是否存在
* @Date 2020.03.28 13:25 * @Date 2020/3/30 13:06
**/ **/
String selectUserIdByOpenId(String openId); UserDTO selectUserDTOByOpenId(WxLoginUserInfoFormDTO formDTO);
} }

96
epmet-user/epmet-user-server/src/main/java/com/epmet/entity/CustomerUserEntity.java

@ -1,96 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 居民用户信息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-16
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("customer_user")
public class CustomerUserEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户Id CUSTOMER.id
*/
private String customerId;
/**
* 微信openId
*/
private String wxOpenId;
/**
* 微信unionId
*/
private String unionId;
/**
* 手机号
*/
private String mobile;
/**
* 昵称
*/
private String nickname;
/**
* 性别:0.未知 1.男性2女性
*/
private Integer sex;
/**
* 头像
*/
private String headImgUrl;
/**
* 国家
*/
private String country;
/**
* 省份
*/
private String province;
/**
* 城市
*/
private String city;
/**
* 语言
*/
private String language;
}

5
epmet-user/epmet-user-server/src/main/java/com/epmet/entity/OperUserEntity.java

@ -73,11 +73,6 @@ public class OperUserEntity extends BaseEpmetEntity {
*/ */
private String phone; private String phone;
/**
* 微信openId
*/
private String wxOpenId;
/** /**
* 部门ID * 部门ID
*/ */

86
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/CustomerUserExcel.java

@ -1,86 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.util.Date;
/**
* 居民用户信息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-16
*/
@Data
public class CustomerUserExcel {
@Excel(name = "唯一标识")
private String id;
@Excel(name = "客户Id CUSTOMER.id")
private String customerId;
@Excel(name = "微信openId")
private String wxOpenId;
@Excel(name = "手机号")
private String mobile;
@Excel(name = "昵称")
private String nickname;
@Excel(name = "性别:0.未知 1.男性2女性")
private Integer sex;
@Excel(name = "头像")
private String headImgUrl;
@Excel(name = "国家")
private String country;
@Excel(name = "省份")
private String province;
@Excel(name = "城市")
private String city;
@Excel(name = "语言")
private String language;
@Excel(name = "删除标识:0.未删除 1.已删除")
private String delFlag;
@Excel(name = "乐观锁")
private Integer revision;
@Excel(name = "创建人")
private String createdBy;
@Excel(name = "创建时间")
private Date createdTime;
@Excel(name = "更新人")
private String updatedBy;
@Excel(name = "更新时间")
private Date updatedTime;
}

47
epmet-user/epmet-user-server/src/main/java/com/epmet/redis/CustomerUserRedis.java

@ -1,47 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.redis;
import com.epmet.commons.tools.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 居民用户信息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-16
*/
@Component
public class CustomerUserRedis {
@Autowired
private RedisUtils redisUtils;
public void delete(Object[] ids) {
}
public void set(){
}
public String get(String id){
return null;
}
}

127
epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerUserService.java

@ -1,127 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerUserDTO;
import com.epmet.dto.form.PasswordLoginUserInfoFormDTO;
import com.epmet.dto.form.WxLoginUserInfoFormDTO;
import com.epmet.dto.result.PasswordLoginUserInfoResultDTO;
import com.epmet.entity.CustomerUserEntity;
import java.util.List;
import java.util.Map;
/**
* 居民用户信息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-16
*/
public interface CustomerUserService extends BaseService<CustomerUserEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<CustomerUserDTO>
* @author generator
* @date 2020-03-16
*/
PageData<CustomerUserDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<CustomerUserDTO>
* @author generator
* @date 2020-03-16
*/
List<CustomerUserDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return CustomerUserDTO
* @author generator
* @date 2020-03-16
*/
CustomerUserDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2020-03-16
*/
void save(CustomerUserDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2020-03-16
*/
void update(CustomerUserDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2020-03-16
*/
void delete(String[] ids);
/**
* 根据openIdapp查询对应终端用户信息
*
* @param formDTO
* @return void
* @author yinzuomei
* @date 2020-03-16
*/
Result selecWxLoginUserInfo(WxLoginUserInfoFormDTO formDTO);
/**
* @param customerUserDTO
* @return 获取居民微信信息保存到customer_user表,返回主键
* @Author yinzuomei
* @Description
* @Date 2020/3/16 15:49
**/
Result<String> saveOrUpdateCustomerUser(CustomerUserDTO customerUserDTO);
/**
* @param passwordLoginUserInfoFormDTO
* @return 根据手机号获取用户信息
* @Author yinzuomei
* @Description
* @Date 2020/3/16 15:49
**/
Result<PasswordLoginUserInfoResultDTO> selectLoginUserInfoByPassword(PasswordLoginUserInfoFormDTO passwordLoginUserInfoFormDTO);
}

77
epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserService.java

@ -2,7 +2,12 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.UserDTO; import com.epmet.dto.UserDTO;
import com.epmet.dto.UserWechatDTO;
import com.epmet.dto.form.PasswordLoginUserInfoFormDTO;
import com.epmet.dto.form.WxLoginUserInfoFormDTO;
import com.epmet.dto.result.PasswordLoginUserInfoResultDTO;
import com.epmet.entity.UserEntity; import com.epmet.entity.UserEntity;
import java.util.List; import java.util.List;
@ -15,65 +20,31 @@ import java.util.Map;
* @date 2020.03.28 14:34 * @date 2020.03.28 14:34
*/ */
public interface UserService extends BaseService<UserEntity> { public interface UserService extends BaseService<UserEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<UserDTO>
* @author generator
* @date 2020-03-18
*/
PageData<UserDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<UserDTO>
* @author generator
* @date 2020-03-18
*/
List<UserDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return UserDTO
* @author generator
* @date 2020-03-18
*/
UserDTO get(String id);
/** /**
* 默认保存 * 根据openIdapp查询对应终端用户信息
* *
* @param dto * @param formDTO
* @return void * @return void
* @author generator * @author yinzuomei
* @date 2020-03-18 * @date 2020-03-16
*/ */
void save(UserDTO dto); Result<UserDTO> selecWxLoginUserInfo(WxLoginUserInfoFormDTO formDTO);
/** /**
* 默认更新 * @param userWechatDTO
* * @return 获取居民微信信息保存到user_wechat表,返回主键
* @param dto * @Author yinzuomei
* @return void * @Description
* @author generator * @Date 2020/3/16 15:49
* @date 2020-03-18 **/
*/ Result<UserDTO> saveOrUpdateUserWechatDTO(UserWechatDTO userWechatDTO);
void update(UserDTO dto);
/** /**
* 批量删除 * @param passwordLoginUserInfoFormDTO
* * @return 根据手机号获取用户信息
* @param ids * @Author yinzuomei
* @return void * @Description
* @author generator * @Date 2020/3/16 15:49
* @date 2020-03-18 **/
*/ Result<PasswordLoginUserInfoResultDTO> selectLoginUserInfoByPassword(PasswordLoginUserInfoFormDTO passwordLoginUserInfoFormDTO);
void delete(String[] ids);
} }

203
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerUserServiceImpl.java

@ -1,203 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.common.token.constant.LoginConstant;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.UserConstant;
import com.epmet.dao.CustomerUserDao;
import com.epmet.dao.UserDao;
import com.epmet.dao.UserWechatDao;
import com.epmet.dto.CustomerUserDTO;
import com.epmet.dto.UserWechatDTO;
import com.epmet.dto.form.PasswordLoginUserInfoFormDTO;
import com.epmet.dto.form.WxLoginUserInfoFormDTO;
import com.epmet.dto.result.PasswordLoginUserInfoResultDTO;
import com.epmet.entity.CustomerUserEntity;
import com.epmet.entity.UserEntity;
import com.epmet.entity.UserWechatEntity;
import com.epmet.redis.CustomerUserRedis;
import com.epmet.service.CustomerUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 居民用户信息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-16
*/
@Service
public class CustomerUserServiceImpl extends BaseServiceImpl<CustomerUserDao, CustomerUserEntity> implements CustomerUserService {
@Autowired
private CustomerUserRedis customerUserRedis;
@Autowired
private UserWechatDao userWechatDao;
@Autowired
private UserDao userDao;
@Override
public PageData<CustomerUserDTO> page(Map<String, Object> params) {
IPage<CustomerUserEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, CustomerUserDTO.class);
}
@Override
public List<CustomerUserDTO> list(Map<String, Object> params) {
List<CustomerUserEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, CustomerUserDTO.class);
}
private QueryWrapper<CustomerUserEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper<CustomerUserEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public CustomerUserDTO get(String id) {
CustomerUserEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, CustomerUserDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(CustomerUserDTO dto) {
CustomerUserEntity entity = ConvertUtils.sourceToTarget(dto, CustomerUserEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(CustomerUserDTO dto) {
CustomerUserEntity entity = ConvertUtils.sourceToTarget(dto, CustomerUserEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
/**
* 根据openIdapp查询对应终端用户信息
*
* 居民端用户与政府端用户都在一张表内且都有微信登录的入口
* user_wechat表保存每一个用户和微信(openId)的绑定关系
*
* @return void
* @author yinzuomei
* @date 2020-03-16
*/
@Override
public Result<String> selecWxLoginUserInfo(WxLoginUserInfoFormDTO formDTO) {
String userId = "";
if (LoginConstant.APP_GOV.equals(formDTO.getApp())) {
//查询customer_staff待完善
//userId = baseDao.selectCustomerStaffId(formDTO.getOpenId());
userId = userWechatDao.selectUserIdByOpenId(formDTO.getOpenId());
} else if (LoginConstant.APP_OPER.equals(formDTO.getApp())) {
//查询oper_staff待完善
//userId = baseDao.selectOperUserId(formDTO.getOpenId());
userId = userWechatDao.selectUserIdByOpenId(formDTO.getOpenId());
} else if (LoginConstant.APP_RESI.equals(formDTO.getApp())) {
//居民端
//userId = baseDao.selectCustomerIdByOpenId(formDTO.getOpenId());
userId = userWechatDao.selectUserIdByOpenId(formDTO.getOpenId());
}
return new Result<String>().ok(userId);
}
/**
* @param customerUserDTO
* @return com.epmet.commons.tools.utils.Result<java.lang.String>
* @Author yinzuomei
* @Description 将获取到的居民微信信息保存到customer_user表,返回主键
* @Date 2020/3/17 11:04
**/
@Override
public Result<String> saveOrUpdateCustomerUser(CustomerUserDTO customerUserDTO) {
CustomerUserEntity entity = ConvertUtils.sourceToTarget(customerUserDTO, CustomerUserEntity.class);
UserWechatDTO dto = ConvertUtils.sourceToTarget(customerUserDTO, UserWechatDTO.class);
if (StringUtils.isNotBlank(customerUserDTO.getId())) {
//updateById(entity);
dto.setUserId(customerUserDTO.getId());
userWechatDao.updateByUserId(dto);
} else {
//insert(entity);
UserEntity userEntity = new UserEntity();
userEntity.setFromApp(UserConstant.APP_RESI);
userEntity.setFromClient(UserConstant.CLIENT_WX);
userDao.insert(userEntity);
dto.setUserId(userEntity.getId());
UserWechatEntity userWechatEntity = ConvertUtils.sourceToTarget(dto,UserWechatEntity.class);
userWechatDao.insert(userWechatEntity);
}
return new Result<String>().ok(entity.getId());
}
/**
* @param formDTO
* @return 根据手机号app获取对应终端用户信息
* @Author yinzuomei
* @Description
* @Date 2020/3/16 15:49
**/
@Override
public Result<PasswordLoginUserInfoResultDTO> selectLoginUserInfoByPassword(PasswordLoginUserInfoFormDTO formDTO) {
PasswordLoginUserInfoResultDTO passwordLoginUserInfoResultDTO = null;
if (LoginConstant.APP_GOV.equals(formDTO.getApp())) {
//查询customer_staff待完善
passwordLoginUserInfoResultDTO = baseDao.selectCustomerStaffByPhone(formDTO.getPhone());
} else if (LoginConstant.APP_OPER.equals(formDTO.getApp())) {
//查询oper_user待完善
passwordLoginUserInfoResultDTO = baseDao.selectOperUserByPhone(formDTO.getPhone());
} else if (LoginConstant.APP_RESI.equals(formDTO.getApp())) {
passwordLoginUserInfoResultDTO = baseDao.selectCustomerUserByPhone(formDTO.getPhone());
}
return new Result<PasswordLoginUserInfoResultDTO>().ok(passwordLoginUserInfoResultDTO);
}
}

92
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java

@ -1,14 +1,23 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.epmet.common.token.constant.LoginConstant;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.UserConstant;
import com.epmet.dao.UserDao; import com.epmet.dao.UserDao;
import com.epmet.dao.UserWechatDao;
import com.epmet.dto.UserDTO; import com.epmet.dto.UserDTO;
import com.epmet.dto.UserWechatDTO;
import com.epmet.dto.form.PasswordLoginUserInfoFormDTO;
import com.epmet.dto.form.WxLoginUserInfoFormDTO;
import com.epmet.dto.result.PasswordLoginUserInfoResultDTO;
import com.epmet.entity.UserEntity; import com.epmet.entity.UserEntity;
import com.epmet.entity.UserWechatEntity;
import com.epmet.service.UserService; import com.epmet.service.UserService;
import org.apache.commons.lang3.StringUtils;
import java.util.List; import org.springframework.beans.factory.annotation.Autowired;
import java.util.Map; import org.springframework.stereotype.Service;
/** /**
@ -17,35 +26,68 @@ import java.util.Map;
* @Author wangc * @Author wangc
* @date 2020.03.28 14:41 * @date 2020.03.28 14:41
*/ */
@Service
public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implements UserService { public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implements UserService {
@Autowired
private UserWechatDao userWechatDao;
/**
* 根据openIdapp查询对应终端用户信息
*
* 居民端用户与政府端用户都在一张表内且都有微信登录的入口
* user_wechat表保存每一个用户和微信(openId)的绑定关系
*
* @return void
* @author yinzuomei
* @date 2020-03-16
*/
@Override @Override
public PageData<UserDTO> page(Map<String, Object> params) { public Result<UserDTO> selecWxLoginUserInfo(WxLoginUserInfoFormDTO formDTO) {
return null; UserDTO userDTO=userWechatDao.selectUserDTOByOpenId(formDTO);
} return new Result<UserDTO>().ok(userDTO);
@Override
public List<UserDTO> list(Map<String, Object> params) {
return null;
} }
/**
* @param userWechatDTO
* @return com.epmet.commons.tools.utils.Result<java.lang.String>
* @Author yinzuomei
* @Description 将获取到的居民微信信息保存到customer_user表,返回主键
* @Date 2020/3/17 11:04
**/
@Override @Override
public UserDTO get(String id) { public Result<UserDTO> saveOrUpdateUserWechatDTO(UserWechatDTO userWechatDTO) {
return null; UserEntity resultUserEntity;
UserWechatEntity userWechatEntity = ConvertUtils.sourceToTarget(userWechatDTO, UserWechatEntity.class);
if (StringUtils.isNotBlank(userWechatEntity.getUserId())) {
userWechatDao.updateByUserId(userWechatDTO);
resultUserEntity = baseDao.selectById(userWechatDTO.getUserId());
} else {
UserEntity userEntity = new UserEntity();
userEntity.setFromApp(UserConstant.APP_RESI);
userEntity.setFromClient(UserConstant.CLIENT_WX);
baseDao.insert(userEntity);
userWechatEntity.setUserId(userEntity.getId());
userWechatDao.insert(userWechatEntity);
resultUserEntity = baseDao.selectById(userEntity.getId());
}
return new Result<UserDTO>().ok(ConvertUtils.sourceToTarget(resultUserEntity, UserDTO.class));
} }
/**
* @param formDTO
* @return 根据手机号app获取对应终端用户信息
* @Author yinzuomei
* @Description
* @Date 2020/3/16 15:49
**/
@Override @Override
public void save(UserDTO dto) { public Result<PasswordLoginUserInfoResultDTO> selectLoginUserInfoByPassword(PasswordLoginUserInfoFormDTO formDTO) {
PasswordLoginUserInfoResultDTO passwordLoginUserInfoResultDTO = null;
} if (LoginConstant.APP_GOV.equals(formDTO.getApp())) {
passwordLoginUserInfoResultDTO = baseDao.selectCustomerStaffByPhone(formDTO.getPhone());
@Override } else if (LoginConstant.APP_OPER.equals(formDTO.getApp())) {
public void update(UserDTO dto) { passwordLoginUserInfoResultDTO = baseDao.selectOperUserByPhone(formDTO.getPhone());
}
} return new Result<PasswordLoginUserInfoResultDTO>().ok(passwordLoginUserInfoResultDTO);
@Override
public void delete(String[] ids) {
} }
} }

80
epmet-user/epmet-user-server/src/main/resources/mapper/CustomerUserDao.xml

@ -1,80 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.CustomerUserDao">
<!-- 根据openId查询居民用户信息 -->
<select id="selectCustomerIdByOpenId" parameterType="java.lang.String" resultType="java.lang.String">
SELECT
cu.id
FROM
customer_user cu
WHERE
cu.DEL_FLAG = '0'
AND cu.WX_OPEN_ID = #{openId}
</select>
<!-- 根据openId查询政府工作人员信息-->
<select id="selectCustomerStaffId" parameterType="java.lang.String" resultType="java.lang.String">
SELECT
cs.id
FROM
customer_staff cs
WHERE
cs.DEL_FLAG = '0'
AND cs.WX_OPEN_ID = #{openId}
</select>
<!-- 根据openId查询运营人员信息-->
<select id="selectOperUserId" parameterType="java.lang.String" resultType="java.lang.String">
SELECT
ou.id
FROM
oper_user ou
WHERE
ou.DEL_FLAG = '0'
AND ou.WX_OPEN_ID = #{openId}
</select>
<!-- 根据手机号查询政府工作人员信息-->
<select id="selectCustomerStaffByPhone" resultType="com.epmet.dto.result.PasswordLoginUserInfoResultDTO">
SELECT
cs.id AS userId,
PASSWORD AS PASSWORD
FROM
customer_staff cs
WHERE
cs.DEL_FLAG = '0'
AND cs.PHONE = #{phone}
</select>
<!-- 根据手机号查询运营人员信息-->
<select id="selectOperUserByPhone" resultType="com.epmet.dto.result.PasswordLoginUserInfoResultDTO">
SELECT
ou.USER_ID AS userId,
PASSWORD AS PASSWORD
FROM
oper_user ou
WHERE
ou.DEL_FLAG = '0'
AND ou.STATUS = '1'
AND ou.PHONE = #{phone}
</select>
<!-- 根据手机号查询居民信息-->
<select id="selectCustomerUserByPhone" resultType="com.epmet.dto.result.PasswordLoginUserInfoResultDTO">
SELECT
cu.id as userId,
null as password
FROM
customer_user cu
WHERE
cu.DEL_FLAG = '0'
AND cu.MOBILE = #{phone}
</select>
</mapper>

24
epmet-user/epmet-user-server/src/main/resources/mapper/UserDao.xml

@ -3,5 +3,29 @@
<mapper namespace="com.epmet.dao.UserDao"> <mapper namespace="com.epmet.dao.UserDao">
<!-- 根据手机号查询政府工作人员信息-->
<select id="selectCustomerStaffByPhone" resultType="com.epmet.dto.result.PasswordLoginUserInfoResultDTO">
SELECT
cs.USER_ID AS userId,
PASSWORD AS PASSWORD
FROM
customer_staff cs
WHERE
cs.DEL_FLAG = '0'
AND cs.PHONE = #{phone}
</select>
<!-- 根据手机号查询运营人员信息-->
<select id="selectOperUserByPhone" resultType="com.epmet.dto.result.PasswordLoginUserInfoResultDTO">
SELECT
ou.USER_ID AS userId,
PASSWORD AS PASSWORD
FROM
oper_user ou
WHERE
ou.DEL_FLAG = '0'
AND ou.STATUS = '1'
AND ou.PHONE = #{phone}
</select>
</mapper> </mapper>

80
epmet-user/epmet-user-server/src/main/resources/mapper/UserWechatDao.xml

@ -4,53 +4,51 @@
<mapper namespace="com.epmet.dao.UserWechatDao"> <mapper namespace="com.epmet.dao.UserWechatDao">
<!-- 根据userId更新 用户-微信关系表里的属性 --> <!-- 根据userId更新 用户-微信关系表里的属性 -->
<update id="updateByUserId"> <update id="updateByUserId" parameterType="com.epmet.dto.UserWechatDTO">
UPDATE user_wechat
UPDATE user_wechat <set>
<set> <if test='null != city and "" != city '>
<if test='null != city and "" != city '> CITY = #{city},
CITY = #{city}, </if>
</if> <if test='null != wxOpenId and "" != wxOpenId'>
WX_OPEN_ID = #{wxOpenId},
<if test='null != nickname and "" != nickname '> </if>
NICKNAME = #{nickname}, <if test='null != unionId and "" != unionId'>
</if> WX_UNION_ID = #{unionId},
</if>
<if test='null != country and "" != country '> <if test='null != nickname and "" != nickname '>
COUNTRY = #{country}, NICKNAME = #{nickname},
</if> </if>
<if test='null != country and "" != country '>
<if test='null != province and "" != province '> COUNTRY = #{country},
PROVINCE = #{province}, </if>
</if> <if test='null != headImgUrl and "" != headImgUrl'>
HEAD_IMG_URL = #{headImgUrl},
<if test='null != sex and "" != sex '> </if>
SEX = #{sex}, <if test='null != province and "" != province '>
</if> PROVINCE = #{province},
<if test='null != wxOpenId and "" != wxOpenId'> </if>
WX_OPEN_ID = #{wxOpenId}, <if test='null != sex and "" != sex '>
</if> SEX = #{sex},
<if test='null != updatedBy and "" != updatedBy'> </if>
UPDATED_BY = #{updatedBy}, UPDATED_TIME = sysdate
</if> </set>
UPDATED_TIME = sysdate
</set>
WHERE WHERE
USER_ID = #{userId} USER_ID = #{userId}
</update> </update>
<!-- 根据app、openId查询用户是否存在 -->
<!-- 根据openId查询系统下(所有身份)用户信息 --> <select id="selectUserDTOByOpenId" parameterType="com.epmet.dto.form.WxLoginUserInfoFormDTO" resultType="com.epmet.dto.UserDTO">
<select id="selectUserIdByOpenId" parameterType="java.lang.String" resultType="java.lang.String">
SELECT SELECT
uw.user_id as id u.*
FROM FROM
user_wechat uw USER u
LEFT JOIN user_wechat uw ON (
u.id = uw.USER_ID
AND uw.WX_OPEN_ID = #{openId})
WHERE WHERE
uw.DEL_FLAG = '0' u.DEL_FLAG = '0'
AND uw.WX_OPEN_ID = #{openId} AND uw.DEL_FLAG = '0'
AND u.FROM_APP = #{app}
</select> </select>
</mapper> </mapper>
Loading…
Cancel
Save