数据隔离

This commit is contained in:
邱贞招 2024-11-14 20:53:08 +08:00
parent 8ca7e970a8
commit 94e3e45afd
41 changed files with 222 additions and 185 deletions

View File

@ -95,7 +95,7 @@ token:
# 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期默认30分钟
expireTime: 30
expireTime: 65535000
## MyBatis配置
#mybatis:

View File

@ -17,19 +17,19 @@ import java.lang.annotation.Target;
public @interface DataScope
{
/**
* 代理商的别名
* 的别名
*/
public String agentAlias() default "";
public String merchantAlias() default "";
/**
* 用户表的别名
*/
public String userAlias() default "";
/**
* 只是用户隔离 如果是1则只查询当前用户的数据
*/
public String onlyUser() default "";
// /**
// * 只是用户隔离 如果是1则只查询当前用户的数据
// */
// public String onlyUser() default "";
/**
* 权限字符用于多个角色匹配符合要求的权限默认根据权限注解@ss获取多个权限用逗号分隔开来

View File

@ -11,7 +11,7 @@ import com.ruoyi.common.utils.poi.ExcelHandlerAdapter;
/**
* 自定义导出Excel数据注解
*
*
* @author ruoyi
*/
@Retention(RetentionPolicy.RUNTIME)
@ -189,4 +189,4 @@ public @interface Excel
return this.value;
}
}
}
}

View File

@ -193,7 +193,12 @@ public class ServiceConstants {
/**
* 车辆状态: 1-正常
*/
public static final String VEHICLE_STATUS_NORMAL_STR = "1";
public static final String VEHICLE_STATUS_NORMAL_STR = "待租";
/**
* 车辆状态: 2-已绑定
*/
public static final String VEHICLE_STATUS__BOUND_STR = "已绑定";
/**
* 车辆状态: 3-使用中

View File

@ -2,7 +2,7 @@ package com.ruoyi.common.constant;
/**
* 用户常量信息
*
*
* @author ruoyi
*/
public class UserConstants
@ -53,7 +53,7 @@ public class UserConstants
/** Layout组件标识 */
public final static String LAYOUT = "Layout";
/** ParentView组件标识 */
public final static String PARENT_VIEW = "ParentView";

View File

@ -122,6 +122,9 @@ public class EUser extends BaseEntity
/** 角色组 */
private Long[] roleIds;
/** 角色ID */
private Long roleId;
/** 服务费比例 */
@Excel(name = "服务费比例")
private BigDecimal serviceFeeProportion;

View File

@ -32,25 +32,15 @@ public class DataScopeAspect
*/
public static final String DATA_SCOPE_ALL = "1";
// /**
// * 自定数据权限
// */
// public static final String DATA_SCOPE_CUSTOM = "2";
/**
* 部门数据权限
* 商家数据权限
*/
public static final String DATA_SCOPE_DEPT = "3";
// /**
// * 部门及以下数据权限
// */
// public static final String DATA_SCOPE_DEPT_AND_CHILD = "4";
// /**
// * 仅本人数据权限
// */
// public static final String DATA_SCOPE_SELF = "5";
/**
* 仅本人数据权限
*/
public static final String DATA_SCOPE_SELF = "5";
/**
* 数据权限过滤关键字
@ -75,8 +65,7 @@ public class DataScopeAspect
if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin())
{
String permission = StringUtils.defaultIfEmpty(controllerDataScope.permission(), PermissionContextHolder.getContext());
dataScopeFilter(joinPoint, currentUser, controllerDataScope.agentAlias(),
controllerDataScope.userAlias(), controllerDataScope.onlyUser(),permission);
dataScopeFilter(joinPoint, currentUser, controllerDataScope.merchantAlias(), controllerDataScope.userAlias(), permission);
}
}
}
@ -86,12 +75,10 @@ public class DataScopeAspect
*
* @param joinPoint 切点
* @param user 用户
* @param agentAlias 部门别名
* @param userAlias 用户别名
* @param onlyUser 只做用户隔离
* @param permission 权限字符
*/
public static void dataScopeFilter(JoinPoint joinPoint, EUserVO user, String agentAlias, String userAlias, String onlyUser, String permission)
public static void dataScopeFilter(JoinPoint joinPoint, EUserVO user, String merchantAlias, String userAlias, String permission)
{
StringBuilder sqlString = new StringBuilder();
List<String> conditions = new ArrayList<String>();
@ -112,16 +99,20 @@ public class DataScopeAspect
}else if (DATA_SCOPE_DEPT.equals(dataScope)){
// 如果是代理商则用 a 来查询
// 如果是商户则用 u 来查询 onlyUser.equals("1")
sqlString.append(StringUtils.format(" OR {}.user_id = {} ", merchantAlias, user.getUserId()));
}else if (DATA_SCOPE_SELF.equals(dataScope)){
// 如果是本人权限 用不同的别名来表示 u2
// 如果是商户则用 u 来查询 onlyUser.equals("1")
sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId()));
}
conditions.add(dataScope);
}
// 角色都不包含传递过来的权限字符这个时候sqlString也会为空所以要限制一下,不查询任何数据
if (StringUtils.isEmpty(conditions))
{
sqlString.append(StringUtils.format(" OR {}.user_id = 0 ", agentAlias));
}
// if (StringUtils.isEmpty(conditions))
// {
// sqlString.append(StringUtils.format(" OR {}.isolate_id = 0 ", agentAlias));
// }
if (StringUtils.isNotBlank(sqlString.toString()))
{

View File

@ -5,14 +5,14 @@ import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 用户和岗位关联 sys_user_post
*
*
* @author ruoyi
*/
public class SysUserPost
{
/** 用户ID */
private Long userId;
/** 岗位ID */
private Long postId;

View File

@ -5,14 +5,14 @@ import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 用户和角色关联 sys_user_role
*
*
* @author ruoyi
*/
public class SysUserRole
{
/** 用户ID */
private Long userId;
/** 角色ID */
private Long roleId;

View File

@ -247,6 +247,12 @@ public class EOrder extends BaseEntity {
@Excel(name = "支付渠道id")
private Long payChannel;
/**
* 支付渠道名称
*/
@Excel(name = "支付渠道名称")
private String channelName;
/**
* 配送方式
*/

View File

@ -42,7 +42,7 @@ public class EAccessoryServiceImpl implements IEAccessoryService
* @return 配件
*/
@Override
@DataScope(agentAlias = "ag",userAlias = "u")
@DataScope(merchantAlias = "m")
public List<EAccessory> selectRlAccessoryList(EAccessory rlAccessory)
{
return rlAccessoryMapper.selectRlAccessoryList(rlAccessory);

View File

@ -38,7 +38,7 @@ public class EArticleClassifyServiceImpl implements IEArticleClassifyService
* @return 分类信息集合
*/
@Override
@DataScope(agentAlias = "a")
// @DataScope(agentAlias = "a")
public List<AsArticleClassify> selectClassifyListWithIsolate(AsArticleClassify classify)
{
return articleClassifyMapper.selectClassifyList(classify);
@ -63,7 +63,7 @@ public class EArticleClassifyServiceImpl implements IEArticleClassifyService
* @return 分类树信息集合
*/
@Override
@DataScope(agentAlias = "a")
// @DataScope(agentAlias = "a")
public List<TreeSelect> selectClassifyTreeList(AsArticleClassify classify)
{
List<AsArticleClassify> depts = selectClassifyListWithIsolate(classify);

View File

@ -60,7 +60,7 @@ public class EArticleServiceImpl implements IEArticleService
* @return 文章
*/
@Override
@DataScope(agentAlias = "ag")
@DataScope(userAlias = "u")
public List<EtArticle> selectAsArticleListByIsolate(EtArticle etArticle)
{
List<EtArticle> etArticles = rlArticleMapper.selectAsArticleList(etArticle);

View File

@ -1,5 +1,6 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.changeBalance.EChangeBalance;
@ -52,7 +53,7 @@ public class EChangeBalanceServiceImpl implements IEChangeBalanceService
* @return 余额变动
*/
@Override
// @DataScope(userAlias = "u",onlyUser = "1")
@DataScope(merchantAlias = "u")
public List<EChangeBalance> selectRlChangeBalanceList(EChangeBalance rlChangeBalance)
{
return rlChangeBalanceMapper.selectRlChangeBalanceList(rlChangeBalance);

View File

@ -244,7 +244,7 @@ public class EDeviceServiceImpl extends ServiceImpl<EDeviceMapper, EDevice> impl
* @return 设备
*/
@Override
@DataScope(agentAlias = "d")
@DataScope(merchantAlias = "m", userAlias = "u")
public List<EDevice> selectEDeviceListWithIsolate(EDeviceQuery asDevice)
{
if(ServiceConstants.VEHICLE_STATUS_NOT_BAND.equals(asDevice.getStatus())){

View File

@ -40,7 +40,7 @@ public class EFeeRuleServiceImpl implements IEFeeRuleService
* @return 收费模板
*/
@Override
@DataScope(agentAlias = "a",userAlias = "u")
@DataScope(merchantAlias = "m")
public List<EFeeRule> selectRlFeeRuleList(EFeeRule rlFeeRule)
{
return rlFeeRuleMapper.selectRlFeeRuleList(rlFeeRule);

View File

@ -1,5 +1,6 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.EFunction;
import com.ruoyi.system.domain.device.EDevice;
@ -66,7 +67,7 @@ public class EModelServiceImpl implements IEModelService
* @return 车辆型号
*/
@Override
// @DataScope(deptAlias = "d")
@DataScope(merchantAlias = "m")
public List<EModelVO> selectEModelList(EModel eModel)
{
return eModelMapper.selectEModelList(eModel);

View File

@ -54,7 +54,7 @@ public class EOperatingAreaServiceImpl implements IEOperatingAreaService
* @return 运营区
*/
@Override
@DataScope(agentAlias = "a",userAlias = "u")
@DataScope(merchantAlias = "m", userAlias = "u")
public List<EOperatingArea> selectRlOperatingAreaList(EOperatingArea rlOperatingArea)
{
return rlOperatingAreaMapper.selectRlOperatingAreaList(rlOperatingArea);

View File

@ -252,7 +252,7 @@ public class EOrderServiceImpl implements IEOrderService
* @return 订单
*/
@Override
// @DataScope(userAlias = "u")
@DataScope(merchantAlias = "m", userAlias = "u")
public List<EOrderVO> selectRlOrderList(EOrderQuery rlOrder)
{
return orderMapper.selectRlOrderList(rlOrder);

View File

@ -79,8 +79,8 @@ public class ERefundServiceImpl implements IERefundService
* @param rlRefund 退款订单
* @return 退款订单
*/
@DataScope(agentAlias = "a")
@Override
@DataScope(merchantAlias = "m", userAlias = "u")
public List<ERefund> selectEtRefundListWithIsolate(ERefund rlRefund)
{
return etRefundMapper.selectEtRefundList(rlRefund);

View File

@ -4,6 +4,7 @@ import java.util.Collections;
import java.util.List;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.ServiceConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -44,6 +45,7 @@ public class EShareKeyServiceImpl implements IEShareKeyService
* @return 共享钥匙
*/
@Override
@DataScope(merchantAlias = "m", userAlias = "u")
public List<EShareKey> selectEShareKeyList(EShareKey eShareKey)
{
return eShareKeyMapper.selectEShareKeyList(eShareKey);

View File

@ -131,7 +131,7 @@ public class EUserServiceImpl implements IEUserService{
* @return 用户信息集合信息
*/
@Override
@DataScope(agentAlias = "a",userAlias = "u")
@DataScope(userAlias = "u")
public List<EUserVO> selectUserList(EUserQuery user)
{
/** 获取设备绑定数量*/
@ -158,7 +158,7 @@ public class EUserServiceImpl implements IEUserService{
* @return 用户信息集合信息
*/
@Override
// @DataScope(deptAlias = "d", userAlias = "u")
@DataScope(userAlias = "u")
public List<EUser> selectAllocatedList(EUser user)
{
return userMapper.selectAllocatedList(user);

View File

@ -43,7 +43,7 @@ public class EWithdrawServiceImpl implements IEWithdrawService
* @return 提现记录
*/
@Override
@DataScope(userAlias = "u",onlyUser = "1")
@DataScope(merchantAlias = "u")
public List<EWithdraw> selectRlWithdrawList(EWithdraw rlWithdraw)
{
return rlWithdrawMapper.selectRlWithdrawList(rlWithdraw);

View File

@ -43,7 +43,7 @@ public class SysDeptServiceImpl implements ISysDeptService
* @return 部门信息集合
*/
@Override
@DataScope(agentAlias = "d")
@DataScope(userAlias = "u")
public List<SysDept> selectDeptList(SysDept dept)
{
return deptMapper.selectDeptList(dept);

View File

@ -54,7 +54,7 @@ public class SysRoleServiceImpl implements ISysRoleService
* @return 角色数据集合信息
*/
@Override
@DataScope(agentAlias = "d")
@DataScope(userAlias = "u")
public List<SysRole> selectRoleList(SysRole role)
{
return roleMapper.selectRoleList(role);

View File

@ -101,6 +101,7 @@ public class WxPayService implements IWxPayService {
order1.setOrderId(order.getOrderId());
order1.setPayChannel(payChannel);
order1.setChannelName(channelVO.getName());
int updateEtOrder = orderService.updateRlOrder(order1);
if(updateEtOrder == 0){
throw new ServiceException("更新订单outTradeNo失败");

View File

@ -7,9 +7,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="EAccessoryVO" id="RlAccessoryResult" autoMapping="true" />
<sql id="selectRlAccessoryVo">
select a.accessory_id, a.name, a.status, a.create_by, a.create_time, a.update_time, m.model from e_accessory a
select a.accessory_id, a.name, a.status, a.create_by, a.create_time, a.update_time, mo.model,a.merchant_id from e_accessory a
left join e_model_accessory ma on a.accessory_id = ma.accessory_id
left join e_model m on m.model_id = ma.model_id
left join e_model mo on mo.model_id = ma.model_id
left join e_user m on m.user_id = a.merchant_id
</sql>
<select id="selectRlAccessoryList" parameterType="EAccessory" resultMap="RlAccessoryResult">
@ -55,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="merchantId != null">merchant_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="accessoryId != null">#{accessoryId},</if>
@ -63,6 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="merchantId != null">#{merchantId},</if>
</trim>
</insert>

View File

@ -38,6 +38,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
de.update_time, de.last_time, de.last_location_time, de.gps, de.remark, de.status, de.lock_status, de.location,
de.remaining_power, de.voltage, de.version, de.qrcode, de.longitude, de.latitude, de.signal_strength, de.satellites, de.quality from e_device de
left join e_hardware_version hv on hv.id = de.hardware_version_id
left join e_user u on u.user_id = de.user_id
left join e_user m on m.user_id = de.user_id
where 1 = 1
<if test="deviceName != null and deviceName != ''"> and de.device_name like concat('%', #{deviceName}, '%')</if>
<if test="mac != null and mac != ''"> and de.mac like concat('%', #{mac}, '%')</if>

View File

@ -7,13 +7,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="EFeeRuleVO" id="RlFeeRuleResult" autoMapping="true" />
<sql id="selectRlFeeRuleVo">
select r.rule_id, r.rental_unit, r.price, r.`explain`, r.instructions, r.out_unit, r.out_price ,r.agent_id from e_fee_rule r
select r.rule_id, r.rental_unit, r.price, r.`explain`, r.instructions, r.out_unit, r.out_price ,r.merchant_id from e_fee_rule r
left join e_fee_rule mr on mr.rule_id = r.rule_id
</sql>
<select id="selectRlFeeRuleList" parameterType="EFeeRule" resultMap="RlFeeRuleResult">
select r.rule_id, r.rental_unit, r.price, r.`explain`, r.instructions, r.out_unit, r.out_price, r.agent_id from e_fee_rule r
where del_flag = '0'
select r.rule_id, r.rental_unit, r.price, r.`explain`, r.instructions, r.out_unit, r.out_price, r.merchant_id from e_fee_rule r
left join e_user m on m.user_id = r.merchant_id
where r.del_flag = '0'
<if test="rentalUnit != null and rentalUnit != ''"> and r.rental_unit = #{rentalUnit}</if>
<if test="price != null "> and r.price = #{price}</if>
<if test="explain != null and explain != ''"> and r.`explain` = #{explain}</if>
@ -50,6 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="instructions != null">instructions,</if>
<if test="outUnit != null">out_unit,</if>
<if test="outPrice != null">out_price,</if>
<if test="merchantId != null">merchant_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="rentalUnit != null">#{rentalUnit},</if>
@ -58,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="instructions != null">#{instructions},</if>
<if test="outUnit != null">#{outUnit},</if>
<if test="outPrice != null">#{outPrice},</if>
<if test="merchantId != null">#{merchantId},</if>
</trim>
</insert>
@ -71,6 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="outUnit != null">out_unit = #{outUnit},</if>
<if test="outPrice != null">out_price = #{outPrice},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="merchantId != null">merchant_id = #{merchantId},</if>
</trim>
where rule_id = #{ruleId}
</update>

View File

@ -8,40 +8,43 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectEModelVo">
select model_id, model, brand_id, brand_name, full_voltage, low_voltage, full_endurance, create_by, create_time,
update_by, update_time, remark, intro, deposit, picture, del_flag from e_model
update_by, update_time, remark, intro, deposit, merchant_id, picture, del_flag from e_model
</sql>
<select id="selectEModelList" parameterType="EModel" resultMap="EModelResult">
select
m.model_id,
m.model,
m.brand_id,
m.brand_name,
m.full_voltage,
m.low_voltage,
m.full_endurance,
m.create_by,
m.create_time,
m.update_by,
m.update_time,
m.remark,
m.intro,
m.deposit,
m.picture,
m.del_flag from e_model m
where 1 = 1 and m.del_flag = '0'
<if test="model != null and model != ''"> and m.model = #{model}</if>
<if test="brandId != null and brandId != ''"> and m.brand_id = #{brandId}</if>
<if test="brandName != null and brandName != ''"> and m.brand_name like concat('%', #{brandName}, '%')</if>
<!-- 数据范围过滤 <if test="operator != null and operator != ''"> and m.operator = #{operator}</if> -->
mo.model_id,
mo.model,
mo.brand_id,
mo.brand_name,
mo.full_voltage,
mo.low_voltage,
mo.full_endurance,
mo.create_by,
mo.create_time,
mo.update_by,
mo.update_time,
mo.remark,
mo.intro,
mo.deposit,
mo.merchant_id,
mo.picture,
mo.del_flag from e_model mo
left join e_user m on m.user_id = mo.merchant_id
where 1 = 1 and mo.del_flag = '0'
<if test="model != null and model != ''"> and mo.model = #{model}</if>
<if test="brandId != null and brandId != ''"> and mo.brand_id = #{brandId}</if>
<if test="brandName != null and brandName != ''"> and mo.brand_name like concat('%', #{brandName}, '%')</if>
<!-- 数据范围过滤 <if test="operator != null and operator != ''"> and mo.operator = #{operator}</if> -->
${params.dataScope}
order by mo.create_time desc
</select>
<select id="selectEModelByModelId" parameterType="Long" resultMap="EModelResult">
select m.model_id, m.model, m.brand_id, m.brand_name, m.brand_name, m.full_voltage, m.low_voltage,
m.full_endurance, m.create_by, m.create_time,m.deposit,m.picture,
m.update_by, m.update_time, m.remark from e_model m
where m.model_id = #{modelId}
select mo.model_id, mo.model, mo.brand_id, mo.brand_name, mo.brand_name, mo.full_voltage, mo.low_voltage,
mo.full_endurance, mo.create_by, mo.create_time,mo.deposit,mo.picture,
mo.update_by, mo.update_time, mo.remark from e_model m
where mo.model_id = #{modelId}
</select>
<select id="selectAllCount" resultType="java.lang.Integer">
@ -65,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">remark,</if>
<if test="intro != null">intro,</if>
<if test="deposit != null">deposit,</if>
<if test="merchantId != null">merchant_id,</if>
<if test="picture != null">picture,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
@ -83,6 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">#{remark},</if>
<if test="intro != null">#{intro},</if>
<if test="deposit != null">#{deposit},</if>
<if test="merchantId != null">#{merchantId},</if>
<if test="picture != null">#{picture},</if>
<if test="delFlag != null">#{delFlag},</if>
</trim>
@ -106,6 +111,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deposit != null">deposit = #{deposit},</if>
<if test="picture != null">picture = #{picture},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="merchantId != null">merchant_id = #{merchantId},</if>
</trim>
where model_id = #{modelId}
</update>

View File

@ -8,7 +8,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectRlOperatingAreaVo">
select oa.area_id, oa.area_name, oa.boundary_str, oa.longitude, oa.latitude, oa.create_by, oa.create_time, oa.status, oa.area_time, oa.area_out_outage,
oa.area_out_dispatch, oa.agreement, oa.area_time_start, oa.area_time_end from e_operating_area oa
oa.area_out_dispatch, oa.agreement, oa.area_time_start, oa.area_time_end, oa.e_user_id from e_operating_area oa
left join e_user m on m.user_id = oa.merchant_id
</sql>
<select id="selectRlOperatingAreaList" parameterType="EOperatingArea" resultMap="RlOperatingAreaResult">

View File

@ -9,7 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectRlOrderVo">
select order_id, order_no, out_trade_no, user_id, user_name, real_name, phone, rule_id, device_mac, sn, pay_time, pay_type, paid, type, total_fee, pay_fee, deposit, overdue_fee, dispatch_fee,delivery_fee,
lease_fee, mark, duration, status, create_time, return_time, deposit_deduction, deposit_order_no, deduction_amount, used_sn, change_reason,
auto_refund_deposit, rental_unit, handling_charge, platform_service_fee, operator_dividend, pay_channel, delivery_method, pickup_time,
auto_refund_deposit, rental_unit, handling_charge, platform_service_fee, operator_dividend, pay_channel, channel_name, delivery_method, pickup_time,
, store_name, merchant_id, pickup_city, pickup_loc, pickup_lon, pickup_lat, model_id, model, expiry_time, original_order_no, num, price, `explain`,
instructions, out_unit, out_price,return_type,return_method,return_address,auto_cancel_time,cost, is_overdue,is_send_msg from e_order
</sql>
@ -55,6 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
o.platform_service_fee,
o.operator_dividend,
o.pay_channel,
o.channel_name,
o.delivery_method,
o.pickup_time,
o.store_id,
@ -72,7 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
o.out_unit,
o.out_price,
u.user_name as userName,
m.model,
mo.model,
r.rental_unit as rentalUnit,
o.return_type,
o.return_method,
@ -106,8 +107,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM
e_order o
left join e_user u on o.user_id = u.user_id
left join e_user m on o.merchant_id = m.user_id
left join e_fee_rule r on o.rule_id = r.rule_id
left join e_model m on o.model_id = m.model_id
left join e_model mo on o.model_id = mo.model_id
</sql>
<select id="selectRlOrderList" parameterType="EOrderQuery" resultMap="RlOrderResult">
@ -406,6 +408,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="platformServiceFee != null">platform_service_fee = #{platformServiceFee},</if>
<if test="operatorDividend != null">operator_dividend = #{operatorDividend},</if>
<if test="payChannel != null">pay_channel = #{payChannel},</if>
<if test="channelName != null">channel_name = #{channelName},</if>
<if test="deliveryMethod != null">delivery_method = #{deliveryMethod},</if>
<if test="pickupTime != null">pickup_time = #{pickupTime},</if>
<if test="storeId != null">store_id = #{storeId},</if>
@ -477,6 +480,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="platformServiceFee != null">platform_service_fee = #{platformServiceFee},</if>
<if test="operatorDividend != null">operator_dividend = #{operatorDividend},</if>
<if test="payChannel != null">pay_channel = #{payChannel},</if>
<if test="channelName != null">channel_name = #{channelName},</if>
<if test="deliveryMethod != null">delivery_method = #{deliveryMethod},</if>
<if test="pickupTime != null">pickup_time = #{pickupTime},</if>
<if test="storeId != null">store_id = #{storeId},</if>

View File

@ -7,17 +7,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="ERefundVO" id="EtRefundResult" autoMapping="true" />
<sql id="selectEtRefundVo">
select id, refund_no, order_no, user_id, amount, dispatch_fee, delivery_fee, lease_fee, deposit, type, reason, create_time, item_desc,refund_result from e_refund
select id, refund_no, order_no, user_id, amount, dispatch_fee, delivery_fee, lease_fee, deposit, type, reason, create_time, item_desc,refund_result, merchant_id from e_refund
</sql>
<select id="selectEtRefundList" parameterType="ERefund" resultMap="EtRefundResult">
select r.id, r.refund_no, r.order_no, r.user_id, u.user_name userName, r.amount, r.dispatch_fee, r.delivery_fee,
r.lease_fee, r.deposit, r.type, r.reason, r.create_time, r.item_desc,r.refund_result from e_refund r
r.lease_fee, r.deposit, r.type, r.reason, r.create_time, r.item_desc,r.refund_result,r.merchant_id from e_refund r
INNER JOIN e_order o on o.order_no = r.order_no
left join e_user u on u.user_id = r.user_id
-- LEFT JOIN e_operating_area oa ON o.area_id = oa.area_id
-- LEFT join et_area_dept ad on ad.area_id = oa.area_id
-- LEFT join sys_dept d on d.dept_id = ad.dept_id
left join e_user m on m.user_id = r.merchant_id
where 1 = 1
<if test="refundNo != null and refundNo != ''"> and r.refund_no = #{refundNo}</if>
<if test="orderNo != null and orderNo != ''"> and r.order_no like concat('%', #{orderNo}, '%')</if>
@ -65,6 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">create_time,</if>
<if test="itemDesc != null">item_desc,</if>
<if test="refundResult != null">refund_result,</if>
<if test="merchantId != null">merchant_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
@ -81,6 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">#{createTime},</if>
<if test="itemDesc != null">#{itemDesc},</if>
<if test="refundResult != null">#{refund_result},</if>
<if test="merchantId != null">#{merchantId},</if>
</trim>
</insert>
@ -100,6 +100,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">create_time = #{createTime},</if>
<if test="itemDesc != null">item_desc = #{itemDesc},</if>
<if test="refundResult != null">refund_result = #{refundResult},</if>
<if test="merchantId != null">merchant_id = #{merchantId},</if>
</trim>
where id = #{id}
</update>
@ -117,6 +118,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">create_time = #{createTime},</if>
<if test="itemDesc != null">item_desc = #{itemDesc},</if>
<if test="refundResult != null">refund_result = #{refundResult},</if>
<if test="merchantId != null">merchant_id = #{merchantId},</if>
</trim>
where refund_no = #{refundNo}
</update>

View File

@ -23,7 +23,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql>
<select id="selectEShareKeyList" parameterType="EShareKey" resultMap="EShareKeyResult">
select k.key_id, k.key_name, k.share_id, k.share_phone, k.share_user_name, k.owner_id, k.owner_name, k.owner_phone, k.sn, k.status, k.expiration_time from e_share_key k
select k.key_id, k.key_name, k.share_id, k.share_phone, k.share_user_name, k.owner_id, k.owner_name, k.owner_phone,
k.sn, k.status, k.expiration_time from e_share_key k
left join e_user u on u.user_id = k.share_id
left join e_user m on m.user_id = k.owner_id
where 1=1 and k.del_flag = '0'
<if test="keyName != null and keyName != ''"> and k.key_name like concat('%', #{keyName}, '%')</if>
<if test="shareUserName != null "> and k.share_user_name like concat('%', #{shareUserName}, '%')</if>
@ -32,6 +35,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ownerName != null "> and k.owner_name like concat('%', #{ownerName}, '%')</if>
<if test="sn != null and sn != ''"> and k.sn like concat('%', #{sn}, '%')</if>
<if test="status != null and status != ''"> and k.status = #{status}</if>
<!-- 数据范围过滤 -->
${params.dataScope}
order by k.key_id desc
</select>
<select id="selectEShareKeyByKeyId" parameterType="Long" resultMap="EShareKeyResult">

View File

@ -21,12 +21,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectDeptVo">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
from sys_dept d
</sql>
<select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
<include refid="selectDeptVo"/>
where d.del_flag = '0'
@ -46,7 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
${params.dataScope}
order by d.parent_id, d.order_num
</select>
<select id="selectDeptListByRoleId" resultType="Long">
select d.dept_id
from sys_dept d
@ -57,36 +57,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
order by d.parent_id, d.order_num
</select>
<select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
from sys_dept d
where d.dept_id = #{deptId}
</select>
<select id="checkDeptExistUser" parameterType="Long" resultType="int">
select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0'
select count(1) from e_user where dept_id = #{deptId} and del_flag = '0'
</select>
<select id="hasChildByDeptId" parameterType="Long" resultType="int">
select count(1) from sys_dept
where del_flag = '0' and parent_id = #{deptId} limit 1
</select>
<select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
select * from sys_dept where find_in_set(#{deptId}, ancestors)
</select>
<select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors)
</select>
<select id="checkDeptNameUnique" resultMap="SysDeptResult">
<include refid="selectDeptVo"/>
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
</select>
<insert id="insertDept" parameterType="SysDept">
insert into sys_dept(
<if test="deptId != null and deptId != 0">dept_id,</if>
@ -114,7 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sysdate()
)
</insert>
<update id="updateDept" parameterType="SysDept">
update sys_dept
<set>
@ -131,7 +131,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</set>
where dept_id = #{deptId}
</update>
<update id="updateDeptChildren" parameterType="java.util.List">
update sys_dept set ancestors =
<foreach collection="depts" item="item" index="index"
@ -144,16 +144,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item.deptId}
</foreach>
</update>
<update id="updateDeptStatusNormal" parameterType="Long">
update sys_dept set status = '0' where dept_id in
update sys_dept set status = '0' where dept_id in
<foreach collection="array" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
</update>
<delete id="deleteDeptById" parameterType="Long">
update sys_dept set del_flag = '2' where dept_id = #{deptId}
</delete>
</mapper>
</mapper>

View File

@ -29,10 +29,10 @@
</resultMap>
<sql id="selectMenuVo">
select menu_id, menu_name, parent_id, order_num, path, component, `query`, route_name, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time
select menu_id, menu_name, parent_id, order_num, path, component, `query`, route_name, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time
from sys_menu
</sql>
<select id="selectMenuList" parameterType="SysMenu" resultMap="SysMenuResult">
<include refid="selectMenuVo"/>
<where>
@ -48,13 +48,13 @@
</where>
order by parent_id, order_num
</select>
<select id="selectMenuTreeAll" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.route_name, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu m where m.menu_type in ('M', 'C') and m.status = 0
order by m.parent_id, m.order_num
</select>
<select id="selectMenuListByUserId" parameterType="SysMenu" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.route_name, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu m
@ -73,18 +73,18 @@
</if>
order by m.parent_id, m.order_num
</select>
<select id="selectMenuTreeByUserId" parameterType="Long" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.route_name, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu m
left join sys_role_menu rm on m.menu_id = rm.menu_id
left join sys_user_role ur on rm.role_id = ur.role_id
left join sys_role ro on ur.role_id = ro.role_id
left join sys_user u on ur.user_id = u.user_id
left join e_user u on ur.user_id = u.user_id
where u.user_id = #{userId} and m.menu_type in ('M', 'C') and m.status = 0 AND ro.status = 0
order by m.parent_id, m.order_num
</select>
<select id="selectMenuListByRoleId" resultType="Long">
select m.menu_id
from sys_menu m
@ -95,7 +95,7 @@
</if>
order by m.parent_id, m.order_num
</select>
<select id="selectMenuPerms" resultType="String">
select distinct m.perms
from sys_menu m
@ -111,28 +111,28 @@
left join sys_role r on r.role_id = ur.role_id
where m.status = '0' and r.status = '0' and ur.user_id = #{userId}
</select>
<select id="selectMenuPermsByRoleId" parameterType="Long" resultType="String">
select distinct m.perms
from sys_menu m
left join sys_role_menu rm on m.menu_id = rm.menu_id
where m.status = '0' and rm.role_id = #{roleId}
</select>
<select id="selectMenuById" parameterType="Long" resultMap="SysMenuResult">
<include refid="selectMenuVo"/>
where menu_id = #{menuId}
</select>
<select id="hasChildByMenuId" resultType="Integer">
select count(1) from sys_menu where parent_id = #{menuId}
select count(1) from sys_menu where parent_id = #{menuId}
</select>
<select id="checkMenuNameUnique" parameterType="SysMenu" resultMap="SysMenuResult">
<include refid="selectMenuVo"/>
where menu_name=#{menuName} and parent_id = #{parentId} limit 1
</select>
<update id="updateMenu" parameterType="SysMenu">
update sys_menu
<set>
@ -198,9 +198,9 @@
sysdate()
)
</insert>
<delete id="deleteMenuById" parameterType="Long">
delete from sys_menu where menu_id = #{menuId}
</delete>
</mapper>
</mapper>

View File

@ -16,12 +16,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectPostVo">
select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark
select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark
from sys_post
</sql>
<select id="selectPostList" parameterType="SysPost" resultMap="SysPostResult">
<include refid="selectPostVo"/>
<where>
@ -36,42 +36,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</where>
</select>
<select id="selectPostAll" resultMap="SysPostResult">
<include refid="selectPostVo"/>
</select>
<select id="selectPostById" parameterType="Long" resultMap="SysPostResult">
<include refid="selectPostVo"/>
where post_id = #{postId}
</select>
<select id="selectPostListByUserId" parameterType="Long" resultType="Long">
select p.post_id
from sys_post p
left join sys_user_post up on up.post_id = p.post_id
left join sys_user u on u.user_id = up.user_id
left join e_user u on u.user_id = up.user_id
where u.user_id = #{userId}
</select>
<select id="selectPostsByUserName" parameterType="String" resultMap="SysPostResult">
select p.post_id, p.post_name, p.post_code
from sys_post p
left join sys_user_post up on up.post_id = p.post_id
left join sys_user u on u.user_id = up.user_id
left join e_user u on u.user_id = up.user_id
where u.user_name = #{userName}
</select>
<select id="checkPostNameUnique" parameterType="String" resultMap="SysPostResult">
<include refid="selectPostVo"/>
where post_name=#{postName} limit 1
</select>
<select id="checkPostCodeUnique" parameterType="String" resultMap="SysPostResult">
<include refid="selectPostVo"/>
where post_code=#{postCode} limit 1
</select>
<update id="updatePost" parameterType="SysPost">
update sys_post
<set>
@ -85,7 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</set>
where post_id = #{postId}
</update>
<insert id="insertPost" parameterType="SysPost" useGeneratedKeys="true" keyProperty="postId">
insert into sys_post(
<if test="postId != null and postId != 0">post_id,</if>
@ -107,16 +107,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sysdate()
)
</insert>
<delete id="deletePostById" parameterType="Long">
delete from sys_post where post_id = #{postId}
</delete>
<delete id="deletePostByIds" parameterType="Long">
delete from sys_post where post_id in
<foreach collection="array" item="postId" open="(" separator="," close=")">
#{postId}
</foreach>
</foreach>
</delete>
</mapper>
</mapper>

View File

@ -20,16 +20,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectRoleVo">
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
r.status, r.del_flag, r.create_time, r.remark
r.status, r.del_flag, r.create_time, r.remark
from sys_role r
left join sys_user_role ur on ur.role_id = r.role_id
left join sys_user u on u.user_id = ur.user_id
left join sys_dept d on u.dept_id = d.dept_id
left join e_user u on u.user_id = ur.user_id
</sql>
<select id="selectRoleList" parameterType="SysRole" resultMap="SysRoleResult">
<include refid="selectRoleVo"/>
where r.del_flag = '0'
@ -55,44 +54,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
${params.dataScope}
order by r.role_sort
</select>
<select id="selectRolePermissionByUserId" parameterType="Long" resultMap="SysRoleResult">
<include refid="selectRoleVo"/>
WHERE r.del_flag = '0' and ur.user_id = #{userId}
</select>
<select id="selectRoleAll" resultMap="SysRoleResult">
<include refid="selectRoleVo"/>
</select>
<select id="selectRoleListByUserId" parameterType="Long" resultType="Long">
select r.role_id
from sys_role r
left join sys_user_role ur on ur.role_id = r.role_id
left join sys_user u on u.user_id = ur.user_id
left join e_user u on u.user_id = ur.user_id
where u.user_id = #{userId}
</select>
<select id="selectRoleById" parameterType="Long" resultMap="SysRoleResult">
<include refid="selectRoleVo"/>
where r.role_id = #{roleId}
</select>
<select id="selectRolesByUserName" parameterType="String" resultMap="SysRoleResult">
<include refid="selectRoleVo"/>
WHERE r.del_flag = '0' and u.user_name = #{userName}
</select>
<select id="checkRoleNameUnique" parameterType="String" resultMap="SysRoleResult">
<include refid="selectRoleVo"/>
where r.role_name=#{roleName} and r.del_flag = '0' limit 1
</select>
<select id="checkRoleKeyUnique" parameterType="String" resultMap="SysRoleResult">
<include refid="selectRoleVo"/>
where r.role_key=#{roleKey} and r.del_flag = '0' limit 1
</select>
<insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId">
insert into sys_role(
<if test="roleId != null and roleId != 0">role_id,</if>
@ -120,7 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sysdate()
)
</insert>
<update id="updateRole" parameterType="SysRole">
update sys_role
<set>
@ -137,16 +136,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</set>
where role_id = #{roleId}
</update>
<delete id="deleteRoleById" parameterType="Long">
update sys_role set del_flag = '2' where role_id = #{roleId}
</delete>
<delete id="deleteRoleByIds" parameterType="Long">
update sys_role set del_flag = '2' where role_id in
<foreach collection="array" item="roleId" open="(" separator="," close=")">
#{roleId}
</foreach>
</foreach>
</delete>
</mapper>
</mapper>

View File

@ -12,23 +12,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<delete id="deleteUserPostByUserId" parameterType="Long">
delete from sys_user_post where user_id=#{userId}
</delete>
<select id="countUserPostById" resultType="Integer">
select count(1) from sys_user_post where post_id=#{postId}
select count(1) from sys_user_post where post_id=#{postId}
</select>
<delete id="deleteUserPost" parameterType="Long">
delete from sys_user_post where user_id in
<foreach collection="array" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</foreach>
</delete>
<insert id="batchUserPost">
insert into sys_user_post(user_id, post_id) values
<foreach item="item" index="index" collection="list" separator=",">
(#{item.userId},#{item.postId})
</foreach>
</insert>
</mapper>
</mapper>

View File

@ -12,33 +12,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<delete id="deleteUserRoleByUserId" parameterType="Long">
delete from sys_user_role where user_id=#{userId}
</delete>
<select id="countUserRoleByRoleId" resultType="Integer">
select count(1) from sys_user_role where role_id=#{roleId}
select count(1) from sys_user_role where role_id=#{roleId}
</select>
<delete id="deleteUserRole" parameterType="Long">
delete from sys_user_role where user_id in
<foreach collection="array" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</foreach>
</delete>
<insert id="batchUserRole">
insert into sys_user_role(user_id, role_id) values
<foreach item="item" index="index" collection="list" separator=",">
(#{item.userId},#{item.roleId})
</foreach>
</insert>
<delete id="deleteUserRoleInfo" parameterType="SysUserRole">
delete from sys_user_role where user_id=#{userId} and role_id=#{roleId}
</delete>
<delete id="deleteUserRoleInfos">
delete from sys_user_role where role_id=#{roleId} and user_id in
<foreach collection="userIds" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</foreach>
</delete>
</mapper>
</mapper>

View File

@ -698,4 +698,4 @@ create table gen_table_column (
update_by varchar(64) default '' comment '更新者',
update_time datetime comment '更新时间',
primary key (column_id)
) engine=innodb auto_increment=1 comment = '代码生成业务表字段';
) engine=innodb auto_increment=1 comment = '代码生成业务表字段';