forked from rongchao/epmet-cloud-rizhao
19 changed files with 724 additions and 14 deletions
@ -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; |
||||
|
} |
||||
|
|
||||
|
} |
@ -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,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)); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
@ -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,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); |
||||
|
} |
@ -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); |
||||
|
} |
||||
|
|
||||
|
} |
@ -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