day_01后台代码

day_01
Yunfei Du 2024-02-23 15:22:22 +08:00
parent 10341472e9
commit 844caadcf4
13 changed files with 568 additions and 16 deletions

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 111.229.102.61:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 111.229.102.61:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 111.229.102.61:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 111.229.102.61:8848
# 配置文件格式
file-extension: yml
# 共享配置
@ -28,12 +28,12 @@ spring:
eager: true
transport:
# 控制台地址
dashboard: 127.0.0.1:8718
dashboard: 111.229.102.61:8718
# nacos配置持久化
datasource:
ds1:
nacos:
server-addr: 127.0.0.1:8848
server-addr: 111.229.102.61:8848
dataId: sentinel-muyu-gateway
groupId: DEFAULT_GROUP
data-type: json

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 111.229.102.61:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 111.229.102.61:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 111.229.102.61:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 111.229.102.61:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 111.229.102.61:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 111.229.102.61:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -0,0 +1,107 @@
package com.muyu.system.controller;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import com.muyu.system.domain.SysConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.system.domain.BookInfo;
import com.muyu.system.service.IBookInfoService;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author muyu
* @date 2024-02-22
*/
@RestController
@RequestMapping("/info")
public class BookInfoController extends BaseController
{
@Autowired
private IBookInfoService bookInfoService;
/**
*
*/
@RequiresPermissions("system:info:list")
@GetMapping("/list")
public Result<TableDataInfo<BookInfo>> list(BookInfo bookInfo)
{
startPage();
List<BookInfo> list = bookInfoService.selectBookInfoList(bookInfo);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("system:info:export")
@Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, BookInfo bookInfo)
{
List<BookInfo> list = bookInfoService.selectBookInfoList(bookInfo);
ExcelUtil<BookInfo> util = new ExcelUtil<BookInfo>(BookInfo.class);
util.exportExcel(response, list, "【请填写功能名称】数据");
}
/**
*
*/
@RequiresPermissions("system:info:query")
@GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id)
{
return success(bookInfoService.selectBookInfoById(id));
}
/**
*
*/
@RequiresPermissions("system:info:add")
@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
@PostMapping
public Result add(@RequestBody BookInfo bookInfo)
{
return toAjax(bookInfoService.insertBookInfo(bookInfo));
}
/**
*
*/
@RequiresPermissions("system:info:edit")
@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit(@RequestBody BookInfo bookInfo)
{
return toAjax(bookInfoService.updateBookInfo(bookInfo));
}
/**
*
*/
@RequiresPermissions("system:info:remove")
@Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids)
{
return toAjax(bookInfoService.deleteBookInfoByIds(ids));
}
}

View File

@ -0,0 +1,128 @@
package com.muyu.system.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
/**
* book_info
*
* @author muyu
* @date 2024-02-22
*/
public class BookInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** ID */
private Long id;
/** 名称 */
@Excel(name = "名称")
private String title;
/** 作者 */
@Excel(name = "作者")
private String author;
/** 类型 */
@Excel(name = "类型")
private String type;
/** 图片 */
@Excel(name = "图片")
private String images;
/** 描述消息 */
@Excel(name = "描述消息")
private String content;
/** 上架时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "上架时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date shelfTime;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setTitle(String title)
{
this.title = title;
}
public String getTitle()
{
return title;
}
public void setAuthor(String author)
{
this.author = author;
}
public String getAuthor()
{
return author;
}
public void setType(String type)
{
this.type = type;
}
public String getType()
{
return type;
}
public void setImages(String images)
{
this.images = images;
}
public String getImages()
{
return images;
}
public void setContent(String content)
{
this.content = content;
}
public String getContent()
{
return content;
}
public void setShelfTime(Date shelfTime)
{
this.shelfTime = shelfTime;
}
public Date getShelfTime()
{
return shelfTime;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("title", getTitle())
.append("author", getAuthor())
.append("type", getType())
.append("images", getImages())
.append("content", getContent())
.append("shelfTime", getShelfTime())
.append("createTime", getCreateTime())
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,61 @@
package com.muyu.system.mapper;
import java.util.List;
import com.muyu.system.domain.BookInfo;
/**
* Mapper
*
* @author muyu
* @date 2024-02-22
*/
public interface BookInfoMapper
{
/**
*
*
* @param id
* @return
*/
public BookInfo selectBookInfoById(Long id);
/**
*
*
* @param bookInfo
* @return
*/
public List<BookInfo> selectBookInfoList(BookInfo bookInfo);
/**
*
*
* @param bookInfo
* @return
*/
public int insertBookInfo(BookInfo bookInfo);
/**
*
*
* @param bookInfo
* @return
*/
public int updateBookInfo(BookInfo bookInfo);
/**
*
*
* @param id
* @return
*/
public int deleteBookInfoById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteBookInfoByIds(Long[] ids);
}

View File

@ -0,0 +1,61 @@
package com.muyu.system.service;
import java.util.List;
import com.muyu.system.domain.BookInfo;
/**
* Service
*
* @author muyu
* @date 2024-02-22
*/
public interface IBookInfoService
{
/**
*
*
* @param id
* @return
*/
public BookInfo selectBookInfoById(Long id);
/**
*
*
* @param bookInfo
* @return
*/
public List<BookInfo> selectBookInfoList(BookInfo bookInfo);
/**
*
*
* @param bookInfo
* @return
*/
public int insertBookInfo(BookInfo bookInfo);
/**
*
*
* @param bookInfo
* @return
*/
public int updateBookInfo(BookInfo bookInfo);
/**
*
*
* @param ids
* @return
*/
public int deleteBookInfoByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteBookInfoById(Long id);
}

View File

@ -0,0 +1,96 @@
package com.muyu.system.service.impl;
import java.util.List;
import com.muyu.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.muyu.system.mapper.BookInfoMapper;
import com.muyu.system.domain.BookInfo;
import com.muyu.system.service.IBookInfoService;
/**
* Service
*
* @author muyu
* @date 2024-02-22
*/
@Service
public class BookInfoServiceImpl implements IBookInfoService
{
@Autowired
private BookInfoMapper bookInfoMapper;
/**
*
*
* @param id
* @return
*/
@Override
public BookInfo selectBookInfoById(Long id)
{
return bookInfoMapper.selectBookInfoById(id);
}
/**
*
*
* @param bookInfo
* @return
*/
@Override
public List<BookInfo> selectBookInfoList(BookInfo bookInfo)
{
return bookInfoMapper.selectBookInfoList(bookInfo);
}
/**
*
*
* @param bookInfo
* @return
*/
@Override
public int insertBookInfo(BookInfo bookInfo)
{
bookInfo.setCreateTime(DateUtils.getNowDate());
return bookInfoMapper.insertBookInfo(bookInfo);
}
/**
*
*
* @param bookInfo
* @return
*/
@Override
public int updateBookInfo(BookInfo bookInfo)
{
bookInfo.setUpdateTime(DateUtils.getNowDate());
return bookInfoMapper.updateBookInfo(bookInfo);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteBookInfoByIds(Long[] ids)
{
return bookInfoMapper.deleteBookInfoByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteBookInfoById(Long id)
{
return bookInfoMapper.deleteBookInfoById(id);
}
}

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 111.229.102.61:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 111.229.102.61:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -0,0 +1,99 @@
<?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.muyu.system.mapper.BookInfoMapper">
<resultMap type="com.muyu.system.domain.BookInfo" id="BookInfoResult">
<result property="id" column="id" />
<result property="title" column="title" />
<result property="author" column="author" />
<result property="type" column="type" />
<result property="images" column="images" />
<result property="content" column="content" />
<result property="shelfTime" column="shelf_time" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectBookInfoVo">
select id, title, author, type, images, content, shelf_time, create_time, create_by, update_by, update_time from book_info
</sql>
<select id="selectBookInfoList" parameterType="com.muyu.system.domain.BookInfo" resultMap="BookInfoResult">
<include refid="selectBookInfoVo"/>
<where>
<if test="title != null and title != ''"> and title = #{title}</if>
<if test="author != null and author != ''"> and author = #{author}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="images != null and images != ''"> and images = #{images}</if>
<if test="content != null and content != ''"> and content = #{content}</if>
<if test="shelfTime != null "> and shelf_time = #{shelfTime}</if>
</where>
</select>
<select id="selectBookInfoById" parameterType="Long" resultMap="BookInfoResult">
<include refid="selectBookInfoVo"/>
where id = #{id}
</select>
<insert id="insertBookInfo" parameterType="com.muyu.system.domain.BookInfo">
insert into book_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="title != null">title,</if>
<if test="author != null">author,</if>
<if test="type != null">type,</if>
<if test="images != null">images,</if>
<if test="content != null">content,</if>
<if test="shelfTime != null">shelf_time,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="title != null">#{title},</if>
<if test="author != null">#{author},</if>
<if test="type != null">#{type},</if>
<if test="images != null">#{images},</if>
<if test="content != null">#{content},</if>
<if test="shelfTime != null">#{shelfTime},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateBookInfo" parameterType="com.muyu.system.domain.BookInfo">
update book_info
<trim prefix="SET" suffixOverrides=",">
<if test="title != null">title = #{title},</if>
<if test="author != null">author = #{author},</if>
<if test="type != null">type = #{type},</if>
<if test="images != null">images = #{images},</if>
<if test="content != null">content = #{content},</if>
<if test="shelfTime != null">shelf_time = #{shelfTime},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteBookInfoById" parameterType="Long">
delete from book_info where id = #{id}
</delete>
<delete id="deleteBookInfoByIds" parameterType="String">
delete from book_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 111.229.102.61:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 111.229.102.61:8848
# 配置文件格式
file-extension: yml
# 共享配置