Commit 7c7d4f22 7c7d4f22beb44ee3a88fb8ef302bec95c9fd9289 by xianghan@topdraw.cn

1.接口优化,删除不必要的接口

1 parent 5f40ee67
Showing 38 changed files with 0 additions and 979 deletions
......@@ -58,14 +58,12 @@ public class CouponHistoryServiceImpl implements CouponHistoryService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void create(CouponHistory resources) {
CouponHistoryRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void update(CouponHistory resources) {
CouponHistory CouponHistory = CouponHistoryRepository.findById(resources.getId()).orElseGet(CouponHistory::new);
ValidationUtil.isNull( CouponHistory.getId(),"CouponHistory","id",resources.getId());
......
......@@ -3,9 +3,7 @@ package com.topdraw.business.module.coupon.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.business.module.coupon.domain.Coupon;
import com.topdraw.business.module.coupon.service.CouponService;
import com.topdraw.business.module.coupon.service.dto.CouponQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
......@@ -22,18 +20,6 @@ public class CouponController {
@Autowired
private CouponService CouponService;
@GetMapping
@ApiOperation("查询Coupon")
public ResultInfo getCoupons(CouponQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(CouponService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有Coupon")
public ResultInfo getCoupons(CouponQueryCriteria criteria) {
return ResultInfo.success(CouponService.queryAll(criteria));
}
@PostMapping(value = "/create")
@ApiOperation("新增Coupon")
public ResultInfo create(@Validated @RequestBody Coupon resources) {
......
......@@ -12,22 +12,6 @@ import java.util.List;
* @date 2021-10-22
*/
public interface CouponService {
/**
* 查询数据分页
* @param criteria 条件参数
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(CouponQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<CouponDTO>
*/
List<CouponDTO> queryAll(CouponQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
......
package com.topdraw.business.module.coupon.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.coupon.domain.Coupon;
import com.topdraw.util.RedissonUtil;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.module.coupon.repository.CouponRepository;
import com.topdraw.business.module.coupon.service.CouponService;
import com.topdraw.business.module.coupon.service.dto.CouponDTO;
import com.topdraw.business.module.coupon.service.dto.CouponQueryCriteria;
import com.topdraw.business.module.coupon.service.mapper.CouponMapper;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
......@@ -16,15 +14,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.StringUtils;
import java.util.List;
import java.util.Map;
/**
* @author XiangHan
......@@ -44,17 +36,6 @@ public class CouponServiceImpl implements CouponService {
private RedissonClient redissonClient;
@Override
public Map<String, Object> queryAll(CouponQueryCriteria criteria, Pageable pageable) {
Page<Coupon> page = CouponRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(CouponMapper::toDto));
}
@Override
public List<CouponDTO> queryAll(CouponQueryCriteria criteria) {
return CouponMapper.toDto(CouponRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
public CouponDTO findById(Long id) {
Coupon Coupon = CouponRepository.findById(id).orElseGet(Coupon::new);
ValidationUtil.isNull(Coupon.getId(),"Coupon","id",id);
......@@ -63,14 +44,12 @@ public class CouponServiceImpl implements CouponService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void create(Coupon resources) {
CouponRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void update(Coupon resources) {
RLock rLock = this.redissonClient.getLock(resources.getId().toString());
try {
......@@ -89,7 +68,6 @@ public class CouponServiceImpl implements CouponService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
Coupon Coupon = CouponRepository.findById(id).orElseThrow(
......@@ -97,7 +75,6 @@ public class CouponServiceImpl implements CouponService {
CouponRepository.delete(Coupon);
}
@Override
public CouponDTO getByCode(String code) {
return StringUtils.isNotEmpty(code) ? CouponMapper.toDto(CouponRepository.findFirstByCode(code).orElseGet(Coupon::new))
......
package com.topdraw.business.module.exp.detail.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.exp.detail.domain.ExpDetail;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.module.exp.detail.repository.ExpDetailRepository;
......@@ -62,14 +61,12 @@ public class ExpDetailServiceImpl implements ExpDetailService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void create(ExpDetail resources) {
ExpDetailRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void update(ExpDetail resources) {
RLock rLock = this.redissonClient.getLock(resources.getId().toString());
try {
......@@ -87,7 +84,6 @@ public class ExpDetailServiceImpl implements ExpDetailService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
ExpDetail ExpDetail = ExpDetailRepository.findById(id).orElseThrow(
......@@ -95,7 +91,6 @@ public class ExpDetailServiceImpl implements ExpDetailService {
ExpDetailRepository.delete(ExpDetail);
}
@Override
public ExpDetailDTO getByCode(String code) {
return StringUtils.isNotEmpty(code) ? ExpDetailMapper.toDto(ExpDetailRepository.findFirstByCode(code).orElseGet(ExpDetail::new))
......
package com.topdraw.business.module.exp.history.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.business.module.exp.history.service.ExpHistoryService;
import com.topdraw.business.module.exp.history.service.dto.ExpHistoryQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Api(tags = "ExpHistory管理")
@RestController
@RequestMapping("/api/ExpHistory")
public class ExpHistoryController {
@Autowired
private ExpHistoryService ExpHistoryService;
@GetMapping
@ApiOperation("查询ExpHistory")
public ResultInfo getExpHistorys(ExpHistoryQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(ExpHistoryService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有ExpHistory")
public ResultInfo getExpHistorys(ExpHistoryQueryCriteria criteria) {
return ResultInfo.success(ExpHistoryService.queryAll(criteria));
}
@GetMapping(value = "/getByCode/{code}")
@ApiOperation(value = "根据标识查询")
public ResultInfo getByCode(@PathVariable String code) {
return ResultInfo.success(ExpHistoryService.getByCode(code));
}
}
......@@ -12,22 +12,6 @@ import java.util.List;
* @date 2021-10-22
*/
public interface ExpHistoryService {
/**
* 查询数据分页
* @param criteria 条件参数
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(ExpHistoryQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<ExpHistoryDTO>
*/
List<ExpHistoryDTO> queryAll(ExpHistoryQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
......
package com.topdraw.business.module.exp.history.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.exp.history.domain.ExpHistory;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.module.exp.history.repository.ExpHistoryRepository;
import com.topdraw.business.module.exp.history.service.ExpHistoryService;
import com.topdraw.business.module.exp.history.service.dto.ExpHistoryDTO;
import com.topdraw.business.module.exp.history.service.dto.ExpHistoryQueryCriteria;
import com.topdraw.business.module.exp.history.service.mapper.ExpHistoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.StringUtils;
import java.util.List;
import java.util.Map;
/**
* @author XiangHan
......@@ -38,17 +30,6 @@ public class ExpHistoryServiceImpl implements ExpHistoryService {
private ExpHistoryMapper ExpHistoryMapper;
@Override
public Map<String, Object> queryAll(ExpHistoryQueryCriteria criteria, Pageable pageable) {
Page<ExpHistory> page = ExpHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(ExpHistoryMapper::toDto));
}
@Override
public List<ExpHistoryDTO> queryAll(ExpHistoryQueryCriteria criteria) {
return ExpHistoryMapper.toDto(ExpHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
public ExpHistoryDTO findById(Long id) {
ExpHistory ExpHistory = ExpHistoryRepository.findById(id).orElseGet(ExpHistory::new);
ValidationUtil.isNull(ExpHistory.getId(),"ExpHistory","id",id);
......@@ -57,14 +38,12 @@ public class ExpHistoryServiceImpl implements ExpHistoryService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void create(ExpHistory resources) {
ExpHistoryRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void update(ExpHistory resources) {
ExpHistory ExpHistory = ExpHistoryRepository.findById(resources.getId()).orElseGet(ExpHistory::new);
ValidationUtil.isNull( ExpHistory.getId(),"ExpHistory","id",resources.getId());
......@@ -74,7 +53,6 @@ public class ExpHistoryServiceImpl implements ExpHistoryService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
ExpHistory ExpHistory = ExpHistoryRepository.findById(id).orElseThrow(
......@@ -82,7 +60,6 @@ public class ExpHistoryServiceImpl implements ExpHistoryService {
ExpHistoryRepository.delete(ExpHistory);
}
@Override
public ExpHistoryDTO getByCode(String code) {
return StringUtils.isNotEmpty(code) ? ExpHistoryMapper.toDto(ExpHistoryRepository.findFirstByCode(code).orElseGet(ExpHistory::new))
......
......@@ -50,7 +50,6 @@ public class MemberAddressServiceImpl implements MemberAddressService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void create(MemberAddress resources) {
log.info("MemberAddressServiceImpl ==>> create ==>> param ==>> [{}]",resources);
MemberDTO memberDTO = this.checkMember(resources);
......@@ -61,7 +60,6 @@ public class MemberAddressServiceImpl implements MemberAddressService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void update(MemberAddress resources) {
log.info("MemberAddressServiceImpl ==>> update ==>> param ==>> [{}]",resources);
Assert.notNull(resources.getId(),"id can't be null");
......@@ -87,7 +85,6 @@ public class MemberAddressServiceImpl implements MemberAddressService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
MemberAddress MemberAddress = this.memberAddressRepository.findById(id).orElseThrow(
......
......@@ -70,7 +70,6 @@ public class MemberProfileServiceImpl implements MemberProfileService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public MemberProfile create(MemberProfile resources) {
log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources);
......@@ -111,7 +110,6 @@ public class MemberProfileServiceImpl implements MemberProfileService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void update(MemberProfile resources) {
log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources);
......@@ -143,7 +141,6 @@ public class MemberProfileServiceImpl implements MemberProfileService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
MemberProfile MemberProfile = this.memberProfileRepository.findById(id).orElseThrow(
......@@ -158,19 +155,6 @@ public class MemberProfileServiceImpl implements MemberProfileService {
this.update(resources);
}
/**
* 同步会员信息
* @param nickName
* @param gender
* @param birthday
* @param avatarUrl
* @param member
*/
private void synchronizedMemberData(String nickName , Integer gender , String birthday,
String avatarUrl,Member member) {
this.synchronizedMemberData(nickName,gender,birthday,avatarUrl,member.getId(),member.getCode());
}
private void synchronizedMemberData(String nickName , Integer gender , String birthday,
String avatarUrl,Long memberId,String memberCode) {
MemberProfile memberProfile = new MemberProfile();
......
......@@ -69,7 +69,6 @@ public class PointsAvailableServiceImpl implements PointsAvailableService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend
public void create(PointsAvailable resources) {
RLock rLock = this.redissonClient.getLock("PointsAvailable::create::id"+resources.getMemberId().toString());
try {
......
......@@ -58,7 +58,6 @@ public class PointsDetailServiceImpl implements PointsDetailService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend
public void create(PointsDetail resources) {
PointsDetailRepository.save(resources);
}
......
......@@ -64,7 +64,6 @@ public class PointsServiceImpl implements PointsService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void create(Points resources) {
Snowflake snowflake = IdUtil.createSnowflake(1, 1);
resources.setId(snowflake.nextId());
......@@ -73,7 +72,6 @@ public class PointsServiceImpl implements PointsService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void update(Points resources) {
RLock rLock = this.redissonClient.getLock(resources.getId().toString());
try {
......@@ -92,7 +90,6 @@ public class PointsServiceImpl implements PointsService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
Points Points = PointsRepository.findById(id).orElseThrow(
......
package com.topdraw.business.module.points.standingbook.domain;
import lombok.Data;
import lombok.experimental.Accessors;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @author XiangHan
* @date 2021-10-29
*/
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="uc_points_standing_book")
public class PointsStandingBook implements Serializable {
// 主键
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 积分生产
@Column(name = "points_produce", nullable = false)
private Long pointsProduce;
// 积分消耗
@Column(name = "points_consume", nullable = false)
private Long pointsConsume;
// 可用总积分
@Column(name = "points_available", nullable = false)
private Long pointsAvailable;
// 积分过期
@Column(name = "points_expire", nullable = false)
private Long pointsExpire;
// 日期
@Column(name = "day")
private String day;
// 创建时间
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 创建时间
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
public void copy(PointsStandingBook source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}
package com.topdraw.business.module.points.standingbook.repository;
import com.topdraw.business.module.points.standingbook.domain.PointsStandingBook;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author XiangHan
* @date 2021-10-29
*/
public interface PointsStandingBookRepository extends JpaRepository<PointsStandingBook, Long>, JpaSpecificationExecutor<PointsStandingBook> {
}
package com.topdraw.business.module.points.standingbook.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.business.module.points.standingbook.domain.PointsStandingBook;
import com.topdraw.business.module.points.standingbook.service.PointsStandingBookService;
import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
/**
* @author XiangHan
* @date 2021-10-29
*/
@Api(tags = "PointsStandingBook管理")
@RestController
@RequestMapping("/api/PointsStandingBook")
public class PointsStandingBookController {
@Autowired
private PointsStandingBookService PointsStandingBookService;
@GetMapping
@ApiOperation("查询PointsStandingBook")
public ResultInfo getPointsStandingBooks(PointsStandingBookQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(PointsStandingBookService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有PointsStandingBook")
public ResultInfo getPointsStandingBooks(PointsStandingBookQueryCriteria criteria) {
return ResultInfo.success(PointsStandingBookService.queryAll(criteria));
}
@PostMapping
@ApiOperation("新增PointsStandingBook")
public ResultInfo create(@Validated @RequestBody PointsStandingBook resources) {
PointsStandingBookService.create(resources);
return ResultInfo.success();
}
@PutMapping
@ApiOperation("修改PointsStandingBook")
public ResultInfo update(@Validated @RequestBody PointsStandingBook resources) {
PointsStandingBookService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/{id}")
@ApiOperation("删除PointsStandingBook")
public ResultInfo delete(@PathVariable Long id) {
PointsStandingBookService.delete(id);
return ResultInfo.success();
}
}
package com.topdraw.business.module.points.standingbook.service;
import com.topdraw.business.module.points.standingbook.domain.PointsStandingBook;
import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookDTO;
import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
/**
* @author XiangHan
* @date 2021-10-29
*/
public interface PointsStandingBookService {
/**
* 查询数据分页
* @param criteria 条件参数
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(PointsStandingBookQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<PointsStandingBookDTO>
*/
List<PointsStandingBookDTO> queryAll(PointsStandingBookQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
* @return PointsStandingBookDTO
*/
PointsStandingBookDTO findById(Long id);
void create(PointsStandingBook resources);
void update(PointsStandingBook resources);
void delete(Long id);
}
package com.topdraw.business.module.points.standingbook.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @author XiangHan
* @date 2021-10-29
*/
@Data
public class PointsStandingBookDTO implements Serializable {
// 主键
private Long id;
// 积分生产
private Long pointsProduce;
// 积分消耗
private Long pointsConsume;
// 可用总积分
private Long pointsAvailable;
// 积分过期
private Long pointsExpire;
// 日期
private String day;
// 创建时间
private Timestamp createTime;
// 创建时间
private Timestamp updateTime;
}
package com.topdraw.business.module.points.standingbook.service.dto;
import lombok.Data;
/**
* @author XiangHan
* @date 2021-10-29
*/
@Data
public class PointsStandingBookQueryCriteria{
}
package com.topdraw.business.module.points.standingbook.service.impl;
import com.topdraw.business.module.points.standingbook.domain.PointsStandingBook;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.module.points.standingbook.repository.PointsStandingBookRepository;
import com.topdraw.business.module.points.standingbook.service.PointsStandingBookService;
import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookDTO;
import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookQueryCriteria;
import com.topdraw.business.module.points.standingbook.service.mapper.PointsStandingBookMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import java.util.List;
import java.util.Map;
/**
* @author XiangHan
* @date 2021-10-29
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class PointsStandingBookServiceImpl implements PointsStandingBookService {
@Autowired
private PointsStandingBookRepository PointsStandingBookRepository;
@Autowired
private PointsStandingBookMapper PointsStandingBookMapper;
@Override
public Map<String, Object> queryAll(PointsStandingBookQueryCriteria criteria, Pageable pageable) {
Page<PointsStandingBook> page = PointsStandingBookRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(PointsStandingBookMapper::toDto));
}
@Override
public List<PointsStandingBookDTO> queryAll(PointsStandingBookQueryCriteria criteria) {
return PointsStandingBookMapper.toDto(PointsStandingBookRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
public PointsStandingBookDTO findById(Long id) {
PointsStandingBook PointsStandingBook = PointsStandingBookRepository.findById(id).orElseGet(PointsStandingBook::new);
ValidationUtil.isNull(PointsStandingBook.getId(),"PointsStandingBook","id",id);
return PointsStandingBookMapper.toDto(PointsStandingBook);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(PointsStandingBook resources) {
PointsStandingBookRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(PointsStandingBook resources) {
PointsStandingBook PointsStandingBook = PointsStandingBookRepository.findById(resources.getId()).orElseGet(PointsStandingBook::new);
ValidationUtil.isNull( PointsStandingBook.getId(),"PointsStandingBook","id",resources.getId());
PointsStandingBook.copy(resources);
PointsStandingBookRepository.save(PointsStandingBook);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
PointsStandingBook PointsStandingBook = PointsStandingBookRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsStandingBook.class, id), 1));
PointsStandingBookRepository.delete(PointsStandingBook);
}
}
package com.topdraw.business.module.points.standingbook.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.module.points.standingbook.domain.PointsStandingBook;
import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author XiangHan
* @date 2021-10-29
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface PointsStandingBookMapper extends BaseMapper<PointsStandingBookDTO, PointsStandingBook> {
}
package com.topdraw.business.module.rights.history.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.business.module.rights.history.service.RightsHistoryService;
import com.topdraw.business.module.rights.history.service.dto.RightsHistoryQueryCriteria;
import com.topdraw.util.TimestampUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Api(tags = "RightsHistory管理")
@RestController
@RequestMapping("/api/RightsHistory")
public class RightsHistoryController {
@Autowired
private RightsHistoryService RightsHistoryService;
@GetMapping(value = "/pageRightsHistory")
@ApiOperation("查询RightsHistory")
public ResultInfo pageRightsHistory(RightsHistoryQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(RightsHistoryService.queryAll(criteria,pageable));
}
@GetMapping(value = "/pageAvailableRights")
@ApiOperation("查询用户可用权益列表")
public ResultInfo pageAvailableRights(RightsHistoryQueryCriteria criteria, Pageable pageable) {
criteria.setExpireTime(TimestampUtil.now());
return ResultInfo.successPage(RightsHistoryService.queryAll(criteria,pageable));
}
}
......@@ -14,21 +14,6 @@ import java.util.List;
public interface RightsHistoryService {
/**
* 查询数据分页
* @param criteria 条件参数
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(RightsHistoryQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<RightsHistoryDTO>
*/
List<RightsHistoryDTO> queryAll(RightsHistoryQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
* @return RightsHistoryDTO
......
package com.topdraw.business.module.rights.history.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.rights.history.domain.RightsHistory;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.module.rights.history.repository.RightsHistoryRepository;
......@@ -13,14 +12,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import java.util.List;
import java.util.Map;
/**
* @author XiangHan
......@@ -37,17 +29,6 @@ public class RightsHistoryServiceImpl implements RightsHistoryService {
private RightsHistoryMapper RightsHistoryMapper;
@Override
public Map<String, Object> queryAll(RightsHistoryQueryCriteria criteria, Pageable pageable) {
Page<RightsHistory> page = RightsHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(RightsHistoryMapper::toDto));
}
@Override
public List<RightsHistoryDTO> queryAll(RightsHistoryQueryCriteria criteria) {
return RightsHistoryMapper.toDto(RightsHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
public RightsHistoryDTO findById(Long id) {
RightsHistory RightsHistory = RightsHistoryRepository.findById(id).orElseGet(RightsHistory::new);
ValidationUtil.isNull(RightsHistory.getId(),"RightsHistory","id",id);
......@@ -56,14 +37,12 @@ public class RightsHistoryServiceImpl implements RightsHistoryService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void create(RightsHistory resources) {
RightsHistoryRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void update(RightsHistory resources) {
RightsHistory RightsHistory = RightsHistoryRepository.findById(resources.getId()).orElseGet(RightsHistory::new);
ValidationUtil.isNull(RightsHistory.getId(),"RightsHistory","id",resources.getId());
......@@ -73,7 +52,6 @@ public class RightsHistoryServiceImpl implements RightsHistoryService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
RightsHistory RightsHistory = RightsHistoryRepository.findById(id).orElseThrow(
......
......@@ -56,14 +56,12 @@ public class PermanentRightsServiceImpl implements PermanentRightsService {
@Override
@Transactional(rollbackFor = Exception.class)
// @AsyncMqSend()
public void create(PermanentRights resources) {
PermanentRightsRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
// @AsyncMqSend()
public void update(PermanentRights resources) {
PermanentRights PermanentRights = PermanentRightsRepository.findById(resources.getId()).orElseGet(PermanentRights::new);
ValidationUtil.isNull( PermanentRights.getId(),"PermanentRights","id",resources.getId());
......
......@@ -69,14 +69,12 @@ public class RightsServiceImpl implements RightsService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void create(Rights resources) {
RightsRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void update(Rights resources) {
RLock rLock = this.redissonClient.getLock(resources.getId().toString());
try {
......@@ -94,7 +92,6 @@ public class RightsServiceImpl implements RightsService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
Rights Rights = RightsRepository.findById(id).orElseThrow(
......
package com.topdraw.business.module.task.attribute.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.business.module.task.attribute.domain.TaskAttr;
import com.topdraw.business.module.task.attribute.service.TaskAttrService;
import com.topdraw.business.module.task.attribute.service.dto.TaskAttrQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author XiangHan
* @date 2022-01-13
*/
@Api(tags = "TaskAttr管理")
@RestController
@RequestMapping("/api/TaskAttr")
public class TaskAttrController {
@Autowired
private TaskAttrService TaskAttrService;
@GetMapping
@ApiOperation("查询TaskAttr")
public ResultInfo getTaskAttrs(TaskAttrQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(TaskAttrService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有TaskAttr")
public ResultInfo getTaskAttrs(TaskAttrQueryCriteria criteria) {
return ResultInfo.success(TaskAttrService.queryAll(criteria));
}
@PostMapping
@ApiOperation("新增TaskAttr")
public ResultInfo create(@Validated @RequestBody TaskAttr resources) {
TaskAttrService.create(resources);
return ResultInfo.success();
}
@PutMapping
@ApiOperation("修改TaskAttr")
public ResultInfo update(@Validated @RequestBody TaskAttr resources) {
TaskAttrService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/{id}")
@ApiOperation("删除TaskAttr")
public ResultInfo delete(@PathVariable Long id) {
TaskAttrService.delete(id);
return ResultInfo.success();
}
}
......@@ -2,34 +2,12 @@ package com.topdraw.business.module.task.attribute.service;
import com.topdraw.business.module.task.attribute.domain.TaskAttr;
import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO;
import com.topdraw.business.module.task.attribute.service.dto.TaskAttrQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author XiangHan
* @date 2022-01-13
*/
public interface TaskAttrService {
/**
* 查询数据分页
* @param criteria 条件参数
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(TaskAttrQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<TaskAttrDTO>
*/
List<TaskAttrDTO> queryAll(TaskAttrQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
......
......@@ -2,30 +2,16 @@ package com.topdraw.business.module.task.attribute.service.impl;
import com.topdraw.business.module.task.attribute.domain.TaskAttr;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.utils.FileUtil;
import com.topdraw.business.module.task.attribute.repository.TaskAttrRepository;
import com.topdraw.business.module.task.attribute.service.TaskAttrService;
import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO;
import com.topdraw.business.module.task.attribute.service.dto.TaskAttrQueryCriteria;
import com.topdraw.business.module.task.attribute.service.mapper.TaskAttrMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.StringUtils;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @author XiangHan
......@@ -42,17 +28,6 @@ public class TaskAttrServiceImpl implements TaskAttrService {
private TaskAttrMapper TaskAttrMapper;
@Override
public Map<String, Object> queryAll(TaskAttrQueryCriteria criteria, Pageable pageable) {
Page<TaskAttr> page = TaskAttrRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(TaskAttrMapper::toDto));
}
@Override
public List<TaskAttrDTO> queryAll(TaskAttrQueryCriteria criteria) {
return TaskAttrMapper.toDto(TaskAttrRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
public TaskAttrDTO findById(Long id) {
TaskAttr TaskAttr = TaskAttrRepository.findById(id).orElseGet(TaskAttr::new);
ValidationUtil.isNull(TaskAttr.getId(),"TaskAttr","id",id);
......
......@@ -38,7 +38,6 @@ public class UserWeixinServiceImpl implements UserWeixinService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend
public UserWeixin create(UserWeixin resources) {
UserWeixin build = UserWeixinBuilder.build(resources);
UserWeixinRepository.save(build);
......@@ -47,7 +46,6 @@ public class UserWeixinServiceImpl implements UserWeixinService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend
public void update(UserWeixin resources) {
UserWeixin UserWeixin = UserWeixinRepository.findById(resources.getId()).orElseGet(UserWeixin::new);
ValidationUtil.isNull( UserWeixin.getId(),"UserWeixin","id",resources.getId());
......@@ -56,7 +54,6 @@ public class UserWeixinServiceImpl implements UserWeixinService {
}
@Override
@AsyncMqSend
public void updateTime(UserWeixin resources) {
UserWeixinRepository.updateTime(resources);
}
......
......@@ -33,22 +33,6 @@ public class RightsOperationController {
/**
*
* @param criteria
* @param pageable
* @return
*/
@GetMapping
@ApiOperation("查询RightsHistory")
public ResultInfo queryRightsHistory(RightsHistoryQueryCriteria criteria, Pageable pageable) {
RightsHistoryQueryType queryType = criteria.getQueryType();
if (queryType == RightsHistoryQueryType.AVAILABLE_ONLY) {
criteria.setExpireTime(TimestampUtil.now());
}
return ResultInfo.successPage(rightsHistoryService.queryAll(criteria,pageable));
}
/**
*
* @param id
* @return
*/
......
package com.topdraw.weixin.beans;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.exception.BadRequestException;
import com.topdraw.utils.StringUtils;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Date;
import java.util.UUID;
@Data
@Component
public class DefaultWeiXinBeanDefinition implements WeiXinBeanDefinition {
//
private String appid;
private String openId;
private String code;
private String token;
private String secret;
private String unionId;
private String nickname;
private String headImgUrl;
private JSONObject userInfo;
private String phoneNumber;
@Value("${file.upload:upload}")
private String filePath;
public DefaultWeiXinBeanDefinition() {
}
public DefaultWeiXinBeanDefinition(String appId, String code,String unionId,String openId, JSONObject userInfoWxJo,String phone) {
this.userInfo = userInfoWxJo;
if (userInfo != null) {
if (StringUtils.isNotBlank(userInfoWxJo.getString("unionId"))) {
unionId = userInfoWxJo.getString("unionId");
}
if (StringUtils.isNotBlank(userInfoWxJo.getString("openId"))) {
openId = userInfoWxJo.getString("openId");
}
headImgUrl = userInfoWxJo.getString("avatarUrl");
if (StringUtils.isNotBlank(userInfoWxJo.getString("nickName"))) {
nickname = Base64.getEncoder().encodeToString(userInfoWxJo.getString("nickName").getBytes(StandardCharsets.UTF_8));
}
String phoneNumber = userInfoWxJo.getString("phoneNumber");
if (StringUtils.isBlank(phoneNumber)) {
throw new BadRequestException("phoneNumber is null...");
}
this.phoneNumber = phoneNumber;
if (StringUtils.isNotBlank(headImgUrl)) {
new Thread(() -> {
String s = UUID.randomUUID().toString();
File file = new File(System.getProperty("user.dir") + "/" + filePath + "/icon/" + DateUtil.format(new Date(), "yyyy-MM-dd"));
if (!file.exists()) {
file.mkdirs();
}
HttpUtil.downloadFile(headImgUrl, new File(System.getProperty("user.dir") + "/" + filePath + "/icon/" + DateUtil.format(new Date(), "yyyy-MM-dd") + "/" + s + ".jpg"));
headImgUrl = filePath + "/icon/" + DateUtil.format(new Date(), "yyyy-MM-dd") + "/" + s + ".jpg";
}).start();
}
}
this.unionId = unionId;
this.phoneNumber = phone;
this.openId = openId;
this.appid = appId;
this.code = code;
}
@Override
public String getAppId() {
return this.appid;
}
@Override
public String getCode() {
return this.code;
}
@Override
public String getToken() {
return this.token;
}
@Override
public String getSecret() {
return this.secret;
}
@Override
public String getOpenId() {
return this.openId;
}
@Override
public String getUnionId() {
return this.unionId;
}
@Override
public String getNickname() {
return this.nickname;
}
@Override
public String getHeadImgUrl() {
return this.headImgUrl;
}
@Override
public JSONObject getUserInfo() {
return this.userInfo;
}
}
package com.topdraw.weixin.beans;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class WeiXinBean {
//
private String appid;
private String openId;
private String code;
private String token;
private String secret;
private String unionId;
private String nickname;
private String headImgUrl;
}
package com.topdraw.weixin.beans;
import com.alibaba.fastjson.JSONObject;
public interface WeiXinBeanDefinition {
String getAppId();
String getCode();
String getToken();
String getSecret();
String getOpenId();
String getUnionId();
String getNickname();
String getHeadImgUrl();
JSONObject getUserInfo();
}
package com.topdraw.weixin.beans;
import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
public interface WeiXinUserParser {
DefaultWeiXinBeanDefinition parse(WeiXinUserBean appletUserLoginInfo);
}
package com.topdraw.weixin.beans.config;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
@Data
@Configuration
@ConfigurationProperties(prefix = "weixin")
public class WeiXinAppListConfig {
private List<Map<String, String>> list;
/*@Value("${uc.service.platform:}")
private String platform;
@Value("${key:}")
private String key;
@Value("${uc.app.subAppId:wx05f35931270014be}")
private String subAppId;
@Value("${uc.app.h5AppId:wxca962918dfeed88c}")
private String h5AppId;
@Value("${uc.app.appletAppid:wxc57d42de3d351cec}")
private String appletAppid;
@Value("${file.upload:upload}")
private String filePath;*/
}
package com.topdraw.test.business.basicdata.rights.history;
import com.topdraw.BaseTest;
import com.topdraw.business.module.rights.history.rest.RightsHistoryController;
import com.topdraw.business.module.rights.history.service.dto.RightsHistoryQueryCriteria;
import com.topdraw.common.ResultInfo;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
public class RightsHistoryControllerTest extends BaseTest {
@Autowired
RightsHistoryController rightsHistoryController;
@Test
public void pageRightsHistory(){
RightsHistoryQueryCriteria memberQueryCriteria = new RightsHistoryQueryCriteria();
memberQueryCriteria.setMemberId(1L);
Pageable pageable = PageRequest.of(0,20);
ResultInfo byId = this.rightsHistoryController.pageRightsHistory(memberQueryCriteria,pageable);
LOG.info("===>>>"+byId);
}
@Test
public void pageAvailableRights(){
RightsHistoryQueryCriteria memberQueryCriteria = new RightsHistoryQueryCriteria();
memberQueryCriteria.setMemberId(1L);
Pageable pageable = PageRequest.of(0,20);
ResultInfo byId = this.rightsHistoryController.pageAvailableRights(memberQueryCriteria,pageable);
LOG.info("===>>>"+byId);
}
}