瀏覽代碼

门店联系人删除时删除联系人用户

liyuan 1 月之前
父節點
當前提交
8594b42019

+ 11 - 0
blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/feign/IUserClient.java

@@ -79,6 +79,8 @@ public interface IUserClient {
 	String UPDATE_CAR_OWNER_STORE_DATA = API_PREFIX + "/updateCarOwnerStoreData";
 	String REMOVE_USER_BY_IDS_AND_DEPT_ID = API_PREFIX + "/removeUserByIdsAndDeptId";
 
+	String DEL_USER_BY_ID = API_PREFIX + "/delUserById";
+
 	/**
 	 * 创建车主用户及车主与门店信息关联
 	 *
@@ -362,4 +364,13 @@ public interface IUserClient {
 	 */
 	@PostMapping(REMOVE_USER_BY_IDS_AND_DEPT_ID)
 	boolean removeUserByIdsAndDeptId(@RequestParam("deptId") String deptId, @RequestParam("userIds") List<Long> userIds);
+
+	/**
+	 * 删除用户
+	 *
+	 * @param delUser 用户信息
+	 * @return 删除结果
+	 */
+	@PostMapping(DEL_USER_BY_ID)
+	int delUserById(@RequestBody User delUser);
 }

+ 5 - 0
blade-service/blade-user/src/main/java/org/springblade/system/user/feign/UserClient.java

@@ -551,6 +551,11 @@ public class UserClient implements IUserClient {
 		return service.remove(new LambdaUpdateWrapper<User>().eq(User::getDeptId, deptId).in(User::getId, userIds));
 	}
 
+	@Override
+	public int delUserById(User delUser) {
+		return service.delUserById(delUser);
+	}
+
 
 	private Dept handleDepartment(String customerName, User srcUser, List<Dept> dealerDeptList,
 								  Long parentId, String tenantId, List<Dept> updateDeptList) {

+ 8 - 0
blade-service/blade-user/src/main/java/org/springblade/system/user/mapper/UserMapper.java

@@ -81,4 +81,12 @@ public interface UserMapper extends BaseMapper<User> {
 
 	@TenantIgnore
 	List<User> selectListUser(String tenantId);
+
+	/**
+	 * 删除用户
+	 *
+	 * @param delUser 删除用户
+	 * @return 删除结果
+	 */
+    int delUserById(User delUser);
 }

+ 10 - 0
blade-service/blade-user/src/main/java/org/springblade/system/user/mapper/UserMapper.xml

@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!--suppress ALL -->
 <mapper namespace="org.springblade.system.user.mapper.UserMapper">
 
     <!-- 通用查询映射结果 -->
@@ -38,6 +39,15 @@
         </if>
         where id = #{users.id}
     </update>
+    <delete id="delUserById" parameterType="org.springblade.system.user.entity.User">
+        UPDATE blade_user
+        SET update_user = #{updateUser},
+            update_time = #{updateTime},
+            is_deleted = #{isDeleted}
+        WHERE
+            id = #{id}
+          AND is_deleted = 0
+    </delete>
 
     <select id="selectUserPage" resultMap="userResultMap">
         select * from blade_user where is_deleted = 0

+ 8 - 0
blade-service/blade-user/src/main/java/org/springblade/system/user/service/IUserService.java

@@ -286,4 +286,12 @@ public interface IUserService extends BaseService<User> {
 	 * @return 结果
 	 */
 	R updateCarUserDetail(User user);
+
+	/**
+	 * 删除用户
+	 *
+	 * @param delUser 删除用户
+	 * @return 删除结果
+	 */
+	int delUserById(User delUser);
 }

+ 5 - 0
blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java

@@ -671,6 +671,11 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
 		return R.status(updateById(updateUser));
 	}
 
+	@Override
+	public int delUserById(User delUser) {
+		return baseMapper.delUserById(delUser);
+	}
+
 	/**
 	 * 查询顶级部门ID
 	 */

+ 11 - 0
blade-service/gubersail-dealer-admin/src/main/java/com/gubersail/admin/corp/controller/CorpsAttnController.java

@@ -135,4 +135,15 @@ public class CorpsAttnController extends BladeController {
 		return corpsAttnService.createUser(id);
 	}
 
+
+	/**
+	 * 删除门店联系人
+	 */
+	@PostMapping("/delCorpsAttn")
+	@ApiOperationSupport(order = 5)
+	@ApiOperation(value = "修改", notes = "传入corpsAttn")
+	public R delCorpsAttn(@Valid @RequestBody PjCorpsAttn corpsAttn) {
+		return corpsAttnService.delCorpsAttn(corpsAttn);
+	}
+
 }

+ 9 - 0
blade-service/gubersail-dealer-admin/src/main/java/com/gubersail/admin/corp/service/ICorpsAttnService.java

@@ -22,6 +22,7 @@ import com.gubersail.dealer.admin.api.corps.entity.PjCorpsAttn;
 import com.gubersail.dealer.admin.api.corps.vo.CorpsAttnVO;
 import org.springblade.core.tool.api.R;
 
+import javax.validation.Valid;
 import java.util.List;
 
 /**
@@ -58,4 +59,12 @@ public interface ICorpsAttnService extends IService<PjCorpsAttn> {
 	 * 根据当前登陆人获得客户联系人-批量
 	 */
 	void createUserBatch(List<PjCorpsAttn> corpsAttnList);
+
+	/**
+	 * 删除客户联系人
+	 *
+	 * @param corpsAttn 参数
+	 * @return 结果
+	 */
+	R delCorpsAttn(@Valid PjCorpsAttn corpsAttn);
 }

+ 33 - 16
blade-service/gubersail-dealer-admin/src/main/java/com/gubersail/admin/corp/service/impl/CorpsAttnServiceImpl.java

@@ -1,19 +1,3 @@
-/*
- *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
- *
- *  Redistribution and use in source and binary forms, with or without
- *  modification, are permitted provided that the following conditions are met:
- *
- *  Redistributions of source code must retain the above copyright notice,
- *  this list of conditions and the following disclaimer.
- *  Redistributions in binary form must reproduce the above copyright
- *  notice, this list of conditions and the following disclaimer in the
- *  documentation and/or other materials provided with the distribution.
- *  Neither the name of the dreamlu.net developer nor the names of its
- *  contributors may be used to endorse or promote products derived from
- *  this software without specific prior written permission.
- *  Author: Chill 庄骞 (smallchill@163.com)
- */
 package com.gubersail.admin.corp.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -26,6 +10,7 @@ import com.gubersail.dealer.admin.api.corps.entity.PjCorpsAttn;
 import com.gubersail.dealer.admin.api.corps.vo.CorpsAttnVO;
 import lombok.AllArgsConstructor;
 import org.springblade.common.constant.LandConstant;
+import org.springblade.common.enums.NumberEnum;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
@@ -36,7 +21,9 @@ import org.springblade.system.user.feign.IUserClient;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Date;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * 配件批发客户明细联系人 服务实现类
@@ -163,4 +150,34 @@ public class CorpsAttnServiceImpl extends ServiceImpl<CorpsAttnMapper, PjCorpsAt
 		this.updateBatchById(corpsAttnList);
 	}
 
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public R delCorpsAttn(PjCorpsAttn corpsAttn) {
+		if (Objects.isNull(corpsAttn.getId())) {
+			return R.fail("请选择要删除的数据");
+		}
+		PjCorpsAttn attn = baseMapper.selectById(corpsAttn.getId());
+		if (Objects.isNull(attn)) {
+			return R.success("操作成功");
+		}
+		Date nowDate = new Date();
+		Long userId = AuthUtil.getUserId();
+		if (!Objects.isNull(attn.getUserId())) {
+			User delUser = new User();
+			delUser.setId(attn.getUserId());
+			delUser.setIsDeleted(NumberEnum.ONE.number);
+			delUser.setUpdateTime(nowDate);
+			delUser.setUpdateUser(userId);
+			int success = userClient.delUserById(delUser);
+			if (success <= 0) {
+				return R.fail("删除用户失败");
+			}
+		}
+		corpsAttn.setUpdateTime(nowDate);
+		corpsAttn.setUpdateUser(userId);
+		corpsAttn.setIsDeleted(NumberEnum.ONE.number);
+		int updateCount = baseMapper.updateById(corpsAttn);
+		return R.status(updateCount > 0);
+	}
+
 }