Browse Source

增加客户模块操作日志

ruqinhu 5 năm trước cách đây
mục cha
commit
22c46c3c80

+ 82 - 0
src/main/java/com/ygj/yuemum/controller/customer/CustomerInfoServicelogController.java

@@ -0,0 +1,82 @@
+package com.ygj.yuemum.controller.customer;
+
+import com.ygj.yuemum.domain.customer.CustomerInfoServiceLog;
+import com.ygj.yuemum.service.customer.CustomerInfoServiceLogService;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+
+/**
+* customer_info_servicelog
+* @author zrz
+* @date 2020/07/13
+*/
+@RestController
+@RequestMapping(value = "/CustomerInfoServicelog")
+public class CustomerInfoServicelogController {
+
+    @Resource
+    private CustomerInfoServiceLogService customerInfoServicelogService;
+
+    /**
+    * [新增]
+    * @author zrz
+    * @date 2020/07/13
+    **/
+    @RequestMapping("/insert")
+    public int insert(CustomerInfoServiceLog customerInfoServicelog){
+        return customerInfoServicelogService.insert(customerInfoServicelog);
+    }
+
+    /**
+    * [刪除]
+    * @author zrz
+    * @date 2020/07/13
+    **/
+    @RequestMapping("/delete")
+    public int delete(int id){
+        return customerInfoServicelogService.delete(id);
+    }
+
+    /**
+    * [更新]
+    * @author zrz
+    * @date 2020/07/13
+    **/
+    @RequestMapping("/update")
+    public int update(CustomerInfoServiceLog customerInfoServicelog){
+        return customerInfoServicelogService.update(customerInfoServicelog);
+    }
+
+    /**
+    * [查询] 根据主键 id 查询
+    * @author zrz
+    * @date 2020/07/13
+    **/
+    @RequestMapping("/load")
+    public CustomerInfoServiceLog load(int id){
+        return customerInfoServicelogService.load(id);
+    }
+
+    @RequestMapping("/loadBySlNo")
+    public List<CustomerInfoServiceLog> loadBySlNo(int id){
+        return customerInfoServicelogService.loadBySlNo(id);
+    }
+
+
+    /**
+    * [查询] 分页查询
+    * @author zrz
+    * @date 2020/07/13
+    **/
+    @RequestMapping("/pageList")
+    public Map<String, Object> pageList(@RequestParam(required = false, defaultValue = "0") int offset,
+                                        @RequestParam(required = false, defaultValue = "10") int pagesize) {
+        return customerInfoServicelogService.pageList(offset, pagesize);
+    }
+
+}

+ 60 - 0
src/main/java/com/ygj/yuemum/dao/customer/CustomerInfoServiceLogMapper.java

@@ -0,0 +1,60 @@
+package com.ygj.yuemum.dao.customer;
+
+import com.ygj.yuemum.domain.customer.CustomerInfoServiceLog;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+* customer_info_servicelog
+* @author zrz
+* @date 2020/07/13
+*/
+@Repository
+public interface CustomerInfoServiceLogMapper {
+
+    /**
+    * [新增]
+    * @author zrz
+    * @date 2020/07/13
+    **/
+    int insert(CustomerInfoServiceLog customerInfoServicelog);
+
+    /**
+    * [刪除]
+    * @author zrz
+    * @date 2020/07/13
+    **/
+    int delete(int id);
+
+    /**
+    * [更新]
+    * @author zrz
+    * @date 2020/07/13
+    **/
+    int update(CustomerInfoServiceLog customerInfoServicelog);
+
+    /**
+    * [查询] 根据主键 id 查询
+    * @author zrz
+    * @date 2020/07/13
+    **/
+    CustomerInfoServiceLog load(int id);
+
+    List<CustomerInfoServiceLog> loadBySlNo(int sl_no);
+
+    /**
+    * [查询] 分页查询
+    * @author zrz
+    * @date 2020/07/13
+    **/
+    List<CustomerInfoServiceLog> pageList(int offset,int pagesize);
+
+    /**
+    * [查询] 分页查询 count
+    * @author zrz
+    * @date 2020/07/13
+    **/
+    int pageListCount(int offset,int pagesize);
+
+}

+ 64 - 0
src/main/java/com/ygj/yuemum/domain/customer/CustomerInfoServiceLog.java

