| | |
| | | package com.yeshi.fanli.service.impl.user.cloud;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.context.annotation.Lazy;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.user.cloud.UserCloudManageMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.cloud.UserCloudManage;
|
| | | import com.yeshi.fanli.service.inter.user.cloud.UserCloudGoodsService;
|
| | | import com.yeshi.fanli.service.inter.user.cloud.UserCloudManageService;
|
| | |
|
| | |
|
| | | @Service
|
| | | public class UserCloudManageServiceImpl implements UserCloudManageService {
|
| | |
|
| | | @Resource
|
| | | private UserCloudManageMapper userCloudManageMapper;
|
| | | |
| | | @Lazy
|
| | | @Resource
|
| | | private UserCloudGoodsService userCloudGoodsService;
|
| | | |
| | | @Override
|
| | | public void save(Long uid, Boolean official, Boolean custom) {
|
| | | if (uid == null) |
| | | return;
|
| | | |
| | | boolean send = false;
|
| | | UserCloudManage cloudManage = userCloudManageMapper.selectByPrimaryKey(uid);
|
| | | if (cloudManage != null) {
|
| | | UserCloudManage update = new UserCloudManage();
|
| | | if (official != null)
|
| | | update.setOfficial(official);
|
| | | if (custom != null) {
|
| | | update.setCustom(custom); |
| | | send = custom;
|
| | | }
|
| | | update.setId(uid);
|
| | | update.setUpdateTime(new Date());
|
| | | userCloudManageMapper.updateByPrimaryKeySelective(update);
|
| | | } else {
|
| | | if (official == null)
|
| | | official = false;
|
| | | if (custom == null)
|
| | | custom = true;
|
| | | UserCloudManage manage = new UserCloudManage();
|
| | | manage.setId(uid);
|
| | | manage.setCustom(custom); |
| | | manage.setOfficial(official);
|
| | | manage.setCreateTime(new Date());
|
| | | userCloudManageMapper.insertSelective(manage);
|
| | | |
| | | send = manage.getCustom();
|
| | | }
|
| | | |
| | | if (send) {
|
| | | userCloudGoodsService.sendGoodsMQMsg(uid);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public UserCloudManage selectByPrimaryKey(Long uid) {
|
| | | return userCloudManageMapper.selectByPrimaryKey(uid);
|
| | | }
|
| | | |
| | | }
|
| | | package com.yeshi.fanli.service.impl.user.cloud; |
| | | |
| | | import java.util.Date; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.yeshi.fanli.dao.mybatis.user.cloud.UserCloudManageMapper; |
| | | import com.yeshi.fanli.entity.bus.user.cloud.UserCloudManage; |
| | | import com.yeshi.fanli.service.inter.user.cloud.UserCloudGoodsService; |
| | | import com.yeshi.fanli.service.inter.user.cloud.UserCloudManageService; |
| | | |
| | | |
| | | @Service |
| | | public class UserCloudManageServiceImpl implements UserCloudManageService { |
| | | |
| | | @Resource |
| | | private UserCloudManageMapper userCloudManageMapper; |
| | | |
| | | @Lazy |
| | | @Resource |
| | | private UserCloudGoodsService userCloudGoodsService; |
| | | |
| | | |
| | | @Async |
| | | @Override |
| | | public void save(Long uid, Boolean official, Boolean custom) { |
| | | if (uid == null) |
| | | return; |
| | | |
| | | boolean send = false; |
| | | UserCloudManage cloudManage = userCloudManageMapper.selectByPrimaryKey(uid); |
| | | if (cloudManage != null) { |
| | | UserCloudManage update = new UserCloudManage(); |
| | | if (official != null) |
| | | update.setOfficial(official); |
| | | if (custom != null) { |
| | | update.setCustom(custom); |
| | | send = custom; |
| | | } |
| | | update.setId(uid); |
| | | update.setUpdateTime(new Date()); |
| | | userCloudManageMapper.updateByPrimaryKeySelective(update); |
| | | } else { |
| | | if (official == null) |
| | | official = false; |
| | | if (custom == null) |
| | | custom = true; |
| | | UserCloudManage manage = new UserCloudManage(); |
| | | manage.setId(uid); |
| | | manage.setCustom(custom); |
| | | manage.setOfficial(official); |
| | | manage.setCreateTime(new Date()); |
| | | manage.setOfflineNotice(false); |
| | | userCloudManageMapper.insertSelective(manage); |
| | | |
| | | send = manage.getCustom(); |
| | | } |
| | | |
| | | if (send) { |
| | | userCloudGoodsService.sendGoodsMQMsg(uid); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public UserCloudManage selectByPrimaryKey(Long uid) { |
| | | return userCloudManageMapper.selectByPrimaryKey(uid); |
| | | } |
| | | |
| | | @Override |
| | | public void updateByPrimaryKeySelective(UserCloudManage record) { |
| | | userCloudManageMapper.updateByPrimaryKeySelective(record); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public UserCloudManage selectForUpdate(Long uid) { |
| | | return userCloudManageMapper.selectForUpdate(uid); |
| | | } |
| | | |
| | | } |