添加订单
This commit is contained in:
parent
d89d17cbb3
commit
37df131b13
@ -0,0 +1,103 @@
|
||||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
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.SysOrder;
|
||||
import com.ruoyi.system.service.ISysOrderService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 销售订单Controller
|
||||
*
|
||||
* @author wonder
|
||||
* @date 2020-09-22
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/order")
|
||||
public class SysOrderController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysOrderService sysOrderService;
|
||||
|
||||
/**
|
||||
* 查询销售订单列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:order:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysOrder sysOrder)
|
||||
{
|
||||
startPage();
|
||||
List<SysOrder> list = sysOrderService.selectSysOrderList(sysOrder);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出销售订单列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:order:export')")
|
||||
@Log(title = "销售订单", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(SysOrder sysOrder)
|
||||
{
|
||||
List<SysOrder> list = sysOrderService.selectSysOrderList(sysOrder);
|
||||
ExcelUtil<SysOrder> util = new ExcelUtil<SysOrder>(SysOrder.class);
|
||||
return util.exportExcel(list, "order");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取销售订单详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:order:query')")
|
||||
@GetMapping(value = "/{orderId}")
|
||||
public AjaxResult getInfo(@PathVariable("orderId") Long orderId)
|
||||
{
|
||||
return AjaxResult.success(sysOrderService.selectSysOrderById(orderId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增销售订单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:order:add')")
|
||||
@Log(title = "销售订单", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SysOrder sysOrder)
|
||||
{
|
||||
return toAjax(sysOrderService.insertSysOrder(sysOrder));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改销售订单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:order:edit')")
|
||||
@Log(title = "销售订单", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SysOrder sysOrder)
|
||||
{
|
||||
return toAjax(sysOrderService.updateSysOrder(sysOrder));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除销售订单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:order:remove')")
|
||||
@Log(title = "销售订单", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{orderIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] orderIds)
|
||||
{
|
||||
return toAjax(sysOrderService.deleteSysOrderByIds(orderIds));
|
||||
}
|
||||
}
|
115
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOrder.java
Normal file
115
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOrder.java
Normal file
@ -0,0 +1,115 @@
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 销售订单对象 sys_order
|
||||
*
|
||||
* @author wonder
|
||||
* @date 2020-09-22
|
||||
*/
|
||||
public class SysOrder extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 编号 */
|
||||
private Long orderId;
|
||||
|
||||
/** 用户ID */
|
||||
@Excel(name = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
/** 用户昵称 */
|
||||
@Excel(name = "用户昵称")
|
||||
private String nickName;
|
||||
|
||||
/** 金额 */
|
||||
@Excel(name = "金额")
|
||||
private Long amount;
|
||||
|
||||
/** 成交日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "成交日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date saleTime;
|
||||
|
||||
/** 销售渠道ID */
|
||||
@Excel(name = "销售渠道ID")
|
||||
private Long channelId;
|
||||
|
||||
public void setOrderId(Long orderId)
|
||||
{
|
||||
this.orderId = orderId;
|
||||
}
|
||||
|
||||
public Long getOrderId()
|
||||
{
|
||||
return orderId;
|
||||
}
|
||||
public void setUserId(Long userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getUserId()
|
||||
{
|
||||
return userId;
|
||||
}
|
||||
public void setNickName(String nickName)
|
||||
{
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public String getNickName()
|
||||
{
|
||||
return nickName;
|
||||
}
|
||||
public void setAmount(Long amount)
|
||||
{
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public Long getAmount()
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
public void setSaleTime(Date saleTime)
|
||||
{
|
||||
this.saleTime = saleTime;
|
||||
}
|
||||
|
||||
public Date getSaleTime()
|
||||
{
|
||||
return saleTime;
|
||||
}
|
||||
public void setChannelId(Long channelId)
|
||||
{
|
||||
this.channelId = channelId;
|
||||
}
|
||||
|
||||
public Long getChannelId()
|
||||
{
|
||||
return channelId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("orderId", getOrderId())
|
||||
.append("userId", getUserId())
|
||||
.append("nickName", getNickName())
|
||||
.append("amount", getAmount())
|
||||
.append("saleTime", getSaleTime())
|
||||
.append("channelId", getChannelId())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.system.domain.SysOrder;
|
||||
|
||||
/**
|
||||
* 销售订单Mapper接口
|
||||
*
|
||||
* @author wonder
|
||||
* @date 2020-09-22
|
||||
*/
|
||||
public interface SysOrderMapper
|
||||
{
|
||||
/**
|
||||
* 查询销售订单
|
||||
*
|
||||
* @param orderId 销售订单ID
|
||||
* @return 销售订单
|
||||
*/
|
||||
public SysOrder selectSysOrderById(Long orderId);
|
||||
|
||||
/**
|
||||
* 查询销售订单列表
|
||||
*
|
||||
* @param sysOrder 销售订单
|
||||
* @return 销售订单集合
|
||||
*/
|
||||
public List<SysOrder> selectSysOrderList(SysOrder sysOrder);
|
||||
|
||||
/**
|
||||
* 新增销售订单
|
||||
*
|
||||
* @param sysOrder 销售订单
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysOrder(SysOrder sysOrder);
|
||||
|
||||
/**
|
||||
* 修改销售订单
|
||||
*
|
||||
* @param sysOrder 销售订单
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysOrder(SysOrder sysOrder);
|
||||
|
||||
/**
|
||||
* 删除销售订单
|
||||
*
|
||||
* @param orderId 销售订单ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysOrderById(Long orderId);
|
||||
|
||||
/**
|
||||
* 批量删除销售订单
|
||||
*
|
||||
* @param orderIds 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysOrderByIds(Long[] orderIds);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.system.domain.SysOrder;
|
||||
|
||||
/**
|
||||
* 销售订单Service接口
|
||||
*
|
||||
* @author wonder
|
||||
* @date 2020-09-22
|
||||
*/
|
||||
public interface ISysOrderService
|
||||
{
|
||||
/**
|
||||
* 查询销售订单
|
||||
*
|
||||
* @param orderId 销售订单ID
|
||||
* @return 销售订单
|
||||
*/
|
||||
public SysOrder selectSysOrderById(Long orderId);
|
||||
|
||||
/**
|
||||
* 查询销售订单列表
|
||||
*
|
||||
* @param sysOrder 销售订单
|
||||
* @return 销售订单集合
|
||||
*/
|
||||
public List<SysOrder> selectSysOrderList(SysOrder sysOrder);
|
||||
|
||||
/**
|
||||
* 新增销售订单
|
||||
*
|
||||
* @param sysOrder 销售订单
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysOrder(SysOrder sysOrder);
|
||||
|
||||
/**
|
||||
* 修改销售订单
|
||||
*
|
||||
* @param sysOrder 销售订单
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysOrder(SysOrder sysOrder);
|
||||
|
||||
/**
|
||||
* 批量删除销售订单
|
||||
*
|
||||
* @param orderIds 需要删除的销售订单ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysOrderByIds(Long[] orderIds);
|
||||
|
||||
/**
|
||||
* 删除销售订单信息
|
||||
*
|
||||
* @param orderId 销售订单ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysOrderById(Long orderId);
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
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.SysOrderMapper;
|
||||
import com.ruoyi.system.domain.SysOrder;
|
||||
import com.ruoyi.system.service.ISysOrderService;
|
||||
|
||||
/**
|
||||
* 销售订单Service业务层处理
|
||||
*
|
||||
* @author wonder
|
||||
* @date 2020-09-22
|
||||
*/
|
||||
@Service
|
||||
public class SysOrderServiceImpl implements ISysOrderService
|
||||
{
|
||||
@Autowired
|
||||
private SysOrderMapper sysOrderMapper;
|
||||
|
||||
/**
|
||||
* 查询销售订单
|
||||
*
|
||||
* @param orderId 销售订单ID
|
||||
* @return 销售订单
|
||||
*/
|
||||
@Override
|
||||
public SysOrder selectSysOrderById(Long orderId)
|
||||
{
|
||||
return sysOrderMapper.selectSysOrderById(orderId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询销售订单列表
|
||||
*
|
||||
* @param sysOrder 销售订单
|
||||
* @return 销售订单
|
||||
*/
|
||||
@Override
|
||||
public List<SysOrder> selectSysOrderList(SysOrder sysOrder)
|
||||
{
|
||||
return sysOrderMapper.selectSysOrderList(sysOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增销售订单
|
||||
*
|
||||
* @param sysOrder 销售订单
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysOrder(SysOrder sysOrder)
|
||||
{
|
||||
sysOrder.setCreateTime(DateUtils.getNowDate());
|
||||
return sysOrderMapper.insertSysOrder(sysOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改销售订单
|
||||
*
|
||||
* @param sysOrder 销售订单
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysOrder(SysOrder sysOrder)
|
||||
{
|
||||
sysOrder.setUpdateTime(DateUtils.getNowDate());
|
||||
return sysOrderMapper.updateSysOrder(sysOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除销售订单
|
||||
*
|
||||
* @param orderIds 需要删除的销售订单ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysOrderByIds(Long[] orderIds)
|
||||
{
|
||||
return sysOrderMapper.deleteSysOrderByIds(orderIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除销售订单信息
|
||||
*
|
||||
* @param orderId 销售订单ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysOrderById(Long orderId)
|
||||
{
|
||||
return sysOrderMapper.deleteSysOrderById(orderId);
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
<?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.SysOrderMapper">
|
||||
|
||||
<resultMap type="SysOrder" id="SysOrderResult">
|
||||
<result property="orderId" column="order_id" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="nickName" column="nick_name" />
|
||||
<result property="amount" column="amount" />
|
||||
<result property="saleTime" column="sale_time" />
|
||||
<result property="channelId" column="channel_id" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSysOrderVo">
|
||||
select order_id, user_id, nick_name, amount, sale_time, channel_id, create_by, create_time, update_by, update_time, remark from sys_order
|
||||
</sql>
|
||||
|
||||
<select id="selectSysOrderList" parameterType="SysOrder" resultMap="SysOrderResult">
|
||||
<include refid="selectSysOrderVo"/>
|
||||
<where>
|
||||
<if test="userId != null "> and user_id = #{userId}</if>
|
||||
<if test="nickName != null and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
|
||||
<if test="amount != null "> and amount = #{amount}</if>
|
||||
<if test="saleTime != null "> and sale_time = #{saleTime}</if>
|
||||
<if test="channelId != null "> and channel_id = #{channelId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSysOrderById" parameterType="Long" resultMap="SysOrderResult">
|
||||
<include refid="selectSysOrderVo"/>
|
||||
where order_id = #{orderId}
|
||||
</select>
|
||||
|
||||
<insert id="insertSysOrder" parameterType="SysOrder" useGeneratedKeys="true" keyProperty="orderId">
|
||||
insert into sys_order
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="nickName != null and nickName != ''">nick_name,</if>
|
||||
<if test="amount != null">amount,</if>
|
||||
<if test="saleTime != null">sale_time,</if>
|
||||
<if test="channelId != null">channel_id,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="nickName != null and nickName != ''">#{nickName},</if>
|
||||
<if test="amount != null">#{amount},</if>
|
||||
<if test="saleTime != null">#{saleTime},</if>
|
||||
<if test="channelId != null">#{channelId},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSysOrder" parameterType="SysOrder">
|
||||
update sys_order
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
||||
<if test="amount != null">amount = #{amount},</if>
|
||||
<if test="saleTime != null">sale_time = #{saleTime},</if>
|
||||
<if test="channelId != null">channel_id = #{channelId},</if>
|
||||
<if test="createBy != null">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>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where order_id = #{orderId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSysOrderById" parameterType="Long">
|
||||
delete from sys_order where order_id = #{orderId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSysOrderByIds" parameterType="String">
|
||||
delete from sys_order where order_id in
|
||||
<foreach item="orderId" collection="array" open="(" separator="," close=")">
|
||||
#{orderId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
Loading…
x
Reference in New Issue
Block a user