This commit is contained in:
sxu 2025-04-14 17:00:21 +08:00
parent 61b5737f3d
commit f89b757232
6 changed files with 556 additions and 0 deletions

View File

@ -0,0 +1,119 @@
package com.bonus.canteen.core.user.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.bonus.common.log.enums.OperaType;
import com.bonus.canteen.core.common.annotation.PreventRepeatSubmit;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.bonus.common.log.annotation.SysLog;
import com.bonus.common.security.annotation.RequiresPermissions;
import com.bonus.canteen.core.user.domain.UserAddr;
import com.bonus.canteen.core.user.service.IUserAddrService;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.utils.poi.ExcelUtil;
import com.bonus.common.core.web.page.TableDataInfo;
/**
* 地址信息Controller
*
* @author xsheng
* @date 2025-04-14
*/
@Api(tags = "地址信息接口")
@RestController
@RequestMapping("/user_addr")
public class UserAddrController extends BaseController {
@Autowired
private IUserAddrService userAddrService;
/**
* 查询地址信息列表
*/
@ApiOperation(value = "查询地址信息列表")
//@RequiresPermissions("user:addr:list")
@GetMapping("/list")
public TableDataInfo list(UserAddr userAddr) {
startPage();
List<UserAddr> list = userAddrService.selectUserAddrList(userAddr);
return getDataTable(list);
}
/**
* 导出地址信息列表
*/
@ApiOperation(value = "导出地址信息列表")
//@PreventRepeatSubmit
//@RequiresPermissions("user:addr:export")
@SysLog(title = "地址信息", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出地址信息")
@PostMapping("/export")
public void export(HttpServletResponse response, UserAddr userAddr) {
List<UserAddr> list = userAddrService.selectUserAddrList(userAddr);
ExcelUtil<UserAddr> util = new ExcelUtil<UserAddr>(UserAddr.class);
util.exportExcel(response, list, "地址信息数据");
}
/**
* 获取地址信息详细信息
*/
@ApiOperation(value = "获取地址信息详细信息")
//@RequiresPermissions("user:addr:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(userAddrService.selectUserAddrById(id));
}
/**
* 新增地址信息
*/
@ApiOperation(value = "新增地址信息")
//@PreventRepeatSubmit
//@RequiresPermissions("user:addr:add")
@SysLog(title = "地址信息", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增地址信息")
@PostMapping
public AjaxResult add(@RequestBody UserAddr userAddr) {
try {
return toAjax(userAddrService.insertUserAddr(userAddr));
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
}
}
/**
* 修改地址信息
*/
@ApiOperation(value = "修改地址信息")
//@PreventRepeatSubmit
//@RequiresPermissions("user:addr:edit")
@SysLog(title = "地址信息", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改地址信息")
@PostMapping("/edit")
public AjaxResult edit(@RequestBody UserAddr userAddr) {
try {
return toAjax(userAddrService.updateUserAddr(userAddr));
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
}
}
/**
* 删除地址信息
*/
@ApiOperation(value = "删除地址信息")
//@PreventRepeatSubmit
//@RequiresPermissions("user:addr:remove")
@SysLog(title = "地址信息", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除地址信息")
@PostMapping("/del/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(userAddrService.deleteUserAddrByIds(ids));
}
}

View File

@ -0,0 +1,89 @@
package com.bonus.canteen.core.user.domain;
import com.bonus.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import com.bonus.common.core.web.domain.BaseEntity;
/**
* 地址信息对象 user_addr
*
* @author xsheng
* @date 2025-04-14
*/
@Data
@ToString
public class UserAddr extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键自增 */
private Long id;
/** 人员id */
@Excel(name = "人员id")
@ApiModelProperty(value = "人员id")
private Long userId;
/** 地址id */
@Excel(name = "地址id")
@ApiModelProperty(value = "地址id")
private Long addrId;
/** 联系人姓名 */
@Excel(name = "联系人姓名")
@ApiModelProperty(value = "联系人姓名")
private String contactName;
/** 手机号 */
@Excel(name = "手机号")
@ApiModelProperty(value = "手机号")
private String mobile;
/** 地区代码 国家统一地区代码,到县级别 */
@Excel(name = "地区代码 国家统一地区代码,到县级别")
@ApiModelProperty(value = "地区代码 国家统一地区代码,到县级别")
private String areaCode;
/** 详细地址 */
@Excel(name = "详细地址")
@ApiModelProperty(value = "详细地址")
private String detailAddr;
/** 地址全称 */
@Excel(name = "地址全称")
@ApiModelProperty(value = "地址全称")
private String addrFullName;
/** openid */
@Excel(name = "openid")
@ApiModelProperty(value = "openid")
private String openid;
/** 来源类型 1-钉钉 2-微信 3-小程序 */
@Excel(name = "来源类型 1-钉钉 2-微信 3-小程序")
@ApiModelProperty(value = "来源类型 1-钉钉 2-微信 3-小程序")
private Long sourceType;
/** 是否默认 1-是2-否 */
@Excel(name = "是否默认 1-是2-否")
@ApiModelProperty(value = "是否默认 1-是2-否")
private Long ifDefault;
/** 乐观锁 */
@Excel(name = "乐观锁")
@ApiModelProperty(value = "乐观锁")
private Long revision;
/** 位置信息id */
@Excel(name = "位置信息id")
@ApiModelProperty(value = "位置信息id")
private Long placeId;
/** 删除标志0代表存在 2代表删除 */
private String delFlag;
}

View File

@ -0,0 +1,60 @@
package com.bonus.canteen.core.user.mapper;
import java.util.List;
import com.bonus.canteen.core.user.domain.UserAddr;
/**
* 地址信息Mapper接口
*
* @author xsheng
* @date 2025-04-14
*/
public interface UserAddrMapper {
/**
* 查询地址信息
*
* @param id 地址信息主键
* @return 地址信息
*/
public UserAddr selectUserAddrById(Long id);
/**
* 查询地址信息列表
*
* @param userAddr 地址信息
* @return 地址信息集合
*/
public List<UserAddr> selectUserAddrList(UserAddr userAddr);
/**
* 新增地址信息
*
* @param userAddr 地址信息
* @return 结果
*/
public int insertUserAddr(UserAddr userAddr);
/**
* 修改地址信息
*
* @param userAddr 地址信息
* @return 结果
*/
public int updateUserAddr(UserAddr userAddr);
/**
* 删除地址信息
*
* @param id 地址信息主键
* @return 结果
*/
public int deleteUserAddrById(Long id);
/**
* 批量删除地址信息
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteUserAddrByIds(Long[] ids);
}

View File

@ -0,0 +1,60 @@
package com.bonus.canteen.core.user.service;
import java.util.List;
import com.bonus.canteen.core.user.domain.UserAddr;
/**
* 地址信息Service接口
*
* @author xsheng
* @date 2025-04-14
*/
public interface IUserAddrService {
/**
* 查询地址信息
*
* @param id 地址信息主键
* @return 地址信息
*/
public UserAddr selectUserAddrById(Long id);
/**
* 查询地址信息列表
*
* @param userAddr 地址信息
* @return 地址信息集合
*/
public List<UserAddr> selectUserAddrList(UserAddr userAddr);
/**
* 新增地址信息
*
* @param userAddr 地址信息
* @return 结果
*/
public int insertUserAddr(UserAddr userAddr);
/**
* 修改地址信息
*
* @param userAddr 地址信息
* @return 结果
*/
public int updateUserAddr(UserAddr userAddr);
/**
* 批量删除地址信息
*
* @param ids 需要删除的地址信息主键集合
* @return 结果
*/
public int deleteUserAddrByIds(Long[] ids);
/**
* 删除地址信息信息
*
* @param id 地址信息主键
* @return 结果
*/
public int deleteUserAddrById(Long id);
}

View File

@ -0,0 +1,98 @@
package com.bonus.canteen.core.user.service.impl;
import java.util.List;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.user.mapper.UserAddrMapper;
import com.bonus.canteen.core.user.domain.UserAddr;
import com.bonus.canteen.core.user.service.IUserAddrService;
/**
* 地址信息Service业务层处理
*
* @author xsheng
* @date 2025-04-14
*/
@Service
public class UserAddrServiceImpl implements IUserAddrService {
@Autowired
private UserAddrMapper userAddrMapper;
/**
* 查询地址信息
*
* @param id 地址信息主键
* @return 地址信息
*/
@Override
public UserAddr selectUserAddrById(Long id) {
return userAddrMapper.selectUserAddrById(id);
}
/**
* 查询地址信息列表
*
* @param userAddr 地址信息
* @return 地址信息
*/
@Override
public List<UserAddr> selectUserAddrList(UserAddr userAddr) {
return userAddrMapper.selectUserAddrList(userAddr);
}
/**
* 新增地址信息
*
* @param userAddr 地址信息
* @return 结果
*/
@Override
public int insertUserAddr(UserAddr userAddr) {
userAddr.setCreateTime(DateUtils.getNowDate());
try {
return userAddrMapper.insertUserAddr(userAddr);
} catch (Exception e) {
throw new ServiceException("错误信息描述");
}
}
/**
* 修改地址信息
*
* @param userAddr 地址信息
* @return 结果
*/
@Override
public int updateUserAddr(UserAddr userAddr) {
userAddr.setUpdateTime(DateUtils.getNowDate());
try {
return userAddrMapper.updateUserAddr(userAddr);
} catch (Exception e) {
throw new ServiceException("错误信息描述");
}
}
/**
* 批量删除地址信息
*
* @param ids 需要删除的地址信息主键
* @return 结果
*/
@Override
public int deleteUserAddrByIds(Long[] ids) {
return userAddrMapper.deleteUserAddrByIds(ids);
}
/**
* 删除地址信息信息
*
* @param id 地址信息主键
* @return 结果
*/
@Override
public int deleteUserAddrById(Long id) {
return userAddrMapper.deleteUserAddrById(id);
}
}

View File

@ -0,0 +1,130 @@
<?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.bonus.canteen.core.user.mapper.UserAddrMapper">
<resultMap type="com.bonus.canteen.core.user.domain.UserAddr" id="UserAddrResult">
<result property="id" column="id" />
<result property="userId" column="user_id" />
<result property="addrId" column="addr_id" />
<result property="contactName" column="contact_name" />
<result property="mobile" column="mobile" />
<result property="areaCode" column="area_code" />
<result property="detailAddr" column="detail_addr" />
<result property="addrFullName" column="addr_full_name" />
<result property="openid" column="openid" />
<result property="sourceType" column="source_type" />
<result property="ifDefault" column="if_default" />
<result property="revision" column="revision" />
<result property="placeId" column="place_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="delFlag" column="del_flag" />
</resultMap>
<sql id="selectUserAddrVo">
select id, user_id, addr_id, contact_name, mobile, area_code, detail_addr, addr_full_name, openid, source_type, if_default, revision, place_id, create_by, create_time, update_by, update_time, del_flag from user_addr
</sql>
<select id="selectUserAddrList" parameterType="com.bonus.canteen.core.user.domain.UserAddr" resultMap="UserAddrResult">
<include refid="selectUserAddrVo"/>
<where>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="addrId != null "> and addr_id = #{addrId}</if>
<if test="contactName != null and contactName != ''"> and contact_name like concat('%', #{contactName}, '%')</if>
<if test="mobile != null and mobile != ''"> and mobile = #{mobile}</if>
<if test="areaCode != null and areaCode != ''"> and area_code = #{areaCode}</if>
<if test="detailAddr != null and detailAddr != ''"> and detail_addr = #{detailAddr}</if>
<if test="addrFullName != null and addrFullName != ''"> and addr_full_name like concat('%', #{addrFullName}, '%')</if>
<if test="openid != null and openid != ''"> and openid = #{openid}</if>
<if test="sourceType != null "> and source_type = #{sourceType}</if>
<if test="ifDefault != null "> and if_default = #{ifDefault}</if>
<if test="revision != null "> and revision = #{revision}</if>
<if test="placeId != null "> and place_id = #{placeId}</if>
</where>
</select>
<select id="selectUserAddrById" parameterType="Long" resultMap="UserAddrResult">
<include refid="selectUserAddrVo"/>
where id = #{id}
</select>
<insert id="insertUserAddr" parameterType="com.bonus.canteen.core.user.domain.UserAddr" useGeneratedKeys="true" keyProperty="id">
insert into user_addr
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">user_id,</if>
<if test="addrId != null">addr_id,</if>
<if test="contactName != null and contactName != ''">contact_name,</if>
<if test="mobile != null and mobile != ''">mobile,</if>
<if test="areaCode != null and areaCode != ''">area_code,</if>
<if test="detailAddr != null and detailAddr != ''">detail_addr,</if>
<if test="addrFullName != null and addrFullName != ''">addr_full_name,</if>
<if test="openid != null and openid != ''">openid,</if>
<if test="sourceType != null">source_type,</if>
<if test="ifDefault != null">if_default,</if>
<if test="revision != null">revision,</if>
<if test="placeId != null">place_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="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">#{userId},</if>
<if test="addrId != null">#{addrId},</if>
<if test="contactName != null and contactName != ''">#{contactName},</if>
<if test="mobile != null and mobile != ''">#{mobile},</if>
<if test="areaCode != null and areaCode != ''">#{areaCode},</if>
<if test="detailAddr != null and detailAddr != ''">#{detailAddr},</if>
<if test="addrFullName != null and addrFullName != ''">#{addrFullName},</if>
<if test="openid != null and openid != ''">#{openid},</if>
<if test="sourceType != null">#{sourceType},</if>
<if test="ifDefault != null">#{ifDefault},</if>
<if test="revision != null">#{revision},</if>
<if test="placeId != null">#{placeId},</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="delFlag != null">#{delFlag},</if>
</trim>
</insert>
<update id="updateUserAddr" parameterType="com.bonus.canteen.core.user.domain.UserAddr">
update user_addr
<trim prefix="SET" suffixOverrides=",">
<if test="userId != null">user_id = #{userId},</if>
<if test="addrId != null">addr_id = #{addrId},</if>
<if test="contactName != null and contactName != ''">contact_name = #{contactName},</if>
<if test="mobile != null and mobile != ''">mobile = #{mobile},</if>
<if test="areaCode != null and areaCode != ''">area_code = #{areaCode},</if>
<if test="detailAddr != null and detailAddr != ''">detail_addr = #{detailAddr},</if>
<if test="addrFullName != null and addrFullName != ''">addr_full_name = #{addrFullName},</if>
<if test="openid != null and openid != ''">openid = #{openid},</if>
<if test="sourceType != null">source_type = #{sourceType},</if>
<if test="ifDefault != null">if_default = #{ifDefault},</if>
<if test="revision != null">revision = #{revision},</if>
<if test="placeId != null">place_id = #{placeId},</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="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteUserAddrById" parameterType="Long">
delete from user_addr where id = #{id}
</delete>
<delete id="deleteUserAddrByIds" parameterType="String">
delete from user_addr where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>