package com.yeshi.fanli.service.impl.homemodule;
|
|
import javax.annotation.Resource;
|
|
import org.springframework.stereotype.Service;
|
|
import com.yeshi.fanli.dao.mybatis.homemodule.SpecialExtraMapper;
|
import com.yeshi.fanli.entity.bus.homemodule.SpecialExtra;
|
import com.yeshi.fanli.exception.goods.ConvertLinkExceptionException;
|
import com.yeshi.fanli.exception.homemodule.SpecialException;
|
import com.yeshi.fanli.service.inter.homemodule.SpecialExtraService;
|
import com.yeshi.fanli.service.manger.goods.ConvertLinkManager;
|
import com.yeshi.fanli.util.Constant;
|
import com.yeshi.fanli.util.StringUtil;
|
|
@Service
|
public class SpecialExtraServiceImpl implements SpecialExtraService {
|
|
@Resource
|
private SpecialExtraMapper specialExtraMapper;
|
|
@Resource
|
private ConvertLinkManager convertLinkManager;
|
|
@Override
|
public void saveExtraInfo(SpecialExtra record) throws SpecialException {
|
if (record == null || record.getId() == null)
|
return;
|
|
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);
|
} catch (ConvertLinkExceptionException e) {
|
if (ConvertLinkExceptionException.CODE_NONE != e.getCode()) {
|
throw new SpecialException(1, "包含不可转链的口令与链接");
|
}
|
} catch (Exception e) {
|
throw new SpecialException(1, "包含不可转链的口令与链接");
|
}
|
}
|
}
|
|
SpecialExtra extra = specialExtraMapper.selectByPrimaryKey(record.getId());
|
if (extra == null) {
|
specialExtraMapper.insertSelective(record);
|
} else {
|
specialExtraMapper.updateByPrimaryKeySelective(record);
|
}
|
}
|
|
@Override
|
public SpecialExtra selectByPrimaryKey(Long id) {
|
return specialExtraMapper.selectByPrimaryKey(id);
|
}
|
|
}
|