yonge před 5 roky
rodič
revize
e887431ff1

+ 16 - 1
cms/pom.xml

@@ -42,10 +42,25 @@
 			<groupId>com.alibaba</groupId>
 			<artifactId>druid-spring-boot-starter</artifactId>
 		</dependency>
-		
+
+		<dependency>
+			<groupId>mysql</groupId>
+			<artifactId>mysql-connector-java</artifactId>
+		</dependency>
+
 		<dependency>
 			<groupId>com.ym</groupId>
 			<artifactId>common-core</artifactId>
+			<exclusions>
+				<exclusion>
+					<groupId>org.springframework.cloud</groupId>
+					<artifactId>spring-cloud-starter-oauth2</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>org.springframework.boot</groupId>
+					<artifactId>spring-boot-starter-security</artifactId>
+				</exclusion>
+			</exclusions>
 		</dependency>
 	</dependencies>
 </project>

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

@@ -17,7 +17,7 @@ import com.spring4all.swagger.EnableSwagger2Doc;
 @EnableDiscoveryClient
 @EnableFeignClients
 @MapperScan("com.ym.mec.cms.dal.dao")
-@ComponentScan(basePackages="com.ym.mec")
+@ComponentScan(basePackages="com.ym.mec.cms")
 @Configuration
 @EnableSwagger2Doc
 public class CmsServerApplication {

+ 35 - 4
cms/src/main/java/com/ym/mec/cms/controller/NewsController.java

@@ -4,12 +4,17 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiOperation;
 
+import java.util.Date;
+
 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.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import com.ym.mec.cms.controller.queryinfo.NewsInformationQueryInfo;
+import com.ym.mec.cms.dal.entity.SysNewsInformation;
 import com.ym.mec.cms.service.SysNewsInformationService;
 import com.ym.mec.common.controller.BaseController;
 
@@ -21,11 +26,37 @@ public class NewsController extends BaseController {
 	@Autowired
 	private SysNewsInformationService sysNewsInformationService;
 
-	@ApiOperation("根据用户名查询用户信息接口")
-	@ApiImplicitParam(name = "type", value = "资讯类型", required = true, dataType = "int", paramType = "path")
+	@ApiOperation("资讯列表分页查询")
 	@GetMapping("/list/{type}")
-	public Object getList(@PathVariable("type") int type) {
-		return succeed();
+	public Object getList(NewsInformationQueryInfo queryInfo) {
+		return succeed(sysNewsInformationService.queryPage(queryInfo));
+	}
+
+	@ApiOperation("查询资讯详情")
+	@ApiImplicitParam(name = "id", value = "资讯ID编号", required = true, dataType = "Long", paramType = "path")
+	@GetMapping("/query/{id}")
+	public Object query(@PathVariable("id") Long id) {
+
+		return succeed(sysNewsInformationService.get(id));
+	}
+
+	@ApiOperation("新增资讯")
+	@PostMapping("/add")
+	public Object add(SysNewsInformation newsInfo) {
+		Date date = new Date();
+		newsInfo.setCreateTime(date);
+		newsInfo.setUpdateTime(date);
+
+		return succeed(sysNewsInformationService.insert(newsInfo));
+	}
+
+	@ApiOperation("更新资讯")
+	@PostMapping("/update")
+	public Object update(SysNewsInformation newsInfo) {
+		Date date = new Date();
+		newsInfo.setUpdateTime(date);
+
+		return succeed(sysNewsInformationService.update(newsInfo));
 	}
 
 }

+ 41 - 0
cms/src/main/java/com/ym/mec/cms/controller/queryinfo/NewsInformationQueryInfo.java

@@ -0,0 +1,41 @@
+package com.ym.mec.cms.controller.queryinfo;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import com.ym.mec.common.page.QueryInfo;
+
+public class NewsInformationQueryInfo extends QueryInfo {
+
+	@ApiModelProperty(value = "资讯类型", required = false)
+	private Integer type;
+
+	@ApiModelProperty(value = "资讯状态", required = false)
+	private String status;
+
+	@ApiModelProperty(value = "标题", required = false)
+	private String title;
+
+	public Integer getType() {
+		return type;
+	}
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+
+	public String getStatus() {
+		return status;
+	}
+
+	public void setStatus(String status) {
+		this.status = status;
+	}
+
+	public String getTitle() {
+		return title;
+	}
+
+	public void setTitle(String title) {
+		this.title = title;
+	}
+}

+ 8 - 1
cms/src/main/java/com/ym/mec/cms/dal/dao/SysNewsInformationDao.java

@@ -1,9 +1,16 @@
 package com.ym.mec.cms.dal.dao;
 
+import java.util.List;
+
 import com.ym.mec.cms.dal.entity.SysNewsInformation;
 import com.ym.mec.common.dal.BaseDAO;
 
 public interface SysNewsInformationDao extends BaseDAO<Long, SysNewsInformation> {
 
-	
+	/**
+	 * 根据类型查询资讯列表
+	 * @param type
+	 * @return
+	 */
+	List<SysNewsInformation> queryByType(Integer type);
 }

+ 47 - 40
cms/src/main/java/com/ym/mec/cms/dal/entity/SysNewsInformation.java

@@ -1,5 +1,7 @@
 package com.ym.mec.cms.dal.entity;
 
+import io.swagger.annotations.ApiModelProperty;
+
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 /**
@@ -9,92 +11,97 @@ public class SysNewsInformation {
 
 	/**  */
 	private Long id;
-	
+
 	/** 标题 */
+	@ApiModelProperty(value = "标题", required = true)
 	private String title;
-	
+
 	/** 内容 */
+	@ApiModelProperty(value = "内容", required = true)
 	private String content;
-	
+
 	/** 封面图片 */
+	@ApiModelProperty(value = "封面图片", required = false)
 	private String coverImage;
-	
+
 	/** 类型 */
+	@ApiModelProperty(value = "类型", required = true)
 	private Integer type;
-	
+
 	/** 状态(1-可见 0-不可见) */
+	@ApiModelProperty(value = "状态(1-可见 0-不可见)", required = true)
 	private String status;
-	
+
 	/**  */
 	private java.util.Date createTime;
-	
+
 	/**  */
 	private java.util.Date updateTime;
-	
-	public void setId(Long id){
+
+	public void setId(Long id) {
 		this.id = id;
 	}
-	
-	public Long getId(){
+
+	public Long getId() {
 		return this.id;
 	}
-			
-	public void setTitle(String title){
+
+	public void setTitle(String title) {
 		this.title = title;
 	}
-	
-	public String getTitle(){
+
+	public String getTitle() {
 		return this.title;
 	}
-			
-	public void setContent(String content){
+
+	public void setContent(String content) {
 		this.content = content;
 	}
-	
-	public String getContent(){
+
+	public String getContent() {
 		return this.content;
 	}
-			
-	public void setCoverImage(String coverImage){
+
+	public void setCoverImage(String coverImage) {
 		this.coverImage = coverImage;
 	}
-	
-	public String getCoverImage(){
+
+	public String getCoverImage() {
 		return this.coverImage;
 	}
-			
-	public void setType(Integer type){
+
+	public void setType(Integer type) {
 		this.type = type;
 	}
-	
-	public Integer getType(){
+
+	public Integer getType() {
 		return this.type;
 	}
-			
-	public void setStatus(String status){
+
+	public void setStatus(String status) {
 		this.status = status;
 	}
-	
-	public String getStatus(){
+
+	public String getStatus() {
 		return this.status;
 	}
-			
-	public void setCreateTime(java.util.Date createTime){
+
+	public void setCreateTime(java.util.Date createTime) {
 		this.createTime = createTime;
 	}
-	
-	public java.util.Date getCreateTime(){
+
+	public java.util.Date getCreateTime() {
 		return this.createTime;
 	}
-			
-	public void setUpdateTime(java.util.Date updateTime){
+
+	public void setUpdateTime(java.util.Date updateTime) {
 		this.updateTime = updateTime;
 	}
-	
-	public java.util.Date getUpdateTime(){
+
+	public java.util.Date getUpdateTime() {
 		return this.updateTime;
 	}
-			
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

+ 8 - 1
cms/src/main/java/com/ym/mec/cms/service/SysNewsInformationService.java

@@ -1,9 +1,16 @@
 package com.ym.mec.cms.service;
 
+import java.util.List;
+
 import com.ym.mec.cms.dal.entity.SysNewsInformation;
 import com.ym.mec.common.service.BaseService;
 
 public interface SysNewsInformationService extends BaseService<Long, SysNewsInformation> {
 
-	
+	/**
+	 * 根据类型查询资讯列表
+	 * @param type
+	 * @return
+	 */
+	List<SysNewsInformation> queryByType(Integer type);
 }

+ 10 - 3
cms/src/main/java/com/ym/mec/cms/service/impl/SysNewsInformationServiceImpl.java

@@ -1,5 +1,7 @@
 package com.ym.mec.cms.service.impl;
 
+import java.util.List;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -10,8 +12,8 @@ import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 
 @Service
-public class SysNewsInformationServiceImpl extends BaseServiceImpl<Long, SysNewsInformation>  implements SysNewsInformationService {
-	
+public class SysNewsInformationServiceImpl extends BaseServiceImpl<Long, SysNewsInformation> implements SysNewsInformationService {
+
 	@Autowired
 	private SysNewsInformationDao sysNewsInformationDao;
 
@@ -19,5 +21,10 @@ public class SysNewsInformationServiceImpl extends BaseServiceImpl<Long, SysNews
 	public BaseDAO<Long, SysNewsInformation> getDAO() {
 		return sysNewsInformationDao;
 	}
-	
+
+	@Override
+	public List<SysNewsInformation> queryByType(Integer type) {
+		return sysNewsInformationDao.queryByType(type);
+	}
+
 }

+ 59 - 31
cms/src/main/resources/config/mybatis/SysNewsInformationMapper.xml

@@ -6,7 +6,7 @@
 -->
 <mapper namespace="com.ym.mec.web.dal.dao.SysNewsInformationDao">
 	
-	<resultMap type="com.ym.mec.web.dal.entity.SysNewsInformation" id="SysNewsInformation">
+	<resultMap type="com.ym.mec.cms.dal.entity.SysNewsInformation" id="SysNewsInformation">
 		<result column="id_" property="id" />
 		<result column="title_" property="title" />
 		<result column="content_" property="content" />
@@ -17,6 +17,20 @@
 		<result column="update_time_" property="updateTime" />
 	</resultMap>
 	
+	<sql id="queryCondition">
+		<where>
+			<if test="type != null">
+				and type_ = #{type}
+			</if>
+			<if test="status != null">
+				and status_ = #{status}
+			</if>
+			<if test="title != null">
+				and title_ like '%' #{title} '%'
+			</if>
+		</where>
+	</sql>
+	
 	<!-- 根据主键查询一条记录 -->
 	<select id="get" resultMap="SysNewsInformation" >
 		SELECT * FROM sys_news_information WHERE id_ = #{id} 
@@ -28,7 +42,7 @@
 	</select>
 	
 	<!-- 向数据库增加一条记录 -->
-	<insert id="insert" parameterType="com.ym.mec.web.dal.entity.SysNewsInformation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+	<insert id="insert" parameterType="com.ym.mec.cms.dal.entity.SysNewsInformation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 		<!--
 		<selectKey resultClass="int" keyProperty="id" > 
 		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
@@ -38,33 +52,35 @@
 	</insert>
 	
 	<!-- 根据主键查询一条记录 -->
-	<update id="update" parameterType="com.ym.mec.web.dal.entity.SysNewsInformation">
-		UPDATE sys_news_information <set>
-<if test="status != null">
-status_ = #{status},
-</if>
-<if test="id != null">
-id_ = #{id},
-</if>
-<if test="title != null">
-title_ = #{title},
-</if>
-<if test="updateTime != null">
-update_time_ = #{updateTime},
-</if>
-<if test="content != null">
-content_ = #{content},
-</if>
-<if test="coverImage != null">
-cover_image_ = #{coverImage},
-</if>
-<if test="type != null">
-type_ = #{type},
-</if>
-<if test="createTime != null">
-create_time_ = #{createTime},
-</if>
-</set> WHERE id_ = #{id} 
+	<update id="update" parameterType="com.ym.mec.cms.dal.entity.SysNewsInformation">
+		UPDATE sys_news_information
+		<set>
+			<if test="status != null">
+				status_ = #{status},
+			</if>
+			<if test="id != null">
+				id_ = #{id},
+			</if>
+			<if test="title != null">
+				title_ = #{title},
+			</if>
+			<if test="updateTime != null">
+				update_time_ = #{updateTime},
+			</if>
+			<if test="content != null">
+				content_ = #{content},
+			</if>
+			<if test="coverImage != null">
+				cover_image_ = #{coverImage},
+			</if>
+			<if test="type != null">
+				type_ = #{type},
+			</if>
+			<if test="createTime != null">
+				create_time_ = #{createTime},
+			</if>
+		</set>
+		WHERE id_ = #{id}
 	</update>
 	
 	<!-- 根据主键删除一条记录 -->
@@ -74,11 +90,23 @@ create_time_ = #{createTime},
 	
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="SysNewsInformation" parameterType="map">
-		SELECT * FROM sys_news_information ORDER BY id_ <include refid="global.limit"/>
+		SELECT * FROM sys_news_information ORDER BY id_ 
+		<include refid="queryCondition" />
+		<include refid="global.limit"/>
 	</select>
 	
 	<!-- 查询当前表的总记录数 -->
 	<select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM sys_news_information
+		SELECT COUNT(*) FROM sys_news_information 
+		<include refid="queryCondition" />
+	</select>
+	
+	<select id="queryByType" resultMap="SysNewsInformation" parameterType="java.lang.Integer">
+		SELECT * FROM sys_news_information 
+		<where>
+			<if test="type != null">
+				and type_ = #{type}
+			</if>
+		</where>
 	</select>
 </mapper>

+ 5 - 0
mec-eureka/pom.xml

@@ -21,6 +21,11 @@
 			<groupId>org.springframework.cloud</groupId>
 			<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
 		</dependency>
+		
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-security</artifactId>
+		</dependency>
 	</dependencies>
 
 	<build>

+ 5 - 0
mec-gateway/mec-gateway-web/pom.xml

@@ -50,6 +50,11 @@
 			<groupId>de.codecentric</groupId>
 			<artifactId>spring-boot-admin-starter-client</artifactId>
 		</dependency>
+		
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-security</artifactId>
+		</dependency>
 	</dependencies>
 
 	<build>

+ 2 - 0
mec-gateway/mec-gateway-web/src/main/java/com/ym/mec/gateway/web/config/SwaggerDocumentConfig.java

@@ -19,6 +19,8 @@ public class SwaggerDocumentConfig implements SwaggerResourcesProvider {
 
 		// 增加服务信息
 		resources.add(swaggerResource("授权服务", "/auth-server/v2/api-docs", "2.0"));
+		resources.add(swaggerResource("CMS服务", "/cms-server/v2/api-docs", "2.0"));
+		resources.add(swaggerResource("WEB服务", "/web-server/v2/api-docs", "2.0"));
 		return resources;
 	}
 

+ 14 - 0
mec-gateway/mec-gateway-web/src/main/resources/application.yml

@@ -29,6 +29,20 @@ zuul:
       #url: http://localhost:8001/
       ##加上下面参数,可将header信息传递至下游
       sensitiveHeaders: 
+    api-cms:
+      ### 以 /api-auth/访问转发到会员服务
+      path: /api-cms/**
+      serviceId: cms-server
+      #url: http://localhost:8001/
+      ##加上下面参数,可将header信息传递至下游
+      sensitiveHeaders: 
+    api-web:
+      ### 以 /api-auth/访问转发到会员服务
+      path: /api-web/**
+      serviceId: web-server
+      #url: http://localhost:8001/
+      ##加上下面参数,可将header信息传递至下游
+      sensitiveHeaders: 
   #忽略某个微服务
   ignored-services: eureka-server
   #重试

+ 6 - 1
mec-monitor/pom.xml

@@ -24,8 +24,13 @@
 			<groupId>de.codecentric</groupId>
 			<artifactId>spring-boot-admin-starter-server</artifactId>
 		</dependency>
+		
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-security</artifactId>
+		</dependency>
 	</dependencies>
-	
+
 	<build>
 		<plugins>
 			<plugin>

+ 64 - 63
mec-web/pom.xml

@@ -1,71 +1,72 @@
 <?xml version="1.0"?>
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>com.ym</groupId>
-    <artifactId>mec</artifactId>
-    <version>1.0</version>
-  </parent>
-  <groupId>com.ym</groupId>
-  <artifactId>mec-web</artifactId>
-  <version>1.0</version>
-  <name>mec-web</name>
-  <url>http://maven.apache.org</url>
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
+<project
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>com.ym</groupId>
+		<artifactId>mec</artifactId>
+		<version>1.0</version>
+	</parent>
+	<artifactId>mec-web</artifactId>
+	<name>mec-web</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>
+	<dependencies>
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+		</dependency>
 
-    <dependency>
-      <groupId>org.springframework.cloud</groupId>
-      <artifactId>spring-cloud-starter-oauth2</artifactId>
-    </dependency>
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-oauth2</artifactId>
+		</dependency>
 
-    <dependency>
-      <groupId>org.springframework.cloud</groupId>
-      <artifactId>spring-cloud-starter-security</artifactId>
-    </dependency>
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-security</artifactId>
+		</dependency>
 
-    <dependency>
-      <groupId>org.springframework.cloud</groupId>
-      <artifactId>spring-cloud-sleuth-zipkin</artifactId>
-    </dependency>
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-sleuth-zipkin</artifactId>
+		</dependency>
 
-    <!-- swagger-spring-boot -->
-    <dependency>
-      <groupId>com.spring4all</groupId>
-      <artifactId>swagger-spring-boot-starter</artifactId>
-    </dependency>
+		<!-- swagger-spring-boot -->
+		<dependency>
+			<groupId>com.spring4all</groupId>
+			<artifactId>swagger-spring-boot-starter</artifactId>
+		</dependency>
 
-    <dependency>
-      <groupId>com.alibaba</groupId>
-      <artifactId>druid-spring-boot-starter</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>mysql</groupId>
-      <artifactId>mysql-connector-java</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>com.ym</groupId>
-      <artifactId>common-core</artifactId>
-    </dependency>
-  </dependencies>
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.springframework.boot</groupId>
-        <artifactId>spring-boot-maven-plugin</artifactId>
-      </plugin>
-      <plugin>
-        <groupId>com.spotify</groupId>
-        <artifactId>docker-maven-plugin</artifactId>
-      </plugin>
-    </plugins>
-  </build>
+		<dependency>
+			<groupId>com.alibaba</groupId>
+			<artifactId>druid-spring-boot-starter</artifactId>
+		</dependency>
+		
+		<dependency>
+			<groupId>mysql</groupId>
+			<artifactId>mysql-connector-java</artifactId>
+		</dependency>
+		
+		<dependency>
+			<groupId>com.ym</groupId>
+			<artifactId>common-core</artifactId>
+		</dependency>
+	</dependencies>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+			</plugin>
+			<plugin>
+				<groupId>com.spotify</groupId>
+				<artifactId>docker-maven-plugin</artifactId>
+			</plugin>
+		</plugins>
+	</build>
 </project>

+ 2 - 2
pom.xml

@@ -228,10 +228,10 @@
 			<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
 		</dependency>
 
-		<dependency>
+		<!-- <dependency>
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-security</artifactId>
-		</dependency>
+		</dependency> -->
 
 		<!--集群监控消息队列 -->
 		<!-- <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-netflix-hystrix-stream</artifactId>