Browse Source

[用户数据权限][修改][相关业务逻辑]

release_toaliyun_real
gongbiao 6 years ago
parent
commit
52f4b4b93e
18 changed files with 609 additions and 2 deletions
  1. +14
    -0
      mallinkAdmin/src/main/java/com/iformall/annotation/UserDataRuleAnnotation.java
  2. +3
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java
  3. +57
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/sys/WxDataRuleTargetController.java
  4. +48
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/sys/WxUserDataRuleController.java
  5. +102
    -0
      mallinkAdmin/src/main/java/com/iformall/log/UserDataRuleAspect.java
  6. +6
    -0
      mallinkService/src/main/java/com/iformall/domain/po/BaseEntity.java
  7. +41
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxDataRuleTarget.java
  8. +1
    -2
      mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java
  9. +41
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxUserDataRule.java
  10. +16
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxDataRuleTargetMapper.java
  11. +16
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxUserDataRuleMapper.java
  12. +34
    -0
      mallinkService/src/main/java/com/iformall/service/WxDataRuleTargetService.java
  13. +14
    -0
      mallinkService/src/main/java/com/iformall/service/WxUserDataRuleService.java
  14. +48
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxDataRuleTargetServiceImpl.java
  15. +45
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxUserDataRuleServiceImpl.java
  16. +53
    -0
      mallinkService/src/main/resources/mapper/WxDataRuleTargetMapper.xml
  17. +15
    -0
      mallinkService/src/main/resources/mapper/WxMerchantMapper.xml
  18. +55
    -0
      mallinkService/src/main/resources/mapper/WxUserDataRuleMapper.xml

+ 14
- 0
mallinkAdmin/src/main/java/com/iformall/annotation/UserDataRuleAnnotation.java View File

@@ -0,0 +1,14 @@
package com.iformall.annotation;

import java.lang.annotation.*;

/**
* @author gongbiao
*/
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface UserDataRuleAnnotation {

String value() default "";
}

+ 3
- 0
mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java View File

@@ -2,6 +2,7 @@ package com.iformall.controller.basic;

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.UserDataRuleAnnotation;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
@@ -18,6 +19,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@@ -37,6 +39,7 @@ public class WxMerchantController extends BaseController {
private QrCodeService qrCodeService;


@UserDataRuleAnnotation("merchant_list")
@ApiOperation("分页列表接口")
@GetMapping("listVo")
@ApiImplicitParams({


+ 57
- 0
mallinkAdmin/src/main/java/com/iformall/controller/sys/WxDataRuleTargetController.java View File

@@ -0,0 +1,57 @@
package com.iformall.controller.sys;


import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxDataRuleTarget;
import com.iformall.service.WxDataRuleTargetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
* @author gongbiao
*/
@RestController
@RequestMapping("wxDataRuleTarget")
@Api(description = "数据权限目标")
public class WxDataRuleTargetController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxDataRuleTargetService wxDataRuleTargetService;

@ApiOperation("列表接口")
@GetMapping("list")
@SystemControllerLog(description = "数据权限目标-列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxDataRuleTarget wxDataRuleTarget, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] wxDataRuleTarget::list");
final PageInfo<WxDataRuleTarget> page = wxDataRuleTargetService.listAsPage(wxDataRuleTarget, pageNum, pageSize);
return new ResultData(page);
}


@ApiOperation("获取全部")
@GetMapping("getList")
@SystemControllerLog(description = "数据权限目标-获取全部")
public ResultData getList() {
logger.debug("[" + getIpAddr() + "] wxDataRuleTarget::getList");
List<WxDataRuleTarget> datalist = wxDataRuleTargetService.getList();
return new ResultData(datalist);
}
}

+ 48
- 0
mallinkAdmin/src/main/java/com/iformall/controller/sys/WxUserDataRuleController.java View File

@@ -0,0 +1,48 @@
package com.iformall.controller.sys;


import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxUserDataRule;
import com.iformall.service.WxUserDataRuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
* @author gongbiao
*/
@RestController
@RequestMapping("wxUserDataRule")
@Api(description = "用户数据权限")
public class WxUserDataRuleController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxUserDataRuleService wxUserDataRuleService;

@ApiOperation("编辑")
@PostMapping("/modify")
@SystemControllerLog(description = "用户数据权限-新增")
public ResultData modify(@RequestBody WxUserDataRule wxUserDataRule) {
logger.debug("[" + getIpAddr() + "] wxDataRuleTarget::modify");
wxUserDataRuleService.modify(wxUserDataRule);
return new ResultData();
}

@ApiOperation("根据用户ID查看")
@GetMapping("/findByUserId")
@ApiImplicitParam(name = "userId", value = "userId", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "用户数据权限-根据用户ID查看")
public ResultData findByUserId(Long userId) {
logger.debug("[" + getIpAddr() + "] wxDataRuleTarget::modify");
WxUserDataRule wxUserDataRule = wxUserDataRuleService.findByUserId(userId);
return new ResultData(wxUserDataRule);
}

}

+ 102
- 0
mallinkAdmin/src/main/java/com/iformall/log/UserDataRuleAspect.java View File

@@ -0,0 +1,102 @@
package com.iformall.log;


import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.iformall.annotation.UserDataRuleAnnotation;
import com.iformall.domain.po.BaseEntity;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxUserDataRule;
import com.iformall.service.WxUserDataRuleService;
import com.iformall.shiro.UserSession;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.stream.Collectors;

/**
* @author gongbiao
*/
@Aspect
@Component
public class UserDataRuleAspect {
private static final Logger logger = LoggerFactory.getLogger(UserDataRuleAspect.class);

@Autowired
private WxUserDataRuleService wxUserDataRuleService;

@Pointcut("@annotation(com.iformall.annotation.UserDataRuleAnnotation)")
public void userDataRulePointcut() {
}

@Before("userDataRulePointcut()")
public void doBefore(JoinPoint joinPoint) {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
MallUserInfo user = (MallUserInfo) request.getSession().getAttribute(UserSession.userInfo);
if (user == null) {
logger.error("session 获取 user 失败");
return;
}

//得到用户的数据权限
WxUserDataRule byUserId = wxUserDataRuleService.findByUserId(user.getId());
if (byUserId == null) {
logger.info("用户的数据权限未配置");
return;
}
String buildingFloor = byUserId.getBuildingFloor();
if (StringUtils.isNotEmpty(buildingFloor)) {
buildingFloor = JSONObject.parseObject(buildingFloor).getJSONArray("data").stream()
.map(m -> {
JSONObject jsonObject = JSONObject.parseObject(String.valueOf(m));
return jsonObject.getString("floor");
}).collect(Collectors.joining(","));
}

String businessForRule = byUserId.getBusinessForRule();
if (StringUtils.isNotEmpty(businessForRule)) {
Object[] data = JSONObject.parseObject(businessForRule).getJSONArray("data").toArray();
businessForRule = StringUtils.join(data, ",");
}

HashSet<String> targetSet = new HashSet();
String target = byUserId.getTarget();
if (StringUtils.isNotEmpty(target)) {
JSONArray objects = JSONArray.parseArray(target);
for (int i = 0; i < objects.size(); i++) {
JSONObject jsonObject = objects.getJSONObject(i);
JSONArray children = jsonObject.getJSONArray("children");
for (int j = 0; j < children.size(); j++) {
targetSet.add(children.getJSONObject(i).getString("tag"));
}
}
}

//得到注释的名称
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
//判断tag是否在用户权限中 如果存在加入参数查询
Method method = signature.getMethod();
String value = method.getAnnotation(UserDataRuleAnnotation.class).value();
if (targetSet.contains(value)) {
//得到方法的参数
Object[] args = joinPoint.getArgs();
BaseEntity baseEntity = (BaseEntity) args[0];
baseEntity.setFloorForRule(buildingFloor);
baseEntity.setBusinessForRule(businessForRule);
}
}

}

+ 6
- 0
mallinkService/src/main/java/com/iformall/domain/po/BaseEntity.java View File

@@ -30,6 +30,12 @@ public class BaseEntity implements Serializable {
@Transient
private String sortColumns;

@Transient
protected String floorForRule;

@Transient
protected String businessForRule;


public String getSortColumns() {
if(StringUtils.isBlank(sortColumn)){


+ 41
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxDataRuleTarget.java View File

@@ -0,0 +1,41 @@
package com.iformall.domain.po;

import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;

/**
* @author gongbiao
*/
@Table(name = "wx_data_rule_target")
@Data
@EqualsAndHashCode(callSuper = true)
public class WxDataRuleTarget extends BaseEntity {
private static final long serialVersionUID = 1L;

@Id
protected Long id;

@Transient
protected List<String> ids;

@io.swagger.annotations.ApiModelProperty(value = "父级ID", name = "parent")
private Long parent;
@io.swagger.annotations.ApiModelProperty(value = "用户ID", name = "name")
private String name;
@io.swagger.annotations.ApiModelProperty(value = "标签", name = "tag")
private String tag;
@io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createTime")
private Date createTime;
@io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateTime")
private Date updateTime;

@Transient
private List<WxDataRuleTarget> children;

}

+ 1
- 2
mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java View File

@@ -4,12 +4,10 @@ import cn.afterturn.easypoi.excel.annotation.Excel;
import com.iformall.domain.vo.WxShopVo;
import com.iformall.enums.EnumBusiness;
import com.iformall.enums.EnumSubBusiness;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.apache.commons.collections.ListUtils;

import javax.persistence.Id;
import javax.persistence.Table;
@@ -237,4 +235,5 @@ public class WxMerchant extends BaseEntity {
return "";
return "t:md:" + id;
}

}

+ 41
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxUserDataRule.java View File

@@ -0,0 +1,41 @@
package com.iformall.domain.po;

import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;

@Table(name = "wx_user_data_rule")
@Data
@EqualsAndHashCode(callSuper = true)
public class WxUserDataRule extends BaseEntity {
private static final long serialVersionUID = 1L;

@Id
protected Long id;

@Transient
protected List<String> ids;

@io.swagger.annotations.ApiModelProperty(value = "用户ID", name = "userId")
private Long userId;
@io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId")
private String tenantId;
@io.swagger.annotations.ApiModelProperty(value = "权限类型", name = "type")
private Integer type;
@io.swagger.annotations.ApiModelProperty(value = "楼层楼座", name = "buildingFloor")
private String buildingFloor;
@io.swagger.annotations.ApiModelProperty(value = "业态", name = "business")
private String business;
@io.swagger.annotations.ApiModelProperty(value = "数据范围", name = "target")
private String target;
@io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createTime")
private Date createTime;
@io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateTime")
private Date updateTime;

}

+ 16
- 0
mallinkService/src/main/java/com/iformall/mapper/WxDataRuleTargetMapper.java View File

@@ -0,0 +1,16 @@
package com.iformall.mapper;

import com.iformall.common.CommonMapper;
import com.iformall.domain.po.WxDataRuleTarget;

import java.util.List;

/**
* @author gongbiao
*/
public interface WxDataRuleTargetMapper extends CommonMapper<WxDataRuleTarget, Long> {

List<WxDataRuleTarget> findList(WxDataRuleTarget param);


}

+ 16
- 0
mallinkService/src/main/java/com/iformall/mapper/WxUserDataRuleMapper.java View File

@@ -0,0 +1,16 @@
package com.iformall.mapper;

import com.iformall.common.CommonMapper;
import com.iformall.domain.po.WxUserDataRule;

import java.util.List;

/**
* @author gongbiao
*/
public interface WxUserDataRuleMapper extends CommonMapper<WxUserDataRule, Long> {

List<WxUserDataRule> findList(WxUserDataRule param);


}

+ 34
- 0
mallinkService/src/main/java/com/iformall/service/WxDataRuleTargetService.java View File

@@ -0,0 +1,34 @@
package com.iformall.service;

import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxDataRuleTarget;

import java.util.List;

/**
* @author gongbiao
*/
public interface WxDataRuleTargetService {

/**
* 根据实体查询分页列表
*
* @param record
* @param pageIndex
* @param pageSize
* @return
*/
PageInfo<WxDataRuleTarget> listAsPage(WxDataRuleTarget record, Integer pageIndex, Integer pageSize);

/**
* 根据实体查询列表
*
* @param record
* @return
*/
List<WxDataRuleTarget> findList(WxDataRuleTarget record);


List<WxDataRuleTarget> getList();

}

+ 14
- 0
mallinkService/src/main/java/com/iformall/service/WxUserDataRuleService.java View File

@@ -0,0 +1,14 @@
package com.iformall.service;

import com.iformall.domain.po.WxUserDataRule;

/**
* @author gongbiao
*/
public interface WxUserDataRuleService {

void modify(WxUserDataRule wxUserDataRule);

WxUserDataRule findByUserId(Long userId);

}

+ 48
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxDataRuleTargetServiceImpl.java View File

@@ -0,0 +1,48 @@
package com.iformall.service.impl;

import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxDataRuleTarget;
import com.iformall.mapper.WxDataRuleTargetMapper;
import com.iformall.service.WxDataRuleTargetService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
* @author gongbiao
*/
@Service
public class WxDataRuleTargetServiceImpl implements WxDataRuleTargetService {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxDataRuleTargetMapper wxDataRuleTargetMapper;

@Override
public PageInfo<WxDataRuleTarget> listAsPage(WxDataRuleTarget record, Integer pageIndex, Integer pageSize) {
return null;
}

@Override
public List<WxDataRuleTarget> findList(WxDataRuleTarget record) {
return null;
}

@Override
public List<WxDataRuleTarget> getList() {
List<WxDataRuleTarget> wxDataRuleTargets = wxDataRuleTargetMapper.selectAll();
List<WxDataRuleTarget> targets = wxDataRuleTargets.stream()
.filter(t -> t.getParent().equals(0L)).collect(Collectors.toList());
for (WxDataRuleTarget parentTarget : targets) {
List<WxDataRuleTarget> children = wxDataRuleTargets.stream()
.filter(t -> t.getParent().equals(parentTarget.getId())).collect(Collectors.toList());
parentTarget.setChildren(children);
}
return targets;
}

}

+ 45
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxUserDataRuleServiceImpl.java View File

@@ -0,0 +1,45 @@
package com.iformall.service.impl;

import com.iformall.common.IdWorker;
import com.iformall.domain.po.WxUserDataRule;
import com.iformall.mapper.WxUserDataRuleMapper;
import com.iformall.service.WxUserDataRuleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
* @author gongbiao
*/
@Service
public class WxUserDataRuleServiceImpl implements WxUserDataRuleService {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxUserDataRuleMapper wxUserDataRuleMapper;

@Override
public void modify(WxUserDataRule record) {
Date date = new Date();
if (record.getId() == null) {
final IdWorker idWorker = IdWorker.get();
record.setId(idWorker.nextId());
record.setCreateTime(date);
record.setUpdateTime(date);
wxUserDataRuleMapper.insertSelective(record);
} else {
record.setUpdateTime(date);
wxUserDataRuleMapper.updateByPrimaryKeySelective(record);
}
}

@Override
public WxUserDataRule findByUserId(Long userId) {
WxUserDataRule wxUserDataRule = new WxUserDataRule();
wxUserDataRule.setUserId(userId);
return wxUserDataRuleMapper.selectOne(wxUserDataRule);
}
}

+ 53
- 0
mallinkService/src/main/resources/mapper/WxDataRuleTargetMapper.xml View File

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.iformall.mapper.WxDataRuleTargetMapper">
<resultMap id="BaseResultMap" type="com.iformall.domain.po.WxDataRuleTarget">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
<result column="parent" jdbcType="BIGINT" property="parent"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="tag" jdbcType="VARCHAR" property="tag"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
</resultMap>
<sql id="allColumns">
`id`,`parent`,`name`,`tag`,`create_time`,`update_time`
</sql>
<sql id="dynamicWhereConditions">
where 1 = 1
<if test=" null != id ">
and `id` = #{id}
</if>
<if test=" null != tenantId ">
and `tenant_id` = #{tenantId}
</if>
<if test=" null != parent ">
and `parent` = #{parent}
</if>
<if test=" null != name ">
and `name` like concat('%',#{name},'%')
</if>
<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</if>
<if test=" null != sortColumns">order by ${sortColumns}</if>
</sql>
<select id="findList" parameterType="com.iformall.domain.po.WxDataRuleTarget" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from wx_data_rule_target
<include refid="dynamicWhereConditions"/>
</select>

</mapper>

+ 15
- 0
mallinkService/src/main/resources/mapper/WxMerchantMapper.xml View File

@@ -232,6 +232,21 @@
#{idItem}
</foreach>
</if>
<if test="(null != floorForRule and '' != floorForRule) or (null != businessForRule and '' != businessForRule)">
and m.id in(
select ms.merchant_id from (select merchant_id,shop_id from wx_merchant_shop where is_del=0) ms
inner join wx_merchant m on ms.merchant_id = m.id
inner join wx_shop s on s.id=ms.shop_id
where m.tenant_id=#{tenantId} and s.is_del=0
<if test=" null != businessForRule ">
and m.business_id in (${businessForRule})
</if>
<if test=" null != floorForRule ">
and s.`floor` in (${floorForRule})
</if>
)
</if>
<if test=" null != sortColumns">order by ${sortColumns}</if>
</sql>


+ 55
- 0
mallinkService/src/main/resources/mapper/WxUserDataRuleMapper.xml View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.iformall.mapper.WxUserDataRuleMapper">
<resultMap id="BaseResultMap" type="com.iformall.domain.po.WxUserDataRule">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
<result column="user_id" jdbcType="BIGINT" property="userId"/>
<result column="type" jdbcType="INTEGER" property="type"/>
<result column="buildingFloor" jdbcType="VARCHAR" property="buildingFloor"/>
<result column="business" jdbcType="VARCHAR" property="business"/>
<result column="target" jdbcType="VARCHAR" property="target"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
</resultMap>
<sql id="allColumns">
`id`,`tenant_id`,`user_id`,`type`,`business`,`target`,`create_time`,`update_time`
</sql>
<sql id="dynamicWhereConditions">
where 1 = 1
<if test=" null != id ">
and `id` = #{id}
</if>
<if test=" null != tenantId ">
and `tenant_id` = #{tenantId}
</if>
<if test=" null != userId ">
and `user_id` = #{userId}
</if>
<if test=" null != type ">
and `type` = #{type}
</if>
<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</if>
<if test=" null != sortColumns">order by ${sortColumns}</if>
</sql>
<select id="findList" parameterType="com.iformall.domain.po.WxUserDataRule" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from wx_user_data_rule
<include refid="dynamicWhereConditions"/>
</select>

</mapper>

Loading…
Cancel
Save