Browse Source

用户反馈相关接口

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

+ 7 - 0
pom.xml

@@ -234,6 +234,13 @@
             <artifactId>spring-boot-devtools</artifactId>
             <optional>true</optional>
         </dependency>
+
+        <!-- lombok -->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.18.10</version>
+        </dependency>
     </dependencies>
 
 

+ 33 - 0
src/main/java/com/ygj/yuemum/controller/customer/CustomerInfoFeedbackController.java

@@ -0,0 +1,33 @@
+package com.ygj.yuemum.controller.customer;
+
+import com.ygj.yuemum.domain.customer.CustomerInfoFeedback;
+import com.ygj.yuemum.domain.customer.dto.CustomerInfoFeedbackDto;
+import com.ygj.yuemum.service.customer.CustomerInfoFeedbackService;
+import com.ygj.yuemum.utils.ResponseUtil;
+import io.swagger.annotations.Api;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+
+@Api(tags = "客户信息反馈表")
+@RestController
+public class CustomerInfoFeedbackController {
+
+    @Resource
+    CustomerInfoFeedbackService customerInfoFeedbackService;
+
+    @PostMapping("/info/feedback")
+    public Map<String, Object> selectByPageNumSize(CustomerInfoFeedbackDto customerInfoFeedbackDto) {
+        List<CustomerInfoFeedback> customerInfoFeedbacks = customerInfoFeedbackService.selectByPageNumSize(customerInfoFeedbackDto);
+        return ResponseUtil.convertRetMap(customerInfoFeedbacks);
+    }
+
+    @PostMapping("/info/feedback/insert")
+    public Integer insertInfoFeedback(@RequestBody CustomerInfoFeedback customerInfoFeedback) {
+        return customerInfoFeedbackService.insertInfoFeedback(customerInfoFeedback);
+    }
+}

+ 25 - 0
src/main/java/com/ygj/yuemum/controller/customer/CustomerSourceChannelController.java

@@ -0,0 +1,25 @@
+package com.ygj.yuemum.controller.customer;
+
+import com.ygj.yuemum.domain.customer.CustomerSourceChannel;
+import com.ygj.yuemum.service.customer.CustomerSourceChannelService;
+import io.swagger.annotations.Api;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Api(tags = "客户咨询来源渠道")
+@RestController
+public class CustomerSourceChannelController {
+
+    @Resource
+    CustomerSourceChannelService customerSourceChannelService;
+
+    @GetMapping("/source/channel")
+    public List<CustomerSourceChannel> selectCustomerBooking() {
+        List<CustomerSourceChannel> customerSourceChannels = customerSourceChannelService.getAllSourceChannel();
+        return customerSourceChannels;
+    }
+
+}

+ 1 - 1
src/main/java/com/ygj/yuemum/controller/wxmini/WXBannerController.java

@@ -28,7 +28,7 @@ public class WXBannerController {
         return wxBanners;
     }
 
-    @GetMapping
+//    @GetMapping
     public int cleanBanner(@RequestParam(value = "id") Integer id) {
         try {
             wxBannerService.cleanBanner(id);

+ 13 - 0
src/main/java/com/ygj/yuemum/dao/customer/CustomerInfoFeedbackDao.java

@@ -0,0 +1,13 @@
+package com.ygj.yuemum.dao.customer;
+
+import com.ygj.yuemum.domain.customer.CustomerInfoFeedback;
+import com.ygj.yuemum.domain.customer.dto.CustomerInfoFeedbackDto;
+
+import java.util.List;
+
+public interface CustomerInfoFeedbackDao {
+
+    List<CustomerInfoFeedback> selectByPageNumSize(CustomerInfoFeedbackDto customerInfoFeedback);
+
+    int insertInfoFeedback(CustomerInfoFeedback customerInfoFeedback);
+}

+ 13 - 0
src/main/java/com/ygj/yuemum/dao/customer/CustomerSourceChannelDao.java

@@ -0,0 +1,13 @@
+package com.ygj.yuemum.dao.customer;
+
+import com.ygj.yuemum.domain.customer.CustomerSourceChannel;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface CustomerSourceChannelDao {
+
+    List<CustomerSourceChannel> getAllSourceChannel();
+
+}

+ 38 - 0
src/main/java/com/ygj/yuemum/domain/customer/CustomerInfoFeedback.java

@@ -0,0 +1,38 @@
+package com.ygj.yuemum.domain.customer;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class CustomerInfoFeedback {
+
+    private Integer id;
+
+    private Date fb_Date;
+
+    private String source_channel;
+
+    private String fb_customer_phone;
+
+    private String branche_name;
+
+    private String fb_type;
+
+    private String create_person;
+
+    private String in_charge_person;
+
+    private String customer_manager;
+
+    private Date entry_date;
+//
+//
+//    private Integer page;
+//    private Integer limit;
+//    private String start_fb_date;
+//    private String end_fb_date;
+//    private String start_entry_date;
+//    private String end_entry_date;
+
+}

+ 12 - 0
src/main/java/com/ygj/yuemum/domain/customer/CustomerSourceChannel.java

@@ -0,0 +1,12 @@
+package com.ygj.yuemum.domain.customer;
+
+import lombok.Data;
+
+@Data
+public class CustomerSourceChannel {
+
+    private Integer id;
+
+    private String source_channel;
+
+}

+ 39 - 0
src/main/java/com/ygj/yuemum/domain/customer/dto/CustomerInfoFeedbackDto.java

@@ -0,0 +1,39 @@
+package com.ygj.yuemum.domain.customer.dto;
+
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+public class CustomerInfoFeedbackDto {
+
+    private Integer id;
+
+    private Date fb_Date;
+
+    private List<String> source_channel;
+
+    private String fb_customer_phone;
+
+    private List<String> branche_name;
+
+    private List<String> fb_type;
+
+    private List<String> create_person;
+
+    private List<String> in_charge_person;
+
+    private List<String> customer_manager;
+
+    private Date entry_date;
+
+
+    private Integer page;
+    private Integer limit;
+    private String start_fb_date;
+    private String end_fb_date;
+    private String start_entry_date;
+    private String end_entry_date;
+
+}

+ 27 - 0
src/main/java/com/ygj/yuemum/service/customer/CustomerInfoFeedbackService.java

@@ -0,0 +1,27 @@
+package com.ygj.yuemum.service.customer;
+
+import com.github.pagehelper.PageHelper;
+import com.ygj.yuemum.dao.customer.CustomerInfoFeedbackDao;
+import com.ygj.yuemum.domain.customer.CustomerInfoFeedback;
+import com.ygj.yuemum.domain.customer.dto.CustomerInfoFeedbackDto;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service
+public class CustomerInfoFeedbackService {
+
+    @Resource
+    CustomerInfoFeedbackDao feedbackDao;
+
+    public List<CustomerInfoFeedback> selectByPageNumSize(CustomerInfoFeedbackDto customerInfoFeedbackDto) {
+        PageHelper.startPage(customerInfoFeedbackDto.getPage(), customerInfoFeedbackDto.getLimit());
+        return feedbackDao.selectByPageNumSize(customerInfoFeedbackDto);
+    }
+
+    public int insertInfoFeedback(CustomerInfoFeedback customerInfoFeedback) {
+        return feedbackDao.insertInfoFeedback(customerInfoFeedback);
+    }
+
+}

+ 20 - 0
src/main/java/com/ygj/yuemum/service/customer/CustomerSourceChannelService.java

@@ -0,0 +1,20 @@
+package com.ygj.yuemum.service.customer;
+
+import com.ygj.yuemum.dao.customer.CustomerSourceChannelDao;
+import com.ygj.yuemum.domain.customer.CustomerSourceChannel;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service
+public class CustomerSourceChannelService {
+
+    @Resource
+    CustomerSourceChannelDao customerSourceChannelDao;
+
+    public List<CustomerSourceChannel> getAllSourceChannel() {
+        return customerSourceChannelDao.getAllSourceChannel();
+    }
+
+}

+ 22 - 0
src/main/java/com/ygj/yuemum/utils/ResponseUtil.java

@@ -0,0 +1,22 @@
+package com.ygj.yuemum.utils;
+
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageInfo;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ResponseUtil {
+
+    public static <T> Map<String, Object> convertRetMap(List<T> list) {
+        Map<String, Object> retMap = new HashMap<>(4);
+        retMap.put("items", list);
+        if (list instanceof Page) {
+            Page page = (Page) list;
+            retMap.put("total", page.getTotal());
+        }
+        return retMap;
+    }
+
+}

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

@@ -0,0 +1,73 @@
+<?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.CustomerInfoFeedbackDao" >
+
+    <!--获取所有数据-->
+    <select id="selectByPageNumSize" resultType="com.ygj.yuemum.domain.customer.CustomerInfoFeedback" parameterType="com.ygj.yuemum.domain.customer.dto.CustomerInfoFeedbackDto">
+        SELECT
+            id,
+            fb_date,
+            source_channel,
+            fb_customer_phone,
+            branche_name,
+            fb_type,
+            create_person,
+            in_charge_person,
+            customer_manager,
+            entry_date
+        FROM
+            customer_info_feedback
+        where 1=1
+        <if test="start_fb_date != null and start_fb_date !=''">
+            and fb_Date &gt;= #{start_fb_date}
+        </if>
+        <if test="end_fb_date != null and end_fb_date !=''">
+            and fb_Date &lt; #{end_fb_date}
+        </if>
+        <if test="source_channel != null ">
+            and source_channel in
+            <foreach collection="source_channel" item="item" index="index" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="fb_customer_phone != null and fb_customer_phone !=''">
+            and fb_customer_phone like "%"#{fb_customer_phone,jdbcType=VARCHAR}"%"
+        </if>
+        <if test="branche_name != null ">
+            and branche_name in
+            <foreach collection="branche_name" item="item" index="index" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="fb_type != null ">
+            and fb_type in
+            <foreach collection="fb_type" item="item" index="index" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="create_person != null ">
+            and create_person in
+            <foreach collection="create_person" item="item" index="index" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="in_charge_person != null ">
+            and in_charge_person in
+            <foreach collection="in_charge_person" item="item" index="index" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="customer_manager != null ">
+            and customer_manager in
+            <foreach collection="customer_manager" item="item" index="index" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+    
+    <insert id="insertInfoFeedback" 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)
+        values (#{fb_date}, #{source_channel}, #{fb_customer_phone}, #{branche_name}, #{fb_type}, #{create_person}, #{in_charge_person}, #{customer_manager}, #{entry_date))
+    </insert>
+
+</mapper>

+ 14 - 0
src/main/resources/mybatis/mapper/customer/CustomerSourceChannelMapper.xml

@@ -0,0 +1,14 @@
+<?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.CustomerSourceChannelDao" >
+
+    <!--获取所有数据-->
+    <select id="getAllSourceChannel" resultType="com.ygj.yuemum.domain.customer.CustomerSourceChannel" >
+        SELECT
+            id,
+            source_channel
+        FROM
+            customer_source_channel
+    </select>
+
+</mapper>

+ 116 - 0
src/test/java/com/ygj/yuemum/client/HttpClientUtil.java

@@ -0,0 +1,116 @@
+package com.ygj.yuemum.client;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.lang.StringUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import springfox.documentation.spring.web.json.Json;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class HttpClientUtil {
+
+    protected final static String DEFAULT_USERNAME = "admin";
+
+    protected final static String DEFAULT_PASSWORD = "e19d5cd5af0378da05f63f891c7467af";
+
+    protected final static String DEFAULT_URL = "http://localhost:8888/";
+
+    public static String post(String url , Map<String, String> params){
+        try {
+            String jsonObject = postByToken(url, params, getToken(), true);
+            return jsonObject;
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return new String();
+    }
+
+    public static String get(String url, Map<String, String> params) {
+        try {
+            String jsonObject = getByToken(url, params);
+            return jsonObject;
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return new String();
+    }
+
+    private static String getByToken(String url, Map<String, String> params) throws IOException {
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        HttpGet httpGet = new HttpGet(DEFAULT_URL + url);
+        httpGet.setHeader("JSESSIONID", getToken());
+        CloseableHttpResponse response1 = httpclient.execute(httpGet);
+
+        try {
+            HttpEntity entity1 = response1.getEntity();
+            // do something useful with the response body
+            // and ensure it is fully consumed
+            String jsonObject = EntityUtils.toString(entity1, "UTF-8");
+            EntityUtils.consume(entity1);
+            return jsonObject;
+        } finally {
+            response1.close();
+        }
+    }
+
+    private static String postNoToken(String url,Map<String,String> params) throws IOException {
+        return postByToken(url, params, null, false);
+    }
+
+    private static String postByToken(String url, Map<String,String> params, String token, boolean isJson) throws IOException {
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+
+        HttpPost httpPost = new HttpPost(DEFAULT_URL + url);
+        List<NameValuePair> nvps = new ArrayList<>();
+        if (params != null) {
+            params.forEach((k, v) -> nvps.add(new BasicNameValuePair(k, v)));
+        }
+        if (isJson) {
+            httpPost.setHeader("Content-Type", "application/json");
+            httpPost.setEntity(new StringEntity(JSON.toJSONString(params)));
+        } else {
+            httpPost.setEntity(new UrlEncodedFormEntity(nvps));
+        }
+        httpPost.setHeader("Accept", "application/json, text/plain, */*");
+        if (StringUtils.isNotBlank(token)) {
+            httpPost.setHeader("JSESSIONID", token);
+        }
+        CloseableHttpResponse response2 = httpclient.execute(httpPost);
+
+        try {
+            System.out.println(response2.getStatusLine());
+            HttpEntity entity2 = response2.getEntity();
+            String jsonObject = EntityUtils.toString(entity2, "UTF-8");
+            EntityUtils.consume(entity2);
+            return jsonObject;
+        } finally {
+            response2.close();
+        }
+    }
+
+
+    private static String getToken() throws IOException {
+        Map<String, String> params = new HashMap<>();
+        params.put("username", DEFAULT_USERNAME);
+        params.put("password", DEFAULT_PASSWORD);
+        params.put("pwd", "abcd1234");
+        params.put("rememberMe", "false");
+        JSONObject jsonObject = JSON.parseObject(postNoToken("login", params));
+        return (String) jsonObject.get("token");
+    }
+}

+ 43 - 0
src/test/java/com/ygj/yuemum/customers/CustomerSourceChannelTest.java

@@ -0,0 +1,43 @@
+package com.ygj.yuemum.customers;
+
+import com.alibaba.fastjson.JSON;
+import com.ygj.yuemum.client.HttpClientUtil;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class CustomerSourceChannelTest {
+
+    @Test
+    public void testCustomerSourceChannel() {
+        String str = HttpClientUtil.get("/source/channel", null);
+        System.out.println(str);
+    }
+
+    @Test
+    public void testSelectByPageNumSize() {
+        Map<String, String> param = new HashMap<>();
+        param.put("pageNum", "1");
+        param.put("pageSize", "11");
+        param.put("branche_name", "1");
+        param.put("fb_type", "1");
+        String str = HttpClientUtil.post("/info/feedback", param);
+        System.out.println(JSON.toJSONString(param));
+        System.out.println(str);
+    }
+
+    @Test
+    public void testInsertFeedback() {
+        Map<String, String> param = new HashMap<>();
+        param.put("pageNum", "1");
+        param.put("pageSize", "11");
+        param.put("branche_name", "1");
+        param.put("fb_type", "1");
+        String str = HttpClientUtil.post("/info/feedback/insert", param);
+        System.out.println(JSON.toJSONString(param));
+        System.out.println(str);
+    }
+
+
+}