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 * 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; package com.muyu.system.controller;
import com.muyu.common.core.domain.Result; import java.util.List;
import com.muyu.common.core.utils.poi.ExcelUtil; import javax.servlet.http.HttpServletResponse;
import com.muyu.common.core.web.controller.BaseController; import org.springframework.beans.factory.annotation.Autowired;
import com.muyu.common.core.web.page.TableDataInfo; 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.annotation.Log;
import com.muyu.common.log.enums.BusinessType; import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions; import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.system.domain.BookInfo; import com.muyu.system.domain.BookInfo;
import com.muyu.system.service.BookInfoService; import com.muyu.system.service.IBookInfoService;
import org.springframework.beans.factory.annotation.Autowired; import com.muyu.common.core.web.controller.BaseController;
import org.springframework.web.bind.annotation.*; import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import javax.servlet.http.HttpServletResponse; import com.muyu.common.core.web.page.TableDataInfo;
import java.util.List;
/** /**
* @ClassName BookInfoController * Controller
* @Description *
* @Author SaiSai.Liu * @author muyu
* @Date 2024/2/22/0022 20:26 * @date 2024-02-23
*/ */
@RestController @RestController
@RequestMapping("/book") @RequestMapping("/info")
public class BookInfoController extends BaseController { public class BookInfoController extends BaseController
{
@Autowired @Autowired
private BookInfoService bookInfoService; private IBookInfoService bookInfoService;
@RequiresPermissions("system:book:list") /**
*
*/
@RequiresPermissions("system:info:list")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<BookInfo>> list (BookInfo book) { public Result<TableDataInfo<BookInfo>> list(BookInfo bookInfo)
{
startPage(); startPage();
List<BookInfo> list = bookInfoService.pageQuery(book); List<BookInfo> list = bookInfoService.selectBookInfoList(bookInfo);
return getDataTable(list); return getDataTable(list);
} }
@Log(title = "参数管理", businessType = BusinessType.EXPORT) /**
@RequiresPermissions("system:book:export") *
*/
@RequiresPermissions("system:info:export")
@Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export (HttpServletResponse response, BookInfo book) { public void export(HttpServletResponse response, BookInfo bookInfo)
List<BookInfo> list = bookInfoService.pageQuery(book); {
List<BookInfo> list = bookInfoService.selectBookInfoList(bookInfo);
ExcelUtil<BookInfo> util = new ExcelUtil<BookInfo>(BookInfo.class); ExcelUtil<BookInfo> util = new ExcelUtil<BookInfo>(BookInfo.class);
util.exportExcel(response, list, "参数数据"); util.exportExcel(response, list, "【请填写功能名称】数据");
} }
/** /**
* *
*/ */
@RequiresPermissions("system:info:query")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public Result getInfo (@PathVariable Long id) { public Result getInfo(@PathVariable("id") Long id)
return success(bookInfoService.getById(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") @RequiresPermissions("system:info:edit")
// @Log(title = "参数管理", businessType = BusinessType.INSERT) @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
// @PostMapping @PutMapping
// public Result add (@Validated @RequestBody BookInfo book) { public Result edit(@RequestBody BookInfo bookInfo)
// if (!bookInfoService.checkConfigKeyUnique(book)) { {
// return error("新增参数'" + book.getConfigName() + "'失败,参数键名已存在"); return toAjax(bookInfoService.updateBookInfo(bookInfo));
// } }
// 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: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="书名") @Excel(name="书名")
private String title; private String title;
/**
*
*/
@Excel(name="书名")
private String remak;
/** /**
* *

View File

@ -1,14 +1,61 @@
package com.muyu.system.mapper; 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.BookInfo;
import com.muyu.system.domain.SysConfig;
/** /**
* @ClassName BookInfoMapper * Mapper
* @Description *
* @Author SaiSai.Liu * @author muyu
* @Date 2024/2/22/0022 20:52 * @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; package com.muyu.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.muyu.common.core.utils.DateUtils;
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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.muyu.system.mapper.BookInfoMapper;
import java.util.Date; import com.muyu.system.domain.BookInfo;
import java.util.List; import com.muyu.system.service.IBookInfoService;
import java.util.Objects;
/** /**
* @ClassName BookInfoServiceImpl * Service
* @Description *
* @Author SaiSai.Liu * @author muyu
* @Date 2024/2/22/0022 20:27 * @date 2024-02-23
*/ */
@Service @Service
public class BookInfoServiceImpl extends ServiceImpl<BookInfoMapper, BookInfo> public class BookInfoServiceImpl implements IBookInfoService
implements BookInfoService { {
@Autowired @Autowired
private RedisService redisService; private BookInfoMapper bookInfoMapper;
/**
*
*
* @param id
* @return
*/
@Override @Override
public List<BookInfo> pageQuery (BookInfo book) { public BookInfo selectBookInfoById(Long id)
LambdaQueryWrapper<BookInfo> queryWrapper = new LambdaQueryWrapper<>(); {
if (StringUtils.isNotEmpty(book.getTitle())){ return bookInfoMapper.selectBookInfoById(id);
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);
} }
/**
*
*
* @param bookInfo
* @return
*/
@Override @Override
public String getById(Long id) { public List<BookInfo> selectBookInfoList(BookInfo bookInfo)
return null; {
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"> <mapper namespace="com.muyu.system.mapper.BookInfoMapper">
<resultMap type="com.muyu.system.domain.BookInfo" id="BookInfoResult"> <resultMap type="com.muyu.system.domain.BookInfo" id="BookInfoResult">
<id property="id" column="id"/> <result property="id" column="id" />
<result property="title" column="title"/> <result property="title" column="title" />
<result property="author" column="author"/> <result property="author" column="author" />
<result property="type" column="type"/> <result property="type" column="type" />
<result property="images" column="images"/> <result property="images" column="images" />
<result property="content" column="content"/> <result property="remak" column="remak" />
<result property="grounding" column="grounding"/> <result property="content" column="content" />
<result property="createBy" column="update_by"/> <result property="grounding" column="grounding" />
<result property="createTime" column="create_time"/> <result property="createBy" column="create_by" />
<result property="updateTime" column="update_time"/> <result property="createTime" column="create_time" />
<result property="remark" column="remark"/> <result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
</resultMap> </resultMap>
<sql id="selectBookInfoVo"> <sql id="selectBookInfoVo">
select id, select id, title, author, type, images, remak, content, grounding, create_by, create_time, update_time, update_by from book_info
title,
author,
type,
images,
remak,
content,
grounding,
create_by,
create_time
from book_info
</sql> </sql>
<!-- 查询条件 --> <select id="selectBookInfoList" parameterType="com.muyu.system.domain.BookInfo" resultMap="BookInfoResult">
<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">
<include refid="selectBookInfoVo"/> <include refid="selectBookInfoVo"/>
<where> <where>
<if test="configName != null and configName != ''"> <if test="title != null and title != ''"> and title = #{title}</if>
AND config_name like concat('%', #{configName}, '%') <if test="author != null and author != ''"> and author = #{author}</if>
</if> <if test="type != null and type != ''"> and type = #{type}</if>
<if test="configType != null and configType != ''"> <if test="images != null and images != ''"> and images = #{images}</if>
AND config_type = #{configType} <if test="remak != null and remak != ''"> and remak = #{remak}</if>
</if> <if test="content != null and content != ''"> and content = #{content}</if>
<if test="configKey != null and configKey != ''"> <if test="grounding != null and grounding != ''"> and grounding = #{grounding}</if>
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>
</where> </where>
</select> </select>
<select id="selectConfigById" parameterType="Long" resultMap="BookInfoResult"> <select id="selectBookInfoById" parameterType="Long" resultMap="BookInfoResult">
<include refid="selectBookInfoVo"/> <include refid="selectBookInfoVo"/>
where id = #{id} where id = #{id}
</select> </select>
<select id="checkConfigKeyUnique" parameterType="String" resultMap="BookInfoResult"> <insert id="insertBookInfo" parameterType="com.muyu.system.domain.BookInfo" useGeneratedKeys="true" keyProperty="id">
<include refid="selectBookInfoVo"/> insert into book_info
where config_key = #{configKey} limit 1 <trim prefix="(" suffix=")" suffixOverrides=",">
</select> <if test="title != null">title,</if>
<if test="author != null and author != ''">author,</if>
<!-- 添加--> <if test="type != null and type != ''">type,</if>
<insert id="insertConfig" parameterType="com.muyu.system.domain.BookInfo"> <if test="images != null and images != ''">images,</if>
insert into sys_config ( <if test="remak != null">remak,</if>
<if test="configName != null and configName != '' ">config_name,</if> <if test="content != null">content,</if>
<if test="configKey != null and configKey != '' ">config_key,</if> <if test="grounding != null and grounding != ''">grounding,</if>
<if test="configValue != null and configValue != '' ">config_value,</if> <if test="createBy != null and createBy != ''">create_by,</if>
<if test="configType != null and configType != '' ">config_type,</if> <if test="createTime != null">create_time,</if>
<if test="createBy != null and createBy != ''">create_by,</if> <if test="updateTime != null">update_time,</if>
<if test="remark != null and remark != ''">remark,</if> <if test="updateBy != null">update_by,</if>
create_time </trim>
)values( <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="configName != null and configName != ''">#{configName},</if> <if test="title != null">#{title},</if>
<if test="configKey != null and configKey != ''">#{configKey},</if> <if test="author != null and author != ''">#{author},</if>
<if test="configValue != null and configValue != ''">#{configValue},</if> <if test="type != null and type != ''">#{type},</if>
<if test="configType != null and configType != ''">#{configType},</if> <if test="images != null and images != ''">#{images},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="remak != null">#{remak},</if>
<if test="remark != null and remark != ''">#{remark},</if> <if test="content != null">#{content},</if>
sysdate() <if test="grounding != null and grounding != ''">#{grounding},</if>
) <if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
</trim>
</insert> </insert>
<!-- 修改--> <update id="updateBookInfo" parameterType="com.muyu.system.domain.BookInfo">
<update id="updateConfig" parameterType="com.muyu.system.domain.BookInfo"> update book_info
update sys_config <trim prefix="SET" suffixOverrides=",">
<set> <if test="title != null">title = #{title},</if>
<if test="configName != null and configName != ''">config_name = #{configName},</if> <if test="author != null and author != ''">author = #{author},</if>
<if test="configKey != null and configKey != ''">config_key = #{configKey},</if> <if test="type != null and type != ''">type = #{type},</if>
<if test="configValue != null and configValue != ''">config_value = #{configValue},</if> <if test="images != null and images != ''">images = #{images},</if>
<if test="configType != null and configType != ''">config_type = #{configType},</if> <if test="remak != null">remak = #{remak},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="content != null">content = #{content},</if>
<if test="remark != null">remark = #{remark},</if> <if test="grounding != null and grounding != ''">grounding = #{grounding},</if>
update_time = sysdate() <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
</set> <if test="createTime != null">create_time = now(),</if>
where config_id = #{configId} <if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where id = #{id}
</update> </update>
<delete id="deleteConfigById" parameterType="Long"> <delete id="deleteBookInfoById" parameterType="Long">
delete delete from book_info where id = #{id}
from sys_config
where config_id = #{configId}
</delete> </delete>
<delete id="deleteConfigByIds" parameterType="Long"> <delete id="deleteBookInfoByIds" parameterType="String">
delete from sys_config where config_id in delete from book_info where id in
<foreach item="configId" collection="array" open="(" separator="," close=")"> <foreach item="id" collection="array" open="(" separator="," close=")">
#{configId} #{id}
</foreach> </foreach>
</delete> </delete>
</mapper> </mapper>