@@ -0,0 +1,64 @@
+package com.ygj.yuemum.domain.customer;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+/**
+*  customer_info_servicelog
+* @author zrz 2020-07-13
+*/
+@Data
+public class CustomerInfoServiceLog implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+    * id
+    */
+    private Integer id;
+
+    /**
+    * 关联表单id
+    */
+    private Integer sl_no;
+
+    /**
+    * 产生操作记录的表
+    */
+    private String sl_table;
+
+    /**
+    * 记录时间
+    */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date sl_createdate;
+
+    /**
+    * varchar(255)
+    */
+    private String sl_comment;
+
+    /**
+    * 记录人
+    */
+    private Integer sl_userid;
+
+    /**
+    * 记录人姓名
+    */
+    private String sl_username;
+
+    /**
+    * 记录类型(增删改查)
+    */
+    private String sl_type;
+
+    public CustomerInfoServiceLog() {
+    }
+
+}

+ 35 - 1
src/main/java/com/ygj/yuemum/service/customer/CustomerInfoBasicService.java

@@ -1,13 +1,19 @@
 package com.ygj.yuemum.service.customer;
 
+import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.ygj.yuemum.dao.customer.CustomerInfoBasicDao;
+import com.ygj.yuemum.domain.admin.JlAdminUser;
 import com.ygj.yuemum.domain.customer.CustomerInfoBasic;
+import com.ygj.yuemum.domain.customer.CustomerInfoServiceLog;
 import com.ygj.yuemum.domain.customer.dto.CustomerInfoBasicCyDto;
 import com.ygj.yuemum.domain.customer.dto.CustomerInfoBasicDto;
