Commit 799a2ce5 799a2ce553c0f1fba5c8405e06f642fe532ebaf9 by xianghan

1.update

1 parent 82a96a78
Showing 33 changed files with 46 additions and 1275 deletions
......@@ -33,8 +33,8 @@
<!--代码生成器-->
<dependency>
<groupId>com.topdraw</groupId>
<artifactId>cronos-system</artifactId>
<version>1.1.0</version>
<artifactId>cronos-generator</artifactId>
<version>1.2.0</version>
</dependency>
<!-- Spring boot 热部署 : 此热部署会遇到 java.lang.ClassCastException 异常 -->
......
......@@ -4,7 +4,6 @@ package com.topdraw;
import com.topdraw.utils.SpringContextHolder;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
......
package com.topdraw.business.module.coupon.history.rest;
import com.topdraw.business.module.coupon.history.domain.CouponHistory;
import com.topdraw.business.module.coupon.history.service.CouponHistoryService;
import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryQueryCriteria;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.*;
/**
* @author XiangHan
* @date 2021-10-23
*/
@Api(tags = "CouponHistory管理")
@RestController
@RequestMapping("/api/CouponHistory")
public class CouponHistoryController {
@Autowired
private CouponHistoryService CouponHistoryService;
@GetMapping
@ApiOperation("查询CouponHistory")
public ResultInfo getCouponHistorys(CouponHistoryQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(CouponHistoryService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有CouponHistory")
public ResultInfo getCouponHistorys(CouponHistoryQueryCriteria criteria) {
return ResultInfo.success(CouponHistoryService.queryAll(criteria));
}
@PostMapping
@ApiOperation("新增CouponHistory")
public ResultInfo create(@Validated @RequestBody CouponHistory resources) {
CouponHistoryService.create(resources);
return ResultInfo.success();
}
@PutMapping
@ApiOperation("修改CouponHistory")
public ResultInfo update(@Validated @RequestBody CouponHistory resources) {
CouponHistoryService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/{id}")
@ApiOperation("删除CouponHistory")
public ResultInfo delete(@PathVariable Long id) {
CouponHistoryService.delete(id);
return ResultInfo.success();
}
}
package com.topdraw.business.module.coupon.rest;
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 com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.*;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Api(tags = "Coupon管理")
@RestController
@RequestMapping("/api/Coupon")
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
@ApiOperation("新增Coupon")
public ResultInfo create(@Validated @RequestBody Coupon resources) {
CouponService.create(resources);
return ResultInfo.success();
}
@PutMapping
@ApiOperation("修改Coupon")
public ResultInfo update(@Validated @RequestBody Coupon resources) {
CouponService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/{id}")
@ApiOperation("删除Coupon")
public ResultInfo delete(@PathVariable Long id) {
CouponService.delete(id);
return ResultInfo.success();
}
@GetMapping(value = "/getByCode/{code}")
@ApiOperation(value = "根据标识查询")
public ResultInfo getByCode(@PathVariable String code) {
return ResultInfo.success(CouponService.getByCode(code));
}
}
package com.topdraw.business.module.exp.detail.rest;
import com.topdraw.business.module.exp.detail.domain.ExpDetail;
import com.topdraw.business.module.exp.detail.service.ExpDetailService;
import com.topdraw.business.module.exp.detail.service.dto.ExpDetailQueryCriteria;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.*;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Api(tags = "ExpDetail管理")
@RestController
@RequestMapping("/api/ExpDetail")
public class ExpDetailController {
@Autowired
private ExpDetailService ExpDetailService;
@GetMapping
@ApiOperation("查询ExpDetail")
public ResultInfo getExpDetails(ExpDetailQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(ExpDetailService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有ExpDetail")
public ResultInfo getExpDetails(ExpDetailQueryCriteria criteria) {
return ResultInfo.success(ExpDetailService.queryAll(criteria));
}
@PostMapping
@ApiOperation("新增ExpDetail")
public ResultInfo create(@Validated @RequestBody ExpDetail resources) {
ExpDetailService.create(resources);
return ResultInfo.success();
}
@PutMapping
@ApiOperation("修改ExpDetail")
public ResultInfo update(@Validated @RequestBody ExpDetail resources) {
ExpDetailService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/{id}")
@ApiOperation("删除ExpDetail")
public ResultInfo delete(@PathVariable Long id) {
ExpDetailService.delete(id);
return ResultInfo.success();
}
@GetMapping(value = "/getByCode/{code}")
@ApiOperation(value = "根据标识查询")
public ResultInfo getByCode(@PathVariable String code) {
return ResultInfo.success(ExpDetailService.getByCode(code));
}
}
package com.topdraw.business.module.exp.history.rest;
import com.topdraw.business.module.exp.history.domain.ExpHistory;
import com.topdraw.business.module.exp.history.service.ExpHistoryService;
import com.topdraw.business.module.exp.history.service.dto.ExpHistoryQueryCriteria;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.*;
/**
* @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));
}
@PostMapping
@ApiOperation("新增ExpHistory")
public ResultInfo create(@Validated @RequestBody ExpHistory resources) {
ExpHistoryService.create(resources);
return ResultInfo.success();
}
@PutMapping
@ApiOperation("修改ExpHistory")
public ResultInfo update(@Validated @RequestBody ExpHistory resources) {
ExpHistoryService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/{id}")
@ApiOperation("删除ExpHistory")
public ResultInfo delete(@PathVariable Long id) {
ExpHistoryService.delete(id);
return ResultInfo.success();
}
@GetMapping(value = "/getByCode/{code}")
@ApiOperation(value = "根据标识查询")
public ResultInfo getByCode(@PathVariable String code) {
return ResultInfo.success(ExpHistoryService.getByCode(code));
}
}
package com.topdraw.business.module.member.address.rest;
import com.topdraw.business.module.member.address.domain.MemberAddress;
import com.topdraw.business.module.member.address.service.MemberAddressService;
import com.topdraw.business.module.member.address.service.dto.MemberAddressQueryCriteria;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.*;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Api(tags = "MemberAddress管理")
@RestController
@RequestMapping("/api/MemberAddress")
public class MemberAddressController {
@Autowired
private MemberAddressService MemberAddressService;
@GetMapping(value = "/pageMemberAddress")
@ApiOperation("查询MemberAddress")
public ResultInfo pageMemberAddress(MemberAddressQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(MemberAddressService.queryAll(criteria,pageable));
}
@GetMapping(value = "/findById/{id}")
@ApiOperation("查询指定MemberAddress")
public ResultInfo findById(@PathVariable(value = "id") Long id) {
return ResultInfo.success(MemberAddressService.findById(id));
}
@PostMapping(value = "/create")
@ApiOperation("新增MemberAddress")
public ResultInfo create(@Validated @RequestBody MemberAddress resources) {
MemberAddressService.create(resources);
return ResultInfo.success();
}
@PutMapping(value = "/update")
@ApiOperation("修改MemberAddress")
public ResultInfo update(@Validated @RequestBody MemberAddress resources) {
MemberAddressService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/delete/{id}")
@ApiOperation("删除MemberAddress")
public ResultInfo delete(@PathVariable Long id) {
MemberAddressService.delete(id);
return ResultInfo.success();
}
}
package com.topdraw.business.module.member.level.rest;
import com.topdraw.business.module.member.level.domain.MemberLevel;
import com.topdraw.business.module.member.level.service.MemberLevelService;
import com.topdraw.business.module.member.level.service.dto.MemberLevelQueryCriteria;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.*;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Api(tags = "MemberLevel管理")
@RestController
@RequestMapping("/api/MemberLevel")
public class MemberLevelController {
@Autowired
private MemberLevelService MemberLevelService;
@GetMapping
@ApiOperation("查询MemberLevel")
public ResultInfo getMemberLevels(MemberLevelQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(MemberLevelService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有MemberLevel")
public ResultInfo getMemberLevels(MemberLevelQueryCriteria criteria) {
return ResultInfo.success(MemberLevelService.queryAll(criteria));
}
@PostMapping
@ApiOperation("新增MemberLevel")
public ResultInfo create(@Validated @RequestBody MemberLevel resources) {
MemberLevelService.create(resources);
return ResultInfo.success();
}
@PutMapping
@ApiOperation("修改MemberLevel")
public ResultInfo update(@Validated @RequestBody MemberLevel resources) {
MemberLevelService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/{id}")
@ApiOperation("删除MemberLevel")
public ResultInfo delete(@PathVariable Long id) {
MemberLevelService.delete(id);
return ResultInfo.success();
}
@GetMapping(value = "/getByCode/{code}")
@ApiOperation(value = "根据标识查询")
public ResultInfo getByCode(@PathVariable String code) {
return ResultInfo.success(MemberLevelService.getByCode(code));
}
}
package com.topdraw.business.module.member.profile.rest;
import com.topdraw.business.module.member.profile.domain.MemberProfile;
import com.topdraw.business.module.member.profile.service.MemberProfileService;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileQueryCriteria;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.*;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Api(tags = "MemberProfile管理")
@RestController
@RequestMapping("/api/MemberProfile")
public class MemberProfileController {
@Autowired
private MemberProfileService MemberProfileService;
@GetMapping
@ApiOperation("查询MemberProfile")
public ResultInfo getMemberProfiles(MemberProfileQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(MemberProfileService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有MemberProfile")
public ResultInfo getMemberProfiles(MemberProfileQueryCriteria criteria) {
return ResultInfo.success(MemberProfileService.queryAll(criteria));
}
@PostMapping
@ApiOperation("新增MemberProfile")
public ResultInfo create(@Validated @RequestBody MemberProfile resources) {
MemberProfileService.create(resources);
return ResultInfo.success();
}
@PutMapping
@ApiOperation("修改MemberProfile")
public ResultInfo update(@Validated @RequestBody MemberProfile resources) {
MemberProfileService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/{id}")
@ApiOperation("删除MemberProfile")
public ResultInfo delete(@PathVariable Long id) {
MemberProfileService.delete(id);
return ResultInfo.success();
}
}
package com.topdraw.business.module.member.relatedinfo.rest;
import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
import com.topdraw.business.module.member.relatedinfo.service.MemberRelatedInfoService;
import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.*;
/**
* @author XiangHan /api/MemberRelatedInfo
* @date 2021-10-22
*/
@Api(tags = "MemberRelatedInfo管理")
@RestController
@RequestMapping("/api/MemberRelatedInfo")
public class MemberRelatedInfoController {
@Autowired
private MemberRelatedInfoService MemberRelatedInfoService;
@GetMapping(value = "/pageMemberRelatedInfos")
@ApiOperation("查询MemberRelatedInfo")
public ResultInfo pageMemberRelatedInfos(@Validated MemberRelatedInfoQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(MemberRelatedInfoService.queryAll(criteria,pageable));
}
@PostMapping(value = "/create")
@ApiOperation("新增MemberRelatedInfo")
public ResultInfo create(@Validated @RequestBody MemberRelatedInfo resources) {
MemberRelatedInfoService.create(resources);
return ResultInfo.success();
}
@PutMapping(value = "/update")
@ApiOperation("修改MemberRelatedInfo")
public ResultInfo update(@Validated @RequestBody MemberRelatedInfo resources) {
MemberRelatedInfoService.update(resources);
return ResultInfo.success();
}
@GetMapping(value = "/findById/{id}")
@ApiOperation("查询指定MemberRelatedInfo")
public ResultInfo findById(@PathVariable("id") Long id) {
return ResultInfo.success(MemberRelatedInfoService.findById(id));
}
@DeleteMapping(value = "/delete//{id}")
@ApiOperation("删除MemberRelatedInfo")
public ResultInfo delete(@PathVariable Long id) {
MemberRelatedInfoService.delete(id);
return ResultInfo.success();
}
}
package com.topdraw.business.module.member.rest;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberQueryCriteria;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.*;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Api(tags = "Member管理")
@RestController
@RequestMapping("/api/member")
public class MemberController {
@Autowired
private MemberService memberService;
@GetMapping(value = "/pageMembers")
@ApiOperation("查询Member")
public ResultInfo pageMembers(MemberQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(memberService.queryAll(criteria,pageable));
}
@GetMapping(value = "/findById/{id}")
@ApiOperation("查询指定Member")
public ResultInfo findById(@PathVariable("id") Long id) {
return ResultInfo.success(memberService.findById(id));
}
@PostMapping(value = "/create")
@ApiOperation("新增Member")
public ResultInfo create(@Validated @RequestBody Member resources) {
memberService.create(resources);
return ResultInfo.success();
}
@PutMapping(value = "/update")
@ApiOperation("修改Member")
public ResultInfo update(@Validated @RequestBody Member resources) {
memberService.update(resources);
return ResultInfo.success();
}
@GetMapping(value = "/getByCode/{code}")
@ApiOperation(value = "根据标识查询")
public ResultInfo getByCode(@PathVariable String code) {
return ResultInfo.success(memberService.getByCode(code));
}
}
......@@ -53,8 +53,8 @@ public class MemberServiceImpl implements MemberService {
@Autowired
private com.topdraw.business.module.user.iptv.service.UserTvService UserTvService;
@Autowired
private RedissonClient redissonClient;
// @Autowired
// private RedissonClient redissonClient;
@Override
public Map<String, Object> queryAll(MemberQueryCriteria criteria, Pageable pageable) {
......@@ -148,7 +148,13 @@ public class MemberServiceImpl implements MemberService {
resources.setBindIptvPlatformType(1);
resources.setBindIptvTime(LocalDateTime.now());
}
} else {
resources.setUserIptvId(member.getUserIptvId());
resources.setBindIptvPlatformType(member.getBindIptvPlatformType());
resources.setBindIptvTime(member.getBindIptvTime());
}
}
member.copy(resources);
......@@ -164,9 +170,9 @@ public class MemberServiceImpl implements MemberService {
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
RLock rLock = this.redissonClient.getLock("Member::delete::code" + id);
// RLock rLock = this.redissonClient.getLock("Member::delete::code" + id);
try {
RedissonUtil.lock(rLock);
// RedissonUtil.lock(rLock);
Member member = memberRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", Member.class, id), 1));
memberRepository.delete(member);
......@@ -174,7 +180,7 @@ public class MemberServiceImpl implements MemberService {
e.printStackTrace();
throw e;
} finally {
RedissonUtil.unlock(rLock);
// RedissonUtil.unlock(rLock);
}
}
......@@ -222,9 +228,7 @@ public class MemberServiceImpl implements MemberService {
@Override
@Transactional(rollbackFor = Exception.class)
public void doUpdateMemberPoints(Member member) {
RLock rLock = this.redissonClient.getLock("Member::update::code::" + member.getCode());
try {
RedissonUtil.lock(rLock);
Long id = member.getId();
Long points = member.getPoints();
Long duePoints = member.getDuePoints();
......@@ -232,8 +236,6 @@ public class MemberServiceImpl implements MemberService {
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
RedissonUtil.unlock(rLock);
}
}
......@@ -250,9 +252,7 @@ public class MemberServiceImpl implements MemberService {
}
public void bindIptvId(Member resources) {
RLock rLock = this.redissonClient.getLock("Member::update::code::" + resources.getCode());
try {
RedissonUtil.lock(rLock);
Member member = memberRepository.findFirstByCode(resources.getCode()).orElseGet(Member::new);
if (member==null) {
ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId());
......@@ -262,8 +262,6 @@ public class MemberServiceImpl implements MemberService {
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
RedissonUtil.unlock(rLock);
}
}
}
......
......@@ -24,6 +24,9 @@ import java.time.LocalDateTime;
@Table(name="uc_member_vip_history")
public class MemberVipHistory implements Serializable {
@Transient
private String memberCode;
// 主键
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
......
package com.topdraw.business.module.member.viphistory.rest;
import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryQueryCriteria;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.*;
/**
* @author luerlong
* @date 2021-12-10
*/
@Api(tags = "MemberVipHistory管理")
@RestController
@RequestMapping("/api/memberVipHistory")
public class MemberVipHistoryController {
@Autowired
private MemberVipHistoryService memberVipHistoryService;
@GetMapping
@ApiOperation("查询MemberVipHistory")
public ResultInfo getMemberVipHistorys(MemberVipHistoryQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(memberVipHistoryService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有MemberVipHistory")
public ResultInfo getMemberVipHistorys(MemberVipHistoryQueryCriteria criteria) {
return ResultInfo.success(memberVipHistoryService.queryAll(criteria));
}
@PostMapping
@ApiOperation("新增MemberVipHistory")
public ResultInfo create(@Validated @RequestBody MemberVipHistory resources) {
memberVipHistoryService.create(resources);
return ResultInfo.success();
}
@PutMapping
@ApiOperation("修改MemberVipHistory")
public ResultInfo update(@Validated @RequestBody MemberVipHistory resources) {
memberVipHistoryService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/{id}")
@ApiOperation("删除MemberVipHistory")
public ResultInfo delete(@PathVariable Long id) {
memberVipHistoryService.delete(id);
return ResultInfo.success();
}
}
package com.topdraw.business.module.member.viphistory.service.impl;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
import com.topdraw.business.module.member.viphistory.repository.MemberVipHistoryRepository;
import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
......@@ -10,6 +12,7 @@ import com.topdraw.business.module.member.viphistory.service.mapper.MemberVipHis
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.ValidationUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page;
......@@ -22,6 +25,7 @@ import org.springframework.util.Assert;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* @author luerlong
......@@ -29,6 +33,7 @@ import java.util.Map;
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
@Slf4j
public class MemberVipHistoryServiceImpl implements MemberVipHistoryService {
@Autowired
......@@ -36,6 +41,8 @@ public class MemberVipHistoryServiceImpl implements MemberVipHistoryService {
@Autowired
private MemberVipHistoryMapper memberVipHistoryMapper;
@Autowired
private MemberService memberService;
@Override
public Map<String, Object> queryAll(MemberVipHistoryQueryCriteria criteria, Pageable pageable) {
......@@ -58,8 +65,16 @@ public class MemberVipHistoryServiceImpl implements MemberVipHistoryService {
@Override
@Transactional(rollbackFor = Exception.class)
public void create(MemberVipHistory resources) {
log.info("MemberVipHistoryServiceImpl ==>> create ==>> resources ==>> [{}]",resources);
String memberCode = resources.getMemberCode();
Assert.notNull(resources.getMemberCode(),"memberCode can't be null !!");
MemberDTO byCode = memberService.getByCode(memberCode);
if (Objects.nonNull(byCode.getCode())) {
Long id = byCode.getId();
resources.setMemberId(id);
memberVipHistoryRepository.save(resources);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
......
......@@ -44,9 +44,6 @@ public class PointsAvailableServiceImpl implements PointsAvailableService {
private PointsAvailableMapper PointsAvailableMapper;
@Autowired
private RedissonClient redissonClient;
@Autowired
private MemberService memberService;
@Override
......@@ -91,9 +88,7 @@ public class PointsAvailableServiceImpl implements PointsAvailableService {
@Override
@Transactional(rollbackFor = Exception.class)
public void update(PointsAvailable resources) {
RLock rLock = this.redissonClient.getLock("PointsAvailable::update::id"+resources.getMemberId().toString());
try {
RedissonUtil.lock(rLock);
PointsAvailable PointsAvailable = PointsAvailableRepository.findById(resources.getId()).orElseGet(PointsAvailable::new);
ValidationUtil.isNull( PointsAvailable.getId(),"PointsAvailable","id",resources.getId());
PointsAvailable.copy(resources);
......@@ -101,8 +96,6 @@ public class PointsAvailableServiceImpl implements PointsAvailableService {
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
RedissonUtil.unlock(rLock);
}
}
......@@ -110,49 +103,37 @@ public class PointsAvailableServiceImpl implements PointsAvailableService {
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
RLock rLock = this.redissonClient.getLock("PointsAvailable::delete::id"+id);
try {
RedissonUtil.lock(rLock);
PointsAvailable PointsAvailable = PointsAvailableRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsAvailable.class, id), 1));
PointsAvailableRepository.delete(PointsAvailable);
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
RedissonUtil.unlock(rLock);
}
}
@Override
public void delete4Custom(Long id) {
Assert.notNull(id, "The given id must not be null!");
RLock rLock = this.redissonClient.getLock("PointsAvailable::delete::id"+id);
try {
RedissonUtil.lock(rLock);
PointsAvailable PointsAvailable = PointsAvailableRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsAvailable.class, id), 1));
PointsAvailableRepository.delete(PointsAvailable);
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
RedissonUtil.unlock(rLock);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteBatchByIds(List<Long> id) {
RLock rLock = this.redissonClient.getLock("PointsAvailable::create::id"+id.get(0));
try {
RedissonUtil.lock(rLock);
PointsAvailableRepository.deleteBatchByIds(id);
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
RedissonUtil.unlock(rLock);
}
}
......
package com.topdraw.business.module.points.rest;
import io.swagger.annotations.Api;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Api(tags = "Points管理")
//@RestController
//@RequestMapping("/api/Points")
public class PointsController {
/*@Autowired
private PointsService PointsService;
@GetMapping
@ApiOperation("查询Points")
public ResultInfo getPointss(PointsQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(PointsService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有Points")
public ResultInfo getPointss(PointsQueryCriteria criteria) {
return ResultInfo.success(PointsService.queryAll(criteria));
}*/
/*@Log
@PostMapping
@ApiOperation("新增Points")
public ResultInfo create(@Validated @RequestBody Points resources) {
PointsService.create(resources);
return ResultInfo.success();
}
@Log
@PutMapping
@ApiOperation("修改Points")
public ResultInfo update(@Validated @RequestBody Points resources) {
PointsService.update(resources);
return ResultInfo.success();
}
@Log
@DeleteMapping(value = "/{id}")
@ApiOperation("删除Points")
public ResultInfo delete(@PathVariable Long id) {
PointsService.delete(id);
return ResultInfo.success();
}*/
}
......@@ -40,9 +40,6 @@ public class PointsServiceImpl implements PointsService {
@Autowired
private PointsMapper PointsMapper;
@Autowired
private RedissonClient redissonClient;
@Override
public Map<String, Object> queryAll(PointsQueryCriteria criteria, Pageable pageable) {
Page<Points> page = PointsRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
......@@ -72,9 +69,7 @@ public class PointsServiceImpl implements PointsService {
@Override
@Transactional(rollbackFor = Exception.class)
public void update(Points resources) {
RLock rLock = this.redissonClient.getLock(resources.getId().toString());
try {
RedissonUtil.lock(rLock);
Points Points = PointsRepository.findById(resources.getId()).orElseGet(Points::new);
ValidationUtil.isNull(Points.getId(), "Points", "id", resources.getId());
Points.copy(resources);
......@@ -82,8 +77,6 @@ public class PointsServiceImpl implements PointsService {
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
RedissonUtil.unlock(rLock);
}
}
......
package com.topdraw.business.module.points.standingbook.rest;
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 com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.*;
/**
* @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.rights.history.rest;
import com.topdraw.business.module.rights.history.service.RightsHistoryService;
import com.topdraw.business.module.rights.history.service.dto.RightsHistoryQueryCriteria;
import com.topdraw.common.ResultInfo;
import com.topdraw.util.TimestampUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @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));
}
}
package com.topdraw.business.module.rights.permanentrights.rest;
import com.topdraw.business.module.rights.permanentrights.domain.PermanentRights;
import com.topdraw.business.module.rights.permanentrights.service.PermanentRightsService;
import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsQueryCriteria;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.*;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Api(tags = "PermanentRights管理")
@RestController
@RequestMapping("/api/PermanentRights")
public class PermanentRightsController {
@Autowired
private PermanentRightsService PermanentRightsService;
@GetMapping
@ApiOperation("查询PermanentRights")
public ResultInfo pagePermanentRights(PermanentRightsQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(PermanentRightsService.queryAll(criteria,pageable));
}
@GetMapping(value = "/findById/{id}")
@ApiOperation("查询PermanentRights")
public ResultInfo findById(@PathVariable("id") Long id) {
return ResultInfo.success(PermanentRightsService.findById(id));
}
@PostMapping(value = "/create")
@ApiOperation("新增PermanentRights")
public ResultInfo create(@Validated @RequestBody PermanentRights resources) {
PermanentRightsService.create(resources);
return ResultInfo.success();
}
@PutMapping(value = "/update")
@ApiOperation("修改PermanentRights")
public ResultInfo update(@Validated @RequestBody PermanentRights resources) {
PermanentRightsService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/delete/{id}")
@ApiOperation("删除PermanentRights")
public ResultInfo delete(@PathVariable Long id) {
PermanentRightsService.delete(id);
return ResultInfo.success();
}
@GetMapping(value = "/getByCode/{code}")
@ApiOperation(value = "根据标识查询")
public ResultInfo getByCode(@PathVariable String code) {
return ResultInfo.success(PermanentRightsService.getByCode(code));
}
}
package com.topdraw.business.module.rights.rest;
import com.topdraw.business.module.rights.service.RightsService;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Api(tags = "Rights管理")
@RestController
@RequestMapping("/api/Rights")
public class RightsController {
@Autowired
private RightsService rightsService;
@GetMapping(value = "/findById/{id}")
@ApiOperation("查询Rights")
public ResultInfo findById(@PathVariable("id") Long id) {
return ResultInfo.success(rightsService.findById(id));
}
}
package com.topdraw.business.module.task.rest;
import com.topdraw.aop.log.Log;
import com.topdraw.business.module.task.domain.Task;
import com.topdraw.business.module.task.service.TaskService;
import com.topdraw.business.module.task.service.dto.TaskQueryCriteria;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.*;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Api(tags = "Task管理")
@RestController
@RequestMapping("/api/Task")
public class TaskController {
@Autowired
private TaskService TaskService;
@GetMapping
@ApiOperation("查询Task")
public ResultInfo getTasks(TaskQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(TaskService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有Task")
public ResultInfo getTasks(TaskQueryCriteria criteria) {
return ResultInfo.success(TaskService.queryAll(criteria));
}
@Log
@PostMapping
@ApiOperation("新增Task")
public ResultInfo create(@Validated @RequestBody Task resources) {
TaskService.create(resources);
return ResultInfo.success();
}
@Log
@PutMapping
@ApiOperation("修改Task")
public ResultInfo update(@Validated @RequestBody Task resources) {
TaskService.update(resources);
return ResultInfo.success();
}
@Log
@DeleteMapping(value = "/{id}")
@ApiOperation("删除Task")
public ResultInfo delete(@PathVariable Long id) {
TaskService.delete(id);
return ResultInfo.success();
}
}
package com.topdraw.business.module.task.template.rest;
import com.topdraw.business.module.task.template.domain.TaskTemplate;
import com.topdraw.business.module.task.template.service.TaskTemplateService;
import com.topdraw.business.module.task.template.service.dto.TaskTemplateQueryCriteria;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.*;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Api(tags = "TaskTemplate管理")
@RestController
@RequestMapping("/api/TaskTemplate")
public class TaskTemplateController {
@Autowired
private TaskTemplateService TaskTemplateService;
@GetMapping
@ApiOperation("查询TaskTemplate")
public ResultInfo getTaskTemplates(TaskTemplateQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(TaskTemplateService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有TaskTemplate")
public ResultInfo getTaskTemplates(TaskTemplateQueryCriteria criteria) {
return ResultInfo.success(TaskTemplateService.queryAll(criteria));
}
@PostMapping
@ApiOperation("新增TaskTemplate")
public ResultInfo create(@Validated @RequestBody TaskTemplate resources) {
TaskTemplateService.create(resources);
return ResultInfo.success();
}
@PutMapping
@ApiOperation("修改TaskTemplate")
public ResultInfo update(@Validated @RequestBody TaskTemplate resources) {
TaskTemplateService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/{id}")
@ApiOperation("删除TaskTemplate")
public ResultInfo delete(@PathVariable Long id) {
TaskTemplateService.delete(id);
return ResultInfo.success();
}
@GetMapping(value = "/getByCode/{code}")
@ApiOperation(value = "根据标识查询")
public ResultInfo getByCode(@PathVariable String code) {
return ResultInfo.success(TaskTemplateService.getByCode(code));
}
}
package com.topdraw.business.module.user.iptv.rest;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.iptv.service.UserTvService;
import com.topdraw.business.module.user.iptv.service.dto.UserTvQueryCriteria;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.*;
/**
* @author XiangHan
* @date 2021-12-16
*/
@Api(tags = "UserTv管理")
@RestController
@RequestMapping("/api/UserTv")
public class UserTvController {
@Autowired
private UserTvService UserTvService;
@GetMapping
@ApiOperation("查询UserTv")
public ResultInfo getUserTvs(UserTvQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(UserTvService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有UserTv")
public ResultInfo getUserTvs(UserTvQueryCriteria criteria) {
return ResultInfo.success(UserTvService.queryAll(criteria));
}
@PostMapping
@ApiOperation("新增UserTv")
public ResultInfo create(@Validated @RequestBody UserTv resources) {
UserTvService.create(resources);
return ResultInfo.success();
}
@PutMapping
@ApiOperation("修改UserTv")
public ResultInfo update(@Validated @RequestBody UserTv resources) {
UserTvService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/{id}")
@ApiOperation("删除UserTv")
public ResultInfo delete(@PathVariable Long id) {
UserTvService.delete(id);
return ResultInfo.success();
}
}
package com.topdraw.business.module.user.weixin.rest;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
import com.topdraw.business.module.user.weixin.service.UserWeixinService;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.*;
/**
* @author XiangHan
* @date 2021-12-16
*/
@Api(tags = "UserWeixin管理")
@RestController
@RequestMapping("/api/UserWeixin")
public class UserWeixinController {
@Autowired
private UserWeixinService UserWeixinService;
@GetMapping
@ApiOperation("查询UserWeixin")
public ResultInfo getUserWeixins(UserWeixinQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(UserWeixinService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有UserWeixin")
public ResultInfo getUserWeixins(UserWeixinQueryCriteria criteria) {
return ResultInfo.success(UserWeixinService.queryAll(criteria));
}
@PostMapping
@ApiOperation("新增UserWeixin")
public ResultInfo create(@Validated @RequestBody UserWeixin resources) {
UserWeixinService.create(resources);
return ResultInfo.success();
}
@PutMapping
@ApiOperation("修改UserWeixin")
public ResultInfo update(@Validated @RequestBody UserWeixin resources) {
UserWeixinService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/{id}")
@ApiOperation("删除UserWeixin")
public ResultInfo delete(@PathVariable Long id) {
UserWeixinService.delete(id);
return ResultInfo.success();
}
}
......@@ -8,11 +8,9 @@ import com.topdraw.business.module.user.weixin.service.UserWeixinService;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
import com.topdraw.business.module.user.weixin.service.mapper.UserWeixinMapper;
import com.topdraw.util.TimestampUtil;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.ValidationUtil;
import jdk.vm.ci.meta.Local;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......
......@@ -41,8 +41,6 @@ public class CouponOperationServiceImpl implements CouponOperationService {
@Autowired
MemberService memberService;
@Autowired
RedissonClient redissonClient;
@Autowired
ThreadPoolTaskExecutor threadPoolTaskExecutor;
// 过期阀值(默认一个月)
......@@ -90,9 +88,7 @@ public class CouponOperationServiceImpl implements CouponOperationService {
// Long userId = tempCoupon.getUserId();
Long memberId = tempCoupon.getMemberId();
Integer rightsAmount = tempCoupon.getRightsAmount();
RLock rLock = this.redissonClient.getLock("refreshMemberCoupon:" + memberId.toString());
try {
RedissonUtil.lock(rLock);
// 1.历史总优惠券数量
Long historyCouponCount = this.getTotalHistoryCoupon(memberId);
// 1.当前总优惠券数量
......@@ -108,8 +104,6 @@ public class CouponOperationServiceImpl implements CouponOperationService {
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
RedissonUtil.unlock(rLock);
}
}
......
......@@ -44,8 +44,6 @@ public class ExpOperationServiceImpl implements ExpOperationService {
@Autowired
MemberService memberService;
@Autowired
RedissonClient redissonClient;
@Autowired
ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Override
......@@ -81,9 +79,7 @@ public class ExpOperationServiceImpl implements ExpOperationService {
MemberDTO memberDTO = this.memberService.getByCode(memberCode);
Long id = memberDTO.getId();
tempExp.setId(id);
RLock lock = this.redissonClient.getLock("uc-refresh-exp:" + tempExp.getMemberId());
try {
RedissonUtil.lock(lock);
// 原始积分
long originExp = this.getExpByMemberId(tempExp);
// 总积分
......@@ -98,8 +94,6 @@ public class ExpOperationServiceImpl implements ExpOperationService {
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
RedissonUtil.unlock(lock);
}
}
......
......@@ -64,9 +64,6 @@ public class PointsOperationServiceImpl implements PointsOperationService {
private static final String DELETE_AVAILABLE_POINTS = "delete";
private static final String INSERT_AVAILABLE_POINTS = "insert";
@Autowired
RedissonClient redissonClient;
@Autowired
ThreadPoolTaskExecutor threadPoolTaskExecutor;
......@@ -110,9 +107,7 @@ public class PointsOperationServiceImpl implements PointsOperationService {
Long memberId = memberDTO.getId();
tempPoints.setMemberId(memberId);
RLock rLock = this.redissonClient.getLock("member::id::" + memberId.toString());
try {
RedissonUtil.lock(rLock);
//1.删除过期的积分
this.cleanInvalidAvailablePointsByMemberId(memberId);
// 1.判断可用积分是否够用
......@@ -139,8 +134,6 @@ public class PointsOperationServiceImpl implements PointsOperationService {
}catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
RedissonUtil.unlock(rLock);
}
}
......@@ -415,10 +408,8 @@ public class PointsOperationServiceImpl implements PointsOperationService {
private void refresh(TempPoints tempPoints) {
Long memberId = tempPoints.getMemberId();
log.info("----------->> points refresh start");
RLock rLock = this.redissonClient.getLock("member::id::" + memberId.toString());
log.info("----------->> rLock --->> start" );
try {
RedissonUtil.lock(rLock);
log.info("----------->> refresh findAvailablePointsByMemberId start");
// 1.可用总积分
Long currentPoints = this.findAvailablePointsByMemberId(memberId);
......@@ -448,8 +439,6 @@ public class PointsOperationServiceImpl implements PointsOperationService {
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
RedissonUtil.unlock(rLock);
}
}
......
package com.topdraw.config;
import com.topdraw.utils.StringUtils;
import org.redisson.Redisson;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RedissonConfig {
@Value("${spring.redis.host}")
private String redisHost;
@Value("${spring.redis.port}")
private String port;
@Value("${spring.redis.password}")
private String password;
@Bean
public Redisson redisson(){
Config config = new Config();
if (StringUtils.isNotEmpty(password)) {
config.useSingleServer().setAddress("redis://"+redisHost+":"+port).setPassword(password);
} else {
config.useSingleServer().setAddress("redis://"+redisHost+":"+port);
}
/* config.useClusterServers().addNodeAddress(
"redis://172.29.3.245:6375","redis://172.29.3.245:6376", "redis://172.29.3.245:6377",
"redis://172.29.3.245:6378","redis://172.29.3.245:6i379", "redis://172.29.3.245:6380")
.setPassword("a123456").setScanInterval(5000);*/
Redisson redissonClient = (Redisson)Redisson.create(config);
return redissonClient;
}
}
......@@ -26,12 +26,6 @@ public class WeiXinEventConsumer {
@Autowired
private RestTemplateClient restTemplateClient;
@Value("${subAppId:wx05f35931270014be}")
private String subAppId;
@Autowired
private RedisUtils redisUtils;
private static final String QR_CODE_URL = "QR_CODE_URL_";
/**
......@@ -41,50 +35,11 @@ public class WeiXinEventConsumer {
@RabbitHandler
@RabbitListener(bindings = {
@QueueBinding(value = @Queue(value = RabbitMqConfig.COLLECTION_DELETE_QUEUE),
exchange = @Exchange(value = ExchangeTypes.DIRECT))})
exchange = @Exchange(value = ExchangeTypes.DIRECT))},
containerFactory = "managementRabbitListenerContainerFactory")
public void deleteCollection(String content) {
try {
log.info("receive UserCollection delete message, content {}", content);
JSONObject jsonObject = JSONObject.parseObject(content);
String platformAccount = jsonObject.getString("platformAccount");
String data = jsonObject.getString("data");
if (StringUtils.isBlank(data) || !data.startsWith("[")) {
// return;
}
/*Optional<TvUser> userOptional = tvUserRepository.findByPlatformAccount(platformAccount);
if (!userOptional.isPresent()) {
return;
}
Long id = userOptional.get().getId();
List<UserCollectionMq> userCollectionMqList = JSONObject.parseArray(data, UserCollectionMq.class);
if (userCollectionMqList == null || userCollectionMqList.isEmpty()) {
return;
}
Map<Long, List<UserCollectionMq>> collect = userCollectionMqList.stream().collect(Collectors.groupingBy(UserCollectionMq::getUserCollectionId));
for (Map.Entry<Long, List<UserCollectionMq>> entry : collect.entrySet()) {
List<UserCollectionMq> value = entry.getValue();
UserCollectionMq userCollectionMq = value.get(0);
if (StringUtils.isBlank(userCollectionMq.getName())) {
userCollectionMq.setName("DEFAULT");
}
Optional<UserCollection> userCollectionOptional = userCollectionRepository.findFirstByUserIdAndTypeAndName(id, userCollectionMq.getType(), userCollectionMq.getName());
UserCollection userCollection = userCollectionOptional.orElseGet(UserCollection::new);
int count = 0;
for (UserCollectionMq collectionMq : value) {
collectionMq.setUserCollectionId(userCollection.getId());
List<UserCollectionDetail> userCollectionDetailOptional = userCollectionDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, collectionMq, criteriaBuilder));
if (!userCollectionDetailOptional.isEmpty()) {
userCollectionDetailRepository.deleteAll(userCollectionDetailOptional);
count++;
}
}
userCollection.setAppId(userCollectionMq.getAppId())
.setUserId(id)
.setName(userCollectionMq.getName())
.setType(userCollectionMq.getType())
.setCount(userCollection.getCount() - count);
userCollectionRepository.save(userCollection);
}*/
this.restTemplateClient.deleteCollection(content);
} catch (Exception e) {
log.error("CollectionDeleteConsumer || UserCollection delete error || {}", e.toString(), e);
......@@ -98,26 +53,12 @@ public class WeiXinEventConsumer {
@RabbitHandler
@RabbitListener(bindings = {
@QueueBinding(value = @Queue(value = RabbitMqConfig.COLLECTION_DELETE_ALL_QUEUE),
exchange = @Exchange(value = ExchangeTypes.DIRECT))})
exchange = @Exchange(value = ExchangeTypes.DIRECT))},
containerFactory = "managementRabbitListenerContainerFactory")
@Transactional
public void deleteAllCollection(String content) {
try {
log.info("receive UserCollection delete all message, content {}", content);
JSONObject jsonObject = JSONObject.parseObject(content);
String platformAccount = jsonObject.getString("platformAccount");
Integer type = jsonObject.getInteger("collectionType");
/* Optional<TvUser> userOptional = tvUserRepository.findByPlatformAccount(platformAccount);
if (!userOptional.isPresent()) {
return;
}
Long id = userOptional.get().getId();
List<UserCollection> userCollections = userCollectionRepository.findByUserIdAndType(id, type);
if (userCollections == null || userCollections.isEmpty()) {
return;
}
for (UserCollection userCollection : userCollections) {
userCollectionDetailRepository.deleteAllByUserCollectionId(userCollection.getId());
}*/
this.restTemplateClient.deleteAllCollection(content);
} catch (Exception e) {
log.error("CollectionDeleteConsumer || UserCollection delete all error || {}", e.toString(), e);
......@@ -132,7 +73,8 @@ public class WeiXinEventConsumer {
@RabbitHandler
@RabbitListener(bindings = {
@QueueBinding(value = @Queue(value = RabbitMqConfig.GET_QR_CODE_QUEUE),
exchange = @Exchange(value = ExchangeTypes.DIRECT))})
exchange = @Exchange(value = ExchangeTypes.DIRECT))},
containerFactory = "managementRabbitListenerContainerFactory")
public void getQrCode(String content) {
try {
log.info("receive get qrCode message, content {}", content);
......@@ -191,7 +133,8 @@ public class WeiXinEventConsumer {
@RabbitHandler
@RabbitListener(bindings = {
@QueueBinding(value = @Queue(value = RabbitMqConfig.WEIXIN_SUBORUNSUB_QUEUE),
exchange = @Exchange(value = ExchangeTypes.DIRECT))})
exchange = @Exchange(value = ExchangeTypes.DIRECT))},
containerFactory = "managementRabbitListenerContainerFactory")
@Transactional
public void subOrUnSubEvent(String content) {
try {
......@@ -237,7 +180,8 @@ public class WeiXinEventConsumer {
@RabbitHandler
@RabbitListener(bindings = {
@QueueBinding(value = @Queue(value = RabbitMqConfig.COLLECTION_ADD_QUEUE),
exchange = @Exchange(value = ExchangeTypes.DIRECT))})
exchange = @Exchange(value = ExchangeTypes.DIRECT))},
containerFactory = "managementRabbitListenerContainerFactory")
@Transactional
public void addCollection(String content) {
try {
......
......@@ -14,6 +14,8 @@ import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.HashMap;
@Slf4j
......@@ -135,6 +137,9 @@ public class RestTemplateClient {
public String addCollection(String content) {
String url = BASE_URL + "/ucEngine/api/userOperation/addCollection";
//处理接口调用 中文不显示问题
content = new String(Base64.getEncoder().encode(content.getBytes(StandardCharsets.UTF_8)));
restTemplate.postForEntity(url, content, String.class);
/* ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, content, String.class);
String entityBody = "";
......