Commit 69e18dae by zhengxj

finish 商户新增/编辑--改为服务项目 on 20191127 by zhengxj

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@25168 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent f33b7247
package com.glsx.usercenter.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.glsx.usercenter.pojo.user.SysUserServiceItems;
import com.glsx.usercenter.pojo.user.SysUserServices;
public interface SysUserServiceItemsMapper {
int deleteByPrimaryKey(Integer id);
int insertSelective(SysUserServiceItems record);
SysUserServiceItems selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(SysUserServices record);
int deleteByUserId(@Param(value = "userId") int userId);
List<SysUserServiceItems> selectByUserId(@Param(value = "userId") Integer userId);
}
\ No newline at end of file \ No newline at end of file
package com.glsx.usercenter.pojo.user;
public class SysUserServiceItems {
private Integer id;
private Integer userId;
/**
* 服务项key
*/
private String serviceCode;
/**
* 商户资源匹配状态(sys_user_status_unbound_service:未绑定服务商;sys_user_status_unbound_mechanic:已绑定服务商未绑定技工;sys_user_status_bound:两者都绑定)
*/
private String matchStatus;
/**
* 安装时间
*/
private Integer installTime;
public Integer getInstallTime() {
return installTime;
}
public void setInstallTime(Integer installTime) {
this.installTime = installTime;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getServiceCode() {
return serviceCode;
}
public void setServiceCode(String serviceCode) {
this.serviceCode = serviceCode;
}
public String getMatchStatus() {
return matchStatus;
}
public void setMatchStatus(String matchStatus) {
this.matchStatus = matchStatus;
}
}
\ No newline at end of file \ No newline at end of file
...@@ -9,6 +9,7 @@ import java.util.Set; ...@@ -9,6 +9,7 @@ import java.util.Set;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UnknownAccountException; import org.apache.shiro.authc.UnknownAccountException;
...@@ -45,6 +46,7 @@ import com.glsx.usercenter.mapper.SysUserImageMapper; ...@@ -45,6 +46,7 @@ import com.glsx.usercenter.mapper.SysUserImageMapper;
import com.glsx.usercenter.mapper.SysUserMapper; import com.glsx.usercenter.mapper.SysUserMapper;
import com.glsx.usercenter.mapper.SysUserOrgMapper; import com.glsx.usercenter.mapper.SysUserOrgMapper;
import com.glsx.usercenter.mapper.SysUserRoleMapper; import com.glsx.usercenter.mapper.SysUserRoleMapper;
import com.glsx.usercenter.mapper.SysUserServiceItemsMapper;
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.SysManager;
...@@ -58,6 +60,7 @@ import com.glsx.usercenter.pojo.user.SysUserImage; ...@@ -58,6 +60,7 @@ import com.glsx.usercenter.pojo.user.SysUserImage;
import com.glsx.usercenter.pojo.user.SysUserImageExample; import com.glsx.usercenter.pojo.user.SysUserImageExample;
import com.glsx.usercenter.pojo.user.SysUserOrg; import com.glsx.usercenter.pojo.user.SysUserOrg;
import com.glsx.usercenter.pojo.user.SysUserRole; import com.glsx.usercenter.pojo.user.SysUserRole;
import com.glsx.usercenter.pojo.user.SysUserServiceItems;
import com.glsx.usercenter.pojo.user.SysUserServices; import com.glsx.usercenter.pojo.user.SysUserServices;
import com.glsx.usercenter.pojo.user.SysUserServicesExample; import com.glsx.usercenter.pojo.user.SysUserServicesExample;
import com.glsx.usercenter.pojo.vo.UserQueryVo; import com.glsx.usercenter.pojo.vo.UserQueryVo;
...@@ -87,6 +90,9 @@ public class SysUserServiceImpl implements SysUserService { ...@@ -87,6 +90,9 @@ public class SysUserServiceImpl implements SysUserService {
private SysUserOrgMapper sysUserOrgMapper; private SysUserOrgMapper sysUserOrgMapper;
@Autowired @Autowired
private SysUserServicesMapper sysUserServicesMapper; private SysUserServicesMapper sysUserServicesMapper;
@Autowired
private SysUserServiceItemsMapper userServiceItemsMapper;
@Autowired @Autowired
private SysResourceMatchingMapper sysResourceMatchingMapper; private SysResourceMatchingMapper sysResourceMatchingMapper;
@Autowired @Autowired
...@@ -434,10 +440,13 @@ public class SysUserServiceImpl implements SysUserService { ...@@ -434,10 +440,13 @@ public class SysUserServiceImpl implements SysUserService {
sysOrganizationMapper.updateByPrimaryKeySelective(sysOrganization); sysOrganizationMapper.updateByPrimaryKeySelective(sysOrganization);
sysMerchant.setUserId(sysMerchant.getId()); sysMerchant.setUserId(sysMerchant.getId());
} }
// 更新角色和服务项 // 更新角色
SysUser sysUser = new SysUser(); SysUser sysUser = new SysUser();
BeanUtils.copyProperties(sysMerchant, sysUser); BeanUtils.copyProperties(sysMerchant, sysUser);
updateServiceItem(sysUser); // 更新务项
if (null != sysUser.getServiceKeyList() && sysUser.getServiceKeyList().size() > 0) {
updateUserServiceItems(sysUser);
}
//如果是未知订单进来的 //如果是未知订单进来的
if (sysMerchant.getOrderId() != null && !Constants.SYS_USER_STATUS_NONUSE.equals(sysMerchant.getUserStatus())) { if (sysMerchant.getOrderId() != null && !Constants.SYS_USER_STATUS_NONUSE.equals(sysMerchant.getUserStatus())) {
JSONObject jsonObject = orderClient.updateOrdersBindShop(sysMerchant.getOrderId(), userId, sysMerchant.getServiceType()); JSONObject jsonObject = orderClient.updateOrdersBindShop(sysMerchant.getOrderId(), userId, sysMerchant.getServiceType());
...@@ -545,6 +554,7 @@ public class SysUserServiceImpl implements SysUserService { ...@@ -545,6 +554,7 @@ public class SysUserServiceImpl implements SysUserService {
logger.info("图片更新成功"); logger.info("图片更新成功");
} }
private void updateServiceItem(SysUser sysUser) { private void updateServiceItem(SysUser sysUser) {
logger.info(sysUser.getName() + "开始更新服务项"); logger.info(sysUser.getName() + "开始更新服务项");
...@@ -1178,4 +1188,39 @@ public class SysUserServiceImpl implements SysUserService { ...@@ -1178,4 +1188,39 @@ public class SysUserServiceImpl implements SysUserService {
return sysUserMapper.get(user); return sysUserMapper.get(user);
} }
/**
*
*
* @author Zheng Xiajun
* @Title: updateUserServiceItem
* @Description: (更新用户服务项目)
* @param @param
* sysUser 设定文件
* @return void 返回类型
* @version 1.5.1
*/
private void updateUserServiceItems(SysUser sysUser) {
logger.info(sysUser.getName() + "开始更新用户服务项目");
int userId = sysUser.getUserId();
// 传入的服务项
List<String> sysUserServices = sysUser.getServiceKeyList();
userServiceItemsMapper.deleteByUserId(sysUser.getUserId());
// 添加新增的服务项
for (int i = 0; i < sysUserServices.size(); i++) {
SysUserServiceItems userServices = new SysUserServiceItems();
userServices.setUserId(userId);
userServices.setServiceCode(sysUserServices.get(i));
if (!sysUser.getInstallTimeList().isEmpty()) {
userServices.setInstallTime(sysUser.getInstallTimeList().get(i));
}
// 商户绑定状态默认为未绑定服务商
if (sysUser.getUserType() == com.glsx.common.constants.Constants.USER_TYPE_MERCHANT) {
userServices.setMatchStatus("sys_user_status_unbound_service");
}
userServiceItemsMapper.insertSelective(userServices);
}
logger.info("更新用户服务项目成功");
}
} }
<?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.glsx.usercenter.mapper.SysUserServiceItemsMapper">
<resultMap id="BaseResultMap" type="com.glsx.usercenter.pojo.user.SysUserServiceItems">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="user_id" jdbcType="INTEGER" property="userId" />
<result column="service_code" jdbcType="VARCHAR" property="serviceCode" />
<result column="match_status" jdbcType="VARCHAR" property="matchStatus" />
<result column="install_time" jdbcType="INTEGER" property="installTime" />
</resultMap>
<sql id="Base_Column_List">
id, user_id, service_code, match_status, install_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from sys_user_service_items
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from sys_user_service_items
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insertSelective" parameterType="com.glsx.usercenter.pojo.user.SysUserServiceItems">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into sys_user_service_items
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">
user_id,
</if>
<if test="serviceCode != null">
service_code,
</if>
<if test="matchStatus != null">
match_status,
</if>
<if test="installTime != null">
install_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">
#{userId,jdbcType=INTEGER},
</if>
<if test="serviceCode != null">
#{serviceCode,jdbcType=VARCHAR},
</if>
<if test="matchStatus != null">
#{matchStatus,jdbcType=VARCHAR},
</if>
<if test="installTime != null">
#{installTime,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.glsx.usercenter.pojo.user.SysUserServiceItems">
update sys_user_service_items
<set>
<if test="userId != null">
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="serviceCode != null">
service_code = #{serviceCode,jdbcType=VARCHAR},
</if>
<if test="matchStatus != null">
match_status = #{matchStatus,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<delete id="deleteByUserId">
DELETE FROM sys_user_service_items
WHERE user_id = #{userId,jdbcType=INTEGER}
</delete>
<select id="selectByUserId" resultType="com.glsx.usercenter.pojo.user.SysUserServiceItems">
SELECT
id ,
user_id userId,
service_code serviceCode,
match_status matchStatus,
install_time installTime,
FROM sys_user_service_items
WHERE user_id = #{userId,jdbcType=INTEGER}
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!