删除时级联删除关联表

main
hshansha 2 months ago
parent ded53abc74
commit 8ca7584f8d

@ -123,7 +123,7 @@ public class KhVoteController extends BaseController {
@Transactional
public AjaxResult add(@RequestBody KhVote khVote) {
khVoteService.insertKhVote(khVote);
if(khVote.getSamePercent().equals("0")){
if(khVote.getSamePercent()==null||khVote.getSamePercent().equals("0")){
//根据评测id查询职工评测关联 职工
KhPcEmp query = new KhPcEmp();
query.setPcId(khVote.getPingceId());
@ -180,7 +180,7 @@ public class KhVoteController extends BaseController {
KhVoteEmp query = new KhVoteEmp();
query.setVoteId(khVote.getId());
List<KhVoteEmp> khVoteEmps = voteEmpService.selectKhVoteEmpList(query);
if (khVote.getSamePercent().equals("0")) {
if (khVote.getSamePercent()==null||khVote.getSamePercent().equals("0")) {
for (KhVoteEmp khVoteEmp : khVoteEmps) {
khVoteEmp.setPercentage(khVote.getPercentage());
khVoteEmp.setVoteTitle(khVote.getVoteTitle());

@ -1,12 +1,17 @@
package com.ruoyi.kaohe.service.impl;
import java.util.List;
import java.util.stream.Collectors;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.kaohe.domain.KhVoteEmp;
import com.ruoyi.kaohe.mapper.KhVoteEmpMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.kaohe.mapper.KhVoteMapper;
import com.ruoyi.kaohe.domain.KhVote;
import com.ruoyi.kaohe.service.IKhVoteService;
import org.springframework.transaction.annotation.Transactional;
/**
* Service
@ -19,7 +24,8 @@ public class KhVoteServiceImpl implements IKhVoteService
{
@Autowired
private KhVoteMapper khVoteMapper;
@Autowired
private KhVoteEmpMapper khVoteEmpMapper;
/**
*
*
@ -77,8 +83,18 @@ public class KhVoteServiceImpl implements IKhVoteService
* @return
*/
@Override
@Transactional
public int deleteKhVoteByIds(Long[] ids)
{
//voteid查询职工评分修改对应值 同步删除关联表对应数据
for (Long id : ids) {
KhVoteEmp query = new KhVoteEmp();
query.setVoteId(id);
List<KhVoteEmp> khVoteEmps = khVoteEmpMapper.selectKhVoteEmpList(query);
List<Long> veIds = khVoteEmps.stream().map(KhVoteEmp::getId).collect(Collectors.toList());
khVoteEmpMapper.deleteKhVoteEmpByIds(veIds.toArray(new Long[veIds.size()]));
}
return khVoteMapper.deleteKhVoteByIds(ids);
}

@ -49,6 +49,7 @@
<if test="state != null and state != ''"> and state = #{state}</if>
<if test="samePercent != null and samePercent != ''"> and same_percent = #{samePercent}</if>
</where>
ORDER BY id DESC
</select>
<select id="getListByPcIdAndItemIds" parameterType="KhVote" resultMap="KhVoteResult">

Loading…
Cancel
Save