yonge 5 年之前
父節點
當前提交
5072bd1761

+ 32 - 2
cms/pom.xml

@@ -11,11 +11,41 @@
 	<artifactId>cms</artifactId>
 	<name>cms</name>
 	<url>http://maven.apache.org</url>
-	
+
 	<properties>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 	</properties>
-	
+
 	<dependencies>
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>de.codecentric</groupId>
+			<artifactId>spring-boot-admin-starter-client</artifactId>
+		</dependency>
+
+		<!-- swagger-spring-boot -->
+		<dependency>
+			<groupId>com.spring4all</groupId>
+			<artifactId>swagger-spring-boot-starter</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>com.github.xiaoymin</groupId>
+			<artifactId>swagger-bootstrap-ui</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>com.alibaba</groupId>
+			<artifactId>druid-spring-boot-starter</artifactId>
+		</dependency>
+		
+		<dependency>
+			<groupId>com.ym</groupId>
+			<artifactId>common-core</artifactId>
+		</dependency>
 	</dependencies>
 </project>

+ 34 - 0
cms/src/main/java/com/ym/mec/cms/CmsServerApplication.java

@@ -0,0 +1,34 @@
+package com.ym.mec.cms;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.client.RestTemplate;
+
+import com.spring4all.swagger.EnableSwagger2Doc;
+
+@SpringBootApplication
+@EnableDiscoveryClient
+@EnableFeignClients
+@MapperScan("com.ym.mec.cms.dal.dao")
+@ComponentScan(basePackages="com.ym.mec")
+@Configuration
+@EnableSwagger2Doc
+public class CmsServerApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(CmsServerApplication.class, args);
+	}
+	
+	@Bean
+	@LoadBalanced
+	public RestTemplate restTemplate(){
+		return new RestTemplate();
+	}
+}

+ 31 - 0
cms/src/main/java/com/ym/mec/cms/controller/NewsController.java

@@ -0,0 +1,31 @@
+package com.ym.mec.cms.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.ym.mec.cms.service.SysNewsInformationService;
+import com.ym.mec.common.controller.BaseController;
+
+@RestController
+@RequestMapping("news")
+@Api(tags = "资讯服务")
+public class NewsController extends BaseController {
+
+	@Autowired
+	private SysNewsInformationService sysNewsInformationService;
+
+	@ApiOperation("根据用户名查询用户信息接口")
+	@ApiImplicitParam(name = "type", value = "资讯类型", required = true, dataType = "int", paramType = "path")
+	@GetMapping("/list/{type}")
+	public Object getList(@PathVariable("type") int type) {
+		return succeed();
+	}
+
+}

+ 2 - 2
mec-web/src/main/java/com/ym/mec/web/dal/dao/SysNewsInformationDao.java → cms/src/main/java/com/ym/mec/cms/dal/dao/SysNewsInformationDao.java

@@ -1,7 +1,7 @@
-package com.ym.mec.web.dal.dao;
+package com.ym.mec.cms.dal.dao;
 
+import com.ym.mec.cms.dal.entity.SysNewsInformation;
 import com.ym.mec.common.dal.BaseDAO;
-import com.ym.mec.web.dal.entity.SysNewsInformation;
 
 public interface SysNewsInformationDao extends BaseDAO<Long, SysNewsInformation> {
 

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/dal/entity/SysNewsInformation.java → cms/src/main/java/com/ym/mec/cms/dal/entity/SysNewsInformation.java

@@ -1,4 +1,4 @@
-package com.ym.mec.web.dal.entity;
+package com.ym.mec.cms.dal.entity;
 
 import org.apache.commons.lang3.builder.ToStringBuilder;
 

+ 3 - 2
mec-web/src/main/java/com/ym/mec/web/service/SysNewsInformationService.java → cms/src/main/java/com/ym/mec/cms/service/SysNewsInformationService.java

@@ -1,8 +1,9 @@
-package com.ym.mec.web.service;
+package com.ym.mec.cms.service;
 
+import com.ym.mec.cms.dal.entity.SysNewsInformation;
 import com.ym.mec.common.service.BaseService;
-import com.ym.mec.web.dal.entity.SysNewsInformation;
 
 public interface SysNewsInformationService extends BaseService<Long, SysNewsInformation> {
 
+	
 }

+ 4 - 4
mec-web/src/main/java/com/ym/mec/web/service/impl/SysNewsInformationServiceImpl.java → cms/src/main/java/com/ym/mec/cms/service/impl/SysNewsInformationServiceImpl.java

@@ -1,13 +1,13 @@
-package com.ym.mec.web.service.impl;
+package com.ym.mec.cms.service.impl;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import com.ym.mec.cms.dal.dao.SysNewsInformationDao;
+import com.ym.mec.cms.dal.entity.SysNewsInformation;
+import com.ym.mec.cms.service.SysNewsInformationService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
-import com.ym.mec.web.dal.dao.SysNewsInformationDao;
-import com.ym.mec.web.dal.entity.SysNewsInformation;
-import com.ym.mec.web.service.SysNewsInformationService;
 
 @Service
 public class SysNewsInformationServiceImpl extends BaseServiceImpl<Long, SysNewsInformation>  implements SysNewsInformationService {

+ 50 - 0
cms/src/main/resources/application.yml

@@ -0,0 +1,50 @@
+server:
+  port: 8006
+
+eureka:
+  client:
+    serviceUrl:
+      defaultZone: http://admin:admin123@localhost:8761/eureka/eureka/
+
+spring:
+  application:
+    name: cms-server
+    
+  datasource:
+    name: test
+    url: jdbc:mysql://47.99.212.176:3306/mec_dev?useUnicode=true&characterEncoding=UTF8
+    username: mec_dev
+    password: mec_dev
+    # 使用druid数据源
+    type: com.alibaba.druid.pool.DruidDataSource
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    filters: stat
+    maxActive: 20
+    initialSize: 1
+    maxWait: 60000
+    minIdle: 1
+    timeBetweenEvictionRunsMillis: 60000
+    minEvictableIdleTimeMillis: 300000
+    validationQuery: select 'x'
+    testWhileIdle: true
+    testOnBorrow: false
+    testOnReturn: false
+    poolPreparedStatements: true
+    maxOpenPreparedStatements: 20
+    
+
+mybatis:
+    mapperLocations: classpath:config/mybatis/*.xml
+    
+swagger:
+  base-package: com.ym.mec.cms.controller
+  
+#spring boot admin 相关配置
+management:
+  endpoints:
+    web:
+      exposure:
+        include: "*"
+  endpoint:
+    health:
+      show-details: ALWAYS

+ 16 - 0
cms/src/main/resources/bootstrap.properties

@@ -0,0 +1,16 @@
+#\u6307\u5b9a\u5f00\u53d1\u73af\u5883
+#spring.profiles.active=dev
+#\u670d\u52a1\u5668\u5730\u5740
+spring.cloud.nacos.config.server-addr=47.99.212.176:8848
+#\u9ed8\u8ba4\u4e3aPublic\u547d\u540d\u7a7a\u95f4,\u53ef\u4ee5\u7701\u7565\u4e0d\u5199
+spring.cloud.nacos.config.namespace=e246d169-227d-4012-8c34-e90e057d95d2
+#\u6307\u5b9a\u914d\u7f6e\u7fa4\u7ec4 --\u5982\u679c\u662fPublic\u547d\u540d\u7a7a\u95f4 \u5219\u53ef\u4ee5\u7701\u7565\u7fa4\u7ec4\u914d\u7f6e
+spring.cloud.nacos.config.group=DEFAULT_GROUP
+#\u6587\u4ef6\u540d -- \u5982\u679c\u6ca1\u6709\u914d\u7f6e\u5219\u9ed8\u8ba4\u4e3a ${spring.appliction.name}
+spring.cloud.nacos.config.prefix=cms
+#\u6307\u5b9a\u6587\u4ef6\u540e\u7f00
+spring.cloud.nacos.config.file-extension=yaml
+#\u662f\u5426\u52a8\u6001\u5237\u65b0
+spring.cloud.nacos.config.refresh.enabled=true
+#\u662f\u5426\u542f\u7528nacos\u914d\u7f6e\u4e2d\u5fc3
+spring.cloud.nacos.config.enabled=true

+ 0 - 0
mec-web/src/main/resources/config.mybatis/SysNewsInformationMapper.xml → cms/src/main/resources/config/mybatis/SysNewsInformationMapper.xml