This commit is contained in:
GeDashi 2024-12-22 18:00:17 +08:00
parent a3fea40b05
commit ddfd027746
6 changed files with 483 additions and 0 deletions

View File

@ -0,0 +1,104 @@
package com.ruoyi.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Recommend;
import com.ruoyi.system.service.IRecommendService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 推荐表Controller
*
* @author LG
* @date 2024-12-22
*/
@RestController
@RequestMapping("/system/recommend")
public class RecommendController extends BaseController
{
@Autowired
private IRecommendService recommendService;
/**
* 查询推荐表列表
*/
@PreAuthorize("@ss.hasPermi('system:recommend:list')")
@GetMapping("/list")
public TableDataInfo list(Recommend recommend)
{
startPage();
List<Recommend> list = recommendService.selectRecommendList(recommend);
return getDataTable(list);
}
/**
* 导出推荐表列表
*/
@PreAuthorize("@ss.hasPermi('system:recommend:export')")
@Log(title = "推荐表", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Recommend recommend)
{
List<Recommend> list = recommendService.selectRecommendList(recommend);
ExcelUtil<Recommend> util = new ExcelUtil<Recommend>(Recommend.class);
util.exportExcel(response, list, "推荐表数据");
}
/**
* 获取推荐表详细信息
*/
@PreAuthorize("@ss.hasPermi('system:recommend:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(recommendService.selectRecommendById(id));
}
/**
* 新增推荐表
*/
@PreAuthorize("@ss.hasPermi('system:recommend:add')")
@Log(title = "推荐表", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Recommend recommend)
{
return toAjax(recommendService.insertRecommend(recommend));
}
/**
* 修改推荐表
*/
@PreAuthorize("@ss.hasPermi('system:recommend:edit')")
@Log(title = "推荐表", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Recommend recommend)
{
return toAjax(recommendService.updateRecommend(recommend));
}
/**
* 删除推荐表
*/
@PreAuthorize("@ss.hasPermi('system:recommend:remove')")
@Log(title = "推荐表", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(recommendService.deleteRecommendByIds(ids));
}
}

View File

@ -0,0 +1,93 @@
package com.ruoyi.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 推荐表对象 recommend
*
* @author LG
* @date 2024-12-22
*/
public class Recommend extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private Long id;
/** 推荐名 */
@Excel(name = "推荐名")
private String tuijianname;
/** 推荐数量 */
@Excel(name = "推荐数量")
private Long tuijiannumber;
/** 推荐语 */
@Excel(name = "推荐语")
private String tuijianyu;
/** 图片展示 */
@Excel(name = "图片展示")
private String picture;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setTuijianname(String tuijianname)
{
this.tuijianname = tuijianname;
}
public String getTuijianname()
{
return tuijianname;
}
public void setTuijiannumber(Long tuijiannumber)
{
this.tuijiannumber = tuijiannumber;
}
public Long getTuijiannumber()
{
return tuijiannumber;
}
public void setTuijianyu(String tuijianyu)
{
this.tuijianyu = tuijianyu;
}
public String getTuijianyu()
{
return tuijianyu;
}
public void setPicture(String picture)
{
this.picture = picture;
}
public String getPicture()
{
return picture;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("tuijianname", getTuijianname())
.append("tuijiannumber", getTuijiannumber())
.append("tuijianyu", getTuijianyu())
.append("picture", getPicture())
.toString();
}
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.Recommend;
/**
* 推荐表Mapper接口
*
* @author LG
* @date 2024-12-22
*/
public interface RecommendMapper
{
/**
* 查询推荐表
*
* @param id 推荐表主键
* @return 推荐表
*/
public Recommend selectRecommendById(Long id);
/**
* 查询推荐表列表
*
* @param recommend 推荐表
* @return 推荐表集合
*/
public List<Recommend> selectRecommendList(Recommend recommend);
/**
* 新增推荐表
*
* @param recommend 推荐表
* @return 结果
*/
public int insertRecommend(Recommend recommend);
/**
* 修改推荐表
*
* @param recommend 推荐表
* @return 结果
*/
public int updateRecommend(Recommend recommend);
/**
* 删除推荐表
*
* @param id 推荐表主键
* @return 结果
*/
public int deleteRecommendById(Long id);
/**
* 批量删除推荐表
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteRecommendByIds(Long[] ids);
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.Recommend;
/**
* 推荐表Service接口
*
* @author LG
* @date 2024-12-22
*/
public interface IRecommendService
{
/**
* 查询推荐表
*
* @param id 推荐表主键
* @return 推荐表
*/
public Recommend selectRecommendById(Long id);
/**
* 查询推荐表列表
*
* @param recommend 推荐表
* @return 推荐表集合
*/
public List<Recommend> selectRecommendList(Recommend recommend);
/**
* 新增推荐表
*
* @param recommend 推荐表
* @return 结果
*/
public int insertRecommend(Recommend recommend);
/**
* 修改推荐表
*
* @param recommend 推荐表
* @return 结果
*/
public int updateRecommend(Recommend recommend);
/**
* 批量删除推荐表
*
* @param ids 需要删除的推荐表主键集合
* @return 结果
*/
public int deleteRecommendByIds(Long[] ids);
/**
* 删除推荐表信息
*
* @param id 推荐表主键
* @return 结果
*/
public int deleteRecommendById(Long id);
}

View File

@ -0,0 +1,93 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.RecommendMapper;
import com.ruoyi.system.domain.Recommend;
import com.ruoyi.system.service.IRecommendService;
/**
* 推荐表Service业务层处理
*
* @author LG
* @date 2024-12-22
*/
@Service
public class RecommendServiceImpl implements IRecommendService
{
@Autowired
private RecommendMapper recommendMapper;
/**
* 查询推荐表
*
* @param id 推荐表主键
* @return 推荐表
*/
@Override
public Recommend selectRecommendById(Long id)
{
return recommendMapper.selectRecommendById(id);
}
/**
* 查询推荐表列表
*
* @param recommend 推荐表
* @return 推荐表
*/
@Override
public List<Recommend> selectRecommendList(Recommend recommend)
{
return recommendMapper.selectRecommendList(recommend);
}
/**
* 新增推荐表
*
* @param recommend 推荐表
* @return 结果
*/
@Override
public int insertRecommend(Recommend recommend)
{
return recommendMapper.insertRecommend(recommend);
}
/**
* 修改推荐表
*
* @param recommend 推荐表
* @return 结果
*/
@Override
public int updateRecommend(Recommend recommend)
{
return recommendMapper.updateRecommend(recommend);
}
/**
* 批量删除推荐表
*
* @param ids 需要删除的推荐表主键
* @return 结果
*/
@Override
public int deleteRecommendByIds(Long[] ids)
{
return recommendMapper.deleteRecommendByIds(ids);
}
/**
* 删除推荐表信息
*
* @param id 推荐表主键
* @return 结果
*/
@Override
public int deleteRecommendById(Long id)
{
return recommendMapper.deleteRecommendById(id);
}
}

View File

@ -0,0 +1,71 @@
<?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.ruoyi.system.mapper.RecommendMapper">
<resultMap type="Recommend" id="RecommendResult">
<result property="id" column="id" />
<result property="tuijianname" column="tuijianname" />
<result property="tuijiannumber" column="tuijiannumber" />
<result property="tuijianyu" column="tuijianyu" />
<result property="picture" column="picture" />
</resultMap>
<sql id="selectRecommendVo">
select id, tuijianname, tuijiannumber, tuijianyu, picture from recommend
</sql>
<select id="selectRecommendList" parameterType="Recommend" resultMap="RecommendResult">
<include refid="selectRecommendVo"/>
<where>
<if test="tuijianname != null and tuijianname != ''"> and tuijianname like concat('%', #{tuijianname}, '%')</if>
<if test="tuijiannumber != null "> and tuijiannumber = #{tuijiannumber}</if>
<if test="tuijianyu != null and tuijianyu != ''"> and tuijianyu = #{tuijianyu}</if>
<if test="picture != null and picture != ''"> and picture = #{picture}</if>
</where>
</select>
<select id="selectRecommendById" parameterType="Long" resultMap="RecommendResult">
<include refid="selectRecommendVo"/>
where id = #{id}
</select>
<insert id="insertRecommend" parameterType="Recommend" useGeneratedKeys="true" keyProperty="id">
insert into recommend
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tuijianname != null">tuijianname,</if>
<if test="tuijiannumber != null">tuijiannumber,</if>
<if test="tuijianyu != null">tuijianyu,</if>
<if test="picture != null">picture,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tuijianname != null">#{tuijianname},</if>
<if test="tuijiannumber != null">#{tuijiannumber},</if>
<if test="tuijianyu != null">#{tuijianyu},</if>
<if test="picture != null">#{picture},</if>
</trim>
</insert>
<update id="updateRecommend" parameterType="Recommend">
update recommend
<trim prefix="SET" suffixOverrides=",">
<if test="tuijianname != null">tuijianname = #{tuijianname},</if>
<if test="tuijiannumber != null">tuijiannumber = #{tuijiannumber},</if>
<if test="tuijianyu != null">tuijianyu = #{tuijianyu},</if>
<if test="picture != null">picture = #{picture},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteRecommendById" parameterType="Long">
delete from recommend where id = #{id}
</delete>
<delete id="deleteRecommendByIds" parameterType="String">
delete from recommend where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>