1. 优惠券
This commit is contained in:
parent
8901137783
commit
6386b46b36
|
@ -0,0 +1,104 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
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.EtCoupon;
|
||||
import com.ruoyi.system.service.IEtCouponService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 优惠券Controller
|
||||
*
|
||||
* @author 邱贞招
|
||||
* @date 2024-08-05
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/coupon")
|
||||
public class EtCouponController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IEtCouponService etCouponService;
|
||||
|
||||
/**
|
||||
* 查询优惠券列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:coupon:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(EtCoupon etCoupon)
|
||||
{
|
||||
startPage();
|
||||
List<EtCoupon> list = etCouponService.selectEtCouponList(etCoupon);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出优惠券列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:coupon:export')")
|
||||
@Log(title = "优惠券", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, EtCoupon etCoupon)
|
||||
{
|
||||
List<EtCoupon> list = etCouponService.selectEtCouponList(etCoupon);
|
||||
ExcelUtil<EtCoupon> util = new ExcelUtil<EtCoupon>(EtCoupon.class);
|
||||
util.exportExcel(response, list, "优惠券数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取优惠券详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:coupon:query')")
|
||||
@GetMapping(value = "/{couponId}")
|
||||
public AjaxResult getInfo(@PathVariable("couponId") Long couponId)
|
||||
{
|
||||
return success(etCouponService.selectEtCouponByCouponId(couponId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增优惠券
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:coupon:add')")
|
||||
@Log(title = "优惠券", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody EtCoupon etCoupon)
|
||||
{
|
||||
return toAjax(etCouponService.insertEtCoupon(etCoupon));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改优惠券
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:coupon:edit')")
|
||||
@Log(title = "优惠券", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody EtCoupon etCoupon)
|
||||
{
|
||||
return toAjax(etCouponService.updateEtCoupon(etCoupon));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除优惠券
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:coupon:remove')")
|
||||
@Log(title = "优惠券", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{couponIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] couponIds)
|
||||
{
|
||||
return toAjax(etCouponService.deleteEtCouponByCouponIds(couponIds));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.ruoyi.system.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 优惠券对象 et_coupon
|
||||
*
|
||||
* @author 邱贞招
|
||||
* @date 2024-08-05
|
||||
*/
|
||||
@Data
|
||||
public class EtCoupon extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 优惠券id */
|
||||
private Long couponId;
|
||||
|
||||
/** 类型 */
|
||||
@Excel(name = "类型")
|
||||
private String type;
|
||||
|
||||
/** 折扣比例 */
|
||||
@Excel(name = "折扣比例")
|
||||
private BigDecimal discountPercent;
|
||||
|
||||
/** 区域 */
|
||||
@Excel(name = "区域")
|
||||
private Long areaId;
|
||||
|
||||
/** 用户 */
|
||||
@Excel(name = "用户")
|
||||
private Long userId;
|
||||
|
||||
/** 抵扣金额 */
|
||||
@Excel(name = "抵扣金额")
|
||||
private BigDecimal discountAmount;
|
||||
|
||||
/** 有效时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "有效时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date expirationTime;
|
||||
|
||||
/** 状态 */
|
||||
@Excel(name = "状态")
|
||||
private String status;
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.ruoyi.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.system.domain.EtCoupon;
|
||||
|
||||
/**
|
||||
* 优惠券Mapper接口
|
||||
*
|
||||
* @author 邱贞招
|
||||
* @date 2024-08-05
|
||||
*/
|
||||
public interface EtCouponMapper
|
||||
{
|
||||
/**
|
||||
* 查询优惠券
|
||||
*
|
||||
* @param couponId 优惠券主键
|
||||
* @return 优惠券
|
||||
*/
|
||||
public EtCoupon selectEtCouponByCouponId(Long couponId);
|
||||
|
||||
/**
|
||||
* 查询优惠券列表
|
||||
*
|
||||
* @param etCoupon 优惠券
|
||||
* @return 优惠券集合
|
||||
*/
|
||||
public List<EtCoupon> selectEtCouponList(EtCoupon etCoupon);
|
||||
|
||||
/**
|
||||
* 新增优惠券
|
||||
*
|
||||
* @param etCoupon 优惠券
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertEtCoupon(EtCoupon etCoupon);
|
||||
|
||||
/**
|
||||
* 修改优惠券
|
||||
*
|
||||
* @param etCoupon 优惠券
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateEtCoupon(EtCoupon etCoupon);
|
||||
|
||||
/**
|
||||
* 删除优惠券
|
||||
*
|
||||
* @param couponId 优惠券主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEtCouponByCouponId(Long couponId);
|
||||
|
||||
/**
|
||||
* 批量删除优惠券
|
||||
*
|
||||
* @param couponIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEtCouponByCouponIds(Long[] couponIds);
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.ruoyi.system.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.system.domain.EtCoupon;
|
||||
|
||||
/**
|
||||
* 优惠券Service接口
|
||||
*
|
||||
* @author 邱贞招
|
||||
* @date 2024-08-05
|
||||
*/
|
||||
public interface IEtCouponService
|
||||
{
|
||||
/**
|
||||
* 查询优惠券
|
||||
*
|
||||
* @param couponId 优惠券主键
|
||||
* @return 优惠券
|
||||
*/
|
||||
public EtCoupon selectEtCouponByCouponId(Long couponId);
|
||||
|
||||
/**
|
||||
* 查询优惠券列表
|
||||
*
|
||||
* @param etCoupon 优惠券
|
||||
* @return 优惠券集合
|
||||
*/
|
||||
public List<EtCoupon> selectEtCouponList(EtCoupon etCoupon);
|
||||
|
||||
/**
|
||||
* 新增优惠券
|
||||
*
|
||||
* @param etCoupon 优惠券
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertEtCoupon(EtCoupon etCoupon);
|
||||
|
||||
/**
|
||||
* 修改优惠券
|
||||
*
|
||||
* @param etCoupon 优惠券
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateEtCoupon(EtCoupon etCoupon);
|
||||
|
||||
/**
|
||||
* 批量删除优惠券
|
||||
*
|
||||
* @param couponIds 需要删除的优惠券主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEtCouponByCouponIds(Long[] couponIds);
|
||||
|
||||
/**
|
||||
* 删除优惠券信息
|
||||
*
|
||||
* @param couponId 优惠券主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEtCouponByCouponId(Long couponId);
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.system.mapper.EtCouponMapper;
|
||||
import com.ruoyi.system.domain.EtCoupon;
|
||||
import com.ruoyi.system.service.IEtCouponService;
|
||||
|
||||
/**
|
||||
* 优惠券Service业务层处理
|
||||
*
|
||||
* @author 邱贞招
|
||||
* @date 2024-08-05
|
||||
*/
|
||||
@Service
|
||||
public class EtCouponServiceImpl implements IEtCouponService
|
||||
{
|
||||
@Autowired
|
||||
private EtCouponMapper etCouponMapper;
|
||||
|
||||
/**
|
||||
* 查询优惠券
|
||||
*
|
||||
* @param couponId 优惠券主键
|
||||
* @return 优惠券
|
||||
*/
|
||||
@Override
|
||||
public EtCoupon selectEtCouponByCouponId(Long couponId)
|
||||
{
|
||||
return etCouponMapper.selectEtCouponByCouponId(couponId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询优惠券列表
|
||||
*
|
||||
* @param etCoupon 优惠券
|
||||
* @return 优惠券
|
||||
*/
|
||||
@Override
|
||||
public List<EtCoupon> selectEtCouponList(EtCoupon etCoupon)
|
||||
{
|
||||
return etCouponMapper.selectEtCouponList(etCoupon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增优惠券
|
||||
*
|
||||
* @param etCoupon 优惠券
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertEtCoupon(EtCoupon etCoupon)
|
||||
{
|
||||
etCoupon.setCreateTime(DateUtils.getNowDate());
|
||||
return etCouponMapper.insertEtCoupon(etCoupon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改优惠券
|
||||
*
|
||||
* @param etCoupon 优惠券
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateEtCoupon(EtCoupon etCoupon)
|
||||
{
|
||||
return etCouponMapper.updateEtCoupon(etCoupon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除优惠券
|
||||
*
|
||||
* @param couponIds 需要删除的优惠券主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteEtCouponByCouponIds(Long[] couponIds)
|
||||
{
|
||||
return etCouponMapper.deleteEtCouponByCouponIds(couponIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除优惠券信息
|
||||
*
|
||||
* @param couponId 优惠券主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteEtCouponByCouponId(Long couponId)
|
||||
{
|
||||
return etCouponMapper.deleteEtCouponByCouponId(couponId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
<?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.EtCouponMapper">
|
||||
|
||||
<resultMap type="EtCoupon" id="EtCouponResult">
|
||||
<result property="couponId" column="coupon_id" />
|
||||
<result property="type" column="type" />
|
||||
<result property="discountPercent" column="discount_percent" />
|
||||
<result property="areaId" column="area_id" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="discountAmount" column="discount_amount" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="expirationTime" column="expiration_time" />
|
||||
<result property="status" column="status" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEtCouponVo">
|
||||
select coupon_id, type, discount_percent, area_id, user_id, discount_amount, create_time, expiration_time, status from et_coupon
|
||||
</sql>
|
||||
|
||||
<select id="selectEtCouponList" parameterType="EtCoupon" resultMap="EtCouponResult">
|
||||
<include refid="selectEtCouponVo"/>
|
||||
<where>
|
||||
<if test="type != null and type != ''"> and type = #{type}</if>
|
||||
<if test="discountPercent != null "> and discount_percent = #{discountPercent}</if>
|
||||
<if test="areaId != null "> and area_id = #{areaId}</if>
|
||||
<if test="userId != null "> and user_id = #{userId}</if>
|
||||
<if test="discountAmount != null "> and discount_amount = #{discountAmount}</if>
|
||||
<if test="expirationTime != null "> and expiration_time = #{expirationTime}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectEtCouponByCouponId" parameterType="Long" resultMap="EtCouponResult">
|
||||
<include refid="selectEtCouponVo"/>
|
||||
where coupon_id = #{couponId}
|
||||
</select>
|
||||
|
||||
<insert id="insertEtCoupon" parameterType="EtCoupon" useGeneratedKeys="true" keyProperty="couponId">
|
||||
insert into et_coupon
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="type != null">type,</if>
|
||||
<if test="discountPercent != null">discount_percent,</if>
|
||||
<if test="areaId != null">area_id,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="discountAmount != null">discount_amount,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="expirationTime != null">expiration_time,</if>
|
||||
<if test="status != null">status,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="type != null">#{type},</if>
|
||||
<if test="discountPercent != null">#{discountPercent},</if>
|
||||
<if test="areaId != null">#{areaId},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="discountAmount != null">#{discountAmount},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="expirationTime != null">#{expirationTime},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateEtCoupon" parameterType="EtCoupon">
|
||||
update et_coupon
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="type != null">type = #{type},</if>
|
||||
<if test="discountPercent != null">discount_percent = #{discountPercent},</if>
|
||||
<if test="areaId != null">area_id = #{areaId},</if>
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="discountAmount != null">discount_amount = #{discountAmount},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="expirationTime != null">expiration_time = #{expirationTime},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
</trim>
|
||||
where coupon_id = #{couponId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteEtCouponByCouponId" parameterType="Long">
|
||||
delete from et_coupon where coupon_id = #{couponId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteEtCouponByCouponIds" parameterType="String">
|
||||
delete from et_coupon where coupon_id in
|
||||
<foreach item="couponId" collection="array" open="(" separator="," close=")">
|
||||
#{couponId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user