Quellcode durchsuchen

运输商管理界面

LiuCheng vor 2 Monaten
Ursprung
Commit
638a63c90e

+ 71
- 0
src/main/java/com/th/demo/controller/maint/TransportController.java Datei anzeigen

@@ -0,0 +1,71 @@
1
+package com.th.demo.controller.maint;
2
+
3
+
4
+import com.alibaba.fastjson.JSON;
5
+import com.th.demo.model.system.ResponseCodeMsg;
6
+import com.th.demo.model.system.ResultJSON;
7
+import com.th.demo.model.system.Type;
8
+import com.th.demo.service.maint.TransportService;
9
+import com.th.demo.tools.JSONTools;
10
+import org.springframework.beans.factory.annotation.Autowired;
11
+import org.springframework.web.bind.annotation.RequestMapping;
12
+import org.springframework.web.bind.annotation.RequestMethod;
13
+import org.springframework.web.bind.annotation.RestController;
14
+
15
+import javax.servlet.http.HttpServletRequest;
16
+
17
+@RestController
18
+@RequestMapping(value = "/MaintTransport")
19
+public class TransportController {
20
+    @Autowired
21
+    public TransportService transportService;
22
+    String result = Type.FAIL;
23
+
24
+    @RequestMapping(value = "/query.do")//查询方法 前两个参数是分页参数
25
+    public String query(int page,
26
+                        int rows,
27
+                        String query,
28
+                        HttpServletRequest request) {
29
+
30
+        try {
31
+            String userId = (String) request.getAttribute("userId");
32
+            String belongId = (String) request.getAttribute("belongId");
33
+            result = transportService.query(page, rows, query, userId, belongId);
34
+        } catch (Exception ex) {
35
+            ex.printStackTrace();
36
+            result = JSONTools.toString(ResponseCodeMsg.CODE_EX, ex.getMessage());
37
+        } finally {
38
+            return result;
39
+        }
40
+    }
41
+
42
+    @RequestMapping(value = "/save.do", method = RequestMethod.POST)//Post方法
43
+    public String save(String json,
44
+                       HttpServletRequest request) {
45
+        try {
46
+            String userId = (String) request.getAttribute("userId");
47
+            String belongId = (String) request.getAttribute("belongId");
48
+            result = transportService.save(json, userId, belongId);
49
+        } catch (Exception ex) {
50
+            ex.printStackTrace();
51
+            result = JSON.toJSONString(new ResultJSON(ResponseCodeMsg.CODE_EX, ex.getMessage(), null));
52
+        } finally {
53
+            return result;
54
+        }
55
+    }
56
+
57
+    @RequestMapping(value = "/remove.do", method = RequestMethod.POST)
58
+    public String remove(String id,
59
+                         HttpServletRequest request) {
60
+        try {
61
+            String userId = (String) request.getAttribute("userId");
62
+            String belongId = (String) request.getAttribute("belongId");
63
+            result = transportService.remove(id, userId);
64
+        } catch (NullPointerException ex) {
65
+            ex.printStackTrace();
66
+            result = JSONTools.toString(ResponseCodeMsg.CODE_NULL, ResponseCodeMsg.MSG_NULL);
67
+        } finally {
68
+            return result;
69
+        }
70
+    }
71
+}

+ 18
- 0
src/main/java/com/th/demo/mapping/maint/TransportMapper.java Datei anzeigen

@@ -0,0 +1,18 @@
1
+package com.th.demo.mapping.maint;
2
+
3
+import com.th.demo.model.maint.Transport;
4
+
5
+import java.util.List;
6
+
7
+public interface TransportMapper {
8
+    int deleteByPrimaryKey(String id);
9
+
10
+    int insert(Transport transprot);
11
+
12
+    Transport selectByPrimaryKey(String id);
13
+
14
+    int updateByPrimaryKey(Transport record);
15
+
16
+    List<Transport> selectByName(String query, String belongId);
17
+
18
+}

+ 43
- 0
src/main/java/com/th/demo/model/maint/Transport.java Datei anzeigen

@@ -0,0 +1,43 @@
1
+package com.th.demo.model.maint;
2
+
3
+public class Transport {
4
+    private String id;
5
+
6
+    private String name;
7
+
8
+    private String cancelFlag;
9
+
10
+    private String belongId;
11
+
12
+    public String getId() {
13
+        return id;
14
+    }
15
+
16
+    public void setId(String id) {
17
+        this.id = id;
18
+    }
19
+
20
+    public String getName() {
21
+        return name;
22
+    }
23
+
24
+    public void setName(String name) {
25
+        this.name = name;
26
+    }
27
+
28
+    public String getCancelFlag() {
29
+        return cancelFlag;
30
+    }
31
+
32
+    public void setCancelFlag(String cancelFlag) {
33
+        this.cancelFlag = cancelFlag;
34
+    }
35
+
36
+    public String getBelongId() {
37
+        return belongId;
38
+    }
39
+
40
+    public void setBelongId(String belongId) {
41
+        this.belongId = belongId;
42
+    }
43
+}

+ 80
- 0
src/main/java/com/th/demo/service/impl/maint/TransportServiceImpl.java Datei anzeigen

@@ -0,0 +1,80 @@
1
+package com.th.demo.service.impl.maint;
2
+
3
+import com.alibaba.fastjson.JSON;
4
+import com.alibaba.fastjson.TypeReference;
5
+import com.github.pagehelper.PageHelper;
6
+import com.github.pagehelper.PageInfo;
7
+import com.th.demo.mapping.maint.CustomerAddressMapper;
8
+import com.th.demo.mapping.maint.CustomerMapper;
9
+import com.th.demo.mapping.maint.TransportMapper;
10
+import com.th.demo.model.maint.Customer;
11
+import com.th.demo.model.maint.CustomerAddress;
12
+import com.th.demo.model.maint.Transport;
13
+import com.th.demo.model.system.Type;
14
+import com.th.demo.service.maint.TransportService;
15
+import com.th.demo.tools.JSONTools;
16
+import com.th.demo.tools.Tools;
17
+import org.springframework.beans.factory.annotation.Autowired;
18
+import org.springframework.stereotype.Service;
19
+import org.springframework.transaction.annotation.Transactional;
20
+
21
+import java.util.ArrayList;
22
+import java.util.Date;
23
+import java.util.List;
24
+
25
+@Service("TransportService")
26
+public class TransportServiceImpl implements TransportService {
27
+
28
+    @Autowired
29
+    public TransportMapper transportMapper;
30
+
31
+
32
+    String result = Type.FAIL;
33
+    int num = 0;
34
+
35
+    @Override
36
+    public String query(int page, int rows, String query, String userId, String belongId) {
37
+        PageHelper.startPage(page, rows);
38
+        List<Transport> list = new ArrayList<Transport>();
39
+
40
+        list = transportMapper.selectByName(query, belongId);
41
+
42
+        PageInfo<Transport> pageInfo = new PageInfo<>(list);
43
+        result = JSONTools.toString(pageInfo);
44
+        return result;
45
+    }
46
+
47
+    @Override
48
+    public String save(String json, String userId, String belongId) {
49
+        result = Type.FAIL;
50
+        Transport transport = JSON.parseObject(json, new TypeReference<Transport>() {
51
+        });
52
+        if (transport.getId() == null || transport.getId().equals("")) {
53
+            List<Transport> transportList = transportMapper.selectByName(transport.getName(),belongId);
54
+            if(transportList.size() == 0){
55
+                transport.setCancelFlag("0");
56
+                transport.setBelongId(belongId);
57
+                num = transportMapper.insert(transport);
58
+            }else {
59
+                return JSONTools.toString(1,"承运单位已存在");
60
+            }
61
+
62
+        } else {
63
+
64
+            num = transportMapper.updateByPrimaryKey(transport);
65
+        }
66
+        result = Tools.moreThanZeroResultJSON(num);
67
+        return result;
68
+    }
69
+
70
+
71
+    @Override
72
+    public String remove(String id, String userId) {
73
+
74
+        num = transportMapper.deleteByPrimaryKey(id);
75
+        result = Tools.moreThanZeroResultJSON(num);
76
+        return result;
77
+
78
+    }
79
+
80
+}

+ 9
- 0
src/main/java/com/th/demo/service/maint/TransportService.java Datei anzeigen

@@ -0,0 +1,9 @@
1
+package com.th.demo.service.maint;
2
+
3
+public interface TransportService {
4
+    String query(int page, int rows, String query, String userId, String belongId);
5
+
6
+    String save(String json, String userId, String belongId);
7
+
8
+    String remove(String id, String userId);
9
+}

+ 10
- 10
src/main/resource/localhost/db.properties Datei anzeigen

@@ -1,16 +1,16 @@
1
-????????
2
-jdbc.driverClass=com.mysql.jdbc.Driver
3
-jdbc.jdbcUrl=jdbc:mysql://172.18.200.32:3306/ware?useUnicode=true&characterEncoding=utf8
4
-jdbc.user=root
5
-jdbc.password=root
6 1
 #????????
7 2
 #jdbc.driverClass=com.mysql.jdbc.Driver
8
-#jdbc.jdbcUrl=jdbc:mysql://localhost:3306/ware?characterEncoding=utf8
3
+#jdbc.jdbcUrl=jdbc:mysql://172.18.200.32:3306/ware?useUnicode=true&characterEncoding=utf8
9 4
 #jdbc.user=root
10 5
 #jdbc.password=root
11
-
12
-##60?????
6
+#????????
13 7
 #jdbc.driverClass=com.mysql.jdbc.Driver
14
-#jdbc.jdbcUrl=jdbc:mysql://60.205.9.174:3309/ware?useUnicode=true&characterEncoding=utf8
8
+#jdbc.jdbcUrl=jdbc:mysql://localhost:3306/ware?characterEncoding=utf8
15 9
 #jdbc.user=root
16
-#jdbc.password=122403
10
+#jdbc.password=root
11
+
12
+###60?????
13
+jdbc.driverClass=com.mysql.jdbc.Driver
14
+jdbc.jdbcUrl=jdbc:mysql://60.205.9.174:3309/ware?useUnicode=true&characterEncoding=utf8
15
+jdbc.user=root
16
+jdbc.password=122403

+ 51
- 0
src/main/resource/mapper/maint/TranspoMapper.xml Datei anzeigen

@@ -0,0 +1,51 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3
+<mapper namespace="com.th.demo.mapping.maint.TransportMapper" >
4
+  <resultMap id="BaseResultMap" type="com.th.demo.model.maint.Transport" >
5
+    <id column="id" property="id" jdbcType="VARCHAR" />
6
+    <result column="name" property="name" jdbcType="VARCHAR" />
7
+    <result column="cancel_flag" property="cancelFlag" jdbcType="VARCHAR" />
8
+    <result column="belong_id" property="belongId" jdbcType="VARCHAR" />
9
+  </resultMap>
10
+  <sql id="Base_Column_List" >
11
+    id, name, cancel_flag, belong_id
12
+  </sql>
13
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
14
+    select 
15
+    <include refid="Base_Column_List" />
16
+    from t_maint_transport
17
+    where id = #{id,jdbcType=VARCHAR}
18
+  </select>
19
+  <update id="deleteByPrimaryKey" parameterType="java.lang.String" >
20
+    update t_maint_transport set cancel_flag = '9'
21
+    where id = #{id,jdbcType=VARCHAR}
22
+  </update>
23
+  <insert id="insert" parameterType="com.th.demo.model.maint.Transport" >
24
+
25
+    <selectKey keyProperty="id" order="BEFORE" resultType="java.lang.String">
26
+      SELECT  REPLACE(UUID(),'-','') as id from dual
27
+    </selectKey>
28
+
29
+
30
+    insert into t_maint_transport (id, name, cancel_flag, belong_id)
31
+    values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
32
+      #{cancelFlag,jdbcType=VARCHAR}, #{belongId,jdbcType=VARCHAR})
33
+  </insert>
34
+
35
+  <update id="updateByPrimaryKey" parameterType="com.th.demo.model.maint.Customer" >
36
+    update t_maint_transport
37
+    set name = #{name,jdbcType=VARCHAR}
38
+    where id = #{id,jdbcType=VARCHAR}
39
+  </update>
40
+
41
+
42
+  <select id="selectByName" resultMap="BaseResultMap" >
43
+    select *
44
+    from t_maint_transport
45
+    where name like concat('%',#{param1,jdbcType=VARCHAR},'%')
46
+    and   belong_id = #{param2,jdbcType=VARCHAR}
47
+    and ifnull(cancel_flag,'0') = '0'
48
+  </select>
49
+
50
+
51
+</mapper>

Laden…
Abbrechen
Speichern