Merge remote-tracking branch 'origin/dev/feat/partner1.3_20230828' into dev/feat/partner1.3_20230828
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
import com.cool.store.dto.label.LabelAddDTO;
|
||||
import com.cool.store.dto.label.LabelDeleteDTO;
|
||||
import com.cool.store.dto.label.LabelListDTO;
|
||||
import com.cool.store.dto.label.LabelUpdateDTO;
|
||||
import com.cool.store.exception.ApiException;
|
||||
import com.cool.store.vo.LabelListVo;
|
||||
|
||||
import java.util.List;
|
||||
@@ -23,5 +26,17 @@ public interface LabelService {
|
||||
* 添加标签组
|
||||
* @param dto 新增标签组信息
|
||||
*/
|
||||
void addLabel(LabelAddDTO dto);
|
||||
void addLabel(LabelAddDTO dto) throws ApiException;
|
||||
|
||||
/**
|
||||
* 修改标签信息
|
||||
* @param dto 新标签信息
|
||||
*/
|
||||
void updateLabel(LabelUpdateDTO dto) throws ApiException;
|
||||
|
||||
/**
|
||||
* 删除标签
|
||||
* @param dto
|
||||
*/
|
||||
void deleteLabel(LabelDeleteDTO dto);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,12 @@ package com.cool.store.service.impl;
|
||||
|
||||
import com.cool.store.context.CurrentUserHolder;
|
||||
import com.cool.store.dto.label.LabelAddDTO;
|
||||
import com.cool.store.dto.label.LabelDeleteDTO;
|
||||
import com.cool.store.dto.label.LabelListDTO;
|
||||
import com.cool.store.dto.label.LabelUpdateDTO;
|
||||
import com.cool.store.entity.HyPartnerLabelDO;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.exception.ApiException;
|
||||
import com.cool.store.mapper.HyPartnerLabelMapper;
|
||||
import com.cool.store.service.LabelService;
|
||||
import com.cool.store.vo.LabelListVo;
|
||||
@@ -38,15 +42,62 @@ public class LabelServiceImpl implements LabelService {
|
||||
* @param dto 新增标签组信息
|
||||
*/
|
||||
@Override
|
||||
public void addLabel(LabelAddDTO dto) {
|
||||
public void addLabel(LabelAddDTO dto) throws ApiException {
|
||||
HyPartnerLabelDO labelDO = new HyPartnerLabelDO();
|
||||
labelDO.setLabelName(dto.getLabelName());
|
||||
if (whetherLabelRepeat(labelDO)) {
|
||||
throw new ApiException(ErrorCodeEnum.LABEL_EXIST);
|
||||
}
|
||||
String userId = CurrentUserHolder.getUserId();
|
||||
labelDO.setLabelGroupId(dto.getLabelGroupId());
|
||||
labelDO.setLabelName(dto.getLabelName());
|
||||
labelDO.setEditUserId(userId);
|
||||
labelDO.setEditDate(new Date());
|
||||
labelDO.setCreateUserId(userId);
|
||||
labelDO.setUpdateUserId(userId);
|
||||
labelMapper.insertSelective(labelDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改标签信息
|
||||
* @param dto 新标签信息
|
||||
*/
|
||||
@Override
|
||||
public void updateLabel(LabelUpdateDTO dto) throws ApiException {
|
||||
HyPartnerLabelDO labelDO = new HyPartnerLabelDO();
|
||||
labelDO.setLabelName(dto.getLabelName());
|
||||
if (whetherLabelRepeat(labelDO)) {
|
||||
throw new ApiException(ErrorCodeEnum.LABEL_EXIST);
|
||||
}
|
||||
String userId = CurrentUserHolder.getUserId();
|
||||
labelDO.setId(dto.getId());
|
||||
labelDO.setLabelGroupId(dto.getLabelGroupId());
|
||||
labelDO.setEditUserId(userId);
|
||||
labelDO.setEditDate(new Date());
|
||||
labelDO.setUpdateUserId(userId);
|
||||
labelMapper.updateByPrimaryKeySelective(labelDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除标签
|
||||
* @param dto
|
||||
*/
|
||||
@Override
|
||||
public void deleteLabel(LabelDeleteDTO dto) {
|
||||
HyPartnerLabelDO labelDO = new HyPartnerLabelDO();
|
||||
String userId = CurrentUserHolder.getUserId();
|
||||
labelDO.setId(dto.getId());
|
||||
labelDO.setEditUserId(userId);
|
||||
labelDO.setEditDate(new Date());
|
||||
labelDO.setUpdateUserId(userId);
|
||||
labelDO.setDeleted(Boolean.TRUE);
|
||||
labelMapper.updateByPrimaryKeySelective(labelDO);
|
||||
}
|
||||
|
||||
private Boolean whetherLabelRepeat(HyPartnerLabelDO label) throws ApiException {
|
||||
List<HyPartnerLabelDO> hyPartnerLabelDOS = labelMapper.selectSelective(label);
|
||||
if (hyPartnerLabelDOS != null && hyPartnerLabelDOS.size() > 0) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user