Commit ffdd5952 authored by luzhuang's avatar luzhuang

修改接口

parent e86b7f8c
......@@ -57,7 +57,7 @@ public class BLabelController extends PaginationController<BLabel> {
@ApiImplicitParam(name = "lName", value = "标签名", required = true, dataType = "varchar")})
@PostMapping(value = "/update")
public Result update(CurUser curUser,@Valid BLabel bLabel,BindingResult br){
PersistModel data = bLabelService.updateLabel(bLabel);
PersistModel data = bLabelService.updateLabel(bLabel,curUser);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
......@@ -69,7 +69,7 @@ public class BLabelController extends PaginationController<BLabel> {
@ApiImplicitParam(name = "lName", value = "标签名", required = true, dataType = "varchar")})
@PostMapping(value = "/add")
public Result insert(CurUser curUser,@Valid BLabel bLabel,BindingResult br){
PersistModel data = bLabelService.insertLabel(bLabel);
PersistModel data = bLabelService.insertLabel(bLabel,curUser);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
......
......@@ -21,8 +21,12 @@ public interface BLabelRepository extends BaseMapper<BLabel> {
List<BLabel> queryBlabels(@Param("lName") String lName,@Param("corpId")String corpId);
// 增加标签是检查标签名重复
@Select("SELECT * from b_label where l_name=#{lName} AND del_flag='0' and flag='1'")
List<BLabel> checknameByName(BLabel bLabel);
@Select("<script>select count(0) from b_label " +
"where l_name = #{lName} " +
"AND del_flag='0' and flag='1' " +
"<if test=\"businessId!=null and businessId != ''\"> and business_id != #{businessId} </if>" +
"and corp_id = #{corpId}</script>")
int checknameByName(@Param("lName")String lName,@Param("businessId")String businessId,@Param("corpId") String corpId);
// 逻辑删除标签
@Update("UPDATE b_label SET del_flag='1' where business_id = #{businessId}")
......
......@@ -3,6 +3,7 @@ package org.rcisoft.business.blabel.service;
import org.rcisoft.business.blabel.entity.BLabel;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.sys.user.bean.CurUser;
import java.util.List;
......@@ -12,9 +13,9 @@ public interface BLabelService {
List<BLabel> queryBlabels(String lName,String corpId);
PersistModel insertLabel(BLabel bLabel);
PersistModel insertLabel(BLabel bLabel, CurUser curUser);
PersistModel updateLabel(BLabel bLabel);
PersistModel updateLabel(BLabel bLabel, CurUser curUser);
PersistModel removeLabel(String id);
}
......@@ -10,6 +10,7 @@ import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.sys.user.bean.CurUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......@@ -34,12 +35,12 @@ public class BLabelServiceImpl implements BLabelService {
@Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public PersistModel insertLabel(BLabel bLabel) {
public PersistModel insertLabel(BLabel bLabel, CurUser curUser) {
if(StringUtils.isBlank(bLabel.getLName())){
throw new ServiceException("标签名称不能为空");
}
List<BLabel> line = bLabelRepository.checknameByName(bLabel);
if(line.size()>0){
int line = bLabelRepository.checknameByName(bLabel.getLName(),bLabel.getBusinessId(),curUser.getCorpId());
if(line > 0){
throw new ServiceException(ResultServiceEnums.NAME_IS_EXISTS);
}
UserUtil.setCurrentPersistOperation(bLabel);
......@@ -48,12 +49,12 @@ public class BLabelServiceImpl implements BLabelService {
@Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public PersistModel updateLabel(BLabel bLabel) {
public PersistModel updateLabel(BLabel bLabel, CurUser curUser) {
if(StringUtils.isBlank(bLabel.getLName())){
throw new ServiceException("标签名称不能为空");
}
List<BLabel> line = bLabelRepository.checknameByName(bLabel);
if(line.size()>0){
int line = bLabelRepository.checknameByName(bLabel.getLName(),bLabel.getBusinessId(),curUser.getCorpId());
if(line > 0){
throw new ServiceException(ResultServiceEnums.NAME_IS_EXISTS);
}
UserUtil.setCurrentMergeOperation(bLabel);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment