wuheng hace 2 años
padre
commit
e725f505f6

+ 25 - 0
travel/admin/src/main/java/com/lc/admin/controller/AddressController.java

@@ -2,11 +2,16 @@ package com.lc.admin.controller;
 
 import com.cl.mbg.mapper.TAddressMapper;
 import com.cl.mbg.model.TAddress;
+import com.lc.common.pojo.TravelParams;
 import com.lc.common.utils.Result;
+import com.lc.service.AddressService;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestPart;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import java.util.HashMap;
 import java.util.List;
 
 @RestController
@@ -16,10 +21,30 @@ public class AddressController {
     @Resource
     TAddressMapper addressMapper;
 
+    @Resource
+    AddressService addressService;
+
     @RequestMapping("/findAllMaps.do")
     public Result findAllMaps(){
         List<TAddress> tAddresses = addressMapper.selectByExample(null);
         return Result.data(tAddresses);
     }
 
+    @RequestMapping("/findPage.do")
+    public Result findPage(@RequestBody TravelParams travelParams){
+        HashMap<String, Object> page = addressService.findPage(travelParams);
+        return Result.data(page);
+    }
+
+    @RequestMapping("/addAddress.do")
+    public Result addAddress(@RequestBody TAddress address){
+        int n = addressService.addAddress(address);
+        return Result.data(n);
+    }
+
+    @RequestMapping("/deleteById.do")
+    public Result deleteById(Integer id){
+        int n = addressService.deleteById(id);
+        return Result.data(n);
+    }
 }

+ 8 - 6
travel/admin/src/main/resources/templates/address.html

@@ -84,13 +84,13 @@
 
                 <el-tab-pane label="详细信息" name="second">
                     <div class="filter-container">
-                        <el-input placeholder="公司地址" v-model="pagination.queryString" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter"></el-input>
+                        <el-input placeholder="公司地址" v-model="pagination.queryString.name" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter"></el-input>
                         <el-button @click="findPage()" class="dalfBut">查询</el-button>
                         <el-button type="primary" class="butT" @click="handleCreate()">新建</el-button>
                     </div>
                     <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
                         <el-table-column type="index" align="center" label="序号"></el-table-column>
-                        <el-table-column prop="addressName" label="公司地址" align="center"></el-table-column>
+                        <el-table-column prop="addressname" label="公司地址" align="center"></el-table-column>
 
                         <el-table-column prop="lng" label="所在经度" align="center"></el-table-column>
                         <el-table-column prop="lat" label="所在纬度" align="center"></el-table-column>
@@ -141,7 +141,9 @@
                 currentPage: 1,
                 pageSize:10,
                 total:100,
-                queryString:null,
+                queryString:{
+                    name:""
+                },
             },
             dataList: [],//列表数据
             formData: {},//表单数据
@@ -226,8 +228,8 @@
                     queryString: this.pagination.queryString
                 };
                 axios.post("/address/findPage.do",param).then((res)=>{
-                    this.dataList=res.data.rows;
-                    this.pagination.total=res.data.total;
+                    this.dataList=res.data.data.rows;
+                    this.pagination.total=res.data.data.total;
                 });
             },
             // 重置表单
@@ -275,7 +277,7 @@
                 console.log(this.userlocation);
 
                 var param={
-                    addressName:this.address_detail,
+                    addressname:this.address_detail,
                     lng:this.userlocation.lng,
                     lat:this.userlocation.lat
                 }

+ 7 - 0
travel/mbg/pom.xml

@@ -21,6 +21,13 @@
     </properties>
 
     <dependencies>
+
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>3.5.2</version>
+        </dependency>
+
         <dependency>
             <groupId>org.mybatis.spring.boot</groupId>
             <artifactId>mybatis-spring-boot-starter</artifactId>

+ 3 - 0
travel/mbg/src/main/java/com/cl/mbg/model/TAddress.java

@@ -1,5 +1,8 @@
 package com.cl.mbg.model;
 
+import com.alibaba.fastjson2.annotation.JSONField;
+import com.baomidou.mybatisplus.annotation.TableField;
+
 import java.io.Serializable;
 
 public class TAddress implements Serializable {

+ 15 - 0
travel/service/src/main/java/com/lc/service/AddressService.java

@@ -0,0 +1,15 @@
+package com.lc.service;
+
+import com.cl.mbg.model.TAddress;
+import com.lc.common.pojo.TravelParams;
+
+import java.util.HashMap;
+import java.util.List;
+
+public interface AddressService {
+    HashMap<String, Object> findPage(TravelParams travelParams);
+
+    int addAddress(TAddress address);
+
+    int deleteById(Integer id);
+}

+ 5 - 0
travel/service/src/main/java/com/lc/service/SetmealService.java

@@ -4,6 +4,7 @@ import com.cl.mbg.model.TSetmeal;
 import com.lc.common.pojo.TravelParams;
 
 import java.util.HashMap;
+import java.util.List;
 
 public interface SetmealService {
 
@@ -12,4 +13,8 @@ public interface SetmealService {
     int add(TSetmeal setmeal, Integer[] travelgroupIds);
 
     int delete(int id);
+
+    List<TSetmeal> findAll();
+
+    TSetmeal findById(int id);
 }

+ 49 - 0
travel/service/src/main/java/com/lc/service/impl/AddressServiceImpl.java

@@ -0,0 +1,49 @@
+package com.lc.service.impl;
+
+import com.cl.mbg.mapper.TAddressMapper;
+import com.cl.mbg.model.TAddress;
+import com.cl.mbg.model.TAddressExample;
+import com.github.pagehelper.PageHelper;
+import com.lc.common.pojo.TravelParams;
+import com.lc.service.AddressService;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.List;
+
+@Service
+public class AddressServiceImpl implements AddressService {
+
+    @Resource
+    TAddressMapper addressMapper;
+
+    @Override
+    public HashMap<String, Object> findPage(TravelParams travelParams) {
+
+        PageHelper.startPage( travelParams.getCurrentPage(), travelParams.getPageSize() );
+        String name = travelParams.getQueryString().getName();
+        TAddressExample tAddressExample = new TAddressExample();
+        if ( StringUtils.hasText(name) ) {
+            TAddressExample.Criteria criteria = tAddressExample.createCriteria();
+            criteria.andAddressnameLike( "%" + name + "%" );
+        }
+        List<TAddress> tAddresses = addressMapper.selectByExample(tAddressExample);
+        long l = addressMapper.countByExample(tAddressExample);
+        HashMap<String, Object> ret = new HashMap<>();
+        ret.put("rows", tAddresses);
+        ret.put("total", l);
+        return ret;
+    }
+
+    @Override
+    public int addAddress(TAddress address) {
+        return  addressMapper.insert(address);
+    }
+
+    @Override
+    public int deleteById(Integer id) {
+        return addressMapper.deleteByPrimaryKey(id);
+    }
+}

+ 10 - 0
travel/service/src/main/java/com/lc/service/impl/SetmealServiceImpl.java

@@ -66,4 +66,14 @@ public class SetmealServiceImpl implements SetmealService {
         setmealTravelgroupMapper.deleteByExample(tSetmealTravelgroupExample);
         return i;
     }
+
+    @Override
+    public List<TSetmeal> findAll() {
+        return setmealMapper.selectByExample(null);
+    }
+
+    @Override
+    public TSetmeal findById(int id) {
+        return setmealMapper.selectByPrimaryKey(id);
+    }
 }

+ 2 - 0
travel/web/src/main/java/com/lc/web/WebApplication.java

@@ -3,9 +3,11 @@ package com.lc.web;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
 
 @SpringBootApplication
 @MapperScan("com.cl.mbg.mapper")
+@ComponentScan({"com.lc.web", "com.lc.service"})
 public class WebApplication {
 
     public static void main(String[] args) {

+ 33 - 0
travel/web/src/main/java/com/lc/web/config/RedisConfig.java

@@ -0,0 +1,33 @@
+package com.lc.web.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.RedisSerializer;
+
+@Configuration
+public class RedisConfig {
+
+    @Bean("deleteImageRedisTemplate")
+    @SuppressWarnings("all")
+    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory){
+        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
+        redisTemplate.setConnectionFactory( redisConnectionFactory );
+
+        //设置KEY 序列化使用 String 字符串
+        redisTemplate.setKeySerializer( RedisSerializer.string() );
+        redisTemplate.setHashKeySerializer( RedisSerializer.string() );
+
+        GenericJackson2JsonRedisSerializer jsonRedisSerializer =
+                new GenericJackson2JsonRedisSerializer();
+
+        //设置 value 序列化为 JSON格式
+        redisTemplate.setValueSerializer( jsonRedisSerializer );
+        redisTemplate.setHashValueSerializer( jsonRedisSerializer );
+
+        return redisTemplate;
+    }
+
+}

+ 1 - 1
travel/web/src/main/java/com/lc/web/config/XxlConfig.java

@@ -5,7 +5,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
-@Configuration
+//@Configuration
 public class XxlConfig {
 
     @Value("${xxl.job.admin.addresses}")

+ 30 - 0
travel/web/src/main/java/com/lc/web/controller/SetmealController.java

@@ -0,0 +1,30 @@
+package com.lc.web.controller;
+
+import com.cl.mbg.model.TSetmeal;
+import com.lc.common.utils.Result;
+import com.lc.service.SetmealService;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RestController
+@RequestMapping("/setmeal")
+public class SetmealController {
+
+    @Resource
+    SetmealService setmealService;
+
+    @RequestMapping("/selectSetmeal.do")
+    public Result selectSetmeal(){
+        List<TSetmeal> list = setmealService.findAll();
+        return Result.data(list);
+    }
+
+    @RequestMapping("/findById.do")
+    public Result findById(int id){
+        TSetmeal setmeal = setmealService.findById(id);
+        return Result.data(setmeal);
+    }
+}

+ 23 - 0
travel/web/src/main/java/com/lc/web/controller/StaticPageController.java

@@ -0,0 +1,23 @@
+package com.lc.web.controller;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+@Controller
+public class StaticPageController {
+
+    @RequestMapping({"/", "index.html"})
+    public String index(){
+        return "index";
+    }
+
+    @RequestMapping( "/pages/setmeal.html")
+    public String setmeal(){
+        return "setmeal";
+    }
+
+    @RequestMapping( "/pages/setmeal_detail.html")
+    public String setmeal_detail(){
+        return "setmeal_detail";
+    }
+}

+ 3 - 3
travel/web/src/main/resources/templates/index.html

@@ -7,13 +7,13 @@
         <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,user-scalable=no,minimal-ui">
         <meta name="description" content="">
         <meta name="author" content="">
-        <meta http-equiv="refresh" content="3;URL=/pages/setmeal.html"> </span>
+        <meta http-equiv="refresh" content="3;URL=/pages/setmeal.html">
         <link rel="icon" href="/static/img/asset-favico.ico">
         <title>空气旅游</title>
         <link rel="stylesheet" href="/static/css/page-health-index.css" />
         <link rel="stylesheet" href="/static/css/page-health-login.css" />
         <link rel="stylesheet" href="/static/plugins/elementui/index.css" />
-        <script src="/static/plugins/jquery/dist/jquery.min.js"></script>
+<!--        <script src="/static/plugins/jquery/dist/jquery.min.js"></script>-->
         <script src="/static/plugins/healthmobile.js"></script>
         <script src="/static/plugins/vue/vue.js"></script>
         <script src="/static/plugins/vue/axios-0.18.0.js"></script>
@@ -23,7 +23,7 @@
         <div class="app">
             <!-- 页面头部 <a href="/pages/setmeal.html" class="link-page"> -->
           
-            <img src="/img/launch_background.jpg">
+            <img src="/static/img/launch_background.jpg">
         </div>
         <script>
 

+ 1 - 1
travel/web/src/main/resources/templates/setmeal.html

@@ -25,7 +25,7 @@
             <ul class="list">
                 <li class="list-item" v-for="setmeal in setmealList">
                     <a class="link-page" :href="'setmeal_detail.html?id='+setmeal.id">
-                    <img class="img-object f-left" :src="setmeal.img" alt="">
+                    <img class="img-object f-left" :src="'https://80boys-beijing.oss-cn-beijing.aliyuncs.com/'+setmeal.img" alt="">
                     <div class="item-body">
                         <h4 class="ellipsis item-title">{{setmeal.name}}</h4>
                         <p class="ellipsis-more item-desc">{{setmeal.remark}}</p>

+ 1 - 1
travel/web/src/main/resources/templates/setmeal_detail.html

@@ -30,7 +30,7 @@
     <div class="contentBox">
         <div class="card">
             <div class="project-img">
-                <img :src="imgUrl" width="100%" height="100%" />
+                <img :src="'https://80boys-beijing.oss-cn-beijing.aliyuncs.com/'+imgUrl" width="100%" height="100%" />
             </div>
             <div class="project-text">
                 <h4 class="tit">{{setmeal.name}}</h4>