Browse Source

代码暂存

dev
jianjun 5 years ago
parent
commit
17e32575db
  1. 6
      epmet-auth/pom.xml
  2. 4
      epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpFormDTO.java
  3. 2
      epmet-auth/src/main/java/com/epmet/dto/form/LoginByWxCodeFormDTO.java
  4. 2
      epmet-auth/src/main/java/com/epmet/dto/form/ResiWxPhoneFormDTO.java
  5. 98
      epmet-auth/src/main/java/com/epmet/redis/CustomerAppWxServiceUtil.java
  6. 3
      epmet-auth/src/main/java/com/epmet/service/LoginService.java
  7. 2
      epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java
  8. 30
      epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java
  9. 9
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  10. 97
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerAppDTO.java
  11. 42
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerAppSecretFormDTO.java
  12. 24
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java
  13. 20
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java
  14. 88
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerAppController.java
  15. 35
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerAppDao.java
  16. 63
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerAppEntity.java
  17. 92
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerAppIdService.java
  18. 96
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerAppIdServiceImpl.java
  19. 25
      epmet-module/oper-crm/oper-crm-server/src/main/resources/CustomerAppDao.xml

6
epmet-auth/pom.xml

@ -122,6 +122,12 @@
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>oper-crm-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

4
epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpFormDTO.java

@ -19,5 +19,9 @@ public class GovWxmpFormDTO extends LoginCommonFormDTO implements Serializable {
*/
@NotBlank(message = "wxCode不能为空",groups = {AddUserInternalGroup.class})
private String wxCode;
/**
* appId
*/
private String appId;
}

2
epmet-auth/src/main/java/com/epmet/dto/form/LoginByWxCodeFormDTO.java

@ -29,4 +29,6 @@ public class LoginByWxCodeFormDTO extends LoginCommonFormDTO implements Serializ
* 加密算法的初始向量
*/
private String iv;
private String appId;
}

2
epmet-auth/src/main/java/com/epmet/dto/form/ResiWxPhoneFormDTO.java

@ -32,4 +32,6 @@ public class ResiWxPhoneFormDTO implements Serializable {
*/
@NotBlank(message = "iv不能为空",groups = {AddUserInternalGroup.class})
private String iv;
private String appId;
}

98
epmet-auth/src/main/java/com/epmet/redis/CustomerAppWxServiceUtil.java

@ -0,0 +1,98 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
* <p>
* https://www.renren.io
* <p>
* 版权所有侵权必究
*/
package com.epmet.redis;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAppDTO;
import com.epmet.dto.form.CustomerAppSecretFormDTO;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.google.common.collect.Maps;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import javax.annotation.PostConstruct;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 客户app Redis
*
* @author Mark sunlightcs@gmail.com
* @since 1.0.0
*/
@Component
public class CustomerAppWxServiceUtil {
private Logger logger = LogManager.getLogger(CustomerAppWxServiceUtil.class);
/**
* 过期时长为30分钟单位
*/
private final static long MINUTE_THIRTY_EXPIRE = 60 * 60 * 24 * 7L;
private final static String JSON_STR = "JSON";
@Autowired
private RedisUtils redisUtils;
@Autowired
private OperCrmOpenFeignClient operCrmOpenFeignClient;
private static Map<String, WxMaService> maServices = Maps.newHashMap();
@PostConstruct
private void initWxMa() {
Result<List<CustomerAppDTO>> configAllAppResult = operCrmOpenFeignClient.getConfigAllApp();
if (configAllAppResult != null && configAllAppResult.success() && CollectionUtils.isEmpty(configAllAppResult.getData())) {
maServices = configAllAppResult.getData().stream()
.map(a -> {
WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
config.setAppid(a.getAppId());
config.setSecret(a.getSecret());
config.setMsgDataFormat(JSON_STR);
WxMaService service = new WxMaServiceImpl();
service.setWxMaConfig(config);
return service;
}).collect(Collectors.toMap(s -> s.getWxMaConfig().getAppid(), a -> a));
}
logger.info("initWxMa success:{}", JSON.toJSONString(maServices));
}
public WxMaService getWxMaService(String appId) {
WxMaService wxMaService = maServices.get(appId);
if (wxMaService == null){
logger.error("getMaService appId:{} is not config from customer_app",appId);
}
return wxMaService;
}
public String get(String appId) {
String key = RedisKeys.getAppSecretKey(appId);
String secret = (String) redisUtils.get(key);
if (StringUtils.isBlank(secret)) {
CustomerAppSecretFormDTO param = new CustomerAppSecretFormDTO();
param.setAppId(appId);
Result<String> result = operCrmOpenFeignClient.getSecretByAppId(param);
if (result.success()) {
secret = result.getData();
if (StringUtils.isNotBlank(secret)) {
redisUtils.set(key, secret, MINUTE_THIRTY_EXPIRE);
}
}
}
return secret;
}
}

3
epmet-auth/src/main/java/com/epmet/service/LoginService.java

@ -45,11 +45,12 @@ public interface LoginService {
* @return cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult
* @param app
* @param wxCode
* @param appId 非必填
* @Author yinzuomei
* @Description 解析wxCode
* @Date 2020/4/19 0:24
**/
WxMaJscode2SessionResult getWxMaUser(String app, String wxCode);
WxMaJscode2SessionResult getWxMaUser(String app, String wxCode, String appId);
/**
* @return java.lang.String

2
epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java

@ -141,7 +141,7 @@ public class GovLoginServiceImpl implements GovLoginService {
@Override
public UserTokenResultDTO loginByWxCode(GovWxmpFormDTO formDTO) {
//1、解析微信用户
WxMaJscode2SessionResult wxMaJscode2SessionResult = loginService.getWxMaUser(formDTO.getApp(), formDTO.getWxCode());
WxMaJscode2SessionResult wxMaJscode2SessionResult = loginService.getWxMaUser(formDTO.getApp(), formDTO.getWxCode(), formDTO.getAppId());
if(null!=wxMaJscode2SessionResult){
logger.info(String.format("app=%s,wxCode=%s,openId=%s",formDTO.getApp(),formDTO.getWxCode(),wxMaJscode2SessionResult.getOpenid()));
}

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

@ -22,6 +22,7 @@ import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.feign.OperAccessOpenFeignClient;
import com.epmet.jwt.JwtTokenProperties;
import com.epmet.jwt.JwtTokenUtils;
import com.epmet.redis.CustomerAppWxServiceUtil;
import com.epmet.service.CaptchaService;
import com.epmet.service.LoginService;
import com.epmet.utils.WxMaServiceUtils;
@ -66,6 +67,8 @@ public class LoginServiceImpl implements LoginService {
@Autowired
private OperAccessOpenFeignClient operAccessOpenFeignClient;
@Autowired
private CustomerAppWxServiceUtil customerAppWxServiceUtil;
/**
* 居民端微信小程序登录
@ -82,7 +85,7 @@ public class LoginServiceImpl implements LoginService {
throw new RenException("参数错误");
}
//1、根据wxCode获取微信信息
WxMaJscode2SessionResult wxMaJscode2SessionResult = this.getWxMaUser(formDTO.getApp(),formDTO.getWxCode());
WxMaJscode2SessionResult wxMaJscode2SessionResult = this.getWxMaUser(formDTO.getApp(),formDTO.getWxCode(),formDTO.getAppId());
logger.info("openId=[" + wxMaJscode2SessionResult.getOpenid() + "]unionId=[" + wxMaJscode2SessionResult.getUnionid() + "]");
//2、根据openId查询数据库,没有则直接插入一条记录
String userId = this.getUserId(formDTO, wxMaJscode2SessionResult);
@ -109,15 +112,19 @@ public class LoginServiceImpl implements LoginService {
* @date 2020/3/14 20:16
*/
@Override
public WxMaJscode2SessionResult getWxMaUser(String app,String wxCode) {
public WxMaJscode2SessionResult getWxMaUser(String app,String wxCode,String appId) {
WxMaJscode2SessionResult wxMaJscode2SessionResult = null;
try {
if (LoginConstant.APP_GOV.equals(app)) {
wxMaJscode2SessionResult = wxMaServiceUtils.govWxMaService().jsCode2SessionInfo(wxCode);
} else if (LoginConstant.APP_OPER.equals(app)) {
wxMaJscode2SessionResult = wxMaServiceUtils.operWxMaService().jsCode2SessionInfo(wxCode);
} else if (LoginConstant.APP_RESI.equals(app)) {
wxMaJscode2SessionResult = wxMaServiceUtils.resiWxMaService().jsCode2SessionInfo(wxCode);
if (StringUtils.isNotBlank(appId)){
wxMaJscode2SessionResult = customerAppWxServiceUtil.getWxMaService(appId).jsCode2SessionInfo(wxCode);
}else{
if (LoginConstant.APP_GOV.equals(app)) {
wxMaJscode2SessionResult = wxMaServiceUtils.govWxMaService().jsCode2SessionInfo(wxCode);
} else if (LoginConstant.APP_OPER.equals(app)) {
wxMaJscode2SessionResult = wxMaServiceUtils.operWxMaService().jsCode2SessionInfo(wxCode);
} else if (LoginConstant.APP_RESI.equals(app)) {
wxMaJscode2SessionResult = wxMaServiceUtils.resiWxMaService().jsCode2SessionInfo(wxCode);
}
}
} catch (WxErrorException e) {
log.error("->[getMaOpenId]::error[{}]", "解析微信code失败");
@ -137,7 +144,12 @@ public class LoginServiceImpl implements LoginService {
String phone="";
try {
ValidatorUtils.validateEntity(formDTO, ResiWxPhoneFormDTO.AddUserInternalGroup.class);
WxMaService wxMaService = wxMaServiceUtils.resiWxMaService();
WxMaService wxMaService = null;
if (StringUtils.isNotBlank(formDTO.getAppId())){
wxMaService = customerAppWxServiceUtil.getWxMaService(formDTO.getAppId());
}else{
wxMaService = wxMaServiceUtils.resiWxMaService();
}
WxMaJscode2SessionResult wxMaJscode2SessionResult = wxMaService.jsCode2SessionInfo(formDTO.getWxCode());
WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService().getPhoneNoInfo(wxMaJscode2SessionResult.getSessionKey(),
formDTO.getEncryptedData(),

9
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -254,4 +254,13 @@ public class RedisKeys {
return rootPrefix.concat("tags:grid:relationTag:").concat(gridId).concat(StrConstant.COLON).concat(tagId);
}
/**
* appId secret 缓存Key
* @param appId
* @return
*/
public static String getAppSecretKey(String appId) {
return rootPrefix.concat("oper:crm:appid:secret").concat(appId);
}
}

97
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerAppDTO.java

@ -0,0 +1,97 @@
/**
* 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 lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 客户表 appId表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-07-27
*/
@Data
public class CustomerAppDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String id;
/**
* 客户Id
*/
private String customerId;
/**
* 小程序的appId
*/
private String appId;
/**
* resiwork
*/
private String client;
/**
* app的secret
*/
private String secret;
/**
* 0停用1启用
*/
private Integer enableFlag;
/**
* 删除标识0.未删除 1.已删除
*/
private Integer delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

42
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerAppSecretFormDTO.java

@ -0,0 +1,42 @@
/**
* 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.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 客户表 appId表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-07-27
*/
@Data
public class CustomerAppSecretFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 小程序的appId
*/
@NotBlank(message = "小程序Id不能为空")
private String appId;
}

24
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java

@ -1,13 +1,16 @@
package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAppDTO;
import com.epmet.dto.CustomerDTO;
import org.springframework.cloud.openfeign.FeignClient;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.dto.form.CustomerAppSecretFormDTO;
import com.epmet.feign.fallback.OperCrmOpenFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.List;
/**
* 本服务对外开放的API,其他服务通过引用此client调用该服务
*
@ -23,4 +26,19 @@ public interface OperCrmOpenFeignClient {
*/
@PostMapping("/oper/crm/customer/getcostomerInfo")
Result<CustomerDTO> getCustomerInfo(CustomerDTO dto);
/**
* 获取客户appId信息
* @param dto
* @return
*/
@PostMapping("/oper/crm/customerapp/getsecretbyappid")
Result<String> getSecretByAppId(CustomerAppSecretFormDTO dto);
/**
* 获取所有已配置的app信息
* @return
*/
@PostMapping("/oper/crm/customerapp/getconfigallapp")
Result<List<CustomerAppDTO> getConfigAllApp();
}

20
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java

@ -3,10 +3,14 @@ package com.epmet.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAppDTO;
import com.epmet.dto.CustomerDTO;
import com.epmet.dto.form.CustomerAppSecretFormDTO;
import com.epmet.feign.OperCrmOpenFeignClient;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 本服务对外开放的API,其他服务通过引用此client调用该服务
*
@ -19,4 +23,20 @@ public class OperCrmOpenFeignClientFallback implements OperCrmOpenFeignClient {
public Result<CustomerDTO> getCustomerInfo(CustomerDTO dto) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getCustomerInfo", dto);
}
/**
* 获取客户appId信息
*
* @param dto
* @return
*/
@Override
public Result<String> getSecretByAppId(CustomerAppSecretFormDTO dto) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getSecretByAppId", dto);
}
@Override
public Result<List<CustomerAppDTO>> getConfigAllApp() {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getConfigAllApp", null);
}
}

88
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerAppController.java

@ -0,0 +1,88 @@
/**
* 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.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.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.CustomerAppDTO;
import com.epmet.dto.form.CustomerAppSecretFormDTO;
import com.epmet.service.CustomerAppIdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* 客户表 app表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-07-27
*/
@RestController
@RequestMapping("customerapp")
public class CustomerAppController {
@Autowired
private CustomerAppIdService customerAppIdService;
@GetMapping("page")
public Result<PageData<CustomerAppDTO>> page(@RequestParam Map<String, Object> params){
PageData<CustomerAppDTO> page = customerAppIdService.page(params);
return new Result<PageData<CustomerAppDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<CustomerAppDTO> get(@PathVariable("id") String id){
CustomerAppDTO data = customerAppIdService.get(id);
return new Result<CustomerAppDTO>().ok(data);
}
@PostMapping
public Result save(@RequestBody CustomerAppDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
customerAppIdService.save(dto);
return new Result();
}
@PutMapping
public Result update(@RequestBody CustomerAppDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
customerAppIdService.update(dto);
return new Result();
}
@PostMapping("getsecretbyappid")
public Result<String> getSecretByAppId(@RequestBody CustomerAppSecretFormDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, DefaultGroup.class);
return new Result<String>().ok(customerAppIdService.selectSecretByAppId(dto.getAppId()));
}
@PostMapping("getconfigallapp")
public Result<List<CustomerAppDTO>> getConfigAllApp(){
return new Result<List<CustomerAppDTO>>().ok(customerAppIdService.list(null));
}
}

35
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerAppDao.java

@ -0,0 +1,35 @@
/**
* 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.entity.CustomerAppEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 客户表 appId表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-07-27
*/
@Mapper
public interface CustomerAppDao extends BaseDao<CustomerAppEntity> {
String selectSecretByAppId(@Param("appId") String appId);
}

63
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerAppEntity.java

@ -0,0 +1,63 @@
/**
* 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;
/**
* 客户表 appId表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-07-27
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("customer_app")
public class CustomerAppEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户Id
*/
private String customerId;
/**
* 小程序的appId
*/
private String appId;
/**
* resiwork
*/
private String client;
/**
* app的secret
*/
private String secret;
/**
* 0停用1启用
*/
private Integer enableFlag;
}

92
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerAppIdService.java

@ -0,0 +1,92 @@
/**
* 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.dto.CustomerAppDTO;
import com.epmet.entity.CustomerAppEntity;
import java.util.List;
import java.util.Map;
/**
* 客户表 appId表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-07-27
*/
public interface CustomerAppIdService extends BaseService<CustomerAppEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<CustomerAppIdDTO>
* @author generator
* @date 2020-07-27
*/
PageData<CustomerAppDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<CustomerAppIdDTO>
* @author generator
* @date 2020-07-27
*/
List<CustomerAppDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return CustomerAppIdDTO
* @author generator
* @date 2020-07-27
*/
CustomerAppDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2020-07-27
*/
void save(CustomerAppDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2020-07-27
*/
void update(CustomerAppDTO dto);
/**
* desc:获取客户app secret
* @param appId
* @return
*/
String selectSecretByAppId(String appId);
}

96
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerAppIdServiceImpl.java

@ -0,0 +1,96 @@
/**
* 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.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.dao.CustomerAppDao;
import com.epmet.dto.CustomerAppDTO;
import com.epmet.entity.CustomerAppEntity;
import com.epmet.service.CustomerAppIdService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/**
* 客户表 appId表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-07-27
*/
@Service
public class CustomerAppIdServiceImpl extends BaseServiceImpl<CustomerAppDao, CustomerAppEntity> implements CustomerAppIdService {
@Override
public PageData<CustomerAppDTO> page(Map<String, Object> params) {
IPage<CustomerAppEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, CustomerAppDTO.class);
}
@Override
public List<CustomerAppDTO> list(Map<String, Object> params) {
List<CustomerAppEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, CustomerAppDTO.class);
}
private QueryWrapper<CustomerAppEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<CustomerAppEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public CustomerAppDTO get(String id) {
CustomerAppEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, CustomerAppDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(CustomerAppDTO dto) {
CustomerAppEntity entity = ConvertUtils.sourceToTarget(dto, CustomerAppEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(CustomerAppDTO dto) {
CustomerAppEntity entity = ConvertUtils.sourceToTarget(dto, CustomerAppEntity.class);
updateById(entity);
}
@Override
public String selectSecretByAppId(String appId) {
return baseDao.selectSecretByAppId(appId);
}
}

25
epmet-module/oper-crm/oper-crm-server/src/main/resources/CustomerAppDao.xml

@ -0,0 +1,25 @@
<?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.CustomerAppDao">
<resultMap type="com.epmet.entity.CustomerAppEntity" id="customerAppIdMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="appId" column="APP_ID"/>
<result property="client" column="CLIENT"/>
<result property="secret" column="SECRET"/>
<result property="enableFlag" column="ENABLE_FLAG"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<select id="selectSecretByAppId" resultType="java.lang.String">
SELECT secret FROM customer_app where APP_ID = #{appId,jdbcType=VARCHAR} and ENABLE_FLAG = 1 and DEL_FLAG = 0
</select>
</mapper>
Loading…
Cancel
Save