jangc第一次上传
parent
094c62be8d
commit
19690e9e6f
|
@ -15,9 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -67,11 +67,15 @@
|
|||
<artifactId>zhilian-common-system</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zhilian</groupId>
|
||||
<artifactId>zhilian-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
@ -100,4 +104,4 @@
|
|||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package com.zhilian.mybatisplus;
|
||||
|
||||
import com.zhilian.common.security.annotation.EnableMyFeignClients;
|
||||
import com.zhilian.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@MapperScan("com.zhilian.mybatisplus.mapper")
|
||||
@SpringBootApplication
|
||||
public class ZhiLianMybatisPlusApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ZhiLianMybatisPlusApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.zhilian.mybatisplus.controller;
|
||||
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import com.zhilian.common.log.annotation.Log;
|
||||
import com.zhilian.common.log.enums.BusinessType;
|
||||
import com.zhilian.mybatisplus.domain.Content;
|
||||
import com.zhilian.mybatisplus.domain.resp.ContentResp;
|
||||
import com.zhilian.mybatisplus.service.ContentServer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/content")
|
||||
public class ContentController {
|
||||
@Autowired
|
||||
private ContentServer contentServer;
|
||||
|
||||
/**
|
||||
* 获取新闻列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Result<List<ContentResp>> searchContentList(){
|
||||
List<ContentResp> list =contentServer.searchContentList();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新闻添加
|
||||
* @return
|
||||
*/
|
||||
@Log(title = "新闻添加",businessType = BusinessType.INSERT)
|
||||
@PostMapping("/addNews")
|
||||
public Result addNews(@RequestBody Content content){
|
||||
contentServer.addNews(content);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新闻添加
|
||||
* @return
|
||||
*/
|
||||
@Log(title = "新闻删除",businessType = BusinessType.DELETE)
|
||||
@PostMapping("/delNews/{id}")
|
||||
public Result delNews(@PathVariable Integer id){
|
||||
contentServer.delNews(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.zhilian.mybatisplus.controller;
|
||||
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import com.zhilian.common.log.enums.BusinessType;
|
||||
import com.zhilian.mybatisplus.domain.NewsType;
|
||||
import com.zhilian.mybatisplus.service.NewsTypeService;
|
||||
import com.zhilian.common.log.annotation.Log;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/newsType")
|
||||
public class NewsTypeController {
|
||||
@Autowired
|
||||
private NewsTypeService newsTypeService;
|
||||
|
||||
/**
|
||||
* 获取新闻类型字典
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Result<List<NewsType>> searchNewsTypes(){
|
||||
List<NewsType> list =newsTypeService.searchNewsTypes();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新闻类型字典添加
|
||||
* @param newsType
|
||||
* @return
|
||||
*/
|
||||
@Log(title = "新闻类型字典添加",businessType = BusinessType.INSERT)
|
||||
@PostMapping("/addNewsTypes")
|
||||
public Result addNewsTypes(@RequestBody NewsType newsType){
|
||||
newsTypeService.addNewsTypes(newsType);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新闻类型字典删除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Log(title = "新闻类型字典删除",businessType = BusinessType.DELETE)
|
||||
@PostMapping("/delNewsTypes/{id}")
|
||||
public Result delNewsTypes(@PathVariable Integer id){
|
||||
newsTypeService.delNewsTypes(id);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.zhilian.mybatisplus.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Content {
|
||||
private Integer id;
|
||||
private Integer typeId;
|
||||
private Date createTime;
|
||||
private String pic;
|
||||
private String details;
|
||||
private Integer isDelete;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.zhilian.mybatisplus.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class NewsType {
|
||||
/**
|
||||
* 新闻属性id
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 新闻属性名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
*1展示 0不展示
|
||||
*/
|
||||
private Integer isDelete;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.zhilian.mybatisplus.domain.resp;
|
||||
|
||||
import com.zhilian.mybatisplus.domain.Content;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ContentResp extends Content {
|
||||
/**
|
||||
* 新闻字典名称
|
||||
*/
|
||||
private String name;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.zhilian.mybatisplus.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhilian.mybatisplus.domain.Content;
|
||||
import com.zhilian.mybatisplus.domain.resp.ContentResp;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ContentMapper extends BaseMapper<ContentResp> {
|
||||
List<ContentResp> searchContentList();
|
||||
|
||||
void addNews(Content content);
|
||||
|
||||
void delNews(@Param("id") Integer id);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.zhilian.mybatisplus.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhilian.mybatisplus.domain.NewsType;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface NewsTypeMapper extends BaseMapper<NewsType> {
|
||||
List<NewsType> searchNewsTypes();
|
||||
|
||||
void addNewsTypes(NewsType newsType);
|
||||
|
||||
void delNewsTypes(@Param("id") Integer id);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.zhilian.mybatisplus.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhilian.mybatisplus.domain.Content;
|
||||
import com.zhilian.mybatisplus.domain.resp.ContentResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ContentServer extends IService<ContentResp> {
|
||||
List<ContentResp> searchContentList();
|
||||
|
||||
void addNews(Content content);
|
||||
|
||||
void delNews(Integer id);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.zhilian.mybatisplus.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhilian.mybatisplus.domain.NewsType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface NewsTypeService extends IService<NewsType> {
|
||||
/**
|
||||
* 查询所有新闻类型字典
|
||||
* @return
|
||||
*/
|
||||
List<NewsType> searchNewsTypes();
|
||||
|
||||
void addNewsTypes(NewsType newsType);
|
||||
|
||||
void delNewsTypes(Integer id);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.zhilian.mybatisplus.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhilian.mybatisplus.domain.Content;
|
||||
import com.zhilian.mybatisplus.domain.resp.ContentResp;
|
||||
import com.zhilian.mybatisplus.mapper.ContentMapper;
|
||||
import com.zhilian.mybatisplus.service.ContentServer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@Service
|
||||
public class ContentServerImpl extends ServiceImpl<ContentMapper, ContentResp> implements ContentServer {
|
||||
@Autowired
|
||||
private ContentMapper contentMapper;
|
||||
@Override
|
||||
public List<ContentResp> searchContentList() {
|
||||
return contentMapper.searchContentList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNews(Content content) {
|
||||
contentMapper.addNews(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delNews(Integer id) {
|
||||
contentMapper.delNews(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.zhilian.mybatisplus.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhilian.mybatisplus.domain.NewsType;
|
||||
import com.zhilian.mybatisplus.mapper.NewsTypeMapper;
|
||||
import com.zhilian.mybatisplus.service.NewsTypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class NewsTypeServiceImpl extends ServiceImpl<NewsTypeMapper, NewsType> implements NewsTypeService {
|
||||
@Autowired
|
||||
private NewsTypeMapper newsTypeMapper;
|
||||
@Override
|
||||
public List<NewsType> searchNewsTypes() {
|
||||
return newsTypeMapper.searchNewsTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNewsTypes(NewsType newsType) {
|
||||
newsTypeMapper.addNewsTypes(newsType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delNewsTypes(Integer id) {
|
||||
newsTypeMapper.delNewsTypes(id);
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ server:
|
|||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: zhilian-gmybatis-plus
|
||||
name: zhilian-mybatisplus
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
|
@ -15,9 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<?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.zhilian.mybatisplus.mapper.ContentMapper">
|
||||
|
||||
<resultMap type="com.zhilian.mybatisplus.domain.resp.ContentResp" id="contentResult">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="pic" column="pic"/>
|
||||
<result property="details" column="details"/>
|
||||
</resultMap>
|
||||
<sql id="contentList">
|
||||
SELECT c.id,
|
||||
t.name,
|
||||
c.create_time,
|
||||
c.pic,
|
||||
c.details
|
||||
from t_content c LEFT JOIN t_news_type t on c.type_id=t.id WHERE c.is_delete=1
|
||||
</sql>
|
||||
|
||||
<!-- 添加新闻 -->
|
||||
<insert id="addNews">
|
||||
INSERT INTO `zhilian-cloud`.`t_content`
|
||||
(`id`, `type_id`, `create_time`, `pic`, `details`, `is_delete`)
|
||||
VALUES
|
||||
(#{id}, #{typeId},DATE_ADD(NOW(), INTERVAL 8 HOUR), NULL, #{details}, 1);
|
||||
</insert>
|
||||
|
||||
<!-- 删除新闻 -->
|
||||
<delete id="delNews">
|
||||
update t_content set is_delete=0 where id=#{id}
|
||||
</delete>
|
||||
|
||||
<!-- 查询新闻列表 -->
|
||||
<select id="searchContentList" resultType="com.zhilian.mybatisplus.domain.resp.ContentResp" resultMap="contentResult">
|
||||
<include refid="contentList"/>
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,30 @@
|
|||
<?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.zhilian.mybatisplus.mapper.NewsTypeMapper">
|
||||
|
||||
<resultMap type="com.zhilian.mybatisplus.domain.NewsType" id="NewsTypeResult">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
</resultMap>
|
||||
<sql id="newsTypeList">
|
||||
select id ,name from t_news_type where is_delete =1
|
||||
</sql>
|
||||
|
||||
<!-- 新增 -->
|
||||
<insert id="addNewsTypes">
|
||||
INSERT INTO `zhilian-cloud`.`t_news_type` (`id`, `name`,`is_delete`) VALUES (0, #{name},1);
|
||||
</insert>
|
||||
|
||||
<!-- 删除 -->
|
||||
<delete id="delNewsTypes">
|
||||
update t_news_type set is_delete = 0 where id = #{id};
|
||||
</delete>
|
||||
|
||||
<!-- 查询 -->
|
||||
<select id="searchNewsTypes" resultType="com.zhilian.mybatisplus.domain.NewsType" resultMap="NewsTypeResult">
|
||||
<include refid="newsTypeList"/>
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -15,9 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
Loading…
Reference in New Issue