+import com.ygj.yuemum.service.admin.JlAdminUserService;
+import org.apache.shiro.SecurityUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -23,9 +29,20 @@ public class CustomerInfoBasicService {
 	@Resource
 	private CustomerInfoBasicDao customerInfoBasicDao;
 
+	@Resource
+	CustomerInfoServiceLogService customerInfoServiceLogService;
+
+	@Resource
+	JlAdminUserService jladminuserService;
+
 
 	public int insert(CustomerInfoBasic customerInfoBasic) {
-		return customerInfoBasicDao.insert(customerInfoBasic);
+		int count =  customerInfoBasicDao.insert(customerInfoBasic);
+		if (count != 0) {
+			this.insertServiceLog(customerInfoBasic.getId(), "新增", customerInfoBasic);
+			return count;
+		}
+		return 0;
 	}
 
 
@@ -36,6 +53,7 @@ public class CustomerInfoBasicService {
 
 
 	public int update(CustomerInfoBasic customerInfoBasic) {
+		this.insertServiceLog(customerInfoBasic.getId(), "修改", customerInfoBasic);
 		int ret = customerInfoBasicDao.update(customerInfoBasic);
 		return ret;
 	}
@@ -68,4 +86,20 @@ public class CustomerInfoBasicService {
 		customerInfoBasicDao.insertInfoBasicList(list);
 	}
 
+	private void insertServiceLog(Integer sl_no, String type, CustomerInfoBasic customerInfoBasic) {
+		String principal = (String) SecurityUtils.getSubject().getPrincipal();
+		JlAdminUser jlAdminUser = jladminuserService.getUserMkt(principal);
+
+		CustomerInfoServiceLog customerInfoServiceLog = new CustomerInfoServiceLog();
+		customerInfoServiceLog.setSl_userid(jlAdminUser.getId());
+		customerInfoServiceLog.setSl_username(jlAdminUser.getName());
+		customerInfoServiceLog.setSl_createdate(new Date());
+		customerInfoServiceLog.setSl_no(sl_no);
+		customerInfoServiceLog.setSl_table("customer_info_basic");
+		customerInfoServiceLog.setSl_type(type);
+		customerInfoServiceLog.setSl_comment(JSONObject.toJSONString(customerInfoBasic));
+
+		customerInfoServiceLogService.insert(customerInfoServiceLog);
+	}
+
 }

+ 35 - 1
src/main/java/com/ygj/yuemum/service/customer/CustomerInfoFeedbackService.java

@@ -1,14 +1,20 @@
 package com.ygj.yuemum.service.customer;
 
+import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.ygj.yuemum.dao.customer.CustomerInfoFeedbackDao;
+import com.ygj.yuemum.domain.admin.JlAdminUser;
 import com.ygj.yuemum.domain.customer.CustomerInfoFeedback;
+import com.ygj.yuemum.domain.customer.CustomerInfoServiceLog;
 import com.ygj.yuemum.domain.customer.dto.CustomerInfoFeedbackCyDto;
 import com.ygj.yuemum.domain.customer.dto.CustomerInfoFeedbackDto;
+import com.ygj.yuemum.service.admin.JlAdminUserService;
 import org.apache.commons.lang.StringUtils;
+import org.apache.shiro.SecurityUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.Date;
 import java.util.List;
 
 @Service
@@ -17,6 +23,12 @@ public class CustomerInfoFeedbackService {
     @Resource
     CustomerInfoFeedbackDao feedbackDao;
 
+    @Resource
+    CustomerInfoServiceLogService customerInfoServiceLogService;
+
+    @Resource
+    JlAdminUserService jladminuserService;
+
     public List<CustomerInfoFeedback> selectByPageNumSize(CustomerInfoFeedbackDto customerInfoFeedbackDto) {
         PageHelper.startPage(customerInfoFeedbackDto.getPage(), customerInfoFeedbackDto.getLimit(), true, false);
         return feedbackDao.selectByPageNumSize(customerInfoFeedbackDto);
@@ -26,7 +38,12 @@ public class CustomerInfoFeedbackService {
         if (StringUtils.isBlank(customerInfoFeedback.getFb_remarks())) {
             customerInfoFeedback.setFb_remarks("");
         }
-        return feedbackDao.insertInfoFeedback(customerInfoFeedback);
+        int count = feedbackDao.insertInfoFeedback(customerInfoFeedback);
+        if (count != 0) {
+            this.insertServiceLog(customerInfoFeedback.getId(), "新增", customerInfoFeedback);
+            return count;
+        }
+        return 0;
     }
 
     public CustomerInfoFeedback getById(Integer id) {
@@ -34,6 +51,7 @@ public class CustomerInfoFeedbackService {
     }
 
     public int updateByPrimaryKeySelective(CustomerInfoFeedback customerInfoFeedback) {
+        this.insertServiceLog(customerInfoFeedback.getId(), "修改", customerInfoFeedback);
         return feedbackDao.updateByPrimaryKeySelective(customerInfoFeedback);
     }
 
@@ -41,4 +59,20 @@ public class CustomerInfoFeedbackService {
         feedbackDao.insertInfoFeedbackList(customerInfoFeedbacks);
     }
 
+    private void insertServiceLog(Integer sl_no, String type, CustomerInfoFeedback customerInfoBasic) {
+        String principal = (String) SecurityUtils.getSubject().getPrincipal();
+        JlAdminUser jlAdminUser = jladminuserService.getUserMkt(principal);
+
+        CustomerInfoServiceLog customerInfoServiceLog = new CustomerInfoServiceLog();
+        customerInfoServiceLog.setSl_userid(jlAdminUser.getId());
+        customerInfoServiceLog.setSl_username(jlAdminUser.getName());
+        customerInfoServiceLog.setSl_createdate(new Date());
+        customerInfoServiceLog.setSl_no(sl_no);
+        customerInfoServiceLog.setSl_table("customer_info_feedback");
+        customerInfoServiceLog.setSl_type(type);
+        customerInfoServiceLog.setSl_comment(JSONObject.toJSONString(customerInfoBasic));
+
+        customerInfoServiceLogService.insert(customerInfoServiceLog);
+    }
+
 }

+ 34 - 2
src/main/java/com/ygj/yuemum/service/customer/CustomerInfoFollowService.java

@@ -1,13 +1,19 @@
 package com.ygj.yuemum.service.customer;
 
+import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.ygj.yuemum.dao.customer.CustomerInfoFollowMapper;
+import com.ygj.yuemum.domain.admin.JlAdminUser;
 import com.ygj.yuemum.domain.customer.CustomerInfoFollow;
+import com.ygj.yuemum.domain.customer.CustomerInfoServiceLog;
 import com.ygj.yuemum.domain.customer.dto.CustomerInfoFollowCyDto;
 import com.ygj.yuemum.domain.customer.dto.CustomerInfoFollowDto;
+import com.ygj.yuemum.service.admin.JlAdminUserService;
+import org.apache.shiro.SecurityUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -21,11 +27,19 @@ public class CustomerInfoFollowService {
 	@Resource
 	private CustomerInfoFollowMapper customerInfoFollowMapper;
 
+	@Resource
+	CustomerInfoServiceLogService customerInfoServiceLogService;
 
+	@Resource
+	JlAdminUserService jladminuserService;
 
 	public int insert(CustomerInfoFollow customerInfoFollow) {
-
-		return customerInfoFollowMapper.insert(customerInfoFollow);
+		int sl_no = customerInfoFollowMapper.insert(customerInfoFollow);
+		if (sl_no != 0) {
+			this.insertServiceLog(customerInfoFollow.getId(), "新增", customerInfoFollow);
+			return sl_no;
+		}
+		return 0;
 	}
 
 
@@ -36,6 +50,7 @@ public class CustomerInfoFollowService {
 
 
 	public int update(CustomerInfoFollow customerInfoFollow) {
+		this.insertServiceLog(customerInfoFollow.getId(), "修改", customerInfoFollow);
 		return customerInfoFollowMapper.update(customerInfoFollow);
 	}
 
@@ -54,4 +69,21 @@ public class CustomerInfoFollowService {
 		customerInfoFollowMapper.insertInfoFollowList(list);
 	}
 
+
+	private void insertServiceLog(Integer sl_no, String type, CustomerInfoFollow customerInfoFollow) {
+		String principal = (String) SecurityUtils.getSubject().getPrincipal();
+		JlAdminUser jlAdminUser = jladminuserService.getUserMkt(principal);
+
+		CustomerInfoServiceLog customerInfoServiceLog = new CustomerInfoServiceLog();
+		customerInfoServiceLog.setSl_userid(jlAdminUser.getId());
+		customerInfoServiceLog.setSl_username(jlAdminUser.getName());
+		customerInfoServiceLog.setSl_createdate(new Date());
+		customerInfoServiceLog.setSl_no(sl_no);
+		customerInfoServiceLog.setSl_table("customer_info_follow");
+		customerInfoServiceLog.setSl_type(type);
+		customerInfoServiceLog.setSl_comment(JSONObject.toJSONString(customerInfoFollow));
+
+		customerInfoServiceLogService.insert(customerInfoServiceLog);
+	}
+
 }

+ 69 - 0
src/main/java/com/ygj/yuemum/service/customer/CustomerInfoServiceLogService.java

@@ -0,0 +1,69 @@
+package com.ygj.yuemum.service.customer;
+
+import com.ygj.yuemum.dao.customer.CustomerInfoServiceLogMapper;
+import com.ygj.yuemum.domain.customer.CustomerInfoServiceLog;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * customer_info_servicelog
+ * @author zrz
+ * @date 2020/07/13
+ */
+@Service
+public class CustomerInfoServiceLogService {
+
+    @Resource
+    private CustomerInfoServiceLogMapper customerInfoServicelogMapper;
+
+
+    public int insert(CustomerInfoServiceLog customerInfoServicelog) {
+
+        // valid
+        if (customerInfoServicelog == null) {
+            return 0;
+        }
+
+        return customerInfoServicelogMapper.insert(customerInfoServicelog);
+    }
+
+
+    public int delete(int id) {
+        int ret = customerInfoServicelogMapper.delete(id);
+        return ret;
+    }
+
+
+    public int update(CustomerInfoServiceLog customerInfoServicelog) {
+        int ret = customerInfoServicelogMapper.update(customerInfoServicelog);
+        return ret;
+    }
+
+
+    public CustomerInfoServiceLog load(int id) {
+        return customerInfoServicelogMapper.load(id);
+    }
+
+    public List<CustomerInfoServiceLog> loadBySlNo(int sl_no) {
+        return customerInfoServicelogMapper.loadBySlNo(sl_no);
+    }
+
+
+    public Map<String,Object> pageList(int offset, int pagesize) {
+
+        List<CustomerInfoServiceLog> pageList = customerInfoServicelogMapper.pageList(offset, pagesize);
+        int totalCount = customerInfoServicelogMapper.pageListCount(offset, pagesize);
+
+        // result
+        Map<String, Object> result = new HashMap<String, Object>();
+        result.put("pageList", pageList);
+        result.put("totalCount", totalCount);
+
+        return result;
+    }
+
+}

+ 1 - 1
src/main/resources/mybatis/mapper/customer/CustomerInfoFeedbackMapper.xml

@@ -78,7 +78,7 @@
         order by id desc
     </select>
     
-    <insert id="insertInfoFeedback" parameterType="com.ygj.yuemum.domain.customer.CustomerInfoFeedback">
+    <insert id="insertInfoFeedback" useGeneratedKeys="true" keyProperty="id" parameterType="com.ygj.yuemum.domain.customer.CustomerInfoFeedback">
         insert into customer_info_feedback (fb_date, source_channel, fb_customer_phone, branche_name, fb_type, create_person, in_charge_person, customer_manager, entry_date, p_code, fb_customer_name, fb_wechat_number, edc_date, fb_remarks)
         values (#{fb_date}, #{source_channel}, #{fb_customer_phone}, #{branche_name}, #{fb_type}, #{create_person}, #{in_charge_person}, #{customer_manager}, #{entry_date}, #{p_code}, #{fb_customer_name}, #{fb_wechat_number}, #{edc_date}, #{fb_remarks})
     </insert>

+ 121 - 0
src/main/resources/mybatis/mapper/customer/CustomerInfoServiceLogMapper.xml

@@ -0,0 +1,121 @@
+<?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">
+<mapper namespace="com.ygj.yuemum.dao.customer.CustomerInfoServiceLogMapper">
+
+    <resultMap id="BaseResultMap" type="com.ygj.yuemum.domain.customer.CustomerInfoServiceLog" >
+        <result column="id" property="id" />
+        <result column="sl_no" property="sl_no" />
+        <result column="sl_table" property="sl_table" />
+        <result column="sl_createdate" property="sl_createdate" />
+        <result column="sl_comment" property="sl_comment" />
+        <result column="sl_userid" property="sl_userid" />
+        <result column="sl_username" property="sl_username" />
+        <result column="sl_type" property="sl_type" />
+    </resultMap>
+
+    <sql id="Base_Column_List">
+                id,
+                sl_no,
+                sl_table,
+                sl_createdate,
+                sl_comment,
+                sl_userid,
+                sl_username,
+                sl_type
+    </sql>
+
+    <insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="com.ygj.yuemum.domain.customer.CustomerInfoServiceLog">
+        INSERT INTO customer_info_servicelog
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test ='null != sl_no'>
+                sl_no,
+            </if>
+            <if test ='null != sl_table'>
+                sl_table,
+            </if>
+            <if test ='null != sl_createdate'>
+                sl_createdate,
+            </if>
+            <if test ='null != sl_comment'>
+                sl_comment,
+            </if>
+            <if test ='null != sl_userid'>
+                sl_userid,
+            </if>
+            <if test ='null != sl_username'>
+                sl_username,
+            </if>
+            <if test ='null != sl_type'>
+                sl_type
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test ='null != sl_no'>
+                #{sl_no},
+            </if>
+            <if test ='null != sl_table'>
+                #{sl_table},
+            </if>
+            <if test ='null != sl_createdate'>
+                #{sl_createdate},
+            </if>
+            <if test ='null != sl_comment'>
+                #{sl_comment},
+            </if>
+            <if test ='null != sl_userid'>
+                #{sl_userid},
+            </if>
+            <if test ='null != sl_username'>
+                #{sl_username},
+            </if>
+            <if test ='null != sl_type'>
+                #{sl_type}
+            </if>
+        </trim>
+    </insert>
+
+    <delete id="delete" >
+        DELETE FROM customer_info_servicelog
+        WHERE id = #{id}
+    </delete>
+
+    <update id="update" parameterType="com.ygj.yuemum.domain.customer.CustomerInfoServiceLog">
+        UPDATE customer_info_servicelog
+        <set>
+            <if test ='null != sl_no'>sl_no = #{sl_no},</if>
+            <if test ='null != sl_table'>sl_table = #{sl_table},</if>
+            <if test ='null != sl_createdate'>sl_createdate = #{sl_createdate},</if>
+            <if test ='null != sl_comment'>sl_comment = #{sl_comment},</if>
+            <if test ='null != sl_userid'>sl_userid = #{sl_userid},</if>
+            <if test ='null != sl_username'>sl_username = #{sl_username},</if>
+            <if test ='null != sl_type'>sl_type = #{sl_type}</if>
+        </set>
+        WHERE id = #{id}
+    </update>
+
+
+    <select id="load" resultMap="BaseResultMap">
+        SELECT <include refid="Base_Column_List" />
+        FROM customer_info_servicelog
+        WHERE id = #{id}
+    </select>
+
+    <select id="loadBySlNo" resultMap="BaseResultMap">
+        SELECT <include refid="Base_Column_List" />
+        FROM customer_info_servicelog
+        WHERE sl_no = #{sl_no}
+    </select>
+
+    <select id="pageList" resultMap="BaseResultMap">
+        SELECT <include refid="Base_Column_List" />
+        FROM customer_info_servicelog
+        LIMIT #{offset}, #{pageSize}
+    </select>
+
+    <select id="pageListCount" resultType="java.lang.Integer">
+        SELECT count(1)
+        FROM customer_info_servicelog
+    </select>
+
+</mapper>