| @@ -38,6 +38,7 @@ import java.util.concurrent.TimeUnit; | |||||
| import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
| import static com.iformall.domain.po.WxCouponOrder.Field.CreateDate_DESC; | import static com.iformall.domain.po.WxCouponOrder.Field.CreateDate_DESC; | ||||
| import static com.iformall.ueditor.define.AppInfo.info; | |||||
| @RestController | @RestController | ||||
| @RequestMapping("wxCUserBasicInfo") | @RequestMapping("wxCUserBasicInfo") | ||||
| @@ -452,4 +453,18 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| wxCUserBasicInfoService.exportCarPayData(record, request, response); | wxCUserBasicInfoService.exportCarPayData(record, request, response); | ||||
| } | } | ||||
| @ApiOperation("根据手机号查询接口") | |||||
| @GetMapping("/findByPhone") | |||||
| @ApiImplicitParam(name = "phone", value = "phone", dataType = "String", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "根据手机号查询接口") | |||||
| public ResultData findByPhone(String phone) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::findByPhone"); | |||||
| List<WxCUserBasicInfo> wxCUserBasicInfoList = wxCUserBasicInfoService.findByPhone(getTenantId(),phone); | |||||
| WxCUserBasicInfo wxCUserBasicInfo = new WxCUserBasicInfo(); | |||||
| if (wxCUserBasicInfoList != null && wxCUserBasicInfoList.size() > 0) { | |||||
| wxCUserBasicInfo = wxCUserBasicInfoList.get(0); | |||||
| } | |||||
| return new ResultData(wxCUserBasicInfo); | |||||
| } | |||||
| } | } | ||||
| @@ -7,11 +7,13 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxLevelConfig; | import com.iformall.domain.po.WxLevelConfig; | ||||
| import com.iformall.domain.po.WxMerchant; | import com.iformall.domain.po.WxMerchant; | ||||
| import com.iformall.domain.po.WxProfitSharingReceiver; | import com.iformall.domain.po.WxProfitSharingReceiver; | ||||
| import com.iformall.domain.vo.WxMerchantSimpleVo; | |||||
| import com.iformall.service.WxMerchantService; | import com.iformall.service.WxMerchantService; | ||||
| import com.iformall.service.WxProfitSharingReceiverService; | import com.iformall.service.WxProfitSharingReceiverService; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.apache.commons.beanutils.BeanUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -154,4 +156,12 @@ public class WxMerchantController extends BaseController { | |||||
| return wxMerchantService.updateMerchantLevel(wxMerchant); | return wxMerchantService.updateMerchantLevel(wxMerchant); | ||||
| } | } | ||||
| @ApiOperation("查询当前租户下商户名称列表") | |||||
| @GetMapping("/name_list") | |||||
| @SystemControllerLog(description = "查询当前租户下商户名称列表") | |||||
| public ResultData nameList() { | |||||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::name_list"); | |||||
| return new ResultData(wxMerchantService.findList(getTenantId())); | |||||
| } | |||||
| } | } | ||||
| @@ -20,6 +20,11 @@ | |||||
| <scope>compile</scope> | <scope>compile</scope> | ||||
| </dependency> | </dependency> | ||||
| --> | --> | ||||
| <dependency> | |||||
| <groupId>net.sf.dozer</groupId> | |||||
| <artifactId>dozer</artifactId> | |||||
| <version>5.5.1</version> | |||||
| </dependency> | |||||
| </dependencies> | </dependencies> | ||||
| </project> | </project> | ||||
| @@ -0,0 +1,16 @@ | |||||
| package com.iformall.domain.vo; | |||||
| import io.swagger.annotations.ApiModelProperty; | |||||
| import lombok.Data; | |||||
| @Data | |||||
| public class WxMerchantSimpleVo { | |||||
| /**id**/ | |||||
| @ApiModelProperty(value="id",name="id") | |||||
| private Long id; | |||||
| /**商户名**/ | |||||
| @ApiModelProperty(value="商户名",name="name") | |||||
| private String merchantName; | |||||
| } | |||||
| @@ -0,0 +1,17 @@ | |||||
| package com.iformall.exception; | |||||
| public class BeanMappingException extends RuntimeException { | |||||
| private static final long serialVersionUID = -3616240376550557648L; | |||||
| public BeanMappingException() { | |||||
| this("Bean对象映射异常"); | |||||
| } | |||||
| public BeanMappingException(String message) { | |||||
| super(message); | |||||
| } | |||||
| public BeanMappingException(Throwable cause) { | |||||
| super(cause); | |||||
| } | |||||
| } | |||||
| @@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxLevelConfig; | import com.iformall.domain.po.WxLevelConfig; | ||||
| import com.iformall.domain.po.WxMerchant; | import com.iformall.domain.po.WxMerchant; | ||||
| import com.iformall.domain.vo.WxMerchantSimpleVo; | |||||
| import com.iformall.domain.vo.WxMerchantVo; | import com.iformall.domain.vo.WxMerchantVo; | ||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| @@ -39,6 +40,13 @@ public interface WxMerchantService { | |||||
| * @return | * @return | ||||
| */ | */ | ||||
| List<WxMerchant> etcpList(WxMerchant record); | List<WxMerchant> etcpList(WxMerchant record); | ||||
| /** | |||||
| * 查询商户列表 | |||||
| * @param tenantId | |||||
| * @return | |||||
| */ | |||||
| List<WxMerchantSimpleVo> findList(String tenantId); | |||||
| /** | /** | ||||
| * 根据Id获得实体 | * 根据Id获得实体 | ||||
| @@ -7,11 +7,13 @@ import com.iformall.common.IdWorker; | |||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.WxMerchantSimpleVo; | |||||
| import com.iformall.domain.vo.WxMerchantVo; | import com.iformall.domain.vo.WxMerchantVo; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.utils.BeanMapping; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -133,6 +135,14 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| return wxMerchantMapper.findList(record); | return wxMerchantMapper.findList(record); | ||||
| } | } | ||||
| @Override | |||||
| public List<WxMerchantSimpleVo> findList(String tenantId) { | |||||
| WxMerchant wxMerchant = new WxMerchant(); | |||||
| wxMerchant.setTenantId(tenantId); | |||||
| List<WxMerchant> wxMerchantList = wxMerchantMapper.findList(wxMerchant); | |||||
| return BeanMapping.mapList(wxMerchantList,WxMerchantSimpleVo.class,(s, t)->t.setMerchantName(s.getName())); | |||||
| } | |||||
| @Override | @Override | ||||
| public WxMerchant getById(Long id) { | public WxMerchant getById(Long id) { | ||||
| WxMerchant wxMerchant = wxMerchantMapper.selectByPrimaryKey(id); | WxMerchant wxMerchant = wxMerchantMapper.selectByPrimaryKey(id); | ||||
| @@ -0,0 +1,139 @@ | |||||
| package com.iformall.utils; | |||||
| import com.iformall.exception.BeanMappingException; | |||||
| import lombok.extern.slf4j.Slf4j; | |||||
| import org.dozer.DozerBeanMapper; | |||||
| import org.dozer.Mapper; | |||||
| import org.dozer.MappingException; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Collection; | |||||
| import java.util.List; | |||||
| import java.util.concurrent.locks.Lock; | |||||
| import java.util.concurrent.locks.ReentrantLock; | |||||
| import java.util.function.BiConsumer; | |||||
| /** | |||||
| * 不同类型的bean对象属性映射转化 | |||||
| * 基于Dozer封装, 对使用者透明 | |||||
| */ | |||||
| @Slf4j | |||||
| public class BeanMapping { | |||||
| private static Mapper __instance__; | |||||
| private static Lock lock = new ReentrantLock(); | |||||
| private BeanMapping() { | |||||
| } | |||||
| private static Mapper getInstance() { | |||||
| // TODO 支持XML配置或者传入映射关系 | |||||
| if (__instance__ == null) { | |||||
| lock.lock(); | |||||
| if (__instance__ == null) { | |||||
| __instance__ = new DozerBeanMapper(); | |||||
| } | |||||
| lock.unlock(); | |||||
| } | |||||
| return __instance__; | |||||
| } | |||||
| /** | |||||
| * 源对象 {@code source} 转换成目标bean对象 {@code D}; 将名称一致的属性进行转换 | |||||
| * @param source 源Bean | |||||
| * @param dstClass 目标Bean的class | |||||
| * @param <S> 原Bean的泛型定义 | |||||
| * @param <D> 目标Bean的泛型定义 | |||||
| * @return 目标Bean对象 | |||||
| */ | |||||
| public static <S, D> D map(S source, Class<D> dstClass) throws BeanMappingException { | |||||
| return map(source, dstClass, null); | |||||
| } | |||||
| /** | |||||
| * 源对象 {@code source} 转换成目标bean对象 {@code D}; 将名称一致的属性进行转换; 转换完成后进行回调后续处理 | |||||
| * @param source 源Bean | |||||
| * @param dstClass 目标Bean的class | |||||
| * @param biConsumer 目标Bean转换完成后的回调操作 | |||||
| * @param <S> 原Bean的泛型定义 | |||||
| * @param <D> 目标Bean的泛型定义 | |||||
| * @return 目标Bean对象 | |||||
| * @throws BeanMappingException | |||||
| */ | |||||
| public static <S, D> D map(S source, Class<D> dstClass, BiConsumer<S, D> biConsumer) throws BeanMappingException { | |||||
| if (source == null) { | |||||
| return null; | |||||
| } | |||||
| try { | |||||
| D dstObject = getInstance().map(source, dstClass); | |||||
| if (dstObject != null && biConsumer != null) { | |||||
| biConsumer.accept(source, dstObject); | |||||
| } | |||||
| return dstObject; | |||||
| } catch (MappingException e) { | |||||
| log.error("对象映射出错, 原对象类型: {}, 目标对象类型: {}", source.getClass(), dstClass); | |||||
| throw new BeanMappingException(e); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 源对象集合 {@code source} 转换成目标bean对象后添加到传入的集合中 {@code D}; 将名称一致的属性进行转换 | |||||
| * @param source 源对象集合 | |||||
| * @param destination 目标对象集合 | |||||
| * @param dstClass 目标Bean的class | |||||
| * @param <S> 原Bean的泛型定义 | |||||
| * @param <D> 目标Bean的泛型定义 | |||||
| * @throws BeanMappingException | |||||
| */ | |||||
| public static <S, D> void map(Collection<S> source, Collection<D> destination, Class<D> dstClass) throws BeanMappingException { | |||||
| map(source, destination, dstClass, null); | |||||
| } | |||||
| /** | |||||
| * 源对象集合 {@code source} 转换成目标bean对象后添加到传入的集合中 {@code D}; 将名称一致的属性进行转换 | |||||
| * @param source 源对象集合 | |||||
| * @param destination 目标对象集合 | |||||
| * @param dstClass 目标Bean的class | |||||
| * @param biConsumer 目标Bean转换完成后的回调操作 | |||||
| * @param <S> 原Bean的泛型定义 | |||||
| * @param <D> 目标Bean的泛型定义 | |||||
| * @throws BeanMappingException | |||||
| */ | |||||
| public static <S, D> void map(Collection<S> source, Collection<D> destination, Class<D> dstClass, BiConsumer<S, D> biConsumer) throws BeanMappingException { | |||||
| for (S s : source) { | |||||
| destination.add(map(s, dstClass, biConsumer)); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 源对象集合 {@code source} 转换成目标bean对象 {@code D}; 将名称一致的属性进行转换 | |||||
| * @param source 源对象集合 | |||||
| * @param dstClass 目标Bean的class | |||||
| * @param <S> 原Bean的泛型定义 | |||||
| * @param <D> 目标Bean的泛型定义 | |||||
| * @return 映射完的List集合, 默认返回ArrayList | |||||
| * @throws BeanMappingException | |||||
| */ | |||||
| public static <S, D> List<D> mapList(Collection<S> source, Class<D> dstClass) throws BeanMappingException { | |||||
| return mapList(source, dstClass, null); | |||||
| } | |||||
| /** | |||||
| * 源对象集合 {@code source} 转换成目标bean对象 {@code D}; 将名称一致的属性进行转换 | |||||
| * @param source 源对象集合 | |||||
| * @param dstClass 目标Bean的class | |||||
| * @param biConsumer 目标Bean转换完成后的回调操作 | |||||
| * @param <S> 原Bean的泛型定义 | |||||
| * @param <D> 目标Bean的泛型定义 | |||||
| * @return 映射完的List集合, 默认返回ArrayList | |||||
| * @throws BeanMappingException | |||||
| */ | |||||
| public static <S, D> List<D> mapList(Collection<S> source, Class<D> dstClass, BiConsumer<S, D> biConsumer) throws BeanMappingException { | |||||
| List<D> result = new ArrayList<>(); | |||||
| map(source, result, dstClass, biConsumer); | |||||
| return result; | |||||
| } | |||||
| } | |||||