book单表

day-02
Saisai Liu 2024-02-23 21:26:11 +08:00
parent 9c612b837c
commit cd8a13e2d9
8 changed files with 349 additions and 244 deletions

View File

@ -24,7 +24,7 @@ public class CacheConstants {
/**
* 10
*/
public final static long PASSWORD_LOCK_TIME = 10;
public final static long PASSWORD_LOCK_TIME = 3;
/**
*

View File

@ -1,107 +1,104 @@
package com.muyu.system.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import java.util.List;
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.BookInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
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;
/**
* @ClassName BookInfoController
* @Description
* @Author SaiSai.Liu
* @Date 2024/2/22/0022 20:26
* Controller
*
* @author muyu
* @date 2024-02-23
*/
@RestController
@RequestMapping("/book")
public class BookInfoController extends BaseController {
@RequestMapping("/info")
public class BookInfoController extends BaseController
{
@Autowired
private BookInfoService bookInfoService;
private IBookInfoService bookInfoService;
@RequiresPermissions("system:book:list")
/**
*
*/
@RequiresPermissions("system:info:list")
@GetMapping("/list")
public Result<TableDataInfo<BookInfo>> list (BookInfo book) {
public Result<TableDataInfo<BookInfo>> list(BookInfo bookInfo)
{
startPage();
List<BookInfo> list = bookInfoService.pageQuery(book);
List<BookInfo> list = bookInfoService.selectBookInfoList(bookInfo);
return getDataTable(list);
}
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:book:export")
/**
*
*/
@RequiresPermissions("system:info:export")
@Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export (HttpServletResponse response, BookInfo book) {
List<BookInfo> list = bookInfoService.pageQuery(book);
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, "参数数据");
util.exportExcel(response, list, "【请填写功能名称】数据");
}
/**
*
*
*/
@RequiresPermissions("system:info:query")
@GetMapping(value = "/{id}")
public Result getInfo (@PathVariable Long id) {
return success(bookInfoService.getById(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:book:add")
// @Log(title = "参数管理", businessType = BusinessType.INSERT)
// @PostMapping
// public Result add (@Validated @RequestBody BookInfo book) {
// if (!bookInfoService.checkConfigKeyUnique(book)) {
// return error("新增参数'" + book.getConfigName() + "'失败,参数键名已存在");
// }
// book.setCreateBy(SecurityUtils.getUsername());
// return toAjax(bookInfoService.save(book));
// }
//
// /**
// * 修改参数配置
// */
// @RequiresPermissions("system:book:edit")
// @Log(title = "参数管理", businessType = BusinessType.UPDATE)
// @PutMapping
// public Result edit (@Validated @RequestBody BookInfo book) {
// if (!bookInfoService.checkConfigKeyUnique(book)) {
// return error("修改参数'" + book.getConfigName() + "'失败,参数键名已存在");
// }
// book.setUpdateBy(SecurityUtils.getUsername());
// return toAjax(bookInfoService.updateById(book));
// }
//
// /**
// * 删除参数配置
// */
// @RequiresPermissions("system:book:remove")
// @Log(title = "参数管理", businessType = BusinessType.DELETE)
// @DeleteMapping("/{configIds}")
// public Result remove (@PathVariable Long[] configIds) {
// bookInfoService.removeBatchByIds(Arrays.asList(configIds));
// return success();
// }
//
// /**
// * 刷新参数缓存
// */
// @RequiresPermissions("system:book:remove")
// @Log(title = "参数管理", businessType = BusinessType.CLEAN)
// @DeleteMapping("/refreshCache")
// public Result refreshCache () {
// bookInfoService.resetConfigCache();
// return success();
// }
/**
*
*/
@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

@ -49,6 +49,12 @@ public class BookInfo extends BaseEntity {
@Excel(name="书名")
private String title;
/**
*
*/
@Excel(name="书名")
private String remak;
/**
*

View File

@ -1,14 +1,61 @@
package com.muyu.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
import com.muyu.system.domain.BookInfo;
import com.muyu.system.domain.SysConfig;
/**
* @ClassName BookInfoMapper
* @Description
* @Author SaiSai.Liu
* @Date 2024/2/22/0022 20:52
* Mapper
*
* @author muyu
* @date 2024-02-23
*/
public interface BookInfoMapper extends BaseMapper<BookInfo> {
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

@ -1,17 +0,0 @@
package com.muyu.system.service;
import com.muyu.system.domain.BookInfo;
import java.util.List;
/**
* @ClassName BookInfoService
* @Description
* @Author SaiSai.Liu
* @Date 2024/2/22/0022 20:27
*/
public interface BookInfoService {
List<BookInfo> pageQuery(BookInfo book);
String getById(Long id);
}

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 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

@ -1,55 +1,96 @@
package com.muyu.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.utils.StringUtils;
import com.muyu.common.redis.service.RedisService;
import com.muyu.system.domain.BookInfo;
import com.muyu.system.domain.BookInfo;
import com.muyu.system.mapper.BookInfoMapper;
import com.muyu.system.service.BookInfoService;
import java.util.List;
import com.muyu.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import com.muyu.system.mapper.BookInfoMapper;
import com.muyu.system.domain.BookInfo;
import com.muyu.system.service.IBookInfoService;
/**
* @ClassName BookInfoServiceImpl
* @Description
* @Author SaiSai.Liu
* @Date 2024/2/22/0022 20:27
* Service
*
* @author muyu
* @date 2024-02-23
*/
@Service
public class BookInfoServiceImpl extends ServiceImpl<BookInfoMapper, BookInfo>
implements BookInfoService {
public class BookInfoServiceImpl implements IBookInfoService
{
@Autowired
private RedisService redisService;
private BookInfoMapper bookInfoMapper;
/**
*
*
* @param id
* @return
*/
@Override
public List<BookInfo> pageQuery (BookInfo book) {
LambdaQueryWrapper<BookInfo> queryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotEmpty(book.getTitle())){
queryWrapper.like(BookInfo::getTitle, book.getTitle());
}
if (StringUtils.isNotEmpty(book.getType())){
queryWrapper.like(BookInfo::getType, book.getType());
}
Object beginTime = book.getParams().get("beginTime");
if (Objects.nonNull(beginTime) && beginTime instanceof Date beginDate){
queryWrapper.gt(BookInfo::getGrounding, beginDate);
}
Object endTime = book.getParams().get("endTime");
if (Objects.nonNull(endTime) && endTime instanceof Date endDate){
queryWrapper.lt(BookInfo::getGrounding, endDate);
}
return this.list(queryWrapper);
public BookInfo selectBookInfoById(Long id)
{
return bookInfoMapper.selectBookInfoById(id);
}
/**
*
*
* @param bookInfo
* @return
*/
@Override
public String getById(Long id) {
return null;
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

@ -5,128 +5,98 @@
<mapper namespace="com.muyu.system.mapper.BookInfoMapper">
<resultMap type="com.muyu.system.domain.BookInfo" id="BookInfoResult">
<id 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="grounding" column="grounding"/>
<result property="createBy" column="update_by"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
<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="remak" column="remak" />
<result property="content" column="content" />
<result property="grounding" column="grounding" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
</resultMap>
<sql id="selectBookInfoVo">
select id,
title,
author,
type,
images,
remak,
content,
grounding,
create_by,
create_time
from book_info
select id, title, author, type, images, remak, content, grounding, create_by, create_time, update_time, update_by from book_info
</sql>
<!-- 查询条件 -->
<sql id="sqlwhereSearch">
<where>
<if test="id !=null">
and id = #{id}
</if>
<if test="configKey !=null and configKey != ''">
and config_key = #{configKey}
</if>
</where>
</sql>
<select id="selectConfig" parameterType="com.muyu.system.domain.BookInfo" resultMap="BookInfoResult">
<include refid="selectBookInfoVo"/>
<include refid="sqlwhereSearch"/>
</select>
<select id="selectConfigList" parameterType="com.muyu.system.domain.BookInfo" resultMap="BookInfoResult">
<select id="selectBookInfoList" parameterType="com.muyu.system.domain.BookInfo" resultMap="BookInfoResult">
<include refid="selectBookInfoVo"/>
<where>
<if test="configName != null and configName != ''">
AND config_name like concat('%', #{configName}, '%')
</if>
<if test="configType != null and configType != ''">
AND config_type = #{configType}
</if>
<if test="configKey != null and configKey != ''">
AND config_key like concat('%', #{configKey}, '%')
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
<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="remak != null and remak != ''"> and remak = #{remak}</if>
<if test="content != null and content != ''"> and content = #{content}</if>
<if test="grounding != null and grounding != ''"> and grounding = #{grounding}</if>
</where>
</select>
<select id="selectConfigById" parameterType="Long" resultMap="BookInfoResult">
<select id="selectBookInfoById" parameterType="Long" resultMap="BookInfoResult">
<include refid="selectBookInfoVo"/>
where id = #{id}
</select>
<select id="checkConfigKeyUnique" parameterType="String" resultMap="BookInfoResult">
<include refid="selectBookInfoVo"/>
where config_key = #{configKey} limit 1
</select>
<!-- 添加-->
<insert id="insertConfig" parameterType="com.muyu.system.domain.BookInfo">
insert into sys_config (
<if test="configName != null and configName != '' ">config_name,</if>
<if test="configKey != null and configKey != '' ">config_key,</if>
<if test="configValue != null and configValue != '' ">config_value,</if>
<if test="configType != null and configType != '' ">config_type,</if>
<insert id="insertBookInfo" parameterType="com.muyu.system.domain.BookInfo" useGeneratedKeys="true" keyProperty="id">
insert into book_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="title != null">title,</if>
<if test="author != null and author != ''">author,</if>
<if test="type != null and type != ''">type,</if>
<if test="images != null and images != ''">images,</if>
<if test="remak != null">remak,</if>
<if test="content != null">content,</if>
<if test="grounding != null and grounding != ''">grounding,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="remark != null and remark != ''">remark,</if>
create_time
)values(
<if test="configName != null and configName != ''">#{configName},</if>
<if test="configKey != null and configKey != ''">#{configKey},</if>
<if test="configValue != null and configValue != ''">#{configValue},</if>
<if test="configType != null and configType != ''">#{configType},</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="title != null">#{title},</if>
<if test="author != null and author != ''">#{author},</if>
<if test="type != null and type != ''">#{type},</if>
<if test="images != null and images != ''">#{images},</if>
<if test="remak != null">#{remak},</if>
<if test="content != null">#{content},</if>
<if test="grounding != null and grounding != ''">#{grounding},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="remark != null and remark != ''">#{remark},</if>
sysdate()
)
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
</trim>
</insert>
<!-- 修改-->
<update id="updateConfig" parameterType="com.muyu.system.domain.BookInfo">
update sys_config
<set>
<if test="configName != null and configName != ''">config_name = #{configName},</if>
<if test="configKey != null and configKey != ''">config_key = #{configKey},</if>
<if test="configValue != null and configValue != ''">config_value = #{configValue},</if>
<if test="configType != null and configType != ''">config_type = #{configType},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
update_time = sysdate()
</set>
where config_id = #{configId}
<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 and author != ''">author = #{author},</if>
<if test="type != null and type != ''">type = #{type},</if>
<if test="images != null and images != ''">images = #{images},</if>
<if test="remak != null">remak = #{remak},</if>
<if test="content != null">content = #{content},</if>
<if test="grounding != null and grounding != ''">grounding = #{grounding},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = now(),</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteConfigById" parameterType="Long">
delete
from sys_config
where config_id = #{configId}
<delete id="deleteBookInfoById" parameterType="Long">
delete from book_info where id = #{id}
</delete>
<delete id="deleteConfigByIds" parameterType="Long">
delete from sys_config where config_id in
<foreach item="configId" collection="array" open="(" separator="," close=")">
#{configId}
<delete id="deleteBookInfoByIds" parameterType="String">
delete from book_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>