移除书籍

day_05
csy 2024-02-29 08:41:39 +08:00
parent 4b5ceee780
commit 4123752016
6 changed files with 645 additions and 0 deletions

View File

@ -0,0 +1,104 @@
package com.muyu.system.controller;
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.ProjectInfo;
import com.muyu.system.service.IProjectInfoService;
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-27
*/
@RestController
@RequestMapping("/info")
public class ProjectInfoController extends BaseController
{
@Autowired
private IProjectInfoService projectInfoService;
/**
*
*/
@RequiresPermissions("system:info:list")
@GetMapping("/list")
public Result<TableDataInfo<ProjectInfo>> list(ProjectInfo projectInfo)
{
startPage();
List<ProjectInfo> list = projectInfoService.selectProjectInfoList(projectInfo);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("system:info:export")
@Log(title = "商品信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ProjectInfo projectInfo)
{
List<ProjectInfo> list = projectInfoService.selectProjectInfoList(projectInfo);
ExcelUtil<ProjectInfo> util = new ExcelUtil<ProjectInfo>(ProjectInfo.class);
util.exportExcel(response, list, "商品信息数据");
}
/**
*
*/
@RequiresPermissions("system:info:query")
@GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id)
{
return success(projectInfoService.selectProjectInfoById(id));
}
/**
*
*/
@RequiresPermissions("system:info:add")
@Log(title = "商品信息", businessType = BusinessType.INSERT)
@PostMapping
public Result add(@RequestBody ProjectInfo projectInfo)
{
return toAjax(projectInfoService.insertProjectInfo(projectInfo));
}
/**
*
*/
@RequiresPermissions("system:info:edit")
@Log(title = "商品信息", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit(@RequestBody ProjectInfo projectInfo)
{
return toAjax(projectInfoService.updateProjectInfo(projectInfo));
}
/**
*
*/
@RequiresPermissions("system:info:remove")
@Log(title = "商品信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids)
{
return toAjax(projectInfoService.deleteProjectInfoByIds(ids));
}
}

View File

@ -0,0 +1,197 @@
package com.muyu.system.domain;
import java.math.BigDecimal;
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;
/**
* project_info
*
* @author muyu
* @date 2024-02-27
*/
public class ProjectInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 商品名称 */
@Excel(name = "商品名称")
private String name;
/** 商品图片 */
@Excel(name = "商品图片")
private String image;
/** 主类型 */
@Excel(name = "主类型")
private String mianType;
/** 父类型 */
@Excel(name = "父类型")
private String parentType;
/** 商品类型 */
@Excel(name = "商品类型")
private String type;
/** 商品价格 */
@Excel(name = "商品价格")
private BigDecimal price;
/** 商品数量 */
@Excel(name = "商品数量")
private Long num;
/** 商品介绍 */
@Excel(name = "商品介绍")
private String introduction;
/** 商品状态 */
@Excel(name = "商品状态")
private String status;
/** 品牌 */
@Excel(name = "品牌")
private Long brandId;
/** 规格 */
@Excel(name = "规格")
private Long ruleId;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setImage(String image)
{
this.image = image;
}
public String getImage()
{
return image;
}
public void setMianType(String mianType)
{
this.mianType = mianType;
}
public String getMianType()
{
return mianType;
}
public void setParentType(String parentType)
{
this.parentType = parentType;
}
public String getParentType()
{
return parentType;
}
public void setType(String type)
{
this.type = type;
}
public String getType()
{
return type;
}
public void setPrice(BigDecimal price)
{
this.price = price;
}
public BigDecimal getPrice()
{
return price;
}
public void setNum(Long num)
{
this.num = num;
}
public Long getNum()
{
return num;
}
public void setIntroduction(String introduction)
{
this.introduction = introduction;
}
public String getIntroduction()
{
return introduction;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
public void setBrandId(Long brandId)
{
this.brandId = brandId;
}
public Long getBrandId()
{
return brandId;
}
public void setRuleId(Long ruleId)
{
this.ruleId = ruleId;
}
public Long getRuleId()
{
return ruleId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("image", getImage())
.append("mianType", getMianType())
.append("parentType", getParentType())
.append("type", getType())
.append("price", getPrice())
.append("num", getNum())
.append("introduction", getIntroduction())
.append("status", getStatus())
.append("brandId", getBrandId())
.append("ruleId", getRuleId())
.append("remark", getRemark())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.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.ProjectInfo;
/**
* Mapper
*
* @author muyu
* @date 2024-02-27
*/
public interface ProjectInfoMapper
{
/**
*
*
* @param id
* @return
*/
public ProjectInfo selectProjectInfoById(Long id);
/**
*
*
* @param projectInfo
* @return
*/
public List<ProjectInfo> selectProjectInfoList(ProjectInfo projectInfo);
/**
*
*
* @param projectInfo
* @return
*/
public int insertProjectInfo(ProjectInfo projectInfo);
/**
*
*
* @param projectInfo
* @return
*/
public int updateProjectInfo(ProjectInfo projectInfo);
/**
*
*
* @param id
* @return
*/
public int deleteProjectInfoById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteProjectInfoByIds(Long[] ids);
}

View File

@ -0,0 +1,61 @@
package com.muyu.system.service;
import java.util.List;
import com.muyu.system.domain.ProjectInfo;
/**
* Service
*
* @author muyu
* @date 2024-02-27
*/
public interface IProjectInfoService
{
/**
*
*
* @param id
* @return
*/
public ProjectInfo selectProjectInfoById(Long id);
/**
*
*
* @param projectInfo
* @return
*/
public List<ProjectInfo> selectProjectInfoList(ProjectInfo projectInfo);
/**
*
*
* @param projectInfo
* @return
*/
public int insertProjectInfo(ProjectInfo projectInfo);
/**
*
*
* @param projectInfo
* @return
*/
public int updateProjectInfo(ProjectInfo projectInfo);
/**
*
*
* @param ids
* @return
*/
public int deleteProjectInfoByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteProjectInfoById(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.ProjectInfoMapper;
import com.muyu.system.domain.ProjectInfo;
import com.muyu.system.service.IProjectInfoService;
/**
* Service
*
* @author muyu
* @date 2024-02-27
*/
@Service
public class ProjectInfoServiceImpl implements IProjectInfoService
{
@Autowired
private ProjectInfoMapper projectInfoMapper;
/**
*
*
* @param id
* @return
*/
@Override
public ProjectInfo selectProjectInfoById(Long id)
{
return projectInfoMapper.selectProjectInfoById(id);
}
/**
*
*
* @param projectInfo
* @return
*/
@Override
public List<ProjectInfo> selectProjectInfoList(ProjectInfo projectInfo)
{
return projectInfoMapper.selectProjectInfoList(projectInfo);
}
/**
*
*
* @param projectInfo
* @return
*/
@Override
public int insertProjectInfo(ProjectInfo projectInfo)
{
projectInfo.setCreateTime(DateUtils.getNowDate());
return projectInfoMapper.insertProjectInfo(projectInfo);
}
/**
*
*
* @param projectInfo
* @return
*/
@Override
public int updateProjectInfo(ProjectInfo projectInfo)
{
projectInfo.setUpdateTime(DateUtils.getNowDate());
return projectInfoMapper.updateProjectInfo(projectInfo);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteProjectInfoByIds(Long[] ids)
{
return projectInfoMapper.deleteProjectInfoByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteProjectInfoById(Long id)
{
return projectInfoMapper.deleteProjectInfoById(id);
}
}

View File

@ -0,0 +1,126 @@
<?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.ProjectInfoMapper">
<resultMap type="com.muyu.system.domain.ProjectInfo" id="ProjectInfoResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="image" column="image" />
<result property="mianType" column="mian_type" />
<result property="parentType" column="parent_type" />
<result property="type" column="type" />
<result property="price" column="price" />
<result property="num" column="num" />
<result property="introduction" column="introduction" />
<result property="status" column="status" />
<result property="brandId" column="brand_id" />
<result property="ruleId" column="rule_id" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectProjectInfoVo">
select id, name, image, mian_type, parent_type, type, price, num, introduction, status, brand_id, rule_id, remark, create_by, create_time, update_by, update_time from project_info
</sql>
<select id="selectProjectInfoList" parameterType="com.muyu.system.domain.ProjectInfo" resultMap="ProjectInfoResult">
<include refid="selectProjectInfoVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="image != null and image != ''"> and image = #{image}</if>
<if test="mianType != null and mianType != ''"> and mian_type = #{mianType}</if>
<if test="parentType != null and parentType != ''"> and parent_type = #{parentType}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="price != null "> and price = #{price}</if>
<if test="num != null "> and num = #{num}</if>
<if test="introduction != null and introduction != ''"> and introduction = #{introduction}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="brandId != null "> and brand_id = #{brandId}</if>
<if test="ruleId != null "> and rule_id = #{ruleId}</if>
</where>
</select>
<select id="selectProjectInfoById" parameterType="Long" resultMap="ProjectInfoResult">
<include refid="selectProjectInfoVo"/>
where id = #{id}
</select>
<insert id="insertProjectInfo" parameterType="com.muyu.system.domain.ProjectInfo" useGeneratedKeys="true" keyProperty="id">
insert into project_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,</if>
<if test="image != null">image,</if>
<if test="mianType != null">mian_type,</if>
<if test="parentType != null">parent_type,</if>
<if test="type != null">type,</if>
<if test="price != null">price,</if>
<if test="num != null">num,</if>
<if test="introduction != null">introduction,</if>
<if test="status != null">status,</if>
<if test="brandId != null">brand_id,</if>
<if test="ruleId != null">rule_id,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
<if test="image != null">#{image},</if>
<if test="mianType != null">#{mianType},</if>
<if test="parentType != null">#{parentType},</if>
<if test="type != null">#{type},</if>
<if test="price != null">#{price},</if>
<if test="num != null">#{num},</if>
<if test="introduction != null">#{introduction},</if>
<if test="status != null">#{status},</if>
<if test="brandId != null">#{brandId},</if>
<if test="ruleId != null">#{ruleId},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateProjectInfo" parameterType="com.muyu.system.domain.ProjectInfo">
update project_info
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="image != null">image = #{image},</if>
<if test="mianType != null">mian_type = #{mianType},</if>
<if test="parentType != null">parent_type = #{parentType},</if>
<if test="type != null">type = #{type},</if>
<if test="price != null">price = #{price},</if>
<if test="num != null">num = #{num},</if>
<if test="introduction != null">introduction = #{introduction},</if>
<if test="status != null">status = #{status},</if>
<if test="brandId != null">brand_id = #{brandId},</if>
<if test="ruleId != null">rule_id = #{ruleId},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null and createBy != ''">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>
</trim>
where id = #{id}
</update>
<delete id="deleteProjectInfoById" parameterType="Long">
delete from project_info where id = #{id}
</delete>
<delete id="deleteProjectInfoByIds" parameterType="String">
delete from project_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>