diff --git a/ruoyi-admin/src/main/java/com/ruoyi/baseUser/controller/ZcBaseUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/baseUser/controller/ZcBaseUserController.java index 8bc02bb..4d9a1d4 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/baseUser/controller/ZcBaseUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/baseUser/controller/ZcBaseUserController.java @@ -23,7 +23,7 @@ import com.ruoyi.common.core.page.TableDataInfo; * 租车用户信息Controller * * @author ruoyi - * @date 2025-07-27 + * @date 2025-07-28 */ @Controller @RequestMapping("/baseUser/user") diff --git a/ruoyi-admin/src/main/java/com/ruoyi/baseUser/domain/ZcBaseUser.java b/ruoyi-admin/src/main/java/com/ruoyi/baseUser/domain/ZcBaseUser.java index f2f2827..225ec3a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/baseUser/domain/ZcBaseUser.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/baseUser/domain/ZcBaseUser.java @@ -1,5 +1,6 @@ package com.ruoyi.baseUser.domain; +import java.util.List; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; @@ -9,7 +10,7 @@ import com.ruoyi.common.core.domain.BaseEntity; * 租车用户信息对象 zc_base_user * * @author ruoyi - * @date 2025-07-27 + * @date 2025-07-28 */ public class ZcBaseUser extends BaseEntity { @@ -23,9 +24,11 @@ public class ZcBaseUser extends BaseEntity private String userName; /** 头像 */ + @Excel(name = "头像") private String avatarUrl; /** 密码 */ + @Excel(name = "密码") private String password; /** 手机号 */ @@ -33,23 +36,29 @@ public class ZcBaseUser extends BaseEntity private String phoneNumber; /** 角色id */ + @Excel(name = "租车用户",dictType = "sys_yes_no") private Long roleId; + @Excel(name = "门店用户",dictType = "sys_yes_no") + private Long isStore; /** 昵称 */ @Excel(name = "昵称") private String nickName; /** 微信小程序 openid */ - @Excel(name = "微信小程序openid") + @Excel(name = "微信小程序 openid") private String wechatOpenid; /** 支付宝小程序 userid */ - @Excel(name = "支付宝小程序userid") + @Excel(name = "支付宝小程序 userid") private String alipayUserid; /** 删除标志(0代表存在 2代表删除) */ private String delFlag; + /** 用户与门店信息信息 */ + private List zcBaseUserStoreList; + public void setId(Long id) { this.id = id; @@ -100,7 +109,15 @@ public class ZcBaseUser extends BaseEntity this.roleId = roleId; } - public Long getRoleId() + public Long getIsStore() { + return isStore; + } + + public void setIsStore(Long isStore) { + this.isStore = isStore; + } + + public Long getRoleId() { return roleId; } @@ -141,6 +158,16 @@ public class ZcBaseUser extends BaseEntity return delFlag; } + public List getZcBaseUserStoreList() + { + return zcBaseUserStoreList; + } + + public void setZcBaseUserStoreList(List zcBaseUserStoreList) + { + this.zcBaseUserStoreList = zcBaseUserStoreList; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -150,12 +177,14 @@ public class ZcBaseUser extends BaseEntity .append("password", getPassword()) .append("phoneNumber", getPhoneNumber()) .append("roleId", getRoleId()) + .append("isStore", getIsStore()) .append("nickName", getNickName()) .append("wechatOpenid", getWechatOpenid()) .append("alipayUserid", getAlipayUserid()) .append("delFlag", getDelFlag()) .append("createTime", getCreateTime()) .append("updateTime", getUpdateTime()) + .append("zcBaseUserStoreList", getZcBaseUserStoreList()) .toString(); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/baseUser/domain/ZcBaseUserStore.java b/ruoyi-admin/src/main/java/com/ruoyi/baseUser/domain/ZcBaseUserStore.java new file mode 100644 index 0000000..2f483d9 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/baseUser/domain/ZcBaseUserStore.java @@ -0,0 +1,114 @@ +package com.ruoyi.baseUser.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; + +/** + * 用户与门店信息对象 zc_base_user_store + * + * @author ruoyi + * @date 2025-07-28 + */ +public class ZcBaseUserStore extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** id主键 */ + private Long id; + + /** 用户名 */ + @Excel(name = "用户名") + private Long userId; + + private Long operatorId; + + @Excel(name = "所属运营商") + private String operatorName; + + @Excel(name = "所属门店") + private String storeName; + + private Long storeId; + + /** 删除标志(0代表存在 2代表删除) */ + private String delFlag; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setUserId(Long userId) + { + this.userId = userId; + } + + public Long getUserId() + { + return userId; + } + public void setOperatorId(Long operatorId) + { + this.operatorId = operatorId; + } + + public Long getOperatorId() + { + return operatorId; + } + public void setStoreId(Long storeId) + { + this.storeId = storeId; + } + + public Long getStoreId() + { + return storeId; + } + public void setDelFlag(String delFlag) + { + this.delFlag = delFlag; + } + + public String getDelFlag() + { + return delFlag; + } + + public String getOperatorName() { + return operatorName; + } + + public void setOperatorName(String operatorName) { + this.operatorName = operatorName; + } + + public String getStoreName() { + return storeName; + } + + public void setStoreName(String storeName) { + this.storeName = storeName; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("userId", getUserId()) + .append("operatorId", getOperatorId()) + .append("storeId", getStoreId()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/baseUser/mapper/ZcBaseUserMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/baseUser/mapper/ZcBaseUserMapper.java index 3f0f72e..6ac3ce4 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/baseUser/mapper/ZcBaseUserMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/baseUser/mapper/ZcBaseUserMapper.java @@ -2,12 +2,13 @@ package com.ruoyi.baseUser.mapper; import java.util.List; import com.ruoyi.baseUser.domain.ZcBaseUser; +import com.ruoyi.baseUser.domain.ZcBaseUserStore; /** * 租车用户信息Mapper接口 * * @author ruoyi - * @date 2025-07-27 + * @date 2025-07-28 */ public interface ZcBaseUserMapper { @@ -58,4 +59,29 @@ public interface ZcBaseUserMapper * @return 结果 */ public int deleteZcBaseUserByIds(String[] ids); + + /** + * 批量删除用户与门店信息 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteZcBaseUserStoreByUserIds(String[] ids); + + /** + * 批量新增用户与门店信息 + * + * @param zcBaseUserStoreList 用户与门店信息列表 + * @return 结果 + */ + public int batchZcBaseUserStore(List zcBaseUserStoreList); + + + /** + * 通过租车用户信息主键删除用户与门店信息信息 + * + * @param id 租车用户信息ID + * @return 结果 + */ + public int deleteZcBaseUserStoreByUserId(Long id); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/baseUser/service/IZcBaseUserService.java b/ruoyi-admin/src/main/java/com/ruoyi/baseUser/service/IZcBaseUserService.java index 6dbaf52..43759d4 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/baseUser/service/IZcBaseUserService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/baseUser/service/IZcBaseUserService.java @@ -7,7 +7,7 @@ import com.ruoyi.baseUser.domain.ZcBaseUser; * 租车用户信息Service接口 * * @author ruoyi - * @date 2025-07-27 + * @date 2025-07-28 */ public interface IZcBaseUserService { diff --git a/ruoyi-admin/src/main/java/com/ruoyi/baseUser/service/impl/ZcBaseUserServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/baseUser/service/impl/ZcBaseUserServiceImpl.java index 6c285ad..68c6b8a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/baseUser/service/impl/ZcBaseUserServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/baseUser/service/impl/ZcBaseUserServiceImpl.java @@ -1,9 +1,16 @@ package com.ruoyi.baseUser.service.impl; +import java.nio.charset.StandardCharsets; import java.util.List; import com.ruoyi.common.utils.DateUtils; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.tomcat.util.security.MD5Encoder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import com.ruoyi.common.utils.StringUtils; +import org.springframework.transaction.annotation.Transactional; +import com.ruoyi.baseUser.domain.ZcBaseUserStore; import com.ruoyi.baseUser.mapper.ZcBaseUserMapper; import com.ruoyi.baseUser.domain.ZcBaseUser; import com.ruoyi.baseUser.service.IZcBaseUserService; @@ -13,7 +20,7 @@ import com.ruoyi.common.core.text.Convert; * 租车用户信息Service业务层处理 * * @author ruoyi - * @date 2025-07-27 + * @date 2025-07-28 */ @Service public class ZcBaseUserServiceImpl implements IZcBaseUserService @@ -51,11 +58,17 @@ public class ZcBaseUserServiceImpl implements IZcBaseUserService * @param zcBaseUser 租车用户信息 * @return 结果 */ + @Transactional @Override public int insertZcBaseUser(ZcBaseUser zcBaseUser) { + String md5Hexpwd = DigestUtils.md5Hex(zcBaseUser.getPassword()); + zcBaseUser.setPassword(md5Hexpwd); + zcBaseUser.setIsStore(1L); zcBaseUser.setCreateTime(DateUtils.getNowDate()); - return zcBaseUserMapper.insertZcBaseUser(zcBaseUser); + int rows = zcBaseUserMapper.insertZcBaseUser(zcBaseUser); + insertZcBaseUserStore(zcBaseUser); + return rows; } /** @@ -64,10 +77,13 @@ public class ZcBaseUserServiceImpl implements IZcBaseUserService * @param zcBaseUser 租车用户信息 * @return 结果 */ + @Transactional @Override public int updateZcBaseUser(ZcBaseUser zcBaseUser) { zcBaseUser.setUpdateTime(DateUtils.getNowDate()); + zcBaseUserMapper.deleteZcBaseUserStoreByUserId(zcBaseUser.getId()); + insertZcBaseUserStore(zcBaseUser); return zcBaseUserMapper.updateZcBaseUser(zcBaseUser); } @@ -77,9 +93,11 @@ public class ZcBaseUserServiceImpl implements IZcBaseUserService * @param ids 需要删除的租车用户信息主键 * @return 结果 */ + @Transactional @Override public int deleteZcBaseUserByIds(String ids) { + zcBaseUserMapper.deleteZcBaseUserStoreByUserIds(Convert.toStrArray(ids)); return zcBaseUserMapper.deleteZcBaseUserByIds(Convert.toStrArray(ids)); } @@ -89,9 +107,36 @@ public class ZcBaseUserServiceImpl implements IZcBaseUserService * @param id 租车用户信息主键 * @return 结果 */ + @Transactional @Override public int deleteZcBaseUserById(Long id) { + zcBaseUserMapper.deleteZcBaseUserStoreByUserId(id); return zcBaseUserMapper.deleteZcBaseUserById(id); } + + /** + * 新增用户与门店信息信息 + * + * @param zcBaseUser 租车用户信息对象 + */ + public void insertZcBaseUserStore(ZcBaseUser zcBaseUser) + { + List zcBaseUserStoreList = zcBaseUser.getZcBaseUserStoreList(); + Long id = zcBaseUser.getId(); + if (StringUtils.isNotNull(zcBaseUserStoreList)) + { + List list = new ArrayList(); + for (ZcBaseUserStore zcBaseUserStore : zcBaseUserStoreList) + { + zcBaseUserStore.setUserId(id); + zcBaseUserStore.setCreateTime(DateUtils.getNowDate()); + list.add(zcBaseUserStore); + } + if (list.size() > 0) + { + zcBaseUserMapper.batchZcBaseUserStore(list); + } + } + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/CompanyStoreController.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/CompanyStoreController.java index 1aa11ab..3c8ca50 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/CompanyStoreController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/CompanyStoreController.java @@ -141,6 +141,20 @@ public class CompanyStoreController extends BaseController return toAjax(companyStoreService.updateCompanyStore(companyStore)); } + /** + * 修改门店 + */ + @RequiresPermissions("operation:store:edit") + @GetMapping("/addStoreUser/{id}") + public String addStoreUser(@PathVariable("id") Long id, ModelMap mmap) + { + + CompanyStore companyStore = companyStoreService.selectCompanyStoreById(id); + mmap.put("companyStore", companyStore); + + return prefix + "/addStoreUser"; + } + /** * 删除门店 */ diff --git a/ruoyi-admin/src/main/resources/mapper/baseUser/ZcBaseUserMapper.xml b/ruoyi-admin/src/main/resources/mapper/baseUser/ZcBaseUserMapper.xml index 5473793..74446ad 100644 --- a/ruoyi-admin/src/main/resources/mapper/baseUser/ZcBaseUserMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/baseUser/ZcBaseUserMapper.xml @@ -11,6 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -19,8 +20,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + + + + + + + + - select id, user_name, avatar_url, password, phone_number, role_id, nick_name, wechat_openid, alipay_userid, del_flag, create_time, update_time from zc_base_user + select id, user_name, avatar_url, password, phone_number, role_id, is_store, nick_name, wechat_openid, alipay_userid, del_flag, create_time, update_time from zc_base_user - + select a.id, a.user_name, a.avatar_url, a.password, a.phone_number, a.role_id, a.is_store, a.nick_name, a.wechat_openid, a.alipay_userid, a.del_flag, a.create_time, a.update_time, + b.id as sub_id, b.user_id as sub_user_id, b.operator_id as sub_operator_id, b.store_id as sub_store_id + from zc_base_user a + left join zc_base_user_store b on b.user_id = a.id + where a.del_flag = '0' and a.id = #{id} @@ -51,6 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" password, phone_number, role_id, + is_store, nick_name, wechat_openid, alipay_userid, @@ -64,6 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{password}, #{phoneNumber}, #{roleId}, + #{isStore}, #{nickName}, #{wechatOpenid}, #{alipayUserid}, @@ -81,6 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" password = #{password}, phone_number = #{phoneNumber}, role_id = #{roleId}, + is_store = #{isStore}, nick_name = #{nickName}, wechat_openid = #{wechatOpenid}, alipay_userid = #{alipayUserid}, @@ -101,5 +125,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{id} + + + delete from zc_base_user_store where user_id in + + #{userId} + + + + + delete from zc_base_user_store where user_id = #{userId} + + + + insert into zc_base_user_store( id, user_id, operator_id, store_id, del_flag, create_by, create_time, update_by, update_time) values + + ( #{item.id}, #{item.userId}, #{item.operatorId}, #{item.storeId}, #{item.delFlag}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}) + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/baseUser/user/add.html b/ruoyi-admin/src/main/resources/templates/baseUser/user/add.html index ee2130f..9fd9697 100644 --- a/ruoyi-admin/src/main/resources/templates/baseUser/user/add.html +++ b/ruoyi-admin/src/main/resources/templates/baseUser/user/add.html @@ -6,6 +6,7 @@
+

租车用户信息信息

@@ -13,6 +14,12 @@
+ +
+ +
+
+
@@ -43,6 +50,22 @@
+
+ +
+ +
+
+

用户与门店信息信息

+
+
+ + +
+
+
+
+
@@ -57,6 +80,116 @@ $.operate.save(prefix + "/add", $('#form-user-add').serialize()); } } + + $(function() { + var options = { + pagination: false, + showSearch: false, + showRefresh: false, + showToggle: false, + showColumns: false, + sidePagination: "client", + columns: [{ + checkbox: true + }, + { + field: 'index', + align: 'center', + title: "序号", + formatter: function (value, row, index) { + var columnIndex = $.common.sprintf("", $.table.serialNumber(index)); + return columnIndex + $.table.serialNumber(index); + } + }, + { + field: 'operatorId', + align: 'center', + title: '${comment}', + formatter: function(value, row, index) { + var html = $.common.sprintf("", index, value); + return html; + } + }, + { + field: 'storeId', + align: 'center', + title: '${comment}', + formatter: function(value, row, index) { + var html = $.common.sprintf("", index, value); + return html; + } + }, + { + field: 'delFlag', + align: 'center', + title: '删除标志', + formatter: function(value, row, index) { + var html = $.common.sprintf("", index, value); + return html; + } + }, + { + field: 'createBy', + align: 'center', + title: '${comment}', + formatter: function(value, row, index) { + var html = $.common.sprintf("", index, value); + return html; + } + }, + { + field: 'createTime', + align: 'center', + title: '创建时间', + formatter: function(value, row, index) { + var html = $.common.sprintf("", index, value); + return html; + } + }, + { + field: 'updateBy', + align: 'center', + title: '${comment}', + formatter: function(value, row, index) { + var html = $.common.sprintf("", index, value); + return html; + } + }, + { + field: 'updateTime', + align: 'center', + title: '更新时间', + formatter: function(value, row, index) { + var html = $.common.sprintf("", index, value); + return html; + } + }, + { + title: '操作', + align: 'center', + formatter: function(value, row, index) { + var value = $.common.isNotEmpty(row.index) ? row.index : $.table.serialNumber(index); + return '删除'; + } + }] + }; + $.table.init(options); + }); + + function addRow() { + var count = $("#" + table.options.id).bootstrapTable('getData').length; + var row = { + index: $.table.serialNumber(count), + operatorId: "", + storeId: "", + delFlag: "", + createBy: "", + createTime: "", + updateBy: "", + updateTime: "", + } + sub.addRow(row); + } \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/baseUser/user/edit.html b/ruoyi-admin/src/main/resources/templates/baseUser/user/edit.html index 0d27eb6..d3e2827 100644 --- a/ruoyi-admin/src/main/resources/templates/baseUser/user/edit.html +++ b/ruoyi-admin/src/main/resources/templates/baseUser/user/edit.html @@ -6,6 +6,7 @@
+

租车用户信息信息

@@ -14,13 +15,7 @@
-
- -
- -
-
-
+
@@ -33,6 +28,22 @@
+
+ +
+ +
+
+
+ +
+ +
+
@@ -45,6 +56,16 @@
+

用户门店信息

+
+
+ + +
+
+
+
+
@@ -59,6 +80,85 @@ $.operate.save(prefix + "/edit", $('#form-user-edit').serialize()); } } + + $(function() { + var options = { + data: [[${zcBaseUser.zcBaseUserStoreList}]], + pagination: false, + showSearch: false, + showRefresh: false, + showToggle: false, + showColumns: false, + sidePagination: "client", + columns: [{ + checkbox: true + }, + { + field: 'index', + align: 'center', + title: "序号", + formatter: function (value, row, index) { + var columnIndex = $.common.sprintf("", $.table.serialNumber(index)); + return columnIndex + $.table.serialNumber(index); + } + }, + + + { + field: 'storeName', + align: 'center', + title: '关联门店', + formatter: function(value, row, index) { + var html = $.common.sprintf("", index, value); + return html; + } + }, + + { + field: 'operatorName', + align: 'center', + title: '门店所属运营商', + formatter: function(value, row, index) { + var html = $.common.sprintf("", index, value); + return html; + } + }, + { + field: 'createTime', + align: 'center', + title: '创建时间', + formatter: function(value, row, index) { + var html = $.common.sprintf("", index, value); + return html; + } + }, + + { + title: '操作', + align: 'center', + formatter: function(value, row, index) { + var value = $.common.isNotEmpty(row.index) ? row.index : $.table.serialNumber(index); + return '删除'; + } + }] + }; + $.table.init(options); + }); + + function addRow() { + var count = $("#" + table.options.id).bootstrapTable('getData').length; + var row = { + index: $.table.serialNumber(count), + operatorId: "", + storeId: "", + delFlag: "", + createBy: "", + createTime: "", + updateBy: "", + updateTime: "", + } + sub.addRow(row); + } \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/baseUser/user/user.html b/ruoyi-admin/src/main/resources/templates/baseUser/user/user.html index 2f45b8f..a980e4b 100644 --- a/ruoyi-admin/src/main/resources/templates/baseUser/user/user.html +++ b/ruoyi-admin/src/main/resources/templates/baseUser/user/user.html @@ -21,10 +21,19 @@
  • - - + + +
  • +
  • + +
  • -
  •  搜索  重置 @@ -35,9 +44,9 @@
    - - - + + 添加 + @@ -57,6 +66,7 @@ + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/operation/store/store.html b/ruoyi-admin/src/main/resources/templates/operation/store/store.html index 361e644..e57b590 100644 --- a/ruoyi-admin/src/main/resources/templates/operation/store/store.html +++ b/ruoyi-admin/src/main/resources/templates/operation/store/store.html @@ -194,6 +194,7 @@ align: 'center', formatter: function(value, row, index) { var actions = []; + actions.push('门店用户 '); actions.push('编辑 '); actions.push('删除'); if (row.status == 1) { @@ -221,6 +222,10 @@ $.operate.post(prefix + "/changeStatus", { "id": id, "status": 0 }); }) } + + function assStoreUser(id){ + $.modal.open("添加门店用户", prefix + "/addStoreUser/" + id); + } \ No newline at end of file