Commit ee06d4a8 by duanhq

资源绑定bug修改,角色模糊查询修改 by duanht 2019/3/18

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@18614 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent e8de154d
...@@ -30,4 +30,7 @@ public interface SysUserServicesMapper { ...@@ -30,4 +30,7 @@ public interface SysUserServicesMapper {
int updateByPrimaryKey(SysUserServices record); int updateByPrimaryKey(SysUserServices record);
int deleteByUserIdAndServiceId(@Param(value = "userId") int userId, @Param(value = "item") String item); int deleteByUserIdAndServiceId(@Param(value = "userId") int userId, @Param(value = "item") String item);
List<SysUserServices> selectByUserId(@Param(value = "userId")Integer userId);
} }
\ No newline at end of file \ No newline at end of file
...@@ -15,6 +15,11 @@ public class SysUserServices { ...@@ -15,6 +15,11 @@ public class SysUserServices {
*/ */
private Integer installTime; private Integer installTime;
/**
* 商户资源匹配状态(sys_user_status_unbound_service:未绑定服务商;sys_user_status_unbound_mechanic:已绑定服务商未绑定技工;sys_user_status_bound:两者都绑定)
*/
private String merchantStatus;
public Integer getId() { public Integer getId() {
return id; return id;
} }
...@@ -46,4 +51,12 @@ public class SysUserServices { ...@@ -46,4 +51,12 @@ public class SysUserServices {
public void setInstallTime(Integer installTime) { public void setInstallTime(Integer installTime) {
this.installTime = installTime; this.installTime = installTime;
} }
public String getMerchantStatus() {
return merchantStatus;
}
public void setMerchantStatus(String merchantStatus) {
this.merchantStatus = merchantStatus;
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -353,6 +353,76 @@ public class SysUserServicesExample { ...@@ -353,6 +353,76 @@ public class SysUserServicesExample {
addCriterion("install_time not between", value1, value2, "installTime"); addCriterion("install_time not between", value1, value2, "installTime");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andMerchantStatusIsNull() {
addCriterion("merchant_status is null");
return (Criteria) this;
}
public Criteria andMerchantStatusIsNotNull() {
addCriterion("merchant_status is not null");
return (Criteria) this;
}
public Criteria andMerchantStatusEqualTo(String value) {
addCriterion("merchant_status =", value, "merchantStatus");
return (Criteria) this;
}
public Criteria andMerchantStatusNotEqualTo(String value) {
addCriterion("merchant_status <>", value, "merchantStatus");
return (Criteria) this;
}
public Criteria andMerchantStatusGreaterThan(String value) {
addCriterion("merchant_status >", value, "merchantStatus");
return (Criteria) this;
}
public Criteria andMerchantStatusGreaterThanOrEqualTo(String value) {
addCriterion("merchant_status >=", value, "merchantStatus");
return (Criteria) this;
}
public Criteria andMerchantStatusLessThan(String value) {
addCriterion("merchant_status <", value, "merchantStatus");
return (Criteria) this;
}
public Criteria andMerchantStatusLessThanOrEqualTo(String value) {
addCriterion("merchant_status <=", value, "merchantStatus");
return (Criteria) this;
}
public Criteria andMerchantStatusLike(String value) {
addCriterion("merchant_status like", value, "merchantStatus");
return (Criteria) this;
}
public Criteria andMerchantStatusNotLike(String value) {
addCriterion("merchant_status not like", value, "merchantStatus");
return (Criteria) this;
}
public Criteria andMerchantStatusIn(List<String> values) {
addCriterion("merchant_status in", values, "merchantStatus");
return (Criteria) this;
}
public Criteria andMerchantStatusNotIn(List<String> values) {
addCriterion("merchant_status not in", values, "merchantStatus");
return (Criteria) this;
}
public Criteria andMerchantStatusBetween(String value1, String value2) {
addCriterion("merchant_status between", value1, value2, "merchantStatus");
return (Criteria) this;
}
public Criteria andMerchantStatusNotBetween(String value1, String value2) {
addCriterion("merchant_status not between", value1, value2, "merchantStatus");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {
......
...@@ -121,7 +121,7 @@ public interface SysUserService { ...@@ -121,7 +121,7 @@ public interface SysUserService {
* @return SysUser * @return SysUser
* @author duanht * @author duanht
* @Title: getUserById * @Title: getUserById
* @Description: TODO 绑定服务商或技工 * @Description: TODO 绑定服务商或技工(bindType 1:绑定服务商,2:绑定技工)
*/ */
int bindingService(SysResourceMatching sysResourceMatching , Integer bindType); int bindingService(SysResourceMatching sysResourceMatching , Integer bindType);
......
...@@ -48,7 +48,7 @@ public class SysRoleServiceImpl implements SysRoleService { ...@@ -48,7 +48,7 @@ public class SysRoleServiceImpl implements SysRoleService {
} }
if (StringUtils.isNotEmpty(roleQueryVo.getName())) { if (StringUtils.isNotEmpty(roleQueryVo.getName())) {
criteria.andNameLike(roleQueryVo.getName()); criteria.andNameLike("%"+roleQueryVo.getName()+"%");
} }
if (StringUtils.isNotEmpty(roleQueryVo.getsTime()) && StringUtils.isNotEmpty(roleQueryVo.geteTime())) { if (StringUtils.isNotEmpty(roleQueryVo.getsTime()) && StringUtils.isNotEmpty(roleQueryVo.geteTime())) {
...@@ -62,7 +62,7 @@ public class SysRoleServiceImpl implements SysRoleService { ...@@ -62,7 +62,7 @@ public class SysRoleServiceImpl implements SysRoleService {
} }
if (StringUtils.isNotEmpty(roleQueryVo.getPermissionCharacter())) { if (StringUtils.isNotEmpty(roleQueryVo.getPermissionCharacter())) {
criteria.andPermissionCharacterLike(roleQueryVo.getPermissionCharacter()); criteria.andPermissionCharacterLike("%"+roleQueryVo.getPermissionCharacter()+"%");
} }
sysRoleExample.setOrderByClause("sort"); sysRoleExample.setOrderByClause("sort");
......
package com.glsx.usercenter.service.impl; package com.glsx.usercenter.service.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import com.glsx.usercenter.pojo.user.*;
import com.glsx.usercenter.service.ISysOrganizationService; import com.glsx.usercenter.service.ISysOrganizationService;
import com.glsx.usercenter.utils.ShiroUtil; import com.glsx.usercenter.utils.ShiroUtil;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
...@@ -30,18 +33,6 @@ import com.glsx.usercenter.mapper.SysUserOrgMapper; ...@@ -30,18 +33,6 @@ import com.glsx.usercenter.mapper.SysUserOrgMapper;
import com.glsx.usercenter.mapper.SysUserRoleMapper; import com.glsx.usercenter.mapper.SysUserRoleMapper;
import com.glsx.usercenter.mapper.SysUserServicesMapper; import com.glsx.usercenter.mapper.SysUserServicesMapper;
import com.glsx.usercenter.pojo.menu.SysOrganization; import com.glsx.usercenter.pojo.menu.SysOrganization;
import com.glsx.usercenter.pojo.user.SysManager;
import com.glsx.usercenter.pojo.user.SysMechanic;
import com.glsx.usercenter.pojo.user.SysMerchant;
import com.glsx.usercenter.pojo.user.SysResourceMatching;
import com.glsx.usercenter.pojo.user.SysResourceMatchingExample;
import com.glsx.usercenter.pojo.user.SysUser;
import com.glsx.usercenter.pojo.user.SysUserExample;
import com.glsx.usercenter.pojo.user.SysUserImage;
import com.glsx.usercenter.pojo.user.SysUserImageExample;
import com.glsx.usercenter.pojo.user.SysUserOrg;
import com.glsx.usercenter.pojo.user.SysUserRole;
import com.glsx.usercenter.pojo.user.SysUserServices;
import com.glsx.usercenter.pojo.vo.UserQueryVo; import com.glsx.usercenter.pojo.vo.UserQueryVo;
import com.glsx.usercenter.service.IAreaService; import com.glsx.usercenter.service.IAreaService;
import com.glsx.usercenter.service.SysUserService; import com.glsx.usercenter.service.SysUserService;
...@@ -461,19 +452,45 @@ public class SysUserServiceImpl implements SysUserService { ...@@ -461,19 +452,45 @@ public class SysUserServiceImpl implements SysUserService {
private void updateServiceItem(Integer userId, SysUser sysUser) { private void updateServiceItem(Integer userId, SysUser sysUser) {
logger.info(sysUser.getName() + "开始更新服务项"); logger.info(sysUser.getName() + "开始更新服务项");
//如果是更新需要先删除原有的连接数据
//传入的服务项
List<SysUserServices> newSysUserServices = new ArrayList<>();
for (int i = 0; i < sysUser.getServiceKeyList().size(); i++) { for (int i = 0; i < sysUser.getServiceKeyList().size(); i++) {
if (userId == null) {
//根据user_id和服务项删除数据
sysUserServicesMapper.deleteByUserIdAndServiceId(sysUser.getUserId(), sysUser.getServiceKeyList().get(i));
}
SysUserServices userServices = new SysUserServices(); SysUserServices userServices = new SysUserServices();
userServices.setUserId(sysUser.getUserId()); userServices.setUserId(sysUser.getUserId());
userServices.setServiceKey(sysUser.getServiceKeyList().get(i)); userServices.setServiceKey(sysUser.getServiceKeyList().get(i));
newSysUserServices.add(userServices);
}
//原先的服务项
List<SysUserServices> originSysUserServices = new ArrayList<>();
originSysUserServices = sysUserServicesMapper.selectByUserId(sysUser.getUserId());
//去重后区分出需要新增和删除的服务项
Set<SysUserServices> unionSysUserServices = new HashSet<>();
//编辑服务项
if (userId == null) {
unionSysUserServices.addAll(newSysUserServices);
unionSysUserServices.addAll(originSysUserServices);
unionSysUserServices.removeAll(newSysUserServices);
//根据user_id和服务项删除数据
for (SysUserServices delList : unionSysUserServices) {
sysUserServicesMapper.deleteByUserIdAndServiceId(delList.getUserId(), delList.getServiceKey());
}
}
unionSysUserServices.addAll(newSysUserServices);
unionSysUserServices.removeAll(originSysUserServices);
List<SysUserServices> addList = new ArrayList<>(unionSysUserServices);
for (int i = 0; i < addList.size(); i++) {
if (!sysUser.getInstallTimeList().isEmpty()) { if (!sysUser.getInstallTimeList().isEmpty()) {
userServices.setInstallTime(sysUser.getInstallTimeList().get(i)); addList.get(i).setInstallTime(sysUser.getInstallTimeList().get(i));
}
//商户绑定状态默认为未绑定服务商
if (sysUser.getUserType() == Constants.USER_TYPE_MERCHANT) {
addList.get(i).setMerchantStatus("sys_user_status_unbound_service");
} }
sysUserServicesMapper.insert(userServices); sysUserServicesMapper.insertSelective(addList.get(i));
} }
logger.info("服务项更新成功"); logger.info("服务项更新成功");
} }
...@@ -482,23 +499,45 @@ public class SysUserServiceImpl implements SysUserService { ...@@ -482,23 +499,45 @@ public class SysUserServiceImpl implements SysUserService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public int bindingService(SysResourceMatching sysResourceMatching, Integer bindType) { public int bindingService(SysResourceMatching sysResourceMatching, Integer bindType) {
List<SysResourceMatching> sysResourceMatchingList = new ArrayList<>();
//绑定前要删除之前的数据 //绑定前要删除之前的数据
SysResourceMatchingExample sysResourceMatchingExample = new SysResourceMatchingExample(); SysResourceMatchingExample sysResourceMatchingExample = new SysResourceMatchingExample();
SysResourceMatchingExample.Criteria criteria = sysResourceMatchingExample.createCriteria(); SysResourceMatchingExample.Criteria criteria = sysResourceMatchingExample.createCriteria();
criteria.andMerchantIdEqualTo(sysResourceMatching.getMerchantId()); criteria.andMerchantIdEqualTo(sysResourceMatching.getMerchantId());
criteria.andServiceKeyEqualTo(sysResourceMatching.getServiceKey()); criteria.andServiceKeyEqualTo(sysResourceMatching.getServiceKey());
sysResourceMatchingMapper.deleteByExample(sysResourceMatchingExample); sysResourceMatchingList = sysResourceMatchingMapper.selectByExample(sysResourceMatchingExample);
//修改绑定服务商时,需要把之前的数据删除
if (sysResourceMatchingList.isEmpty() ||
(sysResourceMatchingList.size() == 1 && bindType == 1) ||
(sysResourceMatchingList.size() == 2 && bindType == 1)) {
sysResourceMatchingMapper.deleteByExample(sysResourceMatchingExample);
}
//只修改绑定技工则只删除绑定技工
if (sysResourceMatchingList.size() == 2 && bindType == 2) {
for(SysResourceMatching resourceMatching : sysResourceMatchingList){
SysUser sysUser = sysUserMapper.selectByPrimaryKey(resourceMatching.getUserId());
if(sysUser.getUserType() == Constants.USER_TYPE_MECHANIC){
criteria.andUserIdEqualTo(sysUser.getId());
sysResourceMatchingMapper.deleteByExample(sysResourceMatchingExample);
}
}
}
//修改门店状态 //修改门店状态
SysMerchant sysMerchant = new SysMerchant(); SysUserServices sysUserService = new SysUserServices();
sysMerchant.setId(sysResourceMatching.getMerchantId()); SysUserServicesExample sysUserServicesExample = new SysUserServicesExample();
SysUserServicesExample.Criteria criteria1 = sysUserServicesExample.createCriteria();
criteria1.andUserIdEqualTo(sysResourceMatching.getMerchantId());
criteria1.andServiceKeyEqualTo(sysResourceMatching.getServiceKey());
//(1:绑定服务商 2:绑定技工) //(1:绑定服务商 2:绑定技工)
if (bindType == 1) { if (bindType == 1) {
sysMerchant.setMerchantStatus("sys_user_status_unbound_mechanic"); sysUserService.setMerchantStatus("sys_user_status_unbound_mechanic");
} else { } else {
sysMerchant.setMerchantStatus("sys_user_status_bound"); sysUserService.setMerchantStatus("sys_user_status_bound");
} }
sysUserMapper.updateSysMerchant(sysMerchant); sysUserServicesMapper.updateByExampleSelective(sysUserService, sysUserServicesExample);
return sysResourceMatchingMapper.insert(sysResourceMatching); return sysResourceMatchingMapper.insert(sysResourceMatching);
} }
...@@ -672,7 +711,7 @@ public class SysUserServiceImpl implements SysUserService { ...@@ -672,7 +711,7 @@ public class SysUserServiceImpl implements SysUserService {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(new SysUserServiceImpl().encryptPassword("glsx8888")); System.out.println(new SysUserServiceImpl().encryptPassword("123456"));
} }
@Override @Override
......
...@@ -514,9 +514,6 @@ ...@@ -514,9 +514,6 @@
<if test="serviceType != null"> <if test="serviceType != null">
service_type = #{serviceType,jdbcType=INTEGER}, service_type = #{serviceType,jdbcType=INTEGER},
</if> </if>
<if test="merchantStatus != null">
merchant_status = #{merchantStatus,jdbcType=VARCHAR},
</if>
</set> </set>
where user_id = #{id,jdbcType=INTEGER} where user_id = #{id,jdbcType=INTEGER}
</update> </update>
...@@ -667,7 +664,7 @@ ...@@ -667,7 +664,7 @@
sm.address address, sm.address address,
GROUP_CONCAT(sdd.data_value SEPARATOR '/') serviceItems, GROUP_CONCAT(sdd.data_value SEPARATOR '/') serviceItems,
GROUP_CONCAT(sdd.data_key ) serviceKey, GROUP_CONCAT(sdd.data_key ) serviceKey,
sm.merchant_status merchantStatus, sms.merchant_status merchantStatus,
u.group_id groupId u.group_id groupId
<choose> <choose>
<when test="userId != 0 and userId!=''"> <when test="userId != 0 and userId!=''">
...@@ -757,7 +754,7 @@ ...@@ -757,7 +754,7 @@
sm.address address, sm.address address,
sdd.data_key serviceKey, sdd.data_key serviceKey,
sdd.data_value serviceItems, sdd.data_value serviceItems,
sm.merchant_status merchantStatus, sms.merchant_status merchantStatus,
u.group_id groupId, u.group_id groupId,
srm.user_id userId srm.user_id userId
<choose> <choose>
...@@ -825,10 +822,10 @@ ...@@ -825,10 +822,10 @@
and u.user_status IN ('sys_user_status_normal') and u.user_status IN ('sys_user_status_normal')
<choose> <choose>
<when test="userStatus != null and userStatus!=''"> <when test="userStatus != null and userStatus!=''">
and sm.merchant_status = #{userStatus,jdbcType=VARCHAR} and sms.merchant_status = #{userStatus,jdbcType=VARCHAR}
</when> </when>
<otherwise> <otherwise>
and sm.merchant_status IN and sms.merchant_status IN
('sys_user_status_unbound_service','sys_user_status_unbound_mechanic','sys_user_status_bound') ('sys_user_status_unbound_service','sys_user_status_unbound_mechanic','sys_user_status_bound')
</otherwise> </otherwise>
</choose> </choose>
...@@ -838,10 +835,10 @@ ...@@ -838,10 +835,10 @@
and u.user_status IN ('sys_user_status_normal') and u.user_status IN ('sys_user_status_normal')
<choose> <choose>
<when test="userStatus != null and userStatus!=''"> <when test="userStatus != null and userStatus!=''">
and sm.merchant_status = #{userStatus,jdbcType=VARCHAR} and sms.merchant_status = #{userStatus,jdbcType=VARCHAR}
</when> </when>
<otherwise> <otherwise>
and sm.merchant_status IN ('sys_user_status_unbound_mechanic','sys_user_status_bound') and sms.merchant_status IN ('sys_user_status_unbound_mechanic','sys_user_status_bound')
</otherwise> </otherwise>
</choose> </choose>
</if> </if>
...@@ -941,6 +938,7 @@ ...@@ -941,6 +938,7 @@
u.user_status userStatus, u.user_status userStatus,
u. NAME, u. NAME,
so.name orgName, so.name orgName,
u.org_id orgId,
phone_number phoneNumber, phone_number phoneNumber,
sm.district district, sm.district district,
sm.address address, sm.address address,
...@@ -1103,7 +1101,7 @@ ...@@ -1103,7 +1101,7 @@
su.id su.id
FROM sys_resource_matching srm LEFT JOIN sys_service_mechanic ssm ON srm.user_id = ssm.service_id FROM sys_resource_matching srm LEFT JOIN sys_service_mechanic ssm ON srm.user_id = ssm.service_id
LEFT JOIN sys_user su ON ssm.mechanic_id = su.id LEFT JOIN sys_user_services sus ON su.id = sus.user_id LEFT JOIN sys_user su ON ssm.mechanic_id = su.id LEFT JOIN sys_user_services sus ON su.id = sus.user_id
WHERE srm.merchant_id = #{merchantId,jdbcType=INTEGER} AND sus.service_key = #{serviceKey,jdbcType=VARCHAR} WHERE srm.merchant_id = #{merchantId,jdbcType=INTEGER}
AND su.user_status = 'sys_user_status_normal' AND su.user_status = 'sys_user_status_normal'
AND su.user_type = 3 AND su.user_type = 3
<if test="orgId != null"> <if test="orgId != null">
......
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.glsx.usercenter.mapper.SysUserServicesMapper"> <mapper namespace="com.glsx.usercenter.mapper.SysUserServicesMapper">
<resultMap id="BaseResultMap" type="com.glsx.usercenter.pojo.user.SysUserServices"> <resultMap id="BaseResultMap" type="com.glsx.usercenter.pojo.user.SysUserServices">
<id column="id" jdbcType="INTEGER" property="id" /> <id column="id" jdbcType="INTEGER" property="id" />
<result column="user_id" jdbcType="INTEGER" property="userId" /> <result column="user_id" jdbcType="INTEGER" property="userId" />
<result column="service_key" jdbcType="VARCHAR" property="serviceKey" /> <result column="service_key" jdbcType="VARCHAR" property="serviceKey" />
<result column="install_time" jdbcType="INTEGER" property="installTime" /> <result column="install_time" jdbcType="INTEGER" property="installTime" />
</resultMap> <result column="merchant_status" jdbcType="VARCHAR" property="merchantStatus" />
<sql id="Example_Where_Clause"> </resultMap>
<where> <sql id="Example_Where_Clause">
<foreach collection="oredCriteria" item="criteria" separator="or"> <where>
<if test="criteria.valid"> <foreach collection="oredCriteria" item="criteria" separator="or">
<trim prefix="(" prefixOverrides="and" suffix=")"> <if test="criteria.valid">
<foreach collection="criteria.criteria" item="criterion"> <trim prefix="(" prefixOverrides="and" suffix=")">
<choose> <foreach collection="criteria.criteria" item="criterion">
<when test="criterion.noValue"> <choose>
and ${criterion.condition} <when test="criterion.noValue">
</when> and ${criterion.condition}
<when test="criterion.singleValue"> </when>
and ${criterion.condition} #{criterion.value} <when test="criterion.singleValue">
</when> and ${criterion.condition} #{criterion.value}
<when test="criterion.betweenValue"> </when>
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} <when test="criterion.betweenValue">
</when> and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
<when test="criterion.listValue"> </when>
and ${criterion.condition} <when test="criterion.listValue">
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> and ${criterion.condition}
#{listItem} <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
</foreach> #{listItem}
</when> </foreach>
</choose> </when>
</choose>
</foreach>
</trim>
</if>
</foreach> </foreach>
</trim> </where>
</if> </sql>
</foreach> <sql id="Update_By_Example_Where_Clause">
</where> <where>
</sql> <foreach collection="example.oredCriteria" item="criteria" separator="or">
<sql id="Update_By_Example_Where_Clause"> <if test="criteria.valid">
<where> <trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="example.oredCriteria" item="criteria" separator="or"> <foreach collection="criteria.criteria" item="criterion">
<if test="criteria.valid"> <choose>
<trim prefix="(" prefixOverrides="and" suffix=")"> <when test="criterion.noValue">
<foreach collection="criteria.criteria" item="criterion"> and ${criterion.condition}
<choose> </when>
<when test="criterion.noValue"> <when test="criterion.singleValue">
and ${criterion.condition} and ${criterion.condition} #{criterion.value}
</when> </when>
<when test="criterion.singleValue"> <when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when> </when>
<when test="criterion.betweenValue"> <when test="criterion.listValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} and ${criterion.condition}
</when> <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
<when test="criterion.listValue"> #{listItem}
and ${criterion.condition} </foreach>
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> </when>
#{listItem} </choose>
</foreach> </foreach>
</when> </trim>
</choose> </if>
</foreach> </foreach>
</trim> </where>
</sql>
<sql id="Base_Column_List">
id, user_id, service_key, install_time, merchant_status
</sql>
<select id="selectByExample" parameterType="com.glsx.usercenter.pojo.user.SysUserServicesExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
'false' as QUERYID,
<include refid="Base_Column_List" />
from sys_user_services
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from sys_user_services
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from sys_user_services
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.glsx.usercenter.pojo.user.SysUserServicesExample">
delete from sys_user_services
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if> </if>
</foreach> </delete>
</where> <insert id="insert" parameterType="com.glsx.usercenter.pojo.user.SysUserServices">
</sql> <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
<sql id="Base_Column_List"> SELECT LAST_INSERT_ID()
id, user_id, service_key, install_time </selectKey>
</sql> insert into sys_user_services (user_id, service_key, install_time,
<select id="selectByExample" parameterType="com.glsx.usercenter.pojo.user.SysUserServicesExample" resultMap="BaseResultMap"> merchant_status)
select values (#{userId,jdbcType=INTEGER}, #{serviceKey,jdbcType=VARCHAR}, #{installTime,jdbcType=INTEGER},
<if test="distinct"> #{merchantStatus,jdbcType=VARCHAR})
distinct </insert>
</if> <insert id="insertSelective" parameterType="com.glsx.usercenter.pojo.user.SysUserServices">
'false' as QUERYID, <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
<include refid="Base_Column_List" /> SELECT LAST_INSERT_ID()
from sys_user_services </selectKey>
<if test="_parameter != null"> insert into sys_user_services
<include refid="Example_Where_Clause" /> <trim prefix="(" suffix=")" suffixOverrides=",">
</if> <if test="userId != null">
<if test="orderByClause != null"> user_id,
order by ${orderByClause} </if>
</if> <if test="serviceKey != null">
</select> service_key,
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> </if>
select <if test="installTime != null">
<include refid="Base_Column_List" /> install_time,
from sys_user_services </if>
where id = #{id,jdbcType=INTEGER} <if test="merchantStatus != null">
</select> merchant_status,
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> </if>
delete from sys_user_services </trim>
where id = #{id,jdbcType=INTEGER} <trim prefix="values (" suffix=")" suffixOverrides=",">
</delete> <if test="userId != null">
<delete id="deleteByExample" parameterType="com.glsx.usercenter.pojo.user.SysUserServicesExample"> #{userId,jdbcType=INTEGER},
delete from sys_user_services </if>
<if test="_parameter != null"> <if test="serviceKey != null">
<include refid="Example_Where_Clause" /> #{serviceKey,jdbcType=VARCHAR},
</if> </if>
</delete> <if test="installTime != null">
<insert id="insert" parameterType="com.glsx.usercenter.pojo.user.SysUserServices"> #{installTime,jdbcType=INTEGER},
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer"> </if>
SELECT LAST_INSERT_ID() <if test="merchantStatus != null">
</selectKey> #{merchantStatus,jdbcType=VARCHAR},
insert into sys_user_services (user_id, service_key, install_time </if>
) </trim>
values (#{userId,jdbcType=INTEGER}, #{serviceKey,jdbcType=VARCHAR}, #{installTime,jdbcType=INTEGER} </insert>
) <select id="countByExample" parameterType="com.glsx.usercenter.pojo.user.SysUserServicesExample" resultType="java.lang.Long">
</insert> select count(*) from sys_user_services
<insert id="insertSelective" parameterType="com.glsx.usercenter.pojo.user.SysUserServices"> <if test="_parameter != null">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer"> <include refid="Example_Where_Clause" />
SELECT LAST_INSERT_ID() </if>
</selectKey> </select>
insert into sys_user_services <update id="updateByExampleSelective" parameterType="map">
<trim prefix="(" suffix=")" suffixOverrides=","> update sys_user_services
<if test="userId != null"> <set>
user_id, <if test="record.id != null">
</if> id = #{record.id,jdbcType=INTEGER},
<if test="serviceKey != null"> </if>
service_key, <if test="record.userId != null">
</if> user_id = #{record.userId,jdbcType=INTEGER},
<if test="installTime != null"> </if>
install_time, <if test="record.serviceKey != null">
</if> service_key = #{record.serviceKey,jdbcType=VARCHAR},
</trim> </if>
<trim prefix="values (" suffix=")" suffixOverrides=","> <if test="record.installTime != null">
<if test="userId != null"> install_time = #{record.installTime,jdbcType=INTEGER},
#{userId,jdbcType=INTEGER}, </if>
</if> <if test="record.merchantStatus != null">
<if test="serviceKey != null"> merchant_status = #{record.merchantStatus,jdbcType=VARCHAR},
#{serviceKey,jdbcType=VARCHAR}, </if>
</if> </set>
<if test="installTime != null"> <if test="_parameter != null">
#{installTime,jdbcType=INTEGER}, <include refid="Update_By_Example_Where_Clause" />
</if> </if>
</trim> </update>
</insert> <update id="updateByExample" parameterType="map">
<select id="countByExample" parameterType="com.glsx.usercenter.pojo.user.SysUserServicesExample" resultType="java.lang.Long"> update sys_user_services
select count(*) from sys_user_services set id = #{record.id,jdbcType=INTEGER},
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update sys_user_services
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=INTEGER}, user_id = #{record.userId,jdbcType=INTEGER},
</if>
<if test="record.serviceKey != null">
service_key = #{record.serviceKey,jdbcType=VARCHAR}, service_key = #{record.serviceKey,jdbcType=VARCHAR},
</if>
<if test="record.installTime != null">
install_time = #{record.installTime,jdbcType=INTEGER}, install_time = #{record.installTime,jdbcType=INTEGER},
</if> merchant_status = #{record.merchantStatus,jdbcType=VARCHAR}
</set> <if test="_parameter != null">
<if test="_parameter != null"> <include refid="Update_By_Example_Where_Clause" />
<include refid="Update_By_Example_Where_Clause" /> </if>
</if> </update>
</update> <update id="updateByPrimaryKeySelective" parameterType="com.glsx.usercenter.pojo.user.SysUserServices">
<update id="updateByExample" parameterType="map"> update sys_user_services
update sys_user_services <set>
set id = #{record.id,jdbcType=INTEGER}, <if test="userId != null">
user_id = #{record.userId,jdbcType=INTEGER}, user_id = #{userId,jdbcType=INTEGER},
service_key = #{record.serviceKey,jdbcType=VARCHAR}, </if>
install_time = #{record.installTime,jdbcType=INTEGER} <if test="serviceKey != null">
<if test="_parameter != null"> service_key = #{serviceKey,jdbcType=VARCHAR},
<include refid="Update_By_Example_Where_Clause" /> </if>
</if> <if test="installTime != null">
</update> install_time = #{installTime,jdbcType=INTEGER},
<update id="updateByPrimaryKeySelective" parameterType="com.glsx.usercenter.pojo.user.SysUserServices"> </if>
update sys_user_services <if test="merchantStatus != null">
<set> merchant_status = #{merchantStatus,jdbcType=VARCHAR},
<if test="userId != null"> </if>
user_id = #{userId,jdbcType=INTEGER}, </set>
</if> where id = #{id,jdbcType=INTEGER}
<if test="serviceKey != null"> </update>
<update id="updateByPrimaryKey" parameterType="com.glsx.usercenter.pojo.user.SysUserServices">
update sys_user_services
set user_id = #{userId,jdbcType=INTEGER},
service_key = #{serviceKey,jdbcType=VARCHAR}, service_key = #{serviceKey,jdbcType=VARCHAR},
</if>
<if test="installTime != null">
install_time = #{installTime,jdbcType=INTEGER}, install_time = #{installTime,jdbcType=INTEGER},
</if> merchant_status = #{merchantStatus,jdbcType=VARCHAR}
</set> where id = #{id,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER} </update>
</update>
<update id="updateByPrimaryKey" parameterType="com.glsx.usercenter.pojo.user.SysUserServices"> <delete id="deleteByUserIdAndServiceId">
update sys_user_services DELETE FROM sys_user_services
set user_id = #{userId,jdbcType=INTEGER}, WHERE user_id = #{userId,jdbcType=INTEGER} AND service_key = #{item,jdbcType=VARCHAR}
service_key = #{serviceKey,jdbcType=VARCHAR}, </delete>
install_time = #{installTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<delete id="deleteByUserIdAndServiceId"> <select id="selectByUserId" resultType="com.glsx.usercenter.pojo.user.SysUserServices">
DELETE FROM sys_user_services SELECT
WHERE user_id = #{userId,jdbcType=INTEGER} AND service_key = #{item,jdbcType=VARCHAR} id,
</delete> user_id userId,
service_key serviceKey
FROM sys_user_services
WHERE user_id = #{userId,jdbcType=INTEGER}
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -171,7 +171,6 @@ CREATE TABLE `sys_merchant` ( ...@@ -171,7 +171,6 @@ CREATE TABLE `sys_merchant` (
`district` varchar(100) DEFAULT NULL COMMENT '门店所在省市区', `district` varchar(100) DEFAULT NULL COMMENT '门店所在省市区',
`address` varchar(255) DEFAULT NULL COMMENT '门店详细地址', `address` varchar(255) DEFAULT NULL COMMENT '门店详细地址',
`service_type` tinyint(4) DEFAULT NULL COMMENT '服务类型(1:上门,2:驻店)', `service_type` tinyint(4) DEFAULT NULL COMMENT '服务类型(1:上门,2:驻店)',
`merchant_status` varchar(64) NOT NULL DEFAULT 'sys_user_status_unbound_service' COMMENT '商户资源匹配状态(sys_user_status_unbound_service:未绑定服务商;sys_user_status_unbound_mechanic:已绑定服务商未绑定技工;sys_user_status_bound:两者都绑定)',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `idx_shop_name` (`shop_name`(191)) USING BTREE COMMENT '门店名称索引', KEY `idx_shop_name` (`shop_name`(191)) USING BTREE COMMENT '门店名称索引',
KEY `idx_user_id` (`user_id`) USING BTREE COMMENT '用户id索引' KEY `idx_user_id` (`user_id`) USING BTREE COMMENT '用户id索引'
...@@ -456,5 +455,6 @@ CREATE TABLE `sys_user_services` ( ...@@ -456,5 +455,6 @@ CREATE TABLE `sys_user_services` (
`user_id` int(11) NOT NULL COMMENT '用户id', `user_id` int(11) NOT NULL COMMENT '用户id',
`service_key` varchar(64) NOT NULL COMMENT '服务项key', `service_key` varchar(64) NOT NULL COMMENT '服务项key',
`install_time` int(11) DEFAULT NULL COMMENT '安装时间(适用于技工)', `install_time` int(11) DEFAULT NULL COMMENT '安装时间(适用于技工)',
`merchant_status` varchar(64) NOT NULL DEFAULT 'sys_user_status_unbound_service' COMMENT '商户资源匹配状态(sys_user_status_unbound_service:未绑定服务商;sys_user_status_unbound_mechanic:已绑定服务商未绑定技工;sys_user_status_bound:两者都绑定)',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=122 DEFAULT CHARSET=utf8mb4 COMMENT='用户服务项表'; ) ENGINE=InnoDB AUTO_INCREMENT=122 DEFAULT CHARSET=utf8mb4 COMMENT='用户服务项表';
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!