| | |
| | | package com.yeshi.fanli.service.impl.homemodule;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.homemodule.CommonShareInfoMapper;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.CommonShareInfo;
|
| | | import com.yeshi.fanli.exception.goods.ConvertLinkExceptionException;
|
| | | import com.yeshi.fanli.exception.homemodule.SpecialException;
|
| | | import com.yeshi.fanli.service.inter.homemodule.CommonShareInfoService;
|
| | | import com.yeshi.fanli.service.manger.goods.ConvertLinkManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | | public class CommonShareInfoServiceImpl implements CommonShareInfoService {
|
| | |
|
| | | @Resource
|
| | | private CommonShareInfoMapper commonShareInfoMapper;
|
| | | |
| | | @Resource
|
| | | private ConvertLinkManager convertLinkManager;
|
| | |
|
| | | @Override
|
| | | public void save(CommonShareInfo record) throws SpecialException {
|
| | | if (record == null || record.getPid() == null || record.getType() == null)
|
| | | throw new SpecialException(1, "参数不完整");
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(record.getComment())) {
|
| | | if (record.getNeedSpin() == null)
|
| | | record.setNeedSpin(false);
|
| | | |
| | | if (record.getNeedSpin()) {
|
| | | try {
|
| | | convertLinkManager.convertLinkFromText(record.getComment(), Constant.LINK_TOKEN_VERIFY_UID, true,false);
|
| | | } catch (ConvertLinkExceptionException e) {
|
| | | if (ConvertLinkExceptionException.CODE_NONE != e.getCode()) {
|
| | | throw new SpecialException(1, "包含不可转链的口令与链接");
|
| | | }
|
| | | } catch (Exception e) {
|
| | | throw new SpecialException(1, "包含不可转链的口令与链接");
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | // 重置id
|
| | | record.setId(null);
|
| | | |
| | | CommonShareInfo info = commonShareInfoMapper.getByPidAndType(record.getPid(), record.getType().name());
|
| | | if (info == null) {
|
| | | commonShareInfoMapper.insertSelective(record);
|
| | | } else {
|
| | | record.setId(info.getId());
|
| | | commonShareInfoMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public CommonShareInfo getByPidAndType(Long pid, String type) {
|
| | | return commonShareInfoMapper.getByPidAndType(pid, type);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public void deleteByPidAndType(Long pid, String type) {
|
| | | commonShareInfoMapper.deleteByPidAndType(pid, type);
|
| | | }
|
| | | }
|
| | | package com.yeshi.fanli.service.impl.homemodule; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.yeshi.fanli.dao.mybatis.homemodule.CommonShareInfoMapper; |
| | | import com.yeshi.fanli.entity.bus.homemodule.CommonShareInfo; |
| | | import com.yeshi.fanli.exception.goods.ConvertLinkException; |
| | | import com.yeshi.fanli.exception.homemodule.SpecialException; |
| | | import com.yeshi.fanli.service.inter.homemodule.CommonShareInfoService; |
| | | import com.yeshi.fanli.service.manger.goods.ConvertLinkManager; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | |
| | | @Service |
| | | public class CommonShareInfoServiceImpl implements CommonShareInfoService { |
| | | |
| | | @Resource |
| | | private CommonShareInfoMapper commonShareInfoMapper; |
| | | |
| | | @Resource |
| | | private ConvertLinkManager convertLinkManager; |
| | | |
| | | @Override |
| | | public void save(CommonShareInfo record) throws SpecialException { |
| | | if (record == null || record.getPid() == null || record.getType() == null) |
| | | throw new SpecialException(1, "参数不完整"); |
| | | |
| | | if (!StringUtil.isNullOrEmpty(record.getComment())) { |
| | | if (record.getNeedSpin() == null) |
| | | record.setNeedSpin(false); |
| | | |
| | | if (record.getNeedSpin()) { |
| | | try { |
| | | convertLinkManager.convertLinkFromText(SystemEnum.blks, record.getComment(), Constant.LINK_TOKEN_VERIFY_UID, true,false); |
| | | } catch (ConvertLinkException e) { |
| | | if (ConvertLinkException.CODE_NONE != e.getCode()) { |
| | | throw new SpecialException(1, "包含不可转链的口令与链接"); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new SpecialException(1, "包含不可转链的口令与链接"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 重置id |
| | | record.setId(null); |
| | | |
| | | CommonShareInfo info = commonShareInfoMapper.getByPidAndType(record.getPid(), record.getType().name()); |
| | | if (info == null) { |
| | | commonShareInfoMapper.insertSelective(record); |
| | | } else { |
| | | record.setId(info.getId()); |
| | | commonShareInfoMapper.updateByPrimaryKeySelective(record); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public CommonShareInfo getByPidAndType(Long pid, String type) { |
| | | return commonShareInfoMapper.getByPidAndType(pid, type); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void deleteByPidAndType(Long pid, String type) { |
| | | commonShareInfoMapper.deleteByPidAndType(pid, type); |
| | | } |
| | | } |