Browse Source
Conflicts: epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.javadev_shibei_match
81 changed files with 1227 additions and 297 deletions
@ -0,0 +1,47 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @Description 单客户-选择组织,进入首页入参Dto |
||||
|
* @Author sun |
||||
|
*/ |
||||
|
@Data |
||||
|
public class ThirdWxmpEnteOrgFormDTO implements Serializable { |
||||
|
public interface AddUserInternalGroup {} |
||||
|
public interface AddUserShowGroup extends CustomerClientShowGroup {} |
||||
|
/** |
||||
|
* wxCode |
||||
|
*/ |
||||
|
@NotBlank(message = "wxCode不能为空",groups = {AddUserInternalGroup.class}) |
||||
|
private String wxCode; |
||||
|
|
||||
|
/** |
||||
|
* 手机号 |
||||
|
*/ |
||||
|
@NotBlank(message = "手机号不能为空",groups = {AddUserShowGroup.class}) |
||||
|
private String mobile; |
||||
|
|
||||
|
/** |
||||
|
* 选择的组织所属的id |
||||
|
*/ |
||||
|
@NotBlank(message = "客户id不能为空",groups = {AddUserInternalGroup.class}) |
||||
|
private String customerId; |
||||
|
|
||||
|
/** |
||||
|
* 选择的要进入的组织(根组织id) |
||||
|
*/ |
||||
|
@NotBlank(message = "组织id不能为空",groups = {AddUserInternalGroup.class}) |
||||
|
private String rootAgencyId; |
||||
|
|
||||
|
/** |
||||
|
* 客户appId(exJson文件中获取) |
||||
|
*/ |
||||
|
@NotBlank(message = "appId不能为空",groups = {AddUserInternalGroup.class}) |
||||
|
private String appId; |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,124 @@ |
|||||
|
/** |
||||
|
* 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.feign.OperCrmOpenFeignClient; |
||||
|
import com.google.common.collect.Maps; |
||||
|
import org.apache.logging.log4j.LogManager; |
||||
|
import org.apache.logging.log4j.Logger; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.boot.ApplicationArguments; |
||||
|
import org.springframework.boot.ApplicationRunner; |
||||
|
import org.springframework.data.redis.core.RedisTemplate; |
||||
|
import org.springframework.data.redis.core.SetOperations; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
import org.springframework.util.CollectionUtils; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Set; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* 客户app Redis |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since 1.0.0 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class CustomerAppWxServiceUtil implements ApplicationRunner { |
||||
|
private static 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 RedisTemplate<String,String> redisTemplate; |
||||
|
@Autowired |
||||
|
private OperCrmOpenFeignClient operCrmOpenFeignClient; |
||||
|
|
||||
|
private static Map<String, WxMaService> maServices = Maps.newHashMap(); |
||||
|
|
||||
|
public static 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; |
||||
|
}*/ |
||||
|
|
||||
|
@Override |
||||
|
public void run(ApplicationArguments args) { |
||||
|
try { |
||||
|
Result<List<CustomerAppDTO>> configAllAppResult = operCrmOpenFeignClient.getConfigAllApp(); |
||||
|
logger.info("initWxMa operCrmOpenFeignClient.getConfigAllApp result:{}", JSON.toJSONString(configAllAppResult)); |
||||
|
if (configAllAppResult == null || !configAllAppResult.success()){ |
||||
|
logger.info("initWxMa operCrmOpenFeignClient.getConfigAllApp fail"); |
||||
|
return; |
||||
|
} |
||||
|
String appKey = RedisKeys.getCustomerAppKey(); |
||||
|
SetOperations<String, String> appSet = redisTemplate.opsForSet(); |
||||
|
Set<String> members = appSet.members(appKey); |
||||
|
|
||||
|
if ( !CollectionUtils.isEmpty(configAllAppResult.getData())) { |
||||
|
//if (!CollectionUtils.isEmpty(members) && CollectionUtils.isEmpty()){
|
||||
|
//todo
|
||||
|
//}
|
||||
|
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); |
||||
|
redisTemplate.opsForSet().add(appKey,a.getSecret()); |
||||
|
return service; |
||||
|
}).collect(Collectors.toMap(s -> s.getWxMaConfig().getAppid(), a -> a)); |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
} catch (Exception e) { |
||||
|
logger.error("init wxMaservice exception",e); |
||||
|
} finally { |
||||
|
logger.info("init wxMaservice end"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,33 +0,0 @@ |
|||||
package com.epmet.commons.tools.utils; |
|
||||
|
|
||||
import org.apache.http.HttpEntity; |
|
||||
import org.apache.http.HttpResponse; |
|
||||
import org.apache.http.StatusLine; |
|
||||
import org.apache.http.client.HttpResponseException; |
|
||||
import org.apache.http.client.ResponseHandler; |
|
||||
import org.apache.http.util.EntityUtils; |
|
||||
|
|
||||
import java.io.IOException; |
|
||||
import java.io.InputStream; |
|
||||
|
|
||||
/** |
|
||||
* 输入流响应处理器. |
|
||||
* |
|
||||
* @author Daniel Qian |
|
||||
*/ |
|
||||
public class InputStreamResponseHandler implements ResponseHandler<InputStream> { |
|
||||
public static final ResponseHandler<InputStream> INSTANCE = new InputStreamResponseHandler(); |
|
||||
private static final int STATUS_CODE_300 = 300; |
|
||||
|
|
||||
@Override |
|
||||
public InputStream handleResponse(final HttpResponse response) throws IOException { |
|
||||
final StatusLine statusLine = response.getStatusLine(); |
|
||||
final HttpEntity entity = response.getEntity(); |
|
||||
if (statusLine.getStatusCode() >= STATUS_CODE_300) { |
|
||||
EntityUtils.consume(entity); |
|
||||
throw new HttpResponseException(statusLine.getStatusCode(), statusLine.getReasonPhrase()); |
|
||||
} |
|
||||
return entity == null ? null : entity.getContent(); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,33 +0,0 @@ |
|||||
package com.epmet.commons.tools.utils; |
|
||||
|
|
||||
import org.apache.http.Consts; |
|
||||
import org.apache.http.HttpEntity; |
|
||||
import org.apache.http.HttpResponse; |
|
||||
import org.apache.http.StatusLine; |
|
||||
import org.apache.http.client.HttpResponseException; |
|
||||
import org.apache.http.client.ResponseHandler; |
|
||||
import org.apache.http.util.EntityUtils; |
|
||||
|
|
||||
import java.io.IOException; |
|
||||
|
|
||||
/** |
|
||||
* copy from {@link org.apache.http.impl.client.BasicResponseHandler} |
|
||||
* |
|
||||
* @author Daniel Qian |
|
||||
*/ |
|
||||
public class Utf8ResponseHandler implements ResponseHandler<String> { |
|
||||
|
|
||||
public static final ResponseHandler<String> INSTANCE = new Utf8ResponseHandler(); |
|
||||
|
|
||||
@Override |
|
||||
public String handleResponse(final HttpResponse response) throws IOException { |
|
||||
final StatusLine statusLine = response.getStatusLine(); |
|
||||
final HttpEntity entity = response.getEntity(); |
|
||||
if (statusLine.getStatusCode() >= 300) { |
|
||||
EntityUtils.consume(entity); |
|
||||
throw new HttpResponseException(statusLine.getStatusCode(), statusLine.toString()); |
|
||||
} |
|
||||
return entity == null ? null : EntityUtils.toString(entity, Consts.UTF_8); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -0,0 +1,66 @@ |
|||||
|
package com.epmet.wxapi.param; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @author zhaoqifeng |
||||
|
* @dscription |
||||
|
* @date 2020/7/27 9:19 |
||||
|
*/ |
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
public class WxExtJson implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = -559311391779774945L; |
||||
|
|
||||
|
private boolean extEnable; |
||||
|
private String extAppid; |
||||
|
private boolean directCommit; |
||||
|
private ExtBean ext; |
||||
|
|
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
private static class ExtBean { |
||||
|
private String extAppid; |
||||
|
private FootbarBean footbar; |
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
private static class FootbarBean { |
||||
|
private WorkBean work; |
||||
|
private OrgBean org; |
||||
|
private DataBean data; |
||||
|
private FindBean find; |
||||
|
|
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
private static class WorkBean { |
||||
|
private String name; |
||||
|
private String pageTile; |
||||
|
} |
||||
|
|
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
private static class OrgBean { |
||||
|
private String name; |
||||
|
private String pageTile; |
||||
|
} |
||||
|
|
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
private static class DataBean { |
||||
|
private String name; |
||||
|
private String pageTile; |
||||
|
} |
||||
|
|
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
private static class FindBean { |
||||
|
private String name; |
||||
|
private String pageTile; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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; |
||||
|
|
||||
|
/** |
||||
|
* resi,work |
||||
|
*/ |
||||
|
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; |
||||
|
|
||||
|
} |
||||
@ -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; |
||||
|
} |
||||
@ -0,0 +1,89 @@ |
|||||
|
/** |
||||
|
* 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(){ |
||||
|
List<CustomerAppDTO> configAllApp = customerAppIdService.getConfigAllApp(); |
||||
|
return new Result<List<CustomerAppDTO>>().ok(configAllApp); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -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); |
||||
|
} |
||||
@ -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; |
||||
|
|
||||
|
/** |
||||
|
* resi,work |
||||
|
*/ |
||||
|
private String client; |
||||
|
|
||||
|
/** |
||||
|
* app的secret |
||||
|
*/ |
||||
|
private String secret; |
||||
|
|
||||
|
/** |
||||
|
* 0:停用,1:启用 |
||||
|
*/ |
||||
|
private Integer enableFlag; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,94 @@ |
|||||
|
/** |
||||
|
* 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); |
||||
|
|
||||
|
List<CustomerAppDTO> getConfigAllApp(); |
||||
|
} |
||||
@ -0,0 +1,103 @@ |
|||||
|
/** |
||||
|
* 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); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<CustomerAppDTO> getConfigAllApp() { |
||||
|
List<CustomerAppEntity> entities = baseDao.selectList(null); |
||||
|
List<CustomerAppDTO> customerAppDTOS = ConvertUtils.sourceToTarget(entities, CustomerAppDTO.class); |
||||
|
return customerAppDTOS; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -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…
Reference in new issue