Преглед на файлове

feat: 商家端登陆注册

pangqijun преди 7 месеца
родител
ревизия
5a6cdf412b

+ 129 - 0
src/main/java/org/springblade/modules/system/controller/UserMerchantController.java

@@ -0,0 +1,129 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.system.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import lombok.AllArgsConstructor;
+import javax.validation.Valid;
+
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.RequestParam;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.modules.system.entity.UserMerchant;
+import org.springblade.modules.system.vo.UserMerchantVO;
+import org.springblade.modules.system.wrapper.UserMerchantWrapper;
+import org.springblade.modules.system.service.IUserMerchantService;
+import org.springblade.core.boot.ctrl.BladeController;
+
+/**
+ * 商家用户表 控制器
+ *
+ * @author BladeX
+ * @since 2024-07-16
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("system/usermerchant")
+@Api(value = "商家用户表", tags = "商家用户表接口")
+public class UserMerchantController extends BladeController {
+
+	private final IUserMerchantService userMerchantService;
+
+	/**
+	 * 详情
+	 */
+	@GetMapping("/detail")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "详情", notes = "传入userMerchant")
+	public R<UserMerchantVO> detail(UserMerchant userMerchant) {
+		UserMerchant detail = userMerchantService.getOne(Condition.getQueryWrapper(userMerchant));
+		return R.data(UserMerchantWrapper.build().entityVO(detail));
+	}
+
+	/**
+	 * 分页 商家用户表
+	 */
+	@GetMapping("/list")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "分页", notes = "传入userMerchant")
+	public R<IPage<UserMerchantVO>> list(UserMerchant userMerchant, Query query) {
+		IPage<UserMerchant> pages = userMerchantService.page(Condition.getPage(query), Condition.getQueryWrapper(userMerchant));
+		return R.data(UserMerchantWrapper.build().pageVO(pages));
+	}
+
+
+	/**
+	 * 自定义分页 商家用户表
+	 */
+	@GetMapping("/page")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "分页", notes = "传入userMerchant")
+	public R<IPage<UserMerchantVO>> page(UserMerchantVO userMerchant, Query query) {
+		IPage<UserMerchantVO> pages = userMerchantService.selectUserMerchantPage(Condition.getPage(query), userMerchant);
+		return R.data(pages);
+	}
+
+	/**
+	 * 新增 商家用户表
+	 */
+	@PostMapping("/save")
+	@ApiOperationSupport(order = 4)
+	@ApiOperation(value = "新增", notes = "传入userMerchant")
+	public R save(@Valid @RequestBody UserMerchant userMerchant) {
+		return R.status(userMerchantService.save(userMerchant));
+	}
+
+	/**
+	 * 修改 商家用户表
+	 */
+	@PostMapping("/update")
+	@ApiOperationSupport(order = 5)
+	@ApiOperation(value = "修改", notes = "传入userMerchant")
+	public R update(@Valid @RequestBody UserMerchant userMerchant) {
+		return R.status(userMerchantService.updateById(userMerchant));
+	}
+
+	/**
+	 * 新增或修改 商家用户表
+	 */
+	@PostMapping("/submit")
+	@ApiOperationSupport(order = 6)
+	@ApiOperation(value = "新增或修改", notes = "传入userMerchant")
+	public R submit(@Valid @RequestBody UserMerchant userMerchant) {
+		return R.status(userMerchantService.saveOrUpdate(userMerchant));
+	}
+
+	
+	/**
+	 * 删除 商家用户表
+	 */
+	@PostMapping("/remove")
+	@ApiOperationSupport(order = 7)
+	@ApiOperation(value = "逻辑删除", notes = "传入ids")
+	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+		return R.status(userMerchantService.removeByIds(Func.toLongList(ids)));
+	}
+
+	
+}

+ 34 - 0
src/main/java/org/springblade/modules/system/dto/UserMerchantDTO.java

@@ -0,0 +1,34 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.system.dto;
+
+import org.springblade.modules.system.entity.UserMerchant;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 商家用户表数据传输对象实体类
+ *
+ * @author BladeX
+ * @since 2024-07-16
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class UserMerchantDTO extends UserMerchant {
+	private static final long serialVersionUID = 1L;
+
+}

+ 65 - 0
src/main/java/org/springblade/modules/system/entity/UserMerchant.java

@@ -0,0 +1,65 @@
+package org.springblade.modules.system.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import org.springblade.common.base.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * 商家用户表实体类
+ *
+ * @author zzyd
+ * @since 2024-07-16
+ */
+@Data
+@TableName("blade_user_merchant")
+@ApiModel(value = "UserMerchant对象", description = "商家用户表")
+public class UserMerchant implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	@JsonSerialize(using = ToStringSerializer.class)
+	@TableId(value = "id", type = IdType.ASSIGN_ID)
+	@ApiModelProperty(value = "主键")
+	protected Long id;
+	/**
+	* 用户id
+	*/
+	@ApiModelProperty(value = "用户id")
+	private Long userId;
+	/**
+	* 身份证号
+	*/
+	@ApiModelProperty(value = "身份证号")
+	private String idCard;
+	/**
+	* 营业执照
+	*/
+	@ApiModelProperty(value = "营业执照")
+	private String businessLicence;
+	/**
+	* 地址
+	*/
+	@ApiModelProperty(value = "地址")
+	private String address;
+	/**
+	* 父id
+	*/
+	@ApiModelProperty(value = "父id")
+	private Long parentId;
+	/**
+	* 授权菜单
+	*/
+	@ApiModelProperty(value = "授权菜单")
+	private String authMenu;
+
+
+}

+ 42 - 0
src/main/java/org/springblade/modules/system/mapper/UserMerchantMapper.java

@@ -0,0 +1,42 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.system.mapper;
+
+import org.springblade.modules.system.entity.UserMerchant;
+import org.springblade.modules.system.vo.UserMerchantVO;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import java.util.List;
+
+/**
+ * 商家用户表 Mapper 接口
+ *
+ * @author BladeX
+ * @since 2024-07-16
+ */
+public interface UserMerchantMapper extends BaseMapper<UserMerchant> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param userMerchant
+	 * @return
+	 */
+	List<UserMerchantVO> selectUserMerchantPage(IPage page, UserMerchantVO userMerchant);
+
+}

+ 21 - 0
src/main/java/org/springblade/modules/system/mapper/UserMerchantMapper.xml

@@ -0,0 +1,21 @@
+<?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="org.springblade.modules.system.mapper.UserMerchantMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="userMerchantResultMap" type="org.springblade.modules.system.entity.UserMerchant">
+        <result column="id" property="id"/>
+        <result column="user_id" property="userId"/>
+        <result column="id_card" property="idCard"/>
+        <result column="business_licence" property="businessLicence"/>
+        <result column="address" property="address"/>
+        <result column="parent_id" property="parentId"/>
+        <result column="auth_menu" property="authMenu"/>
+    </resultMap>
+
+
+    <select id="selectUserMerchantPage" resultMap="userMerchantResultMap">
+        select * from blade_user_merchant where is_delete = 0
+    </select>
+
+</mapper>

+ 48 - 0
src/main/java/org/springblade/modules/system/service/IUserMerchantService.java

@@ -0,0 +1,48 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.system.service;
+
+import org.springblade.modules.system.entity.UserMerchant;
+import org.springblade.modules.system.vo.UserMerchantVO;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ * 商家用户表 服务类
+ *
+ * @author BladeX
+ * @since 2024-07-16
+ */
+public interface IUserMerchantService extends IService<UserMerchant> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param userMerchant
+	 * @return
+	 */
+	IPage<UserMerchantVO> selectUserMerchantPage(IPage<UserMerchantVO> page, UserMerchantVO userMerchant);
+
+	/**
+	 * 根据用户id查询商户信息
+	 * @param userId 用户id
+	 * @return UserMerchantVO
+	 */
+	UserMerchantVO getByUserId(Long userId);
+
+}

+ 49 - 0
src/main/java/org/springblade/modules/system/service/impl/UserMerchantServiceImpl.java

@@ -0,0 +1,49 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.system.service.impl;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import org.springblade.modules.system.entity.UserMerchant;
+import org.springblade.modules.system.vo.UserMerchantVO;
+import org.springblade.modules.system.mapper.UserMerchantMapper;
+import org.springblade.modules.system.service.IUserMerchantService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.modules.system.wrapper.UserMerchantWrapper;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ * 商家用户表 服务实现类
+ *
+ * @author BladeX
+ * @since 2024-07-16
+ */
+@Service
+public class UserMerchantServiceImpl extends ServiceImpl<UserMerchantMapper, UserMerchant> implements IUserMerchantService {
+
+	@Override
+	public IPage<UserMerchantVO> selectUserMerchantPage(IPage<UserMerchantVO> page, UserMerchantVO userMerchant) {
+		return page.setRecords(baseMapper.selectUserMerchantPage(page, userMerchant));
+	}
+
+	@Override
+	public UserMerchantVO getByUserId(Long userId) {
+		UserMerchant one = getOne(Wrappers.lambdaQuery(UserMerchant.class).eq(UserMerchant::getUserId, userId));
+		return UserMerchantWrapper.build().entityVO(one);
+	}
+
+}

+ 52 - 0
src/main/java/org/springblade/modules/system/vo/UserMerchantVO.java

@@ -0,0 +1,52 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.system.vo;
+
+import org.springblade.modules.system.entity.UserMerchant;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import io.swagger.annotations.ApiModel;
+
+/**
+ * 商家用户表视图实体类
+ *
+ * @author BladeX
+ * @since 2024-07-16
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "UserMerchantVO对象", description = "商家用户表")
+public class UserMerchantVO extends UserMerchant {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 商户名称
+	 */
+	private String merchantName;
+	/**
+	 * 姓名
+	 */
+	private String realName;
+	/**
+	 * 头像
+	 */
+	private String avatar;
+	/**
+	 * 手机
+	 */
+	private String phone;
+}

+ 49 - 0
src/main/java/org/springblade/modules/system/wrapper/UserMerchantWrapper.java

@@ -0,0 +1,49 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.system.wrapper;
+
+import org.springblade.core.mp.support.BaseEntityWrapper;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.modules.system.entity.UserMerchant;
+import org.springblade.modules.system.vo.UserMerchantVO;
+import java.util.Objects;
+
+/**
+ * 商家用户表包装类,返回视图层所需的字段
+ *
+ * @author BladeX
+ * @since 2024-07-16
+ */
+public class UserMerchantWrapper extends BaseEntityWrapper<UserMerchant, UserMerchantVO>  {
+
+	public static UserMerchantWrapper build() {
+		return new UserMerchantWrapper();
+ 	}
+
+	@Override
+	public UserMerchantVO entityVO(UserMerchant userMerchant) {
+		UserMerchantVO userMerchantVO = Objects.requireNonNull(BeanUtil.copy(userMerchant, UserMerchantVO.class));
+
+		//User createUser = UserCache.getUser(userMerchant.getCreateUser());
+		//User updateUser = UserCache.getUser(userMerchant.getUpdateUser());
+		//userMerchantVO.setCreateUserName(createUser.getName());
+		//userMerchantVO.setUpdateUserName(updateUser.getName());
+
+		return userMerchantVO;
+	}
+
+}

+ 10 - 0
src/main/java/sql/usermerchant.menu.mysql

@@ -0,0 +1,10 @@
+INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
+VALUES ('1813060589279272967', 1123598815738675201, 'usermerchant', '商家用户表', 'menu', '/system/usermerchant', NULL, 1, 1, 0, 1, NULL, 0);
+INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
+VALUES ('1813060589279272968', '1813060589279272967', 'usermerchant_add', '新增', 'add', '/system/usermerchant/add', 'plus', 1, 2, 1, 1, NULL, 0);
+INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
+VALUES ('1813060589279272969', '1813060589279272967', 'usermerchant_edit', '修改', 'edit', '/system/usermerchant/edit', 'form', 2, 2, 2, 1, NULL, 0);
+INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
+VALUES ('1813060589279272970', '1813060589279272967', 'usermerchant_delete', '删除', 'delete', '/api/system/usermerchant/remove', 'delete', 3, 2, 3, 1, NULL, 0);
+INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
+VALUES ('1813060589279272971', '1813060589279272967', 'usermerchant_view', '查看', 'view', '/system/usermerchant/view', 'file-text', 4, 2, 2, 1, NULL, 0);