用户地址
This commit is contained in:
parent
1b71457b82
commit
e2e0d6f41e
|
|
@ -1,54 +1,54 @@
|
||||||
package com.bonus.common.houqin.utils.id;
|
//package com.bonus.common.houqin.utils.id;
|
||||||
|
//
|
||||||
import com.google.common.base.Preconditions;
|
//import com.google.common.base.Preconditions;
|
||||||
|
//
|
||||||
import java.time.LocalDateTime;
|
//import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
//import java.time.ZoneId;
|
||||||
|
//
|
||||||
public class Id {
|
//public class Id {
|
||||||
private static final long EPOCH = LocalDateTime.of(2021, 12, 29, 9, 2).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
// private static final long EPOCH = LocalDateTime.of(2021, 12, 29, 9, 2).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||||
private static final long SEQUENCE_BITS = 12L;
|
// private static final long SEQUENCE_BITS = 12L;
|
||||||
private static final long WORKER_ID_BITS = 10L;
|
// private static final long WORKER_ID_BITS = 10L;
|
||||||
static final long WORKER_ID_MAX_VALUE = 1024L;
|
// static final long WORKER_ID_MAX_VALUE = 1024L;
|
||||||
private static final long SEQUENCE_MASK = 4095L;
|
// private static final long SEQUENCE_MASK = 4095L;
|
||||||
private static final long WORKER_ID_LEFT_SHIFT_BITS = 12L;
|
// private static final long WORKER_ID_LEFT_SHIFT_BITS = 12L;
|
||||||
private static final long TIMESTAMP_LEFT_SHIFT_BITS = 22L;
|
// private static final long TIMESTAMP_LEFT_SHIFT_BITS = 22L;
|
||||||
static Long WORKER_ID;
|
// static Long WORKER_ID;
|
||||||
private static long SEQUENCE;
|
// private static long SEQUENCE;
|
||||||
private static long LAST_TIME;
|
// private static long LAST_TIME;
|
||||||
|
//
|
||||||
public Id(Long workerId) {
|
// public Id(Long workerId) {
|
||||||
WORKER_ID = workerId;
|
// WORKER_ID = workerId;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static long next() {
|
// public static long next() {
|
||||||
return nextKey();
|
// return nextKey();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static String nextString() {
|
// public static String nextString() {
|
||||||
return String.valueOf(next());
|
// return String.valueOf(next());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private static synchronized long nextKey() {
|
// private static synchronized long nextKey() {
|
||||||
long currentMillis = System.currentTimeMillis();
|
// long currentMillis = System.currentTimeMillis();
|
||||||
Preconditions.checkState(LAST_TIME <= currentMillis, "Clock is moving backwards, last time is %d milliseconds, current time is %d milliseconds", LAST_TIME, currentMillis);
|
// Preconditions.checkState(LAST_TIME <= currentMillis, "Clock is moving backwards, last time is %d milliseconds, current time is %d milliseconds", LAST_TIME, currentMillis);
|
||||||
if (LAST_TIME == currentMillis) {
|
// if (LAST_TIME == currentMillis) {
|
||||||
if (0L == (SEQUENCE = SEQUENCE + 1L & 4095L)) {
|
// if (0L == (SEQUENCE = SEQUENCE + 1L & 4095L)) {
|
||||||
currentMillis = waitUntilNextTime(currentMillis);
|
// currentMillis = waitUntilNextTime(currentMillis);
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
SEQUENCE = 0L;
|
// SEQUENCE = 0L;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
LAST_TIME = currentMillis;
|
// LAST_TIME = currentMillis;
|
||||||
return currentMillis - EPOCH << 22 | WORKER_ID << 12 | SEQUENCE;
|
// return currentMillis - EPOCH << 22 | WORKER_ID << 12 | SEQUENCE;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private static long waitUntilNextTime(final long lastTime) {
|
// private static long waitUntilNextTime(final long lastTime) {
|
||||||
long time;
|
// long time;
|
||||||
for(time = System.currentTimeMillis(); time <= lastTime; time = System.currentTimeMillis()) {
|
// for(time = System.currentTimeMillis(); time <= lastTime; time = System.currentTimeMillis()) {
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return time;
|
// return time;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,37 @@
|
||||||
package com.bonus.common.houqin.utils.id;
|
//package com.bonus.common.houqin.utils.id;
|
||||||
|
//
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
//import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
//
|
||||||
@ConfigurationProperties(
|
//@ConfigurationProperties(
|
||||||
prefix = "id"
|
// prefix = "id"
|
||||||
)
|
//)
|
||||||
public class IdProperties {
|
//public class IdProperties {
|
||||||
public static final String PREFIX = "id";
|
// public static final String PREFIX = "id";
|
||||||
private Boolean enabled = true;
|
// private Boolean enabled = true;
|
||||||
private String key = "worker_id_sequence";
|
// private String key = "worker_id_sequence";
|
||||||
private String workspace;
|
// private String workspace;
|
||||||
|
//
|
||||||
public Boolean getEnabled() {
|
// public Boolean getEnabled() {
|
||||||
return this.enabled;
|
// return this.enabled;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public String getKey() {
|
// public String getKey() {
|
||||||
return this.key;
|
// return this.key;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public String getWorkspace() {
|
// public String getWorkspace() {
|
||||||
return this.workspace;
|
// return this.workspace;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setEnabled(final Boolean enabled) {
|
// public void setEnabled(final Boolean enabled) {
|
||||||
this.enabled = enabled;
|
// this.enabled = enabled;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setKey(final String key) {
|
// public void setKey(final String key) {
|
||||||
this.key = key;
|
// this.key = key;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setWorkspace(final String workspace) {
|
// public void setWorkspace(final String workspace) {
|
||||||
this.workspace = workspace;
|
// this.workspace = workspace;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -1,123 +1,123 @@
|
||||||
package com.bonus.common.houqin.utils.id;
|
//package com.bonus.common.houqin.utils.id;
|
||||||
|
//
|
||||||
import cn.hutool.core.text.CharSequenceUtil;
|
//import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import org.apache.commons.io.FileUtils;
|
//import org.apache.commons.io.FileUtils;
|
||||||
import org.slf4j.Logger;
|
//import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
//import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
//import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
//import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
//import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.CollectionUtils;
|
//import org.springframework.util.CollectionUtils;
|
||||||
|
//
|
||||||
import java.io.File;
|
//import java.io.File;
|
||||||
import java.io.IOException;
|
//import java.io.IOException;
|
||||||
import java.io.RandomAccessFile;
|
//import java.io.RandomAccessFile;
|
||||||
import java.nio.channels.FileChannel;
|
//import java.nio.channels.FileChannel;
|
||||||
import java.nio.channels.FileLock;
|
//import java.nio.channels.FileLock;
|
||||||
import java.nio.charset.StandardCharsets;
|
//import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Collection;
|
//import java.util.Collection;
|
||||||
import java.util.UUID;
|
//import java.util.UUID;
|
||||||
|
//
|
||||||
@Component
|
//@Component
|
||||||
@ConditionalOnClass({StringRedisTemplate.class})
|
//@ConditionalOnClass({StringRedisTemplate.class})
|
||||||
@EnableConfigurationProperties({IdProperties.class})
|
//@EnableConfigurationProperties({IdProperties.class})
|
||||||
@ConditionalOnProperty(
|
//@ConditionalOnProperty(
|
||||||
prefix = "id",
|
// prefix = "id",
|
||||||
name = {"enabled"},
|
// name = {"enabled"},
|
||||||
havingValue = "true",
|
// havingValue = "true",
|
||||||
matchIfMissing = true
|
// matchIfMissing = true
|
||||||
)
|
//)
|
||||||
public class IdWorkConfiguration {
|
//public class IdWorkConfiguration {
|
||||||
private static final Logger log = LoggerFactory.getLogger(IdWorkConfiguration.class);
|
// private static final Logger log = LoggerFactory.getLogger(IdWorkConfiguration.class);
|
||||||
private final IdProperties idProperties;
|
// private final IdProperties idProperties;
|
||||||
|
//
|
||||||
public IdWorkConfiguration(StringRedisTemplate redisTemplate, IdProperties idProperties) throws IOException {
|
// public IdWorkConfiguration(StringRedisTemplate redisTemplate, IdProperties idProperties) throws IOException {
|
||||||
this.idProperties = idProperties;
|
// this.idProperties = idProperties;
|
||||||
Long workerId = this.getLocalWorkId();
|
// Long workerId = this.getLocalWorkId();
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
while(workerId == null) {
|
// while(workerId == null) {
|
||||||
Long newWorkId = redisTemplate.opsForValue().increment(idProperties.getKey(), 1L);
|
// Long newWorkId = redisTemplate.opsForValue().increment(idProperties.getKey(), 1L);
|
||||||
this.saveLocalWorkId(String.valueOf(newWorkId));
|
// this.saveLocalWorkId(String.valueOf(newWorkId));
|
||||||
workerId = this.getLocalWorkId();
|
// workerId = this.getLocalWorkId();
|
||||||
}
|
// }
|
||||||
} catch (Throwable var5) {
|
// } catch (Throwable var5) {
|
||||||
log.error("获取workID失败", var5);
|
// log.error("获取workID失败", var5);
|
||||||
throw var5;
|
// throw var5;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (workerId > 1024L) {
|
// if (workerId > 1024L) {
|
||||||
throw new RuntimeException("超过最大启动实例");
|
// throw new RuntimeException("超过最大启动实例");
|
||||||
} else {
|
// } else {
|
||||||
Id.WORKER_ID = workerId;
|
// Id.WORKER_ID = workerId;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void saveLocalWorkId(String workId) throws IOException {
|
// private void saveLocalWorkId(String workId) throws IOException {
|
||||||
File workIdHome = this.getWorkIdHome();
|
// File workIdHome = this.getWorkIdHome();
|
||||||
String var10002 = String.valueOf(workIdHome.getAbsoluteFile());
|
// String var10002 = String.valueOf(workIdHome.getAbsoluteFile());
|
||||||
FileUtils.writeStringToFile(new File(var10002 + "/" + String.valueOf(UUID.randomUUID()) + ".lock"), workId, StandardCharsets.UTF_8);
|
// FileUtils.writeStringToFile(new File(var10002 + "/" + String.valueOf(UUID.randomUUID()) + ".lock"), workId, StandardCharsets.UTF_8);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private File getWorkIdHome() {
|
// private File getWorkIdHome() {
|
||||||
String workHome = this.idProperties.getWorkspace();
|
// String workHome = this.idProperties.getWorkspace();
|
||||||
if (CharSequenceUtil.isBlank(workHome)) {
|
// if (CharSequenceUtil.isBlank(workHome)) {
|
||||||
workHome = FileUtils.getUserDirectoryPath() + "/.workId/";
|
// workHome = FileUtils.getUserDirectoryPath() + "/.workId/";
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
String var10002 = CharSequenceUtil.removeSuffix(workHome, "/");
|
// String var10002 = CharSequenceUtil.removeSuffix(workHome, "/");
|
||||||
return new File(var10002 + "/" + this.idProperties.getKey());
|
// return new File(var10002 + "/" + this.idProperties.getKey());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private Long getLocalWorkId() throws IOException {
|
// private Long getLocalWorkId() throws IOException {
|
||||||
File workIdHome = this.getWorkIdHome();
|
// File workIdHome = this.getWorkIdHome();
|
||||||
if (!workIdHome.exists()) {
|
// if (!workIdHome.exists()) {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Collection<File> files = FileUtils.listFiles(workIdHome, new String[]{"lock"}, false);
|
// Collection<File> files = FileUtils.listFiles(workIdHome, new String[]{"lock"}, false);
|
||||||
if (CollectionUtils.isEmpty(files)) {
|
// if (CollectionUtils.isEmpty(files)) {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
for (File file : files) {
|
// for (File file : files) {
|
||||||
FileChannel channel = null;
|
// FileChannel channel = null;
|
||||||
FileLock fileLock = null;
|
// FileLock fileLock = null;
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
|
// RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
|
||||||
channel = randomAccessFile.getChannel();
|
// channel = randomAccessFile.getChannel();
|
||||||
fileLock = channel.tryLock();
|
// fileLock = channel.tryLock();
|
||||||
|
//
|
||||||
if (fileLock != null) { // 成功获取文件锁
|
// if (fileLock != null) { // 成功获取文件锁
|
||||||
Long workId = Long.valueOf(randomAccessFile.readLine());
|
// Long workId = Long.valueOf(randomAccessFile.readLine());
|
||||||
releaseResourcesOnShutdown(channel);
|
// releaseResourcesOnShutdown(channel);
|
||||||
return workId;
|
// return workId;
|
||||||
}
|
// }
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
log.error("Error accessing workId file", e);
|
// log.error("Error accessing workId file", e);
|
||||||
} finally {
|
// } finally {
|
||||||
if (fileLock == null && channel != null) {
|
// if (fileLock == null && channel != null) {
|
||||||
try {
|
// try {
|
||||||
channel.close();
|
// channel.close();
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
log.error("Failed to close file channel", e);
|
// log.error("Failed to close file channel", e);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void releaseResourcesOnShutdown(FileChannel channel) {
|
// private void releaseResourcesOnShutdown(FileChannel channel) {
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
// Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||||
try {
|
// try {
|
||||||
channel.close();
|
// channel.close();
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
log.error("Release WorkId file lock error", e);
|
// log.error("Release WorkId file lock error", e);
|
||||||
}
|
// }
|
||||||
}));
|
// }));
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,6 @@ import com.bonus.common.core.web.domain.BaseEntity;
|
||||||
public class UserAddr extends BaseEntity {
|
public class UserAddr extends BaseEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 主键自增 */
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/** 人员id */
|
/** 人员id */
|
||||||
@Excel(name = "人员id")
|
@Excel(name = "人员id")
|
||||||
@ApiModelProperty(value = "人员id")
|
@ApiModelProperty(value = "人员id")
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import java.util.List;
|
||||||
import com.bonus.canteen.core.common.enums.YesOrNoEnum;
|
import com.bonus.canteen.core.common.enums.YesOrNoEnum;
|
||||||
import com.bonus.common.core.exception.ServiceException;
|
import com.bonus.common.core.exception.ServiceException;
|
||||||
import com.bonus.common.core.utils.DateUtils;
|
import com.bonus.common.core.utils.DateUtils;
|
||||||
import com.bonus.common.houqin.utils.id.Id;
|
|
||||||
import com.bonus.common.security.utils.SecurityUtils;
|
import com.bonus.common.security.utils.SecurityUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -57,7 +56,6 @@ public class UserAddrServiceImpl implements IUserAddrService {
|
||||||
public int insertUserAddr(UserAddr userAddr) {
|
public int insertUserAddr(UserAddr userAddr) {
|
||||||
userAddr.setCreateTime(DateUtils.getNowDate());
|
userAddr.setCreateTime(DateUtils.getNowDate());
|
||||||
userAddr.setUserId(SecurityUtils.getUserId());
|
userAddr.setUserId(SecurityUtils.getUserId());
|
||||||
userAddr.setAddrId(Id.next());
|
|
||||||
try {
|
try {
|
||||||
return userAddrMapper.insertUserAddr(userAddr);
|
return userAddrMapper.insertUserAddr(userAddr);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
@ -87,7 +85,7 @@ public class UserAddrServiceImpl implements IUserAddrService {
|
||||||
userAddr.setUpdateTime(DateUtils.getNowDate());
|
userAddr.setUpdateTime(DateUtils.getNowDate());
|
||||||
try {
|
try {
|
||||||
userAddrMapper.updateUserAddrAsNotDefault(userAddr.getUserId(), YesOrNoEnum.NO.key());
|
userAddrMapper.updateUserAddrAsNotDefault(userAddr.getUserId(), YesOrNoEnum.NO.key());
|
||||||
userAddrMapper.updateUserAddrAsDefault(userAddr.getUserId(), userAddr.getId(), YesOrNoEnum.YES.key());
|
userAddrMapper.updateUserAddrAsDefault(userAddr.getUserId(), userAddr.getAddrId(), YesOrNoEnum.YES.key());
|
||||||
return 1;
|
return 1;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ServiceException("设置默认地址失败");
|
throw new ServiceException("设置默认地址失败");
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,16 @@ import com.bonus.common.houqin.mq.MQConfiguration;
|
||||||
import com.bonus.common.houqin.mq.mqtt.MqttProperties;
|
import com.bonus.common.houqin.mq.mqtt.MqttProperties;
|
||||||
import com.bonus.common.houqin.mq.rabbit.RabbitConfiguration;
|
import com.bonus.common.houqin.mq.rabbit.RabbitConfiguration;
|
||||||
import com.bonus.common.houqin.mq.rocket.RocketConfiguration;
|
import com.bonus.common.houqin.mq.rocket.RocketConfiguration;
|
||||||
import com.bonus.common.houqin.utils.id.IdWorkConfiguration;
|
//import com.bonus.common.houqin.utils.id.IdWorkConfiguration;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
|
//@Configuration
|
||||||
|
//@Import({IdWorkConfiguration.class, I18nConfiguration.class, MQConfiguration.class, RabbitConfiguration.class, RocketConfiguration.class, MqttProperties.class})
|
||||||
|
//public class CommonConfiguration {
|
||||||
|
//}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({IdWorkConfiguration.class, I18nConfiguration.class, MQConfiguration.class, RabbitConfiguration.class, RocketConfiguration.class, MqttProperties.class})
|
@Import({I18nConfiguration.class, MQConfiguration.class, RabbitConfiguration.class, RocketConfiguration.class, MqttProperties.class})
|
||||||
public class CommonConfiguration {
|
public class CommonConfiguration {
|
||||||
}
|
}
|
||||||
|
|
@ -4,7 +4,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.bonus.canteen.core.user.mapper.UserAddrMapper">
|
<mapper namespace="com.bonus.canteen.core.user.mapper.UserAddrMapper">
|
||||||
<resultMap type="com.bonus.canteen.core.user.domain.UserAddr" id="UserAddrResult">
|
<resultMap type="com.bonus.canteen.core.user.domain.UserAddr" id="UserAddrResult">
|
||||||
<result property="id" column="id" />
|
|
||||||
<result property="userId" column="user_id" />
|
<result property="userId" column="user_id" />
|
||||||
<result property="addrId" column="addr_id" />
|
<result property="addrId" column="addr_id" />
|
||||||
<result property="contactName" column="contact_name" />
|
<result property="contactName" column="contact_name" />
|
||||||
|
|
@ -25,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectUserAddrVo">
|
<sql id="selectUserAddrVo">
|
||||||
select id, user_id, addr_id, contact_name, mobile, area_code, detail_addr, addr_full_name, openid, source_type, if_default, revision, place_id, create_by, create_time, update_by, update_time, del_flag from user_addr
|
select user_id, addr_id, contact_name, mobile, area_code, detail_addr, addr_full_name, openid, source_type, if_default, revision, place_id, create_by, create_time, update_by, update_time, del_flag from user_addr
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectUserAddrList" parameterType="com.bonus.canteen.core.user.domain.UserAddr" resultMap="UserAddrResult">
|
<select id="selectUserAddrList" parameterType="com.bonus.canteen.core.user.domain.UserAddr" resultMap="UserAddrResult">
|
||||||
|
|
@ -51,11 +50,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertUserAddr" parameterType="com.bonus.canteen.core.user.domain.UserAddr" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertUserAddr" parameterType="com.bonus.canteen.core.user.domain.UserAddr" useGeneratedKeys="true" keyProperty="addrId">
|
||||||
insert into user_addr
|
insert into user_addr
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="userId != null">user_id,</if>
|
<if test="userId != null">user_id,</if>
|
||||||
<if test="addrId != null">addr_id,</if>
|
|
||||||
<if test="contactName != null and contactName != ''">contact_name,</if>
|
<if test="contactName != null and contactName != ''">contact_name,</if>
|
||||||
<if test="mobile != null and mobile != ''">mobile,</if>
|
<if test="mobile != null and mobile != ''">mobile,</if>
|
||||||
<if test="areaCode != null and areaCode != ''">area_code,</if>
|
<if test="areaCode != null and areaCode != ''">area_code,</if>
|
||||||
|
|
@ -74,7 +72,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="userId != null">#{userId},</if>
|
<if test="userId != null">#{userId},</if>
|
||||||
<if test="addrId != null">#{addrId},</if>
|
|
||||||
<if test="contactName != null and contactName != ''">#{contactName},</if>
|
<if test="contactName != null and contactName != ''">#{contactName},</if>
|
||||||
<if test="mobile != null and mobile != ''">#{mobile},</if>
|
<if test="mobile != null and mobile != ''">#{mobile},</if>
|
||||||
<if test="areaCode != null and areaCode != ''">#{areaCode},</if>
|
<if test="areaCode != null and areaCode != ''">#{areaCode},</if>
|
||||||
|
|
@ -97,7 +94,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
update user_addr
|
update user_addr
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
<if test="userId != null">user_id = #{userId},</if>
|
<if test="userId != null">user_id = #{userId},</if>
|
||||||
<if test="addrId != null">addr_id = #{addrId},</if>
|
|
||||||
<if test="contactName != null and contactName != ''">contact_name = #{contactName},</if>
|
<if test="contactName != null and contactName != ''">contact_name = #{contactName},</if>
|
||||||
<if test="mobile != null and mobile != ''">mobile = #{mobile},</if>
|
<if test="mobile != null and mobile != ''">mobile = #{mobile},</if>
|
||||||
<if test="areaCode != null and areaCode != ''">area_code = #{areaCode},</if>
|
<if test="areaCode != null and areaCode != ''">area_code = #{areaCode},</if>
|
||||||
|
|
@ -114,7 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where addr_id = #{addrId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<update id="updateUserAddrAsNotDefault">
|
<update id="updateUserAddrAsNotDefault">
|
||||||
|
|
@ -122,17 +118,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<update id="updateUserAddrAsDefault">
|
<update id="updateUserAddrAsDefault">
|
||||||
update user_addr set if_default = #{ifDefault} where user_id = #{userId} and id = #{id}
|
update user_addr set if_default = #{ifDefault} where user_id = #{userId} and addr_id = #{addrId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<delete id="deleteUserAddrById" parameterType="Long">
|
<delete id="deleteUserAddrById" parameterType="Long">
|
||||||
delete from user_addr where id = #{id}
|
delete from user_addr where addr_id = #{addrId}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<delete id="deleteUserAddrByIds" parameterType="String">
|
<delete id="deleteUserAddrByIds" parameterType="String">
|
||||||
delete from user_addr where id in
|
delete from user_addr where addr_id in
|
||||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
<foreach item="addrId" collection="array" open="(" separator="," close=")">
|
||||||
#{id}
|
#{addrId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue