添加图片(类型搜索, 商品列表, 添加商品, 上传图片)
parent
6d4c584e41
commit
b1cc202f06
|
@ -0,0 +1,8 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,com.github.pagehelper.page.PageMethod,startPage" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
|
@ -98,12 +98,23 @@
|
|||
<artifactId>dysmsapi20170525</artifactId>
|
||||
<version>2.0.1</version>
|
||||
</dependency>
|
||||
<!-- oss 图片上传 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.12.0</version>
|
||||
</dependency>
|
||||
<!-- rabbitMQ -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--fastDfs文件上传-->
|
||||
<dependency>
|
||||
<groupId>com.github.tobato</groupId>
|
||||
<artifactId>fastdfs-client</artifactId>
|
||||
<version>1.26.5</version>
|
||||
</dependency>
|
||||
|
||||
<!--短信依赖 5条依赖-->
|
||||
<dependency>
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package com.bwie.common.pojo.DTO;
|
||||
|
||||
import com.bwie.common.pojo.Picture;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
|
@ -22,4 +25,9 @@ public class DTOShop {
|
|||
//商品类型名称
|
||||
private String typeName;
|
||||
|
||||
//图片
|
||||
private List<String> pictureUrl;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package com.bwie.common.pojo.VO;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class VOShop {
|
||||
|
||||
//类型id
|
||||
private Integer typeId;
|
||||
//商品id
|
||||
private Integer shopId;
|
||||
//商品名称
|
||||
private String shopName;
|
||||
//商品价格
|
||||
private double shopPrice;
|
||||
//商品类型名称
|
||||
private String typeName;
|
||||
|
||||
//图片
|
||||
private List<String> pictureUrl;
|
||||
|
||||
//分页
|
||||
private Integer pageNum=1;
|
||||
private Integer pageSize=3;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.bwie.common.utils;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
|
||||
import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @BelongsProject: 0107day02
|
||||
* @BelongsPackage: com.bw.config
|
||||
* @Author: zhupengfei
|
||||
* @CreateTime: 2023-02-01 08:52
|
||||
*/
|
||||
@Component
|
||||
public class FastUtil {
|
||||
private static final Logger log = LoggerFactory.getLogger(FastUtil.class);
|
||||
|
||||
@Resource
|
||||
private FastFileStorageClient storageClient ;
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*/
|
||||
public String upload(MultipartFile multipartFile) throws Exception{
|
||||
String originalFilename = multipartFile.getOriginalFilename().
|
||||
substring(multipartFile.getOriginalFilename().
|
||||
lastIndexOf(".") + 1);
|
||||
StorePath storePath = this.storageClient.uploadImageAndCrtThumbImage(
|
||||
multipartFile.getInputStream(),
|
||||
multipartFile.getSize(),originalFilename , null);
|
||||
return storePath.getFullPath();
|
||||
}
|
||||
/**
|
||||
* 删除文件
|
||||
*/
|
||||
public String deleteFile(String fileUrl) {
|
||||
if (StringUtils.isEmpty(fileUrl)) {
|
||||
log.info("fileUrl == >>文件路径为空...");
|
||||
return "文件路径不能为空";
|
||||
}
|
||||
try {
|
||||
StorePath storePath = StorePath.parseFromUrl(fileUrl);
|
||||
storageClient.deleteFile(storePath.getGroup(), storePath.getPath());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return "删除成功";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package com.bwie.common.utils;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @description: 生成验证码工具类
|
||||
* @Date 2023-5-11 上午 10:09
|
||||
*/
|
||||
public class GenCodeUtils {
|
||||
|
||||
/**
|
||||
* 数字类型
|
||||
*/
|
||||
private static final String NUMBER_STR = "0123456789";
|
||||
/**
|
||||
* 字母类型
|
||||
*/
|
||||
private static final String LETTERS_STR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
/**
|
||||
* 短信验证码长度
|
||||
*/
|
||||
private static final Integer SMS_CODE_LENGTH = 4;
|
||||
|
||||
/**
|
||||
* 生成短信四位验证码
|
||||
* @return 验证码
|
||||
*/
|
||||
public static String genLetterStrSms(){
|
||||
return genCode(LETTERS_STR, SMS_CODE_LENGTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成短信四位验证码
|
||||
* @return 验证码
|
||||
*/
|
||||
public static String genNumberCodeSms(){
|
||||
return genCode(NUMBER_STR, SMS_CODE_LENGTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成验证码
|
||||
* @param codeLength 验证码长度
|
||||
* @return 验证码
|
||||
*/
|
||||
public static String genLetterStr(int codeLength){
|
||||
return genCode(LETTERS_STR, codeLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成验证码
|
||||
* @param codeLength 验证码长度
|
||||
* @return 验证码
|
||||
*/
|
||||
public static String genNumberCode( int codeLength){
|
||||
return genCode(NUMBER_STR, codeLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成验证码
|
||||
* @param str 验证码字符串
|
||||
* @param codeLength 验证码长度
|
||||
* @return 验证码
|
||||
*/
|
||||
public static String genCode (String str, int codeLength){
|
||||
//将字符串转换为一个新的字符数组。
|
||||
char[] verificationCodeArray = str.toCharArray();
|
||||
Random random = new Random();
|
||||
//计数器
|
||||
int count = 0;
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
do {
|
||||
//随机生成一个随机数
|
||||
int index = random.nextInt(verificationCodeArray.length);
|
||||
char c = verificationCodeArray[index];
|
||||
//限制四位不重复数字
|
||||
if (stringBuilder.indexOf(String.valueOf(c)) == -1) {
|
||||
stringBuilder.append(c);
|
||||
//计数器加1
|
||||
count++;
|
||||
}
|
||||
//当count等于4时结束,随机生成四位数的验证码
|
||||
} while (count != codeLength);
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
package com.bwie.common.utils;
|
||||
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.model.GetObjectRequest;
|
||||
import com.aliyun.oss.model.PutObjectRequest;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Oss服务调用
|
||||
*/
|
||||
@Log4j2
|
||||
public class OssUtil {
|
||||
|
||||
/**
|
||||
* Endpoint 存储对象概述 阿里云主账号AccessKey,accessKeySecret拥有所有API的访问权限 访问路径前缀 存储对象概述
|
||||
*/
|
||||
private static String endPoint = "oss-cn-shanghai.aliyuncs.com";
|
||||
private static String accessKeyId = "LTAI5tD2tppzLQ4Rb6yKYyph";
|
||||
private static String accessKeySecret = "KEKNKwVvDq7PZLjE63NPBouqHXox4Q";
|
||||
private static String accessPre = "https://dzlmuyu.oss-cn-shanghai.aliyuncs.com/";
|
||||
|
||||
/**
|
||||
* bucket名称
|
||||
* @return
|
||||
*/
|
||||
private static String bucketName = "dzlmuyu";
|
||||
|
||||
private static OSS ossClient ;
|
||||
|
||||
static {
|
||||
ossClient = new OSSClientBuilder().build(
|
||||
endPoint,
|
||||
accessKeyId,
|
||||
accessKeySecret);
|
||||
log.info("oss服务连接成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认路径上传本地文件
|
||||
* @param filePath
|
||||
*/
|
||||
public static String uploadFile(String filePath){
|
||||
return uploadFileForBucket(bucketName,getOssFilePath(filePath) ,filePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认路径上传multipartFile文件
|
||||
* @param multipartFile
|
||||
*/
|
||||
public static String uploadMultipartFile(MultipartFile multipartFile) {
|
||||
return uploadMultipartFile(bucketName,getOssFilePath(multipartFile.getOriginalFilename()),multipartFile);
|
||||
}
|
||||
/**
|
||||
* 上传 multipartFile 类型文件
|
||||
* @param bucketName
|
||||
* @param ossPath
|
||||
* @param multipartFile
|
||||
*/
|
||||
public static String uploadMultipartFile(String bucketName , String ossPath , MultipartFile multipartFile){
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = multipartFile.getInputStream();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
uploadFileInputStreamForBucket(bucketName, ossPath, inputStream);
|
||||
return accessPre+ossPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用File上传PutObject上传文件 ** 程序默认使用次方法上传
|
||||
* @param bucketName 实例名称
|
||||
* @param ossPath oss存储路径
|
||||
* @param filePath 本地文件路径
|
||||
*/
|
||||
public static String uploadFileForBucket(String bucketName , String ossPath , String filePath) {
|
||||
// 创建PutObjectRequest对象。
|
||||
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, ossPath, new File(filePath));
|
||||
|
||||
// 上传
|
||||
ossClient.putObject(putObjectRequest);
|
||||
return accessPre+ossPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用文件流上传到指定的bucket实例
|
||||
* @param bucketName 实例名称
|
||||
* @param ossPath oss存储路径
|
||||
* @param filePath 本地文件路径
|
||||
*/
|
||||
public static String uploadFileInputStreamForBucket(String bucketName , String ossPath , String filePath){
|
||||
|
||||
// 填写本地文件的完整路径。如果未指定本地路径,则默认从示例程序所属项目对应本地路径中上传文件流。
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = new FileInputStream(filePath);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 填写Bucket名称和Object完整路径。Object完整路径中不能包含Bucket名称。
|
||||
uploadFileInputStreamForBucket(bucketName, ossPath, inputStream);
|
||||
return accessPre+ossPath;
|
||||
}
|
||||
|
||||
public static void uploadFileInputStreamForBucket(String bucketName , String ossPath , InputStream inputStream ){
|
||||
ossClient.putObject(bucketName, ossPath, inputStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载
|
||||
* @param ossFilePath
|
||||
* @param filePath
|
||||
*/
|
||||
public static void downloadFile(String ossFilePath , String filePath ){
|
||||
downloadFileForBucket(bucketName , ossFilePath , filePath);
|
||||
}
|
||||
/**
|
||||
* 下载
|
||||
* @param bucketName 实例名称
|
||||
* @param ossFilePath oss存储路径
|
||||
* @param filePath 本地文件路径
|
||||
*/
|
||||
public static void downloadFileForBucket(String bucketName , String ossFilePath , String filePath ){
|
||||
ossClient.getObject(new GetObjectRequest(bucketName, ossFilePath), new File(filePath));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getOssDefaultPath(){
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
String url =
|
||||
now.getYear()+"/"+
|
||||
now.getMonth()+"/"+
|
||||
now.getDayOfMonth()+"/"+
|
||||
now.getHour()+"/"+
|
||||
now.getMinute()+"/";
|
||||
return url;
|
||||
}
|
||||
|
||||
public static String getOssFilePath(String filePath){
|
||||
String fileSuf = filePath.substring(filePath.indexOf(".") + 1);
|
||||
return getOssDefaultPath() + UUID.randomUUID().toString() + "." + fileSuf;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.bwie.list.controller;
|
||||
|
||||
import com.bwie.common.pojo.VO.VOShop;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.list.service.ShopService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@Log4j2
|
||||
public class ShopController {
|
||||
@Autowired
|
||||
private ShopService shopService;
|
||||
|
||||
//展示商品列表
|
||||
@PostMapping("/shopList")
|
||||
public Result shopList(@RequestBody VOShop voShop){
|
||||
return shopService.shopList(voShop);
|
||||
}
|
||||
|
||||
//上传图片
|
||||
@PostMapping("/upImg")
|
||||
public Result upImg(@RequestParam("file")MultipartFile myFile){
|
||||
return shopService.upImg(myFile);
|
||||
}
|
||||
//添加商品
|
||||
@PostMapping("/addShop")
|
||||
public Result addShop(@RequestBody VOShop shop){
|
||||
return shopService.addShop(shop);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.bwie.list.controller;
|
||||
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.list.service.TypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class TypeController {
|
||||
@Autowired
|
||||
private TypeService typeService;
|
||||
|
||||
// 根据商品类型查询商品的商品类型菜单栏
|
||||
@GetMapping("/findType")
|
||||
public Result findType(){
|
||||
return typeService.findType();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.bwie.list.mapper;
|
||||
|
||||
import com.bwie.common.pojo.DTO.DTOShop;
|
||||
import com.bwie.common.pojo.VO.VOShop;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ShopMapper {
|
||||
List<DTOShop> shopList(VOShop voShop);
|
||||
|
||||
Integer addShop(VOShop shop);
|
||||
|
||||
void addImg(VOShop shop);
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.bwie.list.mapper;
|
||||
|
||||
import com.bwie.common.pojo.Type;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface TypeMapper {
|
||||
|
||||
List<Type> findType();
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.bwie.list.service;
|
||||
|
||||
import com.bwie.common.pojo.VO.VOShop;
|
||||
import com.bwie.common.result.Result;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
public interface ShopService {
|
||||
Result shopList(VOShop voShop);
|
||||
|
||||
Result addShop(VOShop shop);
|
||||
|
||||
Result upImg(MultipartFile myFile);
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.bwie.list.service;
|
||||
|
||||
import com.bwie.common.result.Result;
|
||||
|
||||
public interface TypeService {
|
||||
Result findType();
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package com.bwie.list.service.impl;
|
||||
|
||||
import com.bwie.common.pojo.DTO.DTOShop;
|
||||
import com.bwie.common.pojo.VO.VOShop;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.common.utils.FastUtil;
|
||||
import com.bwie.list.mapper.ShopMapper;
|
||||
import com.bwie.list.service.ShopService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ShopServiceImpl implements ShopService {
|
||||
@Autowired
|
||||
private ShopMapper shopMapper;
|
||||
@Autowired
|
||||
private FastUtil fastUtil;
|
||||
|
||||
@Override
|
||||
public Result shopList(VOShop voShop) {
|
||||
|
||||
PageHelper.startPage(voShop.getPageNum(),voShop.getPageSize());
|
||||
|
||||
List<DTOShop> dtoShops = shopMapper.shopList(voShop);
|
||||
|
||||
PageInfo<DTOShop> info = new PageInfo<>(dtoShops);
|
||||
|
||||
return Result.success(info,"商品列表展示");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result addShop(VOShop shop) {
|
||||
|
||||
Integer i = shopMapper.addShop(shop);
|
||||
if (i>0){
|
||||
shopMapper.addImg(shop);
|
||||
return Result.success(shop,"成功");
|
||||
}
|
||||
return Result.error("失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result upImg(MultipartFile myFile) {
|
||||
|
||||
String url = null;
|
||||
|
||||
try {
|
||||
url = fastUtil.upload(myFile);
|
||||
|
||||
if (url==null || url.equals("")){
|
||||
return Result.error("图片上传失败");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
return Result.success("http://82.157.236.130:8888/"+url,"上传成功");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.bwie.list.service.impl;
|
||||
|
||||
import com.bwie.common.pojo.Type;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.list.mapper.TypeMapper;
|
||||
import com.bwie.list.service.TypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class TypeServiceImpl implements TypeService {
|
||||
@Autowired
|
||||
private TypeMapper typeMapper;
|
||||
|
||||
@Override
|
||||
public Result findType() {
|
||||
List<Type> typeList = typeMapper.findType();
|
||||
return Result.success(typeList,"类型展示");
|
||||
}
|
||||
}
|
||||
|
|
@ -27,3 +27,15 @@ spring:
|
|||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
fdfs:
|
||||
so-timeout: 1500 # socket 连接时长
|
||||
connect-timeout: 600 # 连接 tracker 服务器超时时长
|
||||
# 这两个是你服务器的 IP 地址,注意 23000 端口也要打开,阿里云服务器记得配置安全组。tracker 要和 stroage 服务进行交流
|
||||
tracker-list: 82.157.236.130:22122
|
||||
web-server-url: 82.157.236.130:8888
|
||||
pool:
|
||||
jmx-enabled: false
|
||||
# 生成缩略图
|
||||
thumb-image:
|
||||
height: 500
|
||||
width: 500
|
|
@ -0,0 +1,42 @@
|
|||
<?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.bwie.list.mapper.ShopMapper">
|
||||
|
||||
<resultMap id="map" type="com.bwie.common.pojo.DTO.DTOShop">
|
||||
<id property="shopId" column="shop_id"></id>
|
||||
<result property="shopName" column="shop_name"></result>
|
||||
<result property="shopPrice" column="shop_price"></result>
|
||||
<result property="typeId" column="type_id"></result>
|
||||
<result property="typeName" column="type_name"></result>
|
||||
<collection property="pictureUrl" ofType="java.lang.String">
|
||||
<result column="picture_url"></result>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<insert id="addShop" keyProperty="shopId" useGeneratedKeys="true">
|
||||
INSERT INTO `shop_manage`.`t_shop` (`shop_name`, `shop_price`, `type_id`)
|
||||
VALUES ( #{shopName}, #{shopPrice}, #{typeId});
|
||||
</insert>
|
||||
<insert id="addImg">
|
||||
INSERT INTO `shop_manage`.`t_picture`(`picture_url`,`shop_id`)
|
||||
VALUES
|
||||
<foreach collection="pictureUrl" separator="," item="url">
|
||||
(#{url},#{shopId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
<select id="shopList" resultMap="map">
|
||||
select s.shop_id,s.shop_name,s.shop_price,s.type_id,t.type_name,p.picture_id,p.picture_url
|
||||
from t_shop s
|
||||
left join t_type t on s.type_id=t.type_id
|
||||
left join t_picture p on s.shop_id = p.shop_id
|
||||
<where>
|
||||
<if test="typeId != null">
|
||||
and s.type_id = #{typeId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -1,6 +0,0 @@
|
|||
<?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.bwie.system.mapper.SystemMapper">
|
||||
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,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" >
|
||||
<mapper namespace="com.bwie.list.mapper.TypeMapper">
|
||||
|
||||
<select id="findType" resultType="com.bwie.common.pojo.Type">
|
||||
select type_id,type_name from t_type
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue