添加商户广告关联时删除之前的关联

master
吴顺杰 2 years ago
parent 7dcd519017
commit 336e930833

@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
/**
*
@ -53,7 +54,7 @@ public class WeChatController extends BaseController {
*/
@ApiOperation("获取微信二维码")
@PostMapping("/findWxCode")
public AjaxResult findWxCode(@RequestBody WeChatCodeRequest req) {
public AjaxResult findWxCode(@Valid @RequestBody WeChatCodeRequest req) {
return AjaxResult.success(weChatService.findWxCode(req));
}

@ -91,4 +91,11 @@ public interface BShanghuMapper {
* @return
*/
BShanghu findByPhone(@Param("phoneNumber") String phoneNumber);
/**
* 广
*
* @param posterId 广id
*/
void editByPosterId(@Param("posterId") Long posterId);
}

@ -1,6 +1,5 @@
package com.ruoyi.system.service;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.domain.BShanghu;
import java.util.List;
@ -87,8 +86,16 @@ public interface IBShanghuService {
/**
*
*
* @param phoneNumber
* @return
*/
BShanghu findByPhone(String phoneNumber);
/**
* 广
*
* @param posterId 广id
*/
void editByPosterId(Long posterId);
}

@ -115,6 +115,11 @@ public class BPosterServiceImpl implements IBPosterService {
if (BeanUtil.isEmpty(bPoster)) {
throw new ServiceException("所选广告不存在");
}
if (CollectionUtil.isEmpty(req.getShanghuIds()) && StrUtil.isEmpty(req.getShanghuCity()) && StrUtil.isEmpty(req.getShanghuName())) {
throw new ServiceException("商户不能为空");
}
// 删除广告商户关联
shanghuService.editByPosterId(req.getPosterId());
if (CollectionUtil.isNotEmpty(req.getShanghuIds())) {
shanghuService.editPostIdByIds(req.getPosterId(), req.getShanghuIds());
return;

@ -170,4 +170,14 @@ public class BShanghuServiceImpl implements IBShanghuService {
public BShanghu findByPhone(String phoneNumber) {
return bShanghuMapper.findByPhone(phoneNumber);
}
/**
* 广
*
* @param posterId 广id
*/
@Override
public void editByPosterId(Long posterId) {
bShanghuMapper.editByPosterId(posterId);
}
}

@ -116,6 +116,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</update>
<update id="editByPosterId">
update b_shanghu
set poster_id = null
where poster_id = #{posterId}
</update>
<delete id="deleteBShanghuById" parameterType="Long">
delete from b_shanghu where id = #{id}

Loading…
Cancel
Save