feat:验证码(选择图形验证码)接口开发
This commit is contained in:
@@ -3,4 +3,6 @@ package com.xiang.xservice.auth.service.constants;
|
||||
public class RedisConstant {
|
||||
|
||||
public static final String XS_PERMISSION_ROLE = "auth:permission:role";
|
||||
public static final String XS_SMS_CODE_KEY = "auth:sms:code:key:";
|
||||
public static final String XS_CAPTCHA_CODE_KEY = "auth:captcha:code:key:";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xiang.xservice.auth.service.convert;
|
||||
|
||||
import com.xiang.xservice.auth.api.dto.resp.XCaptchaImageDTO;
|
||||
import com.xiang.xservice.auth.service.entity.XCaptchaImage;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface XCaptchaImageConvert {
|
||||
XDeptConvert INSTANCE = Mappers.getMapper(XDeptConvert.class);
|
||||
|
||||
XCaptchaImageDTO toDTO(XCaptchaImage captchaImage);
|
||||
List<XCaptchaImageDTO> toDTOList(List<XCaptchaImage> captchaImage);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.xiang.xservice.auth.service.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class XCaptchaImage implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 类型id
|
||||
*/
|
||||
private Long typeId;
|
||||
|
||||
/**
|
||||
* 图片地址url
|
||||
*/
|
||||
private String imageUrl;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 是否删除(0:否 1:是)
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updateBy;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.xiang.xservice.auth.service.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class XCaptchaType implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 图片类型
|
||||
*/
|
||||
private Integer imageType;
|
||||
|
||||
/**
|
||||
* 类型名称
|
||||
*/
|
||||
private String typeName;
|
||||
|
||||
/**
|
||||
* 状态(0:禁用,1:启用)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除标识(0:未删除 1:已删除)
|
||||
*/
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -7,8 +7,9 @@ import lombok.Getter;
|
||||
@AllArgsConstructor
|
||||
public enum CaptchaTypeEnum {
|
||||
|
||||
NORMAL_CAPTCHA_IMAGE(1, "图形验证码"),
|
||||
|
||||
NUMBER_CAPTCHA_CODE(-1, "数字验证码"),
|
||||
NORMAL_CAPTCHA_IMAGE(0, "图形验证码"),
|
||||
IMAGE_CAPTCHA_CHOOSE(1, "图形选择验证码")
|
||||
;
|
||||
|
||||
private final Integer type;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.xiang.xservice.auth.service.repository.mapper;
|
||||
|
||||
import com.xiang.xservice.auth.service.entity.XCaptchaImage;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface XCaptchaImageMapper {
|
||||
|
||||
List<XCaptchaImage> getByTypeId(@Param("typeId") Long typeId);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xiang.xservice.auth.service.repository.mapper;
|
||||
|
||||
import com.xiang.xservice.auth.service.entity.XCaptchaType;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface XCaptchaTypeMapper {
|
||||
|
||||
List<XCaptchaType> getCaptchaTypeList(XCaptchaType xCaptchaType);
|
||||
List<XCaptchaType> getAllAvailableCaptchaTypeList();
|
||||
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.xiang.xservice.auth.service.service;
|
||||
|
||||
import com.xiang.xservice.auth.api.dto.req.CaptchaImageRequest;
|
||||
import com.xiang.xservice.auth.api.dto.resp.CaptchaDTO;
|
||||
import com.xiang.xservice.auth.service.enums.CaptchaTypeEnum;
|
||||
|
||||
public interface ICaptchaService {
|
||||
|
||||
String getCaptchaImage();
|
||||
CaptchaDTO getCaptchaImage(CaptchaImageRequest request);
|
||||
|
||||
CaptchaTypeEnum getCaptchaType();
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@Component
|
||||
public class CaptchaGenerateFactory {
|
||||
public class ValidCodeGenerateFactory {
|
||||
|
||||
private final Map<Integer, ICaptchaService> strategies = Maps.newConcurrentMap();
|
||||
|
||||
public CaptchaGenerateFactory(List<ICaptchaService> strategyList) {
|
||||
public ValidCodeGenerateFactory(List<ICaptchaService> strategyList) {
|
||||
for (ICaptchaService captchaService : strategyList) {
|
||||
strategies.put(captchaService.getCaptchaType().getType(), captchaService);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.xiang.xservice.auth.service.service.impl.captcha;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.xiang.xservice.auth.api.dto.req.CaptchaImageRequest;
|
||||
import com.xiang.xservice.auth.api.dto.resp.CaptchaDTO;
|
||||
import com.xiang.xservice.auth.service.convert.XCaptchaImageConvert;
|
||||
import com.xiang.xservice.auth.service.entity.XCaptchaImage;
|
||||
import com.xiang.xservice.auth.service.entity.XCaptchaType;
|
||||
import com.xiang.xservice.auth.service.enums.CaptchaTypeEnum;
|
||||
import com.xiang.xservice.auth.service.repository.mapper.XCaptchaImageMapper;
|
||||
import com.xiang.xservice.auth.service.repository.mapper.XCaptchaTypeMapper;
|
||||
import com.xiang.xservice.auth.service.service.ICaptchaService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ImageChooseCaptcha implements ICaptchaService {
|
||||
private final XCaptchaTypeMapper captchaTypeMapper;
|
||||
private final XCaptchaImageMapper captchaImageMapper;
|
||||
private final XCaptchaImageConvert captchaImageConvert;
|
||||
|
||||
|
||||
@Override
|
||||
public CaptchaDTO getCaptchaImage(CaptchaImageRequest request) {
|
||||
CaptchaDTO captchaDTO = new CaptchaDTO();
|
||||
List<XCaptchaType> typeList = captchaTypeMapper.getAllAvailableCaptchaTypeList();
|
||||
Map<Long, XCaptchaType> typeMap = typeList.stream().collect(Collectors.toMap(XCaptchaType::getId, Function.identity(), (a, b) -> a));
|
||||
if (CollectionUtils.isNotEmpty(typeList)) {
|
||||
List<Long> types = new java.util.ArrayList<>(typeList.stream().map(XCaptchaType::getId).distinct().toList());
|
||||
Collections.shuffle(types);
|
||||
List<XCaptchaImage> result = Lists.newArrayList();
|
||||
// 第一组
|
||||
Long type = types.get(0);
|
||||
XCaptchaType captchaType = typeMap.get(type);
|
||||
String question = "请选择所有" + captchaType.getTypeName();
|
||||
// 问题
|
||||
captchaDTO.setQuestions(question);
|
||||
List<XCaptchaImage> captchaImages = buildCaptchaMap(type, result);
|
||||
List<Long> captchaIds = captchaImages.stream().map(XCaptchaImage::getId).toList();
|
||||
// 正确的图片id集合
|
||||
captchaDTO.setCaptchaIds(captchaIds);
|
||||
|
||||
type = types.get(1);
|
||||
buildCaptchaMap(type, result);
|
||||
|
||||
type = types.get(2);
|
||||
buildCaptchaMap(type, result);
|
||||
Collections.shuffle(result);
|
||||
// 所有的验证码集合
|
||||
captchaDTO.setCaptchaCode(captchaImageConvert.toDTOList(result));
|
||||
}
|
||||
return captchaDTO;
|
||||
}
|
||||
|
||||
private List<XCaptchaImage> buildCaptchaMap(Long type, List<XCaptchaImage> result) {
|
||||
List<XCaptchaImage> images = captchaImageMapper.getByTypeId(type);
|
||||
Collections.shuffle(images);
|
||||
images = images.subList(0, 2);
|
||||
result.addAll(images);
|
||||
return images;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CaptchaTypeEnum getCaptchaType() {
|
||||
return CaptchaTypeEnum.IMAGE_CAPTCHA_CHOOSE;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.xiang.xservice.auth.service.service.impl.captcha;
|
||||
|
||||
import com.xiang.xservice.auth.api.dto.req.CaptchaImageRequest;
|
||||
import com.xiang.xservice.auth.api.dto.resp.CaptchaDTO;
|
||||
import com.xiang.xservice.auth.service.constants.RedisConstant;
|
||||
import com.xiang.xservice.auth.service.enums.CaptchaTypeEnum;
|
||||
import com.xiang.xservice.auth.service.service.ICaptchaService;
|
||||
import com.xiang.xservice.basic.utils.RandomCodeUtils;
|
||||
@@ -15,6 +18,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Base64;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -27,11 +31,10 @@ public class NormalCaptchaImage implements ICaptchaService {
|
||||
private static final int WIDTH = 160;// 宽
|
||||
private static final int HEIGHT = 40;// 高
|
||||
private static final int LINE_SIZE = 30;// 干扰线数量
|
||||
private static final int STRING_NUMBER = 4;//随机产生字符的个数
|
||||
|
||||
|
||||
@Override
|
||||
public String getCaptchaImage() {
|
||||
public CaptchaDTO getCaptchaImage(CaptchaImageRequest request) {
|
||||
// BufferedImage类是具有缓冲区的Image类,Image类是用于描述图像信息的类
|
||||
BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_BGR);
|
||||
Graphics g = image.getGraphics();
|
||||
@@ -44,11 +47,13 @@ public class NormalCaptchaImage implements ICaptchaService {
|
||||
drawLine(g);
|
||||
}
|
||||
String randomCode = "";
|
||||
CaptchaDTO captchaDTO = new CaptchaDTO();
|
||||
// 绘制随机字符
|
||||
for (int i = 0; i < STRING_NUMBER; i++) {
|
||||
for (int i = 0; i < request.getNumber(); i++) {
|
||||
randomCode = drawString(g, randomCode, i);
|
||||
}
|
||||
log.info("生成的随机验证码:{}", randomCode);
|
||||
redisService.set(RedisConstant.XS_CAPTCHA_CODE_KEY + request.getUsername(), randomCode, 5, TimeUnit.MINUTES);
|
||||
g.dispose();
|
||||
|
||||
String base64String = "";
|
||||
@@ -60,11 +65,12 @@ public class NormalCaptchaImage implements ICaptchaService {
|
||||
byte[] bytes = bos.toByteArray();
|
||||
Base64.Encoder encoder = Base64.getEncoder();
|
||||
base64String = encoder.encodeToString(bytes);
|
||||
return base64String;
|
||||
captchaDTO.setCaptchaImageCode(base64String);
|
||||
return captchaDTO;
|
||||
} catch (IOException e) {
|
||||
log.error("IO异常,验证码异常", e);
|
||||
}
|
||||
return base64String;
|
||||
return captchaDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.xiang.xservice.auth.service.service.impl.captcha;
|
||||
|
||||
import com.xiang.xservice.auth.api.dto.req.CaptchaImageRequest;
|
||||
import com.xiang.xservice.auth.api.dto.resp.CaptchaDTO;
|
||||
import com.xiang.xservice.auth.service.constants.RedisConstant;
|
||||
import com.xiang.xservice.auth.service.enums.CaptchaTypeEnum;
|
||||
import com.xiang.xservice.auth.service.service.ICaptchaService;
|
||||
import com.xiang.xservice.basic.utils.RandomCodeUtils;
|
||||
import com.xiang.xservice.cache.service.IRedisService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class NumberCaptchaCode implements ICaptchaService {
|
||||
private final IRedisService redisService;
|
||||
|
||||
@Override
|
||||
public CaptchaDTO getCaptchaImage(CaptchaImageRequest request) {
|
||||
String randomCode = RandomCodeUtils.getMixtureRandomCode(request.getNumber());
|
||||
redisService.set(RedisConstant.XS_SMS_CODE_KEY + request.getUsername(), randomCode, 5, TimeUnit.MINUTES);
|
||||
CaptchaDTO captchaDTO = new CaptchaDTO();
|
||||
captchaDTO.setCaptchaImageCode(randomCode);
|
||||
return captchaDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CaptchaTypeEnum getCaptchaType() {
|
||||
return CaptchaTypeEnum.NUMBER_CAPTCHA_CODE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?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.xiang.xservice.auth.service.repository.mapper.XCaptchaImageMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.xiang.xservice.auth.service.entity.XCaptchaImage" >
|
||||
<result column="id" property="id" />
|
||||
<result column="type_id" property="typeId" />
|
||||
<result column="image_url" property="imageUrl" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="create_by" property="createBy" />
|
||||
<result column="del_flag" property="delFlag" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="update_by" property="updateBy" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,
|
||||
type_id,
|
||||
image_url,
|
||||
create_time,
|
||||
create_by,
|
||||
del_flag,
|
||||
update_time,
|
||||
update_by
|
||||
</sql>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="com.xiang.xservice.auth.service.entity.XCaptchaImage">
|
||||
INSERT INTO x_captcha_image
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="null != typeId ">
|
||||
type_id,
|
||||
</if>
|
||||
<if test="null != imageUrl and '' != imageUrl">
|
||||
image_url,
|
||||
</if>
|
||||
<if test="null != createTime ">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="null != createBy and '' != createBy">
|
||||
create_by,
|
||||
</if>
|
||||
<if test="null != delFlag ">
|
||||
del_flag,
|
||||
</if>
|
||||
<if test="null != updateTime ">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="null != updateBy and '' != updateBy">
|
||||
update_by
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="null != typeId ">
|
||||
#{typeId},
|
||||
</if>
|
||||
<if test="null != imageUrl and '' != imageUrl">
|
||||
#{imageUrl},
|
||||
</if>
|
||||
<if test="null != createTime ">
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="null != createBy and '' != createBy">
|
||||
#{createBy},
|
||||
</if>
|
||||
<if test="null != delFlag ">
|
||||
#{delFlag},
|
||||
</if>
|
||||
<if test="null != updateTime ">
|
||||
#{updateTime},
|
||||
</if>
|
||||
<if test="null != updateBy and '' != updateBy">
|
||||
#{updateBy}
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.xiang.xservice.auth.service.entity.XCaptchaImage">
|
||||
UPDATE x_captcha_image
|
||||
<set>
|
||||
<if test="null != typeId ">type_id = #{typeId},</if>
|
||||
<if test="null != imageUrl and '' != imageUrl">image_url = #{imageUrl},</if>
|
||||
<if test="null != createTime ">create_time = #{createTime},</if>
|
||||
<if test="null != createBy and '' != createBy">create_by = #{createBy},</if>
|
||||
<if test="null != delFlag ">del_flag = #{delFlag},</if>
|
||||
<if test="null != updateTime ">update_time = #{updateTime},</if>
|
||||
<if test="null != updateBy and '' != updateBy">update_by = #{updateBy}</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
<select id="getByTypeId" resultMap="BaseResultMap">
|
||||
select <include refid="Base_Column_List"/>
|
||||
from x_captcha_image where del_flag = 0 and type_id = #{typeId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
122
xs-service/src/main/resources/mapper/user/XCaptchaTypeMapper.xml
Normal file
122
xs-service/src/main/resources/mapper/user/XCaptchaTypeMapper.xml
Normal file
@@ -0,0 +1,122 @@
|
||||
<?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.xiang.xservice.auth.service.repository.mapper.XCaptchaTypeMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.xiang.xservice.auth.service.entity.XCaptchaType" >
|
||||
<result column="id" property="id" />
|
||||
<result column="image_type" property="imageType" />
|
||||
<result column="type_name" property="typeName" />
|
||||
<result column="status" property="status" />
|
||||
<result column="create_by" property="createBy" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_by" property="updateBy" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="del_flag" property="delFlag" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,
|
||||
image_type,
|
||||
type_name,
|
||||
status,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
del_flag
|
||||
</sql>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="com.xiang.xservice.auth.service.entity.XCaptchaType">
|
||||
INSERT INTO x_captcha_type
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="null != imageType ">
|
||||
image_type,
|
||||
</if>
|
||||
<if test="null != typeName and '' != typeName">
|
||||
type_name,
|
||||
</if>
|
||||
<if test="null != status ">
|
||||
status,
|
||||
</if>
|
||||
<if test="null != createBy and '' != createBy">
|
||||
create_by,
|
||||
</if>
|
||||
<if test="null != createTime ">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="null != updateBy and '' != updateBy">
|
||||
update_by,
|
||||
</if>
|
||||
<if test="null != updateTime ">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="null != delFlag ">
|
||||
del_flag
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="null != imageType ">
|
||||
#{imageType},
|
||||
</if>
|
||||
<if test="null != typeName and '' != typeName">
|
||||
#{typeName},
|
||||
</if>
|
||||
<if test="null != status ">
|
||||
#{status},
|
||||
</if>
|
||||
<if test="null != createBy and '' != createBy">
|
||||
#{createBy},
|
||||
</if>
|
||||
<if test="null != createTime ">
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="null != updateBy and '' != updateBy">
|
||||
#{updateBy},
|
||||
</if>
|
||||
<if test="null != updateTime ">
|
||||
#{updateTime},
|
||||
</if>
|
||||
<if test="null != delFlag ">
|
||||
#{delFlag}
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.xiang.xservice.auth.service.entity.XCaptchaType">
|
||||
UPDATE x_captcha_type
|
||||
<set>
|
||||
<if test="null != imageType ">image_type = #{imageType},</if>
|
||||
<if test="null != typeName and '' != typeName">type_name = #{typeName},</if>
|
||||
<if test="null != status ">status = #{status},</if>
|
||||
<if test="null != createBy and '' != createBy">create_by = #{createBy},</if>
|
||||
<if test="null != createTime ">create_time = #{createTime},</if>
|
||||
<if test="null != updateBy and '' != updateBy">update_by = #{updateBy},</if>
|
||||
<if test="null != updateTime ">update_time = #{updateTime},</if>
|
||||
<if test="null != delFlag ">del_flag = #{delFlag}</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
<select id="getCaptchaTypeList" resultMap="BaseResultMap">
|
||||
select <include refid="Base_Column_List"/>
|
||||
from x_captcha_type
|
||||
<trim prefix="AND">
|
||||
<where>
|
||||
status = 1 and del_flag = 0
|
||||
<if test="imageType != null">and image_type = #{imageType}</if>
|
||||
<if test="typeName != null and typeName != ''">and type_name = #{typeName}</if>
|
||||
</where>
|
||||
</trim>
|
||||
</select>
|
||||
|
||||
<select id="getAllAvailableCaptchaTypeList" resultMap="BaseResultMap">
|
||||
select <include refid="Base_Column_List"/>
|
||||
from x_captcha_type
|
||||
where status = 1 and del_flag = 0
|
||||
<trim prefix="AND">
|
||||
<if test="imageType != null">and image_type = #{imageType}</if>
|
||||
<if test="typeName != null and typeName != ''">and type_name = #{typeName}</if>
|
||||
</trim>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user