添加地址管理
This commit is contained in:
@ -0,0 +1,104 @@
|
||||
package com.ruoyi.carpool.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.carpool.domain.PAddress;
|
||||
import com.ruoyi.carpool.service.IPAddressService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 地址详情Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2021-12-18
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/carpool/address")
|
||||
public class PAddressController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IPAddressService pAddressService;
|
||||
|
||||
/**
|
||||
* 查询地址详情列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('address:address:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(PAddress pAddress)
|
||||
{
|
||||
startPage();
|
||||
List<PAddress> list = pAddressService.selectPAddressList(pAddress);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出地址详情列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('address:address:export')")
|
||||
@Log(title = "地址详情", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, PAddress pAddress)
|
||||
{
|
||||
List<PAddress> list = pAddressService.selectPAddressList(pAddress);
|
||||
ExcelUtil<PAddress> util = new ExcelUtil<PAddress>(PAddress.class);
|
||||
util.exportExcel(response, list, "地址详情数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取地址详情详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('address:address:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return AjaxResult.success(pAddressService.selectPAddressById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增地址详情
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('address:address:add')")
|
||||
@Log(title = "地址详情", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody PAddress pAddress)
|
||||
{
|
||||
return toAjax(pAddressService.insertPAddress(pAddress));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改地址详情
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('address:address:edit')")
|
||||
@Log(title = "地址详情", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PAddress pAddress)
|
||||
{
|
||||
return toAjax(pAddressService.updatePAddress(pAddress));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除地址详情
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('address:address:remove')")
|
||||
@Log(title = "地址详情", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(pAddressService.deletePAddressByIds(ids));
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package com.ruoyi.carpool.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;
|
||||
|
||||
/**
|
||||
* 地址详情对象 p_address
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2021-12-18
|
||||
*/
|
||||
public class PAddress extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 自增ID */
|
||||
private Long id;
|
||||
|
||||
/** 地址 */
|
||||
@Excel(name = "地址")
|
||||
private String address;
|
||||
|
||||
/** 地址类型,1:出发地;2:目的地 */
|
||||
@Excel(name = "地址类型,1:出发地;2:目的地")
|
||||
private String type;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setAddress(String address)
|
||||
{
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getAddress()
|
||||
{
|
||||
return address;
|
||||
}
|
||||
public void setType(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("address", getAddress())
|
||||
.append("type", getType())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.ruoyi.carpool.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.carpool.domain.PAddress;
|
||||
|
||||
/**
|
||||
* 地址详情Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2021-12-18
|
||||
*/
|
||||
public interface PAddressMapper
|
||||
{
|
||||
/**
|
||||
* 查询地址详情
|
||||
*
|
||||
* @param id 地址详情主键
|
||||
* @return 地址详情
|
||||
*/
|
||||
public PAddress selectPAddressById(Long id);
|
||||
|
||||
/**
|
||||
* 查询地址详情列表
|
||||
*
|
||||
* @param pAddress 地址详情
|
||||
* @return 地址详情集合
|
||||
*/
|
||||
public List<PAddress> selectPAddressList(PAddress pAddress);
|
||||
|
||||
/**
|
||||
* 新增地址详情
|
||||
*
|
||||
* @param pAddress 地址详情
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPAddress(PAddress pAddress);
|
||||
|
||||
/**
|
||||
* 修改地址详情
|
||||
*
|
||||
* @param pAddress 地址详情
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePAddress(PAddress pAddress);
|
||||
|
||||
/**
|
||||
* 删除地址详情
|
||||
*
|
||||
* @param id 地址详情主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePAddressById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除地址详情
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePAddressByIds(Long[] ids);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.ruoyi.carpool.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.carpool.domain.PAddress;
|
||||
|
||||
/**
|
||||
* 地址详情Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2021-12-18
|
||||
*/
|
||||
public interface IPAddressService
|
||||
{
|
||||
/**
|
||||
* 查询地址详情
|
||||
*
|
||||
* @param id 地址详情主键
|
||||
* @return 地址详情
|
||||
*/
|
||||
public PAddress selectPAddressById(Long id);
|
||||
|
||||
/**
|
||||
* 查询地址详情列表
|
||||
*
|
||||
* @param pAddress 地址详情
|
||||
* @return 地址详情集合
|
||||
*/
|
||||
public List<PAddress> selectPAddressList(PAddress pAddress);
|
||||
|
||||
/**
|
||||
* 新增地址详情
|
||||
*
|
||||
* @param pAddress 地址详情
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPAddress(PAddress pAddress);
|
||||
|
||||
/**
|
||||
* 修改地址详情
|
||||
*
|
||||
* @param pAddress 地址详情
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePAddress(PAddress pAddress);
|
||||
|
||||
/**
|
||||
* 批量删除地址详情
|
||||
*
|
||||
* @param ids 需要删除的地址详情主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePAddressByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除地址详情信息
|
||||
*
|
||||
* @param id 地址详情主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePAddressById(Long id);
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package com.ruoyi.carpool.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.carpool.mapper.PAddressMapper;
|
||||
import com.ruoyi.carpool.domain.PAddress;
|
||||
import com.ruoyi.carpool.service.IPAddressService;
|
||||
|
||||
/**
|
||||
* 地址详情Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2021-12-18
|
||||
*/
|
||||
@Service
|
||||
public class PAddressServiceImpl implements IPAddressService
|
||||
{
|
||||
@Autowired
|
||||
private PAddressMapper pAddressMapper;
|
||||
|
||||
/**
|
||||
* 查询地址详情
|
||||
*
|
||||
* @param id 地址详情主键
|
||||
* @return 地址详情
|
||||
*/
|
||||
@Override
|
||||
public PAddress selectPAddressById(Long id)
|
||||
{
|
||||
return pAddressMapper.selectPAddressById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询地址详情列表
|
||||
*
|
||||
* @param pAddress 地址详情
|
||||
* @return 地址详情
|
||||
*/
|
||||
@Override
|
||||
public List<PAddress> selectPAddressList(PAddress pAddress)
|
||||
{
|
||||
return pAddressMapper.selectPAddressList(pAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增地址详情
|
||||
*
|
||||
* @param pAddress 地址详情
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertPAddress(PAddress pAddress)
|
||||
{
|
||||
pAddress.setCreateTime(DateUtils.getNowDate());
|
||||
return pAddressMapper.insertPAddress(pAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改地址详情
|
||||
*
|
||||
* @param pAddress 地址详情
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updatePAddress(PAddress pAddress)
|
||||
{
|
||||
pAddress.setUpdateTime(DateUtils.getNowDate());
|
||||
return pAddressMapper.updatePAddress(pAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除地址详情
|
||||
*
|
||||
* @param ids 需要删除的地址详情主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePAddressByIds(Long[] ids)
|
||||
{
|
||||
return pAddressMapper.deletePAddressByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除地址详情信息
|
||||
*
|
||||
* @param id 地址详情主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePAddressById(Long id)
|
||||
{
|
||||
return pAddressMapper.deletePAddressById(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
<?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.carpool.mapper.PAddressMapper">
|
||||
|
||||
<resultMap type="PAddress" id="PAddressResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="address" column="address" />
|
||||
<result property="type" column="type" />
|
||||
<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="selectPAddressVo">
|
||||
select id, address, type, create_by, create_time, update_by, update_time from p_address
|
||||
</sql>
|
||||
|
||||
<select id="selectPAddressList" parameterType="PAddress" resultMap="PAddressResult">
|
||||
<include refid="selectPAddressVo"/>
|
||||
<where>
|
||||
<if test="address != null and address != ''"> and address = #{address}</if>
|
||||
<if test="type != null and type != ''"> and type = #{type}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectPAddressById" parameterType="Long" resultMap="PAddressResult">
|
||||
<include refid="selectPAddressVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertPAddress" parameterType="PAddress" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into p_address
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="address != null">address,</if>
|
||||
<if test="type != null">type,</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>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="address != null">#{address},</if>
|
||||
<if test="type != null">#{type},</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>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updatePAddress" parameterType="PAddress">
|
||||
update p_address
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="address != null">address = #{address},</if>
|
||||
<if test="type != null">type = #{type},</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>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deletePAddressById" parameterType="Long">
|
||||
delete from p_address where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deletePAddressByIds" parameterType="String">
|
||||
delete from p_address where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
Reference in New Issue
Block a user