Ver código fonte

i标签删除做权限控制,删除记录保留

zyy 2 semanas atrás
pai
commit
43a6213d98

+ 44 - 5
fs-company/src/main/java/com/fs/company/controller/crm/CrmCustomerPropertyController.java

@@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
+import java.util.Date;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
@@ -136,25 +137,63 @@ public class CrmCustomerPropertyController extends BaseController {
         return toAjax(crmCustomerPropertyService.updateCrmCustomerProperty(property));
         return toAjax(crmCustomerPropertyService.updateCrmCustomerProperty(property));
     }
     }
 
 
+//    @ApiOperation("删除客户属性标签")
+//    @PreAuthorize("@ss.hasPermi('crm:customer:edit')")
+//    @Log(title = "客户属性标签", businessType = BusinessType.DELETE)
+//    @DeleteMapping("/{ids}")
+//    public AjaxResult remove(@PathVariable Long[] ids) {
+//        return toAjax(crmCustomerPropertyService.deleteCrmCustomerPropertyByIds(ids));
+//    }
+
+//    @ApiOperation("删除客户单个属性标签")
+//    @PreAuthorize("@ss.hasPermi('crm:customer:edit')")
+//    @Log(title = "客户属性标签", businessType = BusinessType.DELETE)
+//    @DeleteMapping("/deleteByPropertyId")
+//    public AjaxResult deleteByPropertyId(
+//            @ApiParam(required = true, name = "customerId", value = "客户 ID") @RequestParam Long customerId,
+//            @ApiParam(required = true, name = "propertyId", value = "属性模板 ID") @RequestParam Long propertyId) {
+//        return toAjax(crmCustomerPropertyService.lambdaUpdate()
+//                .eq(CrmCustomerProperty::getCustomerId, customerId)
+//                .eq(CrmCustomerProperty::getPropertyId, propertyId)
+//                .remove());
+//    }
+
     @ApiOperation("删除客户属性标签")
     @ApiOperation("删除客户属性标签")
-    @PreAuthorize("@ss.hasPermi('crm:customer:edit')")
+    @PreAuthorize("@ss.hasPermi('crm:customerProperty:delete')")
     @Log(title = "客户属性标签", businessType = BusinessType.DELETE)
     @Log(title = "客户属性标签", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}")
     @DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable Long[] ids) {
     public AjaxResult remove(@PathVariable Long[] ids) {
-        return toAjax(crmCustomerPropertyService.deleteCrmCustomerPropertyByIds(ids));
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Date now = new Date();
+        boolean success = crmCustomerPropertyService.lambdaUpdate()
+                .in(CrmCustomerProperty::getId, ids)
+                .eq(CrmCustomerProperty::getDeleted, 0)
+                .set(CrmCustomerProperty::getDeleted, 1)
+                .set(CrmCustomerProperty::getDeleteBy, loginUser.getUsername())
+                .set(CrmCustomerProperty::getDeleteTime, now)
+                .update();
+
+        return toAjax(success);
     }
     }
 
 
     @ApiOperation("删除客户单个属性标签")
     @ApiOperation("删除客户单个属性标签")
-    @PreAuthorize("@ss.hasPermi('crm:customer:edit')")
+    @PreAuthorize("@ss.hasPermi('crm:customerProperty:delete')")
     @Log(title = "客户属性标签", businessType = BusinessType.DELETE)
     @Log(title = "客户属性标签", businessType = BusinessType.DELETE)
     @DeleteMapping("/deleteByPropertyId")
     @DeleteMapping("/deleteByPropertyId")
     public AjaxResult deleteByPropertyId(
     public AjaxResult deleteByPropertyId(
             @ApiParam(required = true, name = "customerId", value = "客户 ID") @RequestParam Long customerId,
             @ApiParam(required = true, name = "customerId", value = "客户 ID") @RequestParam Long customerId,
             @ApiParam(required = true, name = "propertyId", value = "属性模板 ID") @RequestParam Long propertyId) {
             @ApiParam(required = true, name = "propertyId", value = "属性模板 ID") @RequestParam Long propertyId) {
-        return toAjax(crmCustomerPropertyService.lambdaUpdate()
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        boolean success = crmCustomerPropertyService.lambdaUpdate()
                 .eq(CrmCustomerProperty::getCustomerId, customerId)
                 .eq(CrmCustomerProperty::getCustomerId, customerId)
                 .eq(CrmCustomerProperty::getPropertyId, propertyId)
                 .eq(CrmCustomerProperty::getPropertyId, propertyId)
-                .remove());
+                .eq(CrmCustomerProperty::getDeleted, 0)
+                .set(CrmCustomerProperty::getDeleted, 1)
+                .set(CrmCustomerProperty::getDeleteBy, loginUser.getUsername())
+                .set(CrmCustomerProperty::getDeleteTime, new Date())
+                .update();
+
+        return toAjax(success);
     }
     }
 
 
     @ApiOperation("导出客户属性标签")
     @ApiOperation("导出客户属性标签")

+ 8 - 0
fs-service/src/main/java/com/fs/crm/domain/CrmCustomerProperty.java

@@ -5,6 +5,8 @@ import com.fs.common.core.domain.BaseEntityTow;
 import lombok.Data;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.EqualsAndHashCode;
 
 
+import java.util.Date;
+
 @Data
 @Data
 @EqualsAndHashCode(callSuper = true)
 @EqualsAndHashCode(callSuper = true)
 public class CrmCustomerProperty extends BaseEntityTow {
 public class CrmCustomerProperty extends BaseEntityTow {
@@ -35,4 +37,10 @@ public class CrmCustomerProperty extends BaseEntityTow {
 
 
     @Excel(name = "喜欢占比")
     @Excel(name = "喜欢占比")
     private Integer likeRatio;
     private Integer likeRatio;
+
+    private Integer deleted;
+
+    private String deleteBy;
+
+    private Date deleteTime;
 }
 }

+ 14 - 2
fs-service/src/main/java/com/fs/crm/service/impl/CrmCustomerPropertyServiceImpl.java

@@ -23,6 +23,7 @@ import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 
 
+import java.util.Date;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
@@ -230,12 +231,23 @@ public class CrmCustomerPropertyServiceImpl extends ServiceImpl<CrmCustomerPrope
                 property.setTradeType("3");
                 property.setTradeType("3");
                 property.setIntention("medium");
                 property.setIntention("medium");
                 property.setLikeRatio(50);
                 property.setLikeRatio(50);
+                property.setDeleted(0);
+                property.setDeleteBy(null);
+                property.setDeleteTime(null);
                 return property;
                 return property;
             }).collect(Collectors.toList());
             }).collect(Collectors.toList());
-            remove(new LambdaQueryWrapper<CrmCustomerProperty>()
+//            remove(new LambdaQueryWrapper<CrmCustomerProperty>()
+//                    .eq(CrmCustomerProperty::getCustomerId, companyVoiceRoboticCallees.getUserId())
+//                    .in(CrmCustomerProperty::getPropertyId, ids)
+//            );
+            lambdaUpdate()
                     .eq(CrmCustomerProperty::getCustomerId, companyVoiceRoboticCallees.getUserId())
                     .eq(CrmCustomerProperty::getCustomerId, companyVoiceRoboticCallees.getUserId())
                     .in(CrmCustomerProperty::getPropertyId, ids)
                     .in(CrmCustomerProperty::getPropertyId, ids)
-            );
+                    .eq(CrmCustomerProperty::getDeleted, 0)
+                    .set(CrmCustomerProperty::getDeleted, 1)
+                    .set(CrmCustomerProperty::getDeleteBy, "system")
+                    .set(CrmCustomerProperty::getDeleteTime, DateUtils.getNowDate())
+                    .update();
             saveBatch(propertyList);
             saveBatch(propertyList);
         } catch (JsonProcessingException e) {
         } catch (JsonProcessingException e) {
             throw new RuntimeException(e);
             throw new RuntimeException(e);

+ 17 - 4
fs-service/src/main/resources/mapper/crm/CrmCustomerPropertyMapper.xml

@@ -20,15 +20,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateTime"    column="update_time"    />
         <result property="updateTime"    column="update_time"    />
         <result property="updateBy"    column="update_by"    />
         <result property="updateBy"    column="update_by"    />
         <result property="remark"    column="remark"    />
         <result property="remark"    column="remark"    />
+        <result property="deleted" column="deleted"/>
+        <result property="deleteBy" column="delete_by"/>
+        <result property="deleteTime" column="delete_time"/>
     </resultMap>
     </resultMap>
 
 
     <sql id="selectCrmCustomerPropertyVo">
     <sql id="selectCrmCustomerPropertyVo">
-        select id, customer_id, property_id, property_name, property_value, property_value_type, trade_type, ai_analysis, intention, like_ratio, create_time, create_by, update_time, update_by, remark from crm_customer_property
+        select id, customer_id, property_id, property_name, property_value, property_value_type, trade_type, ai_analysis, intention, like_ratio, create_time, create_by, update_time, update_by, remark, deleted, delete_by, delete_time from crm_customer_property
     </sql>
     </sql>
 
 
     <select id="selectCrmCustomerPropertyList" parameterType="CrmCustomerProperty" resultMap="CrmCustomerPropertyResult">
     <select id="selectCrmCustomerPropertyList" parameterType="CrmCustomerProperty" resultMap="CrmCustomerPropertyResult">
         <include refid="selectCrmCustomerPropertyVo"/>
         <include refid="selectCrmCustomerPropertyVo"/>
         <where>
         <where>
+            deleted = 0
             <if test="customerId != null"> and customer_id = #{customerId}</if>
             <if test="customerId != null"> and customer_id = #{customerId}</if>
             <if test="propertyId != null"> and property_id = #{propertyId}</if>
             <if test="propertyId != null"> and property_id = #{propertyId}</if>
             <if test="propertyName != null and propertyName != ''"> and property_name like concat('%', #{propertyName}, '%')</if>
             <if test="propertyName != null and propertyName != ''"> and property_name like concat('%', #{propertyName}, '%')</if>
@@ -41,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
     <select id="selectCrmCustomerPropertyById" parameterType="Long" resultMap="CrmCustomerPropertyResult">
     <select id="selectCrmCustomerPropertyById" parameterType="Long" resultMap="CrmCustomerPropertyResult">
         <include refid="selectCrmCustomerPropertyVo"/>
         <include refid="selectCrmCustomerPropertyVo"/>
-        where id = #{id}
+        where id = #{id} and deleted = 0
     </select>
     </select>
 
 
     <insert id="insertCrmCustomerProperty" parameterType="CrmCustomerProperty" useGeneratedKeys="true" keyProperty="id">
     <insert id="insertCrmCustomerProperty" parameterType="CrmCustomerProperty" useGeneratedKeys="true" keyProperty="id">
@@ -61,6 +65,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateTime != null">update_time,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="updateBy != null">update_by,</if>
             <if test="updateBy != null">update_by,</if>
             <if test="remark != null">remark,</if>
             <if test="remark != null">remark,</if>
+            <if test="deleted != null">deleted,</if>
+            <if test="deleteBy != null">delete_by,</if>
+            <if test="deleteTime != null">delete_time,</if>
         </trim>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="customerId != null">#{customerId},</if>
             <if test="customerId != null">#{customerId},</if>
@@ -77,6 +84,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateTime != null">#{updateTime},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateBy != null">#{updateBy},</if>
             <if test="remark != null">#{remark},</if>
             <if test="remark != null">#{remark},</if>
+            <if test="deleted != null">#{deleted},</if>
+            <if test="deleteBy != null">#{deleteBy},</if>
+            <if test="deleteTime != null">#{deleteTime},</if>
         </trim>
         </trim>
     </insert>
     </insert>
 
 
@@ -97,6 +107,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="remark != null">remark = #{remark},</if>
             <if test="remark != null">remark = #{remark},</if>
+            <if test="deleted != null">deleted = #{deleted},</if>
+            <if test="deleteBy != null">delete_by = #{deleteBy},</if>
+            <if test="deleteTime != null">delete_time = #{deleteTime},</if>
         </trim>
         </trim>
         where id = #{id}
         where id = #{id}
     </update>
     </update>
@@ -114,13 +127,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
     <select id="selectCrmCustomerPropertyByCustomerId" parameterType="Long" resultMap="CrmCustomerPropertyResult">
     <select id="selectCrmCustomerPropertyByCustomerId" parameterType="Long" resultMap="CrmCustomerPropertyResult">
         <include refid="selectCrmCustomerPropertyVo"/>
         <include refid="selectCrmCustomerPropertyVo"/>
-        where customer_id = #{customerId}
+        where customer_id = #{customerId} and deleted = 0
         order by id desc
         order by id desc
     </select>
     </select>
 
 
     <select id="selectByCustomerIdAndPropertyId" resultMap="CrmCustomerPropertyResult">
     <select id="selectByCustomerIdAndPropertyId" resultMap="CrmCustomerPropertyResult">
         <include refid="selectCrmCustomerPropertyVo"/>
         <include refid="selectCrmCustomerPropertyVo"/>
-        where customer_id = #{customerId} and property_id = #{propertyId}
+        where customer_id = #{customerId} and property_id = #{propertyId} and deleted = 0
         limit 1
         limit 1
     </select>
     </select>