Merge remote-tracking branch 'origin/1.1.0-future-UserCenter接口转移' into 1.1.0-future-UserCenter接口转移
# Conflicts: # member-service-impl/src/main/java/com/topdraw/business/process/service/impl/UserOperationServiceImpl.java
Showing
15 changed files
with
449 additions
and
0 deletions
| 1 | package com.topdraw.business.module.member.profile.repository; | 1 | package com.topdraw.business.module.member.profile.repository; |
| 2 | 2 | ||
| 3 | import com.topdraw.business.module.member.domain.Member; | ||
| 3 | import com.topdraw.business.module.member.profile.domain.MemberProfile; | 4 | import com.topdraw.business.module.member.profile.domain.MemberProfile; |
| 4 | import org.springframework.data.jpa.repository.JpaRepository; | 5 | import org.springframework.data.jpa.repository.JpaRepository; |
| 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | 6 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| ... | @@ -13,4 +14,6 @@ import java.util.Optional; | ... | @@ -13,4 +14,6 @@ import java.util.Optional; |
| 13 | public interface MemberProfileRepository extends JpaRepository<MemberProfile, Long>, JpaSpecificationExecutor<MemberProfile> { | 14 | public interface MemberProfileRepository extends JpaRepository<MemberProfile, Long>, JpaSpecificationExecutor<MemberProfile> { |
| 14 | 15 | ||
| 15 | Optional<MemberProfile> findByMemberId(Long memberId); | 16 | Optional<MemberProfile> findByMemberId(Long memberId); |
| 17 | |||
| 18 | Optional<MemberProfile> findFirstByMemberId(Long memberId); | ||
| 16 | } | 19 | } | ... | ... |
| 1 | package com.topdraw.business.module.weixin.domain; | ||
| 2 | |||
| 3 | import cn.hutool.core.bean.BeanUtil; | ||
| 4 | import cn.hutool.core.bean.copier.CopyOptions; | ||
| 5 | import lombok.Data; | ||
| 6 | import lombok.experimental.Accessors; | ||
| 7 | import org.springframework.data.annotation.CreatedDate; | ||
| 8 | import org.springframework.data.annotation.LastModifiedDate; | ||
| 9 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
| 10 | |||
| 11 | import javax.persistence.*; | ||
| 12 | import java.io.Serializable; | ||
| 13 | import java.sql.Timestamp; | ||
| 14 | |||
| 15 | /** | ||
| 16 | * @author pengmengqing | ||
| 17 | * @date 2021-01-28 | ||
| 18 | */ | ||
| 19 | @Entity | ||
| 20 | @Data | ||
| 21 | @EntityListeners(AuditingEntityListener.class) | ||
| 22 | @Accessors(chain = true) | ||
| 23 | @Table(name="uc_user_weixin__weixin_message_template") | ||
| 24 | public class UserWeixinWeixinMessageTemplate implements Serializable { | ||
| 25 | |||
| 26 | // ID | ||
| 27 | @Id | ||
| 28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| 29 | @Column(name = "id") | ||
| 30 | private Long id; | ||
| 31 | |||
| 32 | // 用户id | ||
| 33 | @Column(name = "user_weixin_id", nullable = false) | ||
| 34 | private Long userWeixinId; | ||
| 35 | |||
| 36 | // 微信消息模板id | ||
| 37 | @Column(name = "weixin_message_template_id", nullable = false) | ||
| 38 | private Long weixinMessageTemplateId; | ||
| 39 | |||
| 40 | // 用户是否订阅: 0-否, 1-是 | ||
| 41 | @Column(name = "status", nullable = false) | ||
| 42 | private Integer status; | ||
| 43 | |||
| 44 | // 创建时间 | ||
| 45 | @CreatedDate | ||
| 46 | @Column(name = "create_time") | ||
| 47 | private Timestamp createTime; | ||
| 48 | |||
| 49 | // 更新时间 | ||
| 50 | @LastModifiedDate | ||
| 51 | @Column(name = "update_time") | ||
| 52 | private Timestamp updateTime; | ||
| 53 | |||
| 54 | public void copy(UserWeixinWeixinMessageTemplate source){ | ||
| 55 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
| 56 | } | ||
| 57 | } |
| 1 | package com.topdraw.business.module.weixin.domain; | ||
| 2 | |||
| 3 | import cn.hutool.core.bean.BeanUtil; | ||
| 4 | import cn.hutool.core.bean.copier.CopyOptions; | ||
| 5 | import lombok.Data; | ||
| 6 | import lombok.experimental.Accessors; | ||
| 7 | import org.springframework.data.annotation.CreatedDate; | ||
| 8 | import org.springframework.data.annotation.LastModifiedDate; | ||
| 9 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
| 10 | |||
| 11 | import javax.persistence.*; | ||
| 12 | import java.io.Serializable; | ||
| 13 | import java.sql.Timestamp; | ||
| 14 | |||
| 15 | /** | ||
| 16 | * @author pengmengqing | ||
| 17 | * @date 2021-01-28 | ||
| 18 | */ | ||
| 19 | @Entity | ||
| 20 | @Data | ||
| 21 | @EntityListeners(AuditingEntityListener.class) | ||
| 22 | @Accessors(chain = true) | ||
| 23 | @Table(name="uc_weixin_message_template") | ||
| 24 | public class WeixinMessageTemplate implements Serializable { | ||
| 25 | |||
| 26 | // ID | ||
| 27 | @Id | ||
| 28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| 29 | @Column(name = "id") | ||
| 30 | private Long id; | ||
| 31 | |||
| 32 | // 标识 order-下单成功通知,cancellation-核销成功通知 | ||
| 33 | @Column(name = "code", nullable = false) | ||
| 34 | private String code; | ||
| 35 | |||
| 36 | // 微信appid | ||
| 37 | @Column(name = "appid", nullable = false) | ||
| 38 | private String appid; | ||
| 39 | |||
| 40 | // 微信模板id | ||
| 41 | @Column(name = "template_id", nullable = false) | ||
| 42 | private String templateId; | ||
| 43 | |||
| 44 | // 状态:0-无效,1-有效 | ||
| 45 | @Column(name = "status", nullable = false) | ||
| 46 | private Integer status; | ||
| 47 | |||
| 48 | // 描述 | ||
| 49 | @Column(name = "description") | ||
| 50 | private String description; | ||
| 51 | |||
| 52 | // 创建时间 | ||
| 53 | @CreatedDate | ||
| 54 | @Column(name = "create_time") | ||
| 55 | private Timestamp createTime; | ||
| 56 | |||
| 57 | // 更新时间 | ||
| 58 | @LastModifiedDate | ||
| 59 | @Column(name = "update_time") | ||
| 60 | private Timestamp updateTime; | ||
| 61 | |||
| 62 | public void copy(WeixinMessageTemplate source){ | ||
| 63 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
| 64 | } | ||
| 65 | } |
| 1 | package com.topdraw.business.module.weixin.repository; | ||
| 2 | |||
| 3 | import com.topdraw.business.module.weixin.domain.UserWeixinWeixinMessageTemplate; | ||
| 4 | import org.springframework.data.jpa.repository.JpaRepository; | ||
| 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
| 6 | |||
| 7 | |||
| 8 | /** | ||
| 9 | * @author pengmengqing | ||
| 10 | * @date 2021-01-28 | ||
| 11 | */ | ||
| 12 | public interface UserWeixinWeixinMessageTemplateRepository extends JpaRepository<UserWeixinWeixinMessageTemplate, Long>, JpaSpecificationExecutor<UserWeixinWeixinMessageTemplate> { | ||
| 13 | |||
| 14 | } |
| 1 | package com.topdraw.business.module.weixin.repository; | ||
| 2 | |||
| 3 | |||
| 4 | import com.topdraw.business.module.weixin.domain.WeixinMessageTemplate; | ||
| 5 | import org.springframework.data.jpa.repository.JpaRepository; | ||
| 6 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
| 7 | |||
| 8 | import java.util.Optional; | ||
| 9 | |||
| 10 | /** | ||
| 11 | * @author pengmengqing | ||
| 12 | * @date 2021-01-28 | ||
| 13 | */ | ||
| 14 | public interface WeixinMessageTemplateRepository extends JpaRepository<WeixinMessageTemplate, Long>, JpaSpecificationExecutor<WeixinMessageTemplate> { | ||
| 15 | |||
| 16 | Optional<WeixinMessageTemplate> findFirstByCode(String code); | ||
| 17 | |||
| 18 | Optional<WeixinMessageTemplate> findFirstByCodeAndAppid(String code, String appid); | ||
| 19 | |||
| 20 | Optional<WeixinMessageTemplate> findFirstByTemplateId(String templateId); | ||
| 21 | } |
| 1 | package com.topdraw.business.module.weixin.rest; | ||
| 2 | |||
| 3 | import com.topdraw.business.module.weixin.service.UserWeixinWeixinMessageTemplateService; | ||
| 4 | import com.topdraw.business.module.weixin.service.dto.UpdateUserWeixinWeixinMessageTemplateQueryCriteria; | ||
| 5 | import com.topdraw.common.ResultInfo; | ||
| 6 | import io.swagger.annotations.Api; | ||
| 7 | import io.swagger.annotations.ApiOperation; | ||
| 8 | import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | import org.springframework.web.bind.annotation.PostMapping; | ||
| 10 | import org.springframework.web.bind.annotation.RequestBody; | ||
| 11 | import org.springframework.web.bind.annotation.RequestMapping; | ||
| 12 | import org.springframework.web.bind.annotation.RestController; | ||
| 13 | |||
| 14 | import java.util.ArrayList; | ||
| 15 | |||
| 16 | /** | ||
| 17 | * @author pengmengqing | ||
| 18 | * @date 2021-01-28 | ||
| 19 | */ | ||
| 20 | @Api(tags = "UserWeixinWeixinMessageTemplate管理") | ||
| 21 | @RestController | ||
| 22 | @RequestMapping("/ucEngine/api/UserWeixinWeixinMessageTemplate") | ||
| 23 | public class UserWeixinWeixinMessageTemplateController { | ||
| 24 | |||
| 25 | @Autowired | ||
| 26 | private UserWeixinWeixinMessageTemplateService userWeixinWeixinMessageTemplateService; | ||
| 27 | |||
| 28 | |||
| 29 | @PostMapping | ||
| 30 | @ApiOperation("新增或修改MemberWeixinMessageTemplate") | ||
| 31 | public ResultInfo createOrUpdate(@RequestBody UpdateUserWeixinWeixinMessageTemplateQueryCriteria criteria) { | ||
| 32 | userWeixinWeixinMessageTemplateService.createOrUpdate(criteria); | ||
| 33 | return ResultInfo.success(new ArrayList<>()); | ||
| 34 | } | ||
| 35 | |||
| 36 | } |
| 1 | package com.topdraw.business.module.weixin.service; | ||
| 2 | |||
| 3 | |||
| 4 | import com.topdraw.business.module.weixin.domain.UserWeixinWeixinMessageTemplate; | ||
| 5 | import com.topdraw.business.module.weixin.service.dto.UpdateUserWeixinWeixinMessageTemplateQueryCriteria; | ||
| 6 | import com.topdraw.business.module.weixin.service.dto.UserWeixinWeixinMessageTemplateDTO; | ||
| 7 | import com.topdraw.business.module.weixin.service.dto.UserWeixinWeixinMessageTemplateQueryCriteria; | ||
| 8 | import org.springframework.data.domain.Pageable; | ||
| 9 | |||
| 10 | import javax.servlet.http.HttpServletResponse; | ||
| 11 | import java.io.IOException; | ||
| 12 | import java.util.List; | ||
| 13 | import java.util.Map; | ||
| 14 | |||
| 15 | /** | ||
| 16 | * @author pengmengqing | ||
| 17 | * @date 2021-01-28 | ||
| 18 | */ | ||
| 19 | public interface UserWeixinWeixinMessageTemplateService { | ||
| 20 | |||
| 21 | void createOrUpdate(UpdateUserWeixinWeixinMessageTemplateQueryCriteria criteria); | ||
| 22 | } |
| 1 | package com.topdraw.business.module.weixin.service.dto; | ||
| 2 | |||
| 3 | import lombok.Data; | ||
| 4 | |||
| 5 | import java.io.Serializable; | ||
| 6 | import java.sql.Timestamp; | ||
| 7 | |||
| 8 | |||
| 9 | /** | ||
| 10 | * @author pengmengqing | ||
| 11 | * @date 2021-01-28 | ||
| 12 | */ | ||
| 13 | @Data | ||
| 14 | public class UserWeixinWeixinMessageTemplateDTO implements Serializable { | ||
| 15 | |||
| 16 | // ID | ||
| 17 | private Long id; | ||
| 18 | |||
| 19 | // 用户id | ||
| 20 | private Long userWeixinId; | ||
| 21 | |||
| 22 | // 微信消息模板id | ||
| 23 | private Long weixinMessageTemplateId; | ||
| 24 | |||
| 25 | // 用户是否订阅: 0-否, 1-是 | ||
| 26 | private Integer status; | ||
| 27 | |||
| 28 | // 创建时间 | ||
| 29 | private Timestamp createTime; | ||
| 30 | |||
| 31 | // 更新时间 | ||
| 32 | private Timestamp updateTime; | ||
| 33 | } |
| 1 | package com.topdraw.business.module.weixin.service.dto; | ||
| 2 | |||
| 3 | import com.topdraw.annotation.Query; | ||
| 4 | import lombok.Data; | ||
| 5 | |||
| 6 | /** | ||
| 7 | * @author pengmengqing | ||
| 8 | * @date 2021-01-28 | ||
| 9 | */ | ||
| 10 | @Data | ||
| 11 | public class UserWeixinWeixinMessageTemplateQueryCriteria { | ||
| 12 | // 用户id | ||
| 13 | @Query(propName = "userWeixinId") | ||
| 14 | private Long memberId; | ||
| 15 | |||
| 16 | // 微信消息模板id | ||
| 17 | @Query | ||
| 18 | private Long weixinMessageTemplateId; | ||
| 19 | |||
| 20 | // 用户是否订阅: 0-否, 1-是 | ||
| 21 | @Query | ||
| 22 | private Integer status = 1; | ||
| 23 | |||
| 24 | private String templateId; | ||
| 25 | } |
| 1 | package com.topdraw.business.module.weixin.service.dto; | ||
| 2 | |||
| 3 | import lombok.Data; | ||
| 4 | |||
| 5 | import java.io.Serializable; | ||
| 6 | |||
| 7 | |||
| 8 | /** | ||
| 9 | * @author pengmengqing | ||
| 10 | * @date 2021-01-28 | ||
| 11 | */ | ||
| 12 | @Data | ||
| 13 | public class WeixinMessageTemplateDTO implements Serializable { | ||
| 14 | |||
| 15 | // ID | ||
| 16 | private Long id; | ||
| 17 | |||
| 18 | // 标识 order-下单成功通知,cancellation-核销成功通知 | ||
| 19 | private String code; | ||
| 20 | |||
| 21 | // 微信模板id | ||
| 22 | private String templateId; | ||
| 23 | |||
| 24 | // 描述 | ||
| 25 | private String description; | ||
| 26 | } |
| 1 | package com.topdraw.business.module.weixin.service.dto; | ||
| 2 | |||
| 3 | import com.topdraw.annotation.Query; | ||
| 4 | import lombok.Data; | ||
| 5 | |||
| 6 | import java.util.List; | ||
| 7 | |||
| 8 | /** | ||
| 9 | * @author pengmengqing | ||
| 10 | * @date 2021-01-28 | ||
| 11 | */ | ||
| 12 | @Data | ||
| 13 | public class WeixinMessageTemplateQueryCriteria{ | ||
| 14 | |||
| 15 | private String codes; | ||
| 16 | |||
| 17 | @Query(propName = "code", type = Query.Type.IN) | ||
| 18 | private List<String> codeList; | ||
| 19 | |||
| 20 | @Query | ||
| 21 | private String appid; | ||
| 22 | |||
| 23 | @Query | ||
| 24 | private Integer status = 1; | ||
| 25 | } |
| 1 | package com.topdraw.business.module.weixin.service.impl; | ||
| 2 | |||
| 3 | |||
| 4 | import com.topdraw.business.module.weixin.domain.UserWeixinWeixinMessageTemplate; | ||
| 5 | import com.topdraw.business.module.weixin.domain.WeixinMessageTemplate; | ||
| 6 | import com.topdraw.business.module.weixin.repository.UserWeixinWeixinMessageTemplateRepository; | ||
| 7 | import com.topdraw.business.module.weixin.repository.WeixinMessageTemplateRepository; | ||
| 8 | import com.topdraw.business.module.weixin.service.UserWeixinWeixinMessageTemplateService; | ||
| 9 | import com.topdraw.business.module.weixin.service.dto.UpdateUserWeixinWeixinMessageTemplateQueryCriteria; | ||
| 10 | import com.topdraw.business.module.weixin.service.dto.UserWeixinWeixinMessageTemplateDTO; | ||
| 11 | import com.topdraw.business.module.weixin.service.dto.UserWeixinWeixinMessageTemplateQueryCriteria; | ||
| 12 | import com.topdraw.business.module.weixin.service.mapper.UserWeixinWeixinMessageTemplateMapper; | ||
| 13 | import com.topdraw.utils.FileUtil; | ||
| 14 | import com.topdraw.utils.PageUtil; | ||
| 15 | import com.topdraw.utils.QueryHelp; | ||
| 16 | import com.topdraw.utils.ValidationUtil; | ||
| 17 | import lombok.extern.slf4j.Slf4j; | ||
| 18 | import org.springframework.beans.factory.annotation.Autowired; | ||
| 19 | import org.springframework.dao.EmptyResultDataAccessException; | ||
| 20 | import org.springframework.data.domain.Page; | ||
| 21 | import org.springframework.data.domain.Pageable; | ||
| 22 | import org.springframework.stereotype.Service; | ||
| 23 | import org.springframework.transaction.annotation.Propagation; | ||
| 24 | import org.springframework.transaction.annotation.Transactional; | ||
| 25 | import org.springframework.util.Assert; | ||
| 26 | |||
| 27 | import javax.servlet.http.HttpServletResponse; | ||
| 28 | import java.io.IOException; | ||
| 29 | import java.util.*; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * @author pengmengqing | ||
| 33 | * @date 2021-01-28 | ||
| 34 | */ | ||
| 35 | @Service | ||
| 36 | @Slf4j | ||
| 37 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
| 38 | public class UserWeixinWeixinMessageTemplateServiceImpl implements UserWeixinWeixinMessageTemplateService { | ||
| 39 | |||
| 40 | @Autowired | ||
| 41 | private UserWeixinWeixinMessageTemplateRepository userWeixinWeixinMessageTemplateRepository; | ||
| 42 | |||
| 43 | @Autowired | ||
| 44 | private WeixinMessageTemplateRepository weixinMessageTemplateRepository; | ||
| 45 | |||
| 46 | @Override | ||
| 47 | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = Exception.class) | ||
| 48 | public void createOrUpdate(UpdateUserWeixinWeixinMessageTemplateQueryCriteria criteria) { | ||
| 49 | for (UserWeixinWeixinMessageTemplateQueryCriteria queryCriteria : criteria.getTemplateList()) { | ||
| 50 | queryCriteria.setMemberId(criteria.getMemberId()); | ||
| 51 | Integer status = queryCriteria.getStatus(); | ||
| 52 | queryCriteria.setStatus(null); | ||
| 53 | String templateId = queryCriteria.getTemplateId(); | ||
| 54 | Optional<WeixinMessageTemplate> templateOptional = weixinMessageTemplateRepository.findFirstByTemplateId(templateId); | ||
| 55 | if (!templateOptional.isPresent()) { | ||
| 56 | log.info("template " + templateId + " not exist"); | ||
| 57 | continue; | ||
| 58 | } | ||
| 59 | Long id = templateOptional.get().getId(); | ||
| 60 | queryCriteria.setWeixinMessageTemplateId(id); | ||
| 61 | Optional<UserWeixinWeixinMessageTemplate> optional = userWeixinWeixinMessageTemplateRepository.findOne(((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, queryCriteria, criteriaBuilder))); | ||
| 62 | if (!optional.isPresent()) { | ||
| 63 | UserWeixinWeixinMessageTemplate userWeixinWeixinMessageTemplate = new UserWeixinWeixinMessageTemplate(); | ||
| 64 | userWeixinWeixinMessageTemplate.setUserWeixinId(queryCriteria.getMemberId()) | ||
| 65 | .setWeixinMessageTemplateId(queryCriteria.getWeixinMessageTemplateId()) | ||
| 66 | .setStatus(status); | ||
| 67 | userWeixinWeixinMessageTemplateRepository.save(userWeixinWeixinMessageTemplate); | ||
| 68 | } else { | ||
| 69 | UserWeixinWeixinMessageTemplate UserWeixinWeixinMessageTemplate = optional.get(); | ||
| 70 | if (!status.equals(UserWeixinWeixinMessageTemplate.getStatus())) { | ||
| 71 | UserWeixinWeixinMessageTemplate.setStatus(status); | ||
| 72 | userWeixinWeixinMessageTemplateRepository.save(UserWeixinWeixinMessageTemplate); | ||
| 73 | } | ||
| 74 | } | ||
| 75 | } | ||
| 76 | } | ||
| 77 | } |
| 1 | package com.topdraw.business.module.weixin.service.mapper; | ||
| 2 | |||
| 3 | import com.topdraw.base.BaseMapper; | ||
| 4 | import com.topdraw.business.module.weixin.domain.UserWeixinWeixinMessageTemplate; | ||
| 5 | import com.topdraw.business.module.weixin.service.dto.UserWeixinWeixinMessageTemplateDTO; | ||
| 6 | import org.mapstruct.Mapper; | ||
| 7 | import org.mapstruct.ReportingPolicy; | ||
| 8 | |||
| 9 | /** | ||
| 10 | * @author pengmengqing | ||
| 11 | * @date 2021-01-28 | ||
| 12 | */ | ||
| 13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
| 14 | public interface UserWeixinWeixinMessageTemplateMapper extends BaseMapper<UserWeixinWeixinMessageTemplateDTO, UserWeixinWeixinMessageTemplate> { | ||
| 15 | |||
| 16 | } |
| 1 | package com.topdraw.business.module.weixin.service.mapper; | ||
| 2 | |||
| 3 | import com.topdraw.base.BaseMapper; | ||
| 4 | import com.topdraw.business.module.weixin.domain.WeixinMessageTemplate; | ||
| 5 | import com.topdraw.business.module.weixin.service.dto.WeixinMessageTemplateDTO; | ||
| 6 | import org.mapstruct.Mapper; | ||
| 7 | import org.mapstruct.ReportingPolicy; | ||
| 8 | |||
| 9 | /** | ||
| 10 | * @author pengmengqing | ||
| 11 | * @date 2021-01-28 | ||
| 12 | */ | ||
| 13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
| 14 | public interface WeixinMessageTemplateMapper extends BaseMapper<WeixinMessageTemplateDTO, WeixinMessageTemplate> { | ||
| 15 | |||
| 16 | } |
-
Please register or sign in to post a comment