DAY_01作业内容

day_01
yaoxin 2024-02-23 14:06:22 +08:00
parent 10341472e9
commit 955a6b0960
13 changed files with 577 additions and 24 deletions

View File

@ -1,7 +1,6 @@
# Tomcat
server:
port: 9200
port: 9001
# Spring
spring:
application:
@ -14,10 +13,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 43.142.44.217:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 43.142.44.217:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

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

View File

@ -1,6 +1,6 @@
# Tomcat
server:
port: 9300
port: 9006
# Spring
spring:
@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 43.142.44.217:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 43.142.44.217:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -1,6 +1,6 @@
# Tomcat
server:
port: 9202
port: 9005
# Spring
spring:
@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 43.142.44.217:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 43.142.44.217:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -1,6 +1,6 @@
# Tomcat
server:
port: 9203
port: 9004
# Spring
spring:
@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 43.142.44.217:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 43.142.44.217:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -0,0 +1,105 @@
package com.muyu.system.controller;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
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-23
*/
@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 = "/{bid}")
public Result getInfo(@PathVariable("bid") Long bid)
{
return success(bookInfoService.selectBookInfoByBid(bid));
}
/**
*
*/
@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("/{bids}")
public Result remove(@PathVariable Long[] bids)
{
return toAjax(bookInfoService.deleteBookInfoByBids(bids));
}
}

View File

@ -0,0 +1,129 @@
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-23
*/
public class BookInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 书籍编号 */
private Long bid;
/** 书籍名称 */
@Excel(name = "书籍名称")
private String title;
/** 作者名称 */
@Excel(name = "作者名称")
private String author;
/** 书籍类型 */
@Excel(name = "书籍类型")
private String type;
/** 图片 */
@Excel(name = "图片")
private String image;
/** 书籍介绍 */
@Excel(name = "书籍介绍")
private String description;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date shelfTime;
public void setBid(Long bid)
{
this.bid = bid;
}
public Long getBid()
{
return bid;
}
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 setImage(String image)
{
this.image = image;
}
public String getImage()
{
return image;
}
public void setDescription(String description)
{
this.description = description;
}
public String getDescription()
{
return description;
}
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("bid", getBid())
.append("title", getTitle())
.append("author", getAuthor())
.append("type", getType())
.append("image", getImage())
.append("description", getDescription())
.append("shelfTime", getShelfTime())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}

View File

@ -0,0 +1,62 @@
package com.muyu.system.mapper;
import java.util.List;
import com.muyu.system.domain.BookInfo;
import org.apache.ibatis.annotations.Mapper;
/**
* Mapper
*
* @author muyu
* @date 2024-02-23
*/
public interface BookInfoMapper
{
/**
*
*
* @param bid
* @return
*/
public BookInfo selectBookInfoByBid(Long bid);
/**
*
*
* @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 bid
* @return
*/
public int deleteBookInfoByBid(Long bid);
/**
*
*
* @param bids
* @return
*/
public int deleteBookInfoByBids(Long[] bids);
}

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-23
*/
public interface IBookInfoService
{
/**
*
*
* @param bid
* @return
*/
public BookInfo selectBookInfoByBid(Long bid);
/**
*
*
* @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 bids
* @return
*/
public int deleteBookInfoByBids(Long[] bids);
/**
*
*
* @param bid
* @return
*/
public int deleteBookInfoByBid(Long bid);
}

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-23
*/
@Service
public class BookInfoServiceImpl implements IBookInfoService
{
@Autowired
private BookInfoMapper bookInfoMapper;
/**
*
*
* @param bid
* @return
*/
@Override
public BookInfo selectBookInfoByBid(Long bid)
{
return bookInfoMapper.selectBookInfoByBid(bid);
}
/**
*
*
* @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 bids
* @return
*/
@Override
public int deleteBookInfoByBids(Long[] bids)
{
return bookInfoMapper.deleteBookInfoByBids(bids);
}
/**
*
*
* @param bid
* @return
*/
@Override
public int deleteBookInfoByBid(Long bid)
{
return bookInfoMapper.deleteBookInfoByBid(bid);
}
}

View File

@ -1,6 +1,6 @@
# Tomcat
server:
port: 9201
port: 9003
# Spring
spring:
@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 43.142.44.217:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 43.142.44.217:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -0,0 +1,101 @@
<?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="bid" column="bid" />
<result property="title" column="title" />
<result property="author" column="author" />
<result property="type" column="type" />
<result property="image" column="image" />
<result property="description" column="description" />
<result property="shelfTime" column="shelf_time" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectBookInfoVo">
select bid, title, author, type, image, description, shelf_time, create_by, create_time, update_by, update_time, remark 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="image != null and image != ''"> and image = #{image}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
<if test="shelfTime != null "> and shelf_time = #{shelfTime}</if>
</where>
</select>
<select id="selectBookInfoByBid" parameterType="Long" resultMap="BookInfoResult">
<include refid="selectBookInfoVo"/>
where bid = #{bid}
</select>
<insert id="insertBookInfo" parameterType="com.muyu.system.domain.BookInfo" useGeneratedKeys="true" keyProperty="bid">
insert into book_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="title != null">title,</if>
<if test="author != null">author,</if>
<if test="type != null">type,</if>
<if test="image != null">image,</if>
<if test="description != null">description,</if>
<if test="shelfTime != null">shelf_time,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="title != null">#{title},</if>
<if test="author != null">#{author},</if>
<if test="type != null">#{type},</if>
<if test="image != null">#{image},</if>
<if test="description != null">#{description},</if>
<if test="shelfTime != null">#{shelfTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</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="image != null">image = #{image},</if>
<if test="description != null">description = #{description},</if>
<if test="shelfTime != null">shelf_time = #{shelfTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where bid = #{bid}
</update>
<delete id="deleteBookInfoByBid" parameterType="Long">
delete from book_info where bid = #{bid}
</delete>
<delete id="deleteBookInfoByBids" parameterType="String">
delete from book_info where bid in
<foreach item="bid" collection="array" open="(" separator="," close=")">
#{bid}
</foreach>
</delete>
</mapper>

View File

@ -1,6 +1,6 @@
# Tomcat
server:
port: 9100
port: 9002
# Spring
spring:
@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 43.142.44.217:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 43.142.44.217:8848
# 配置文件格式
file-extension: yml
# 共享配置