门店用户
This commit is contained in:
@ -1,6 +1,9 @@
|
||||
package com.ruoyi.baseUser.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -124,4 +127,21 @@ public class ZcBaseUserController extends BaseController
|
||||
{
|
||||
return toAjax(zcBaseUserService.deleteZcBaseUserByIds(ids));
|
||||
}
|
||||
|
||||
@PostMapping("/removeStore")
|
||||
@ResponseBody
|
||||
public AjaxResult removeStore(Long id) {
|
||||
try {
|
||||
// 验证参数
|
||||
if (id == null) {
|
||||
return AjaxResult.error("参数错误");
|
||||
}
|
||||
// 调用Service删除关联记录
|
||||
zcBaseUserService.deleteZcBaseUserStoreById(id);
|
||||
return AjaxResult.success("删除成功");
|
||||
} catch (Exception e) {
|
||||
logger.error("删除用户门店关联记录失败", e);
|
||||
return AjaxResult.error("删除失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,11 +24,9 @@ public class ZcBaseUser extends BaseEntity
|
||||
private String userName;
|
||||
|
||||
/** 头像 */
|
||||
@Excel(name = "头像")
|
||||
private String avatarUrl;
|
||||
|
||||
/** 密码 */
|
||||
@Excel(name = "密码")
|
||||
private String password;
|
||||
|
||||
/** 手机号 */
|
||||
|
||||
@ -28,6 +28,9 @@ public interface ZcBaseUserMapper
|
||||
*/
|
||||
public List<ZcBaseUser> selectZcBaseUserList(ZcBaseUser zcBaseUser);
|
||||
|
||||
public List<ZcBaseUser> selectZcBaseUserByStoreId(Long storeId);
|
||||
|
||||
public ZcBaseUser selectZcBaseUserByPhone(String phone);
|
||||
/**
|
||||
* 新增租车用户信息
|
||||
*
|
||||
@ -84,4 +87,6 @@ public interface ZcBaseUserMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteZcBaseUserStoreByUserId(Long id);
|
||||
|
||||
public int deleteZcBaseUserStoreById(Long id);
|
||||
}
|
||||
|
||||
@ -27,6 +27,9 @@ public interface IZcBaseUserService
|
||||
*/
|
||||
public List<ZcBaseUser> selectZcBaseUserList(ZcBaseUser zcBaseUser);
|
||||
|
||||
|
||||
public List<ZcBaseUser> selectZcBaseUserByStoreId(Long storeId);
|
||||
|
||||
/**
|
||||
* 新增租车用户信息
|
||||
*
|
||||
@ -58,4 +61,6 @@ public interface IZcBaseUserService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteZcBaseUserById(Long id);
|
||||
|
||||
public int deleteZcBaseUserStoreById(Long id);
|
||||
}
|
||||
|
||||
@ -52,6 +52,11 @@ public class ZcBaseUserServiceImpl implements IZcBaseUserService
|
||||
return zcBaseUserMapper.selectZcBaseUserList(zcBaseUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ZcBaseUser> selectZcBaseUserByStoreId(Long storeId){
|
||||
return zcBaseUserMapper.selectZcBaseUserByStoreId(storeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增租车用户信息
|
||||
*
|
||||
@ -62,13 +67,28 @@ public class ZcBaseUserServiceImpl implements IZcBaseUserService
|
||||
@Override
|
||||
public int insertZcBaseUser(ZcBaseUser zcBaseUser)
|
||||
{
|
||||
String md5Hexpwd = DigestUtils.md5Hex(zcBaseUser.getPassword());
|
||||
zcBaseUser.setPassword(md5Hexpwd);
|
||||
zcBaseUser.setIsStore(1L);
|
||||
zcBaseUser.setCreateTime(DateUtils.getNowDate());
|
||||
int rows = zcBaseUserMapper.insertZcBaseUser(zcBaseUser);
|
||||
insertZcBaseUserStore(zcBaseUser);
|
||||
return rows;
|
||||
|
||||
ZcBaseUser oldUser = zcBaseUserMapper.selectZcBaseUserByPhone(zcBaseUser.getPhoneNumber());
|
||||
if(oldUser != null) {
|
||||
// 如果用户存在,只修改门店用户标识
|
||||
ZcBaseUser a = new ZcBaseUser();
|
||||
a.setId(oldUser.getId());
|
||||
a.setIsStore(1L);
|
||||
a.setUpdateTime(DateUtils.getNowDate());
|
||||
int rows = zcBaseUserMapper.updateZcBaseUser(a);
|
||||
// 然后绑定与门店的关联
|
||||
oldUser.setZcBaseUserStoreList(zcBaseUser.getZcBaseUserStoreList());
|
||||
insertZcBaseUserStore(oldUser);
|
||||
return rows;
|
||||
}else{
|
||||
String md5Hexpwd = DigestUtils.md5Hex(zcBaseUser.getPassword());
|
||||
zcBaseUser.setPassword(md5Hexpwd);
|
||||
zcBaseUser.setIsStore(1L);
|
||||
zcBaseUser.setCreateTime(DateUtils.getNowDate());
|
||||
int rows = zcBaseUserMapper.insertZcBaseUser(zcBaseUser);
|
||||
insertZcBaseUserStore(zcBaseUser);
|
||||
return rows;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,4 +159,9 @@ public class ZcBaseUserServiceImpl implements IZcBaseUserService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteZcBaseUserStoreById(Long id) {
|
||||
return zcBaseUserMapper.deleteZcBaseUserStoreById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,8 @@ package com.ruoyi.operation.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.baseUser.domain.ZcBaseUser;
|
||||
import com.ruoyi.baseUser.service.IZcBaseUserService;
|
||||
import com.ruoyi.common.constant.CompanyConstants;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
@ -37,6 +39,9 @@ public class CompanyStoreController extends BaseController
|
||||
private ICompanyStoreService companyStoreService;
|
||||
@Autowired
|
||||
private ICompanyService companyService;
|
||||
@Autowired
|
||||
private IZcBaseUserService zcBaseUserService;
|
||||
|
||||
|
||||
@RequiresPermissions("operation:store:view")
|
||||
@GetMapping()
|
||||
@ -152,6 +157,8 @@ public class CompanyStoreController extends BaseController
|
||||
CompanyStore companyStore = companyStoreService.selectCompanyStoreById(id);
|
||||
mmap.put("companyStore", companyStore);
|
||||
|
||||
List<ZcBaseUser> zcBaseUserList = zcBaseUserService.selectZcBaseUserByStoreId(id);
|
||||
mmap.put("zcBaseUserList", zcBaseUserList);
|
||||
return prefix + "/addStoreUser";
|
||||
}
|
||||
|
||||
|
||||
@ -29,6 +29,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="userId" column="sub_user_id" />
|
||||
<result property="operatorId" column="sub_operator_id" />
|
||||
<result property="storeId" column="sub_store_id" />
|
||||
<result property="operatorName" column="sub_operator_name" />
|
||||
<result property="storeName" column="sub_store_name" />
|
||||
<result property="delFlag" column="sub_del_flag" />
|
||||
<result property="createBy" column="sub_create_by" />
|
||||
<result property="createTime" column="sub_create_time" />
|
||||
@ -56,13 +58,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectZcBaseUserById" parameterType="Long" resultMap="ZcBaseUserZcBaseUserStoreResult">
|
||||
<select id="selectZcBaseUserByStoreId" parameterType="Long" resultMap="ZcBaseUserZcBaseUserStoreResult">
|
||||
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
|
||||
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, b.create_time as sub_create_time
|
||||
from zc_base_user a
|
||||
left join zc_base_user_store b on b.user_id = a.id
|
||||
where a.del_flag = '0' and b.store_id = #{storeId}
|
||||
</select>
|
||||
|
||||
<select id="selectZcBaseUserById" parameterType="Long" resultMap="ZcBaseUserZcBaseUserStoreResult">
|
||||
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, b.create_time as sub_create_time,
|
||||
c.name as sub_store_name, d.company_name as sub_operator_name
|
||||
from zc_base_user a
|
||||
left join zc_base_user_store b on b.user_id = a.id
|
||||
left join zc_company_store c on c.id = b.store_id
|
||||
left join zc_company d on d.id = b.operator_id
|
||||
where a.del_flag = '0' and a.id = #{id}
|
||||
</select>
|
||||
<select id="selectZcBaseUserByPhone" resultMap="ZcBaseUserResult">
|
||||
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
|
||||
from zc_base_user a
|
||||
where a.del_flag = '0' and a.phone_number = #{phoneNumber}
|
||||
</select>
|
||||
|
||||
<insert id="insertZcBaseUser" parameterType="ZcBaseUser" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into zc_base_user
|
||||
@ -137,6 +155,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
delete from zc_base_user_store where user_id = #{userId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteZcBaseUserStoreById">
|
||||
DELETE FROM zc_base_user_store WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<insert id="batchZcBaseUserStore">
|
||||
insert into zc_base_user_store( id, user_id, operator_id, store_id, del_flag, create_by, create_time, update_by, update_time) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
|
||||
@ -56,7 +56,8 @@
|
||||
<input name="alipayUserid" th:field="*{alipayUserid}" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<h4 class="form-header h4">用户门店信息</h4>
|
||||
<br/>
|
||||
<h4 class="form-header h4">用户归属门店信息</h4>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<!-- <button type="button" class="btn btn-white btn-sm" onclick="addRow()"><i class="fa fa-plus"> 增加</i></button>-->
|
||||
@ -107,30 +108,18 @@
|
||||
{
|
||||
field: 'storeName',
|
||||
align: 'center',
|
||||
title: '关联门店',
|
||||
formatter: function(value, row, index) {
|
||||
var html = $.common.sprintf("<input class='form-control' type='text' name='zcBaseUserStoreList[%s].storeId' value='%s'>", index, value);
|
||||
return html;
|
||||
}
|
||||
title: '关联门店'
|
||||
},
|
||||
|
||||
{
|
||||
field: 'operatorName',
|
||||
align: 'center',
|
||||
title: '门店所属运营商',
|
||||
formatter: function(value, row, index) {
|
||||
var html = $.common.sprintf("<input class='form-control' type='text' name='zcBaseUserStoreList[%s].operatorId' value='%s'>", index, value);
|
||||
return html;
|
||||
}
|
||||
title: '门店所属运营商'
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
align: 'center',
|
||||
title: '创建时间',
|
||||
formatter: function(value, row, index) {
|
||||
var html = $.common.sprintf("<input class='form-control' type='text' name='zcBaseUserStoreList[%s].createTime' value='%s'>", index, value);
|
||||
return html;
|
||||
}
|
||||
title: '创建时间'
|
||||
},
|
||||
|
||||
{
|
||||
@ -145,20 +134,45 @@
|
||||
$.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: "",
|
||||
var sub = {
|
||||
|
||||
delRowByIndex: function(index) {
|
||||
// 获取表格数据
|
||||
var data = $("#" + table.options.id).bootstrapTable('getData');
|
||||
var row = data[index-1]; // 序号从1开始,数组索引从0开始
|
||||
|
||||
// 如果该行数据有ID,说明是已存在的记录,需要调用后台删除
|
||||
if (row && row.id) {
|
||||
// 调用后台删除接口
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: prefix + "/removeStore",
|
||||
data: {
|
||||
"id": row.id,
|
||||
"userId": $("input[name='id']").val()
|
||||
},
|
||||
success: function(result) {
|
||||
if (result.code == web_status.SUCCESS) {
|
||||
// 后台删除成功后,移除前端表格行
|
||||
$("#" + table.options.id).bootstrapTable('removeByUniqueId', row.id);
|
||||
$.modal.msgSuccess("删除成功");
|
||||
} else {
|
||||
$.modal.msgError(result.msg);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$.modal.msgError("删除失败");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 如果是新增但未保存的行,直接在前端移除
|
||||
$("#" + table.options.id).bootstrapTable('remove', {
|
||||
field: 'index',
|
||||
values: [index]
|
||||
});
|
||||
}
|
||||
}
|
||||
sub.addRow(row);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -44,9 +44,9 @@
|
||||
</div>
|
||||
|
||||
<div class="btn-group-sm" id="toolbar" role="group">
|
||||
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="baseUser:user:add">
|
||||
<i class="fa fa-plus"></i> 添加
|
||||
</a>
|
||||
<!-- <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="baseUser:user:add">-->
|
||||
<!-- <i class="fa fa-plus"></i> 添加-->
|
||||
<!-- </a>-->
|
||||
<!-- <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="baseUser:user:edit">-->
|
||||
<!-- <i class="fa fa-edit"></i> 修改-->
|
||||
<!-- </a>-->
|
||||
@ -124,8 +124,8 @@
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
var actions = [];
|
||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||||
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
|
||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + ' btnOption" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||||
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + ' btnOption" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
|
||||
return actions.join('');
|
||||
}
|
||||
}]
|
||||
|
||||
@ -6,8 +6,8 @@
|
||||
<body class="white-bg">
|
||||
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||
<form class="form-horizontal m" id="form-user-add">
|
||||
<input class='form-control' type='text' name='zcBaseUserStoreList[0].operatorId' th:value='${companyStore.operatingCompanyId}'>
|
||||
<input class='form-control' type='text' name='zcBaseUserStoreList[0].storeId' th:value="${companyStore.id}" >
|
||||
<input class='form-control' type='hidden' name='zcBaseUserStoreList[0].operatorId' th:value='${companyStore.operatingCompanyId}'>
|
||||
<input class='form-control' type='hidden' name='zcBaseUserStoreList[0].storeId' th:value="${companyStore.id}" >
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">用户名:</label>
|
||||
<div class="col-sm-8">
|
||||
@ -33,16 +33,13 @@
|
||||
<input name="nickName" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">微信小程序openid:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="wechatOpenid" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">支付宝小程序userid:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="alipayUserid" class="form-control" type="text">
|
||||
<br/>
|
||||
<h4 class="form-header h4">门店用户</h4>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="col-sm-12 select-table table-striped">
|
||||
<table id="bootstrap-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@ -59,6 +56,57 @@
|
||||
$.operate.save(prefix + "/add", $('#form-user-add').serialize());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$(function() {
|
||||
var options = {
|
||||
data: [[${zcBaseUserList}]],
|
||||
pagination: false,
|
||||
showSearch: false,
|
||||
showRefresh: false,
|
||||
showToggle: false,
|
||||
showColumns: false,
|
||||
sidePagination: "client",
|
||||
columns: [{
|
||||
checkbox: false
|
||||
},
|
||||
{
|
||||
field: 'index',
|
||||
align: 'center',
|
||||
title: "序号",
|
||||
formatter: function (value, row, index) {
|
||||
var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
|
||||
return columnIndex + $.table.serialNumber(index);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
field: 'userName',
|
||||
align: 'center',
|
||||
title: '用户名'
|
||||
},
|
||||
|
||||
{
|
||||
field: 'phoneNumber',
|
||||
align: 'center',
|
||||
title: '手机号'
|
||||
},
|
||||
{
|
||||
field: 'nickName',
|
||||
align: 'center',
|
||||
title: '昵称'
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
align: 'center',
|
||||
title: '创建时间'
|
||||
},
|
||||
]
|
||||
};
|
||||
$.table.init(options);
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user