diff --git "a/doc/database/bill/campuso2o_bill_2.0_\345\210\235\345\247\213\345\214\226.sql" "b/doc/database/bill/campuso2o_bill_2.0_\345\210\235\345\247\213\345\214\226.sql" new file mode 100644 index 0000000000000000000000000000000000000000..5e2c3f33945bbe0262d5f79170901b5d72e2b814 --- /dev/null +++ "b/doc/database/bill/campuso2o_bill_2.0_\345\210\235\345\247\213\345\214\226.sql" @@ -0,0 +1,77 @@ +/* +Navicat MySQL Data Transfer + +Source Server : 阿里云_mark_7561669Dong! +Source Server Version : 50722 +Source Host : 47.95.13.238:3306 +Source Database : campuso2o_bill_2.0 + +Target Server Type : MYSQL +Target Server Version : 50722 +File Encoding : 65001 + +Date: 2019-01-31 15:01:39 +*/ + +SET FOREIGN_KEY_CHECKS=0; + +-- ---------------------------- +-- Table structure for tb_bill_account +-- ---------------------------- +DROP TABLE IF EXISTS `tb_bill_account`; +CREATE TABLE `tb_bill_account` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', + `fk_goods_id` int(11) unsigned NOT NULL COMMENT '逻辑外键,商品id', + `fk_user_id` int(11) unsigned NOT NULL COMMENT '逻辑外键,用户id', + `quantity` int(10) DEFAULT NULL COMMENT '商品数量', + `total_price` decimal(20,2) DEFAULT NULL COMMENT '总价,单位是元,保留两位小数', + `description` varchar(100) DEFAULT NULL COMMENT '账单的描述', + `enable_status` int(4) NOT NULL COMMENT '1-未结算,2-已结算', + `create_time` datetime NOT NULL COMMENT '创建时间', + `payment_time` datetime NOT NULL COMMENT '结算时间', + `last_edit_time` datetime NOT NULL COMMENT '最后一次更新时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='账单信息表'; + +-- ---------------------------- +-- Records of tb_bill_account +-- ---------------------------- + +-- ---------------------------- +-- Table structure for tb_bill_goods +-- ---------------------------- +DROP TABLE IF EXISTS `tb_bill_goods`; +CREATE TABLE `tb_bill_goods` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', + `fk_owner_id` int(11) unsigned NOT NULL COMMENT '逻辑外键,拥有者id', + `goods_name` varchar(50) NOT NULL COMMENT '商品名称', + `price` decimal(20,2) NOT NULL COMMENT '单价,单位-元保留两位小数', + `priority` int(4) DEFAULT NULL, + `enable_status` int(4) NOT NULL COMMENT '1-可用,2-禁用', + `create_time` datetime NOT NULL COMMENT '创建时间', + `last_edit_time` datetime NOT NULL COMMENT '最后一次更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY `goods_name_unique` (`goods_name`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='账单商品表'; + +-- ---------------------------- +-- Records of tb_bill_goods +-- ---------------------------- + +-- ---------------------------- +-- Table structure for tb_bill_goods_img +-- ---------------------------- +DROP TABLE IF EXISTS `tb_bill_goods_img`; +CREATE TABLE `tb_bill_goods_img` ( + `id` int(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `goods_id` int(20) DEFAULT NULL COMMENT '逻辑外键,商品id', + `img_addr` varchar(2000) NOT NULL COMMENT '地址', + `priority` int(2) DEFAULT '0' COMMENT '权重', + `enable_status` int(4) NOT NULL COMMENT '1-可用,2-禁用', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='商品资源图片表'; + +-- ---------------------------- +-- Records of tb_bill_goods_img +-- ---------------------------- diff --git a/src/main/java/com/mark/web/data/util/BigDecimalUtil.java b/src/main/java/com/mark/common/utils/BigDecimalUtil.java similarity index 76% rename from src/main/java/com/mark/web/data/util/BigDecimalUtil.java rename to src/main/java/com/mark/common/utils/BigDecimalUtil.java index 542e4ff05b4c4d37125a1f41d50ff43cae3a3774..d530a643dbe99298f32ca0ed4849f5beac24139b 100644 --- a/src/main/java/com/mark/web/data/util/BigDecimalUtil.java +++ b/src/main/java/com/mark/common/utils/BigDecimalUtil.java @@ -1,6 +1,7 @@ -package com.mark.web.data.util; +package com.mark.common.utils; import java.math.BigDecimal; +import java.math.RoundingMode; /** * @Description: 计算商品价格的工具类 @@ -35,4 +36,15 @@ public class BigDecimalUtil { BigDecimal b2 = new BigDecimal(Double.toString(v2)); return b1.divide(b2,2,BigDecimal.ROUND_HALF_UP);//四舍五入,保留2位小数 } + + /** + * BigDecimal参数格式化:保留两位小数 + * @param bigDecimal :原始value :eg 2.9 + * @return :格式化的value:eg 2.90 + */ + public static BigDecimal saveScale2(BigDecimal bigDecimal){ + return bigDecimal.setScale(2, RoundingMode.HALF_UP); + } + + } diff --git a/src/main/java/com/mark/common/utils/DownloadFileUtil.java b/src/main/java/com/mark/common/utils/DownloadFileUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..0500ae12be5660535d715e2f99d4813ef1de747a --- /dev/null +++ b/src/main/java/com/mark/common/utils/DownloadFileUtil.java @@ -0,0 +1,108 @@ +package com.mark.common.utils; + +import sun.misc.BASE64Encoder; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; + +/** + * @Description: 下载文件的工具类 + * @Author: Mark + * @CreateDate: 2019/2/21 16:29 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +public class DownloadFileUtil { + + /** + * 下载文件 + * + * @param originalFileName :下载文件的原始文件名 + * @param file :下载的文件 + * @param response :相应对象 + */ + public static void downloadFile(String originalFileName, File file, HttpServletResponse response, HttpServletRequest request) { + // TODO: 2019/2/21 数据校验 + + //相应头的处理 + //清空response中的输出流 + response.reset(); + //设置文件大小 + response.setContentLength((int) file.length()); + //设置Content-Type头 + response.setContentType("application/octet-stream;charset=UTF-8"); + //设置Content-Disposition头 以附件形式解析 + String encodedFilename = getEncodedFilename(request, originalFileName); + response.addHeader("Content-Disposition", "attchment;filename=" + encodedFilename); + + //将来文件流写入response中 + FileInputStream fileInputStream = null; + ServletOutputStream outputStream = null; + try { + //获取文件输入流 + fileInputStream = new FileInputStream(file); + //创建数据缓冲区 + byte[] buffers = new byte[1024]; + //通过response中获取ServletOutputStream输出流 + outputStream = response.getOutputStream(); + int length; + while ((length = fileInputStream.read(buffers)) > 0) { + //写入到输出流中 + outputStream.write(buffers, 0, length); + } + + } catch (IOException e) { + e.printStackTrace(); + } finally { + //流的关闭 + if(fileInputStream != null){ + try { + fileInputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (outputStream != null) { + try { + outputStream.flush(); + outputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + private static String getEncodedFilename(HttpServletRequest request, String originalFileName) { + String encodedFilename = null; + String agent = request.getHeader("User-Agent"); + if(agent.contains("MSIE")){ + //IE浏览器 + try { + encodedFilename = URLEncoder.encode(originalFileName, "utf-8"); + encodedFilename = encodedFilename.replace("+", " "); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + }else if(agent.contains("Firefox")){ + //火狐浏览器 + BASE64Encoder base64Encoder = new BASE64Encoder(); + encodedFilename = "=?utf-8?B?" + base64Encoder.encode(originalFileName.getBytes(StandardCharsets.UTF_8))+"?="; + }else{ + //其他浏览器 + try { + encodedFilename = URLEncoder.encode(originalFileName, "utf-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + return encodedFilename; + } +} diff --git a/src/main/java/com/mark/web/data/util/OSSClientUtil.java b/src/main/java/com/mark/common/utils/OSSClientUtil.java similarity index 94% rename from src/main/java/com/mark/web/data/util/OSSClientUtil.java rename to src/main/java/com/mark/common/utils/OSSClientUtil.java index 8e77e980c0400b6923f007e41d56d8bd24697266..3cc90ce21ab3208f2d6056b1936a80ba104a8163 100644 --- a/src/main/java/com/mark/web/data/util/OSSClientUtil.java +++ b/src/main/java/com/mark/common/utils/OSSClientUtil.java @@ -1,10 +1,11 @@ -package com.mark.web.data.util; +package com.mark.common.utils; import com.aliyun.oss.OSSClient; import com.aliyun.oss.model.PutObjectResult; import com.google.common.collect.Maps; import com.mark.common.exception.Campuso2oException; import com.mark.web.data.exception.ImageException; +import com.mark.web.data.util.ImageUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.mock.web.MockMultipartFile; @@ -68,9 +69,20 @@ public class OSSClientUtil { * @return :返回存放到OSS服务中的相对路径,该值存放到数据库中 */ public static String uploadImg2Oss(MultipartFile multipartFile,String imageRole ,Integer roleId) { + //参数校验 + if(multipartFile == null) { + throw new ImageException("上传的文件不能为空!"); + } if (multipartFile.getSize() > MAX_SIZE) { throw new ImageException("上传的图片大小不能超过10M!"); } + if(StringUtils.isBlank(imageRole)){ + throw new ImageException("输入的图片所属类型不能为空!"); + } + if(roleId == null){ + throw new ImageException("输入的类型ID不能为空!"); + } + Map resultMap = getNewName(multipartFile, imageRole, roleId); String relativePath = (String) resultMap.get("relativePath"); multipartFile = (MultipartFile) resultMap.get("file"); diff --git a/src/main/java/com/mark/conf/MySwagger2Conf.java b/src/main/java/com/mark/conf/MySwagger2Conf.java index 6d39094a79cc5f12a6ce0242c6e841aec9ea1960..2375e729c0ab74cd1fc60e4bf78dc4764892cc56 100644 --- a/src/main/java/com/mark/conf/MySwagger2Conf.java +++ b/src/main/java/com/mark/conf/MySwagger2Conf.java @@ -35,10 +35,13 @@ public class MySwagger2Conf { final String basePackagePath = "com.mark.web.data.controller"; //shiro权限控制的相关的控制器包的路径 final String sysBashPackagePath = "com.mark.web.sys.controller"; + //账单模块的控制器包路径 + final String billBashPackagePath = "com.mark.web.bill.controller"; + return new Docket(DocumentationType.SWAGGER_2) .apiInfo(this.getApiInfo()) .select() - .apis(basePackage(basePackagePath+SPLITOR+sysBashPackagePath)) + .apis(basePackage(basePackagePath+SPLITOR+sysBashPackagePath+SPLITOR+billBashPackagePath)) .paths(PathSelectors.any()) .build(); } diff --git a/src/main/java/com/mark/conf/ShiroConfig.java b/src/main/java/com/mark/conf/ShiroConfig.java index 05f5772b67bf21fd0bd34e7a962b243915a8fe3c..f4320cc7f3e28dafefdd34f6b874e0a00fe4392c 100644 --- a/src/main/java/com/mark/conf/ShiroConfig.java +++ b/src/main/java/com/mark/conf/ShiroConfig.java @@ -126,6 +126,9 @@ public class ShiroConfig { //访问路径 Map filterChanDefinitionMap = new LinkedHashMap<>(); + // TODO: 2019/2/21 测试完成记得儿删除 + //测试用放行路径 + filterChanDefinitionMap.put("/common/file/**", "anon"); //Swagger2-UI的访问路径的放行 filterChanDefinitionMap.put("/swagger-ui.html", "anon"); filterChanDefinitionMap.put("/swagger/**", "anon"); diff --git a/src/main/java/com/mark/conf/datasourceconf/MyBillDataSourceConf.java b/src/main/java/com/mark/conf/datasourceconf/MyBillDataSourceConf.java new file mode 100644 index 0000000000000000000000000000000000000000..dcd991ff04ea2aa1568a2b542ba060bfb8c5c299 --- /dev/null +++ b/src/main/java/com/mark/conf/datasourceconf/MyBillDataSourceConf.java @@ -0,0 +1,66 @@ +package com.mark.conf.datasourceconf; + +import com.alibaba.druid.pool.DruidDataSource; +import com.mark.common.utils.PropertiesUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.ibatis.session.SqlSessionFactory; +import org.mybatis.spring.SqlSessionFactoryBean; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.Resource; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; +import org.springframework.core.io.support.ResourcePatternResolver; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; + +import javax.sql.DataSource; +/** + * @Description: 账单能模块数据库的配置 + * @Author: Mark + * @CreateDate: 2019/01/31 18:32 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +@Configuration +@MapperScan(basePackages = "com.mark.web.bill.mapper", sqlSessionFactoryRef = "myBillSqlSessionFactory") +@Slf4j +public class MyBillDataSourceConf { + private String className = PropertiesUtil.getDataSourceProperty("bill.database.classname"); + private String url = PropertiesUtil.getDataSourceProperty("bill.database.url"); + private String useName = PropertiesUtil.getDataSourceProperty("bill.database.username"); + private String password = PropertiesUtil.getDataSourceProperty("bill.database.password"); + private String location = PropertiesUtil.getDataSourceProperty("bill.mapper.locations"); + + @Bean(name = "myBillDataSource") + public DataSource myBillSource(){ + DruidDataSource dataSource = new DruidDataSource(); + dataSource.setDriverClassName(className); + dataSource.setUrl(url); + dataSource.setUsername(useName); + dataSource.setPassword(password); + return dataSource; + } + + @Bean(name = "myBillTransactionManager") + public DataSourceTransactionManager myBillDataSourceTransactionManager(){ + return new DataSourceTransactionManager(this.myBillSource()); + } + + @Bean(name = "myBillSqlSessionFactory") + public SqlSessionFactory myBillSqlSessionFactory(@Qualifier("myBillDataSource") DataSource myBillDataSource) { + final SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); + //设置数据源 + sqlSessionFactoryBean.setDataSource(myBillDataSource); + ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); + try { + Resource[] resources = resolver.getResources(location); + //设置mapper.XML文件 + sqlSessionFactoryBean.setMapperLocations(resources); + return sqlSessionFactoryBean.getObject(); + } catch(Exception e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/src/main/java/com/mark/conf/datasourceconf/package-info.java b/src/main/java/com/mark/conf/datasourceconf/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..1ebf5f7dc78810d2300b22d99c82c0332fce33c9 --- /dev/null +++ b/src/main/java/com/mark/conf/datasourceconf/package-info.java @@ -0,0 +1,18 @@ +/** + * @Description: 多数据源的配置 + * @Author: Mark + * @CreateDate: 2019/01/31 18:32 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + * + * 多数据源的配置的步骤: + * + * 1.建表 + * + * 2.使用generatorConfig文件自动连接数据自动生成表实体类和dao层接口以及XML文件 + * + * 3.添加数据库的连接信息到:dataSource.properties文件中 + * + * 4.在改目录下新建的配置类 + */ +package com.mark.conf.datasourceconf; \ No newline at end of file diff --git a/src/main/java/com/mark/web/bill/controller/AccountController.java b/src/main/java/com/mark/web/bill/controller/AccountController.java new file mode 100644 index 0000000000000000000000000000000000000000..11ba99b99fc1fa37daf428eba9733fcc1df9a0f8 --- /dev/null +++ b/src/main/java/com/mark/web/bill/controller/AccountController.java @@ -0,0 +1,70 @@ +package com.mark.web.bill.controller; + +import com.github.pagehelper.PageInfo; +import com.mark.common.CurrentUser; +import com.mark.common.ServerResponse; +import com.mark.web.bill.entity.from.AddAccountFrom; +import com.mark.web.bill.entity.po.Account; +import com.mark.web.bill.entity.vo.AccountVo; +import com.mark.web.bill.service.IAccountService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import java.util.Date; +import java.util.Map; +import java.util.Objects; + +@Api(tags = "账单-我的账单模块") +@RestController +@RequestMapping(value = "/bill/account/") +public class AccountController { + + @Autowired + private IAccountService iAccountService; + + @ApiOperation(value = "添加账单") + @PostMapping(value = "add") + public ServerResponse add(@Valid AddAccountFrom addAccountFrom, BindingResult result){ + if(result.hasErrors()){ + return ServerResponse.createByErrorMessage(Objects.requireNonNull(result.getFieldError()).getDefaultMessage()); + } + Account account = new Account(); + BeanUtils.copyProperties(addAccountFrom,account); + account.setCreateTime(new Date(addAccountFrom.getCreateTime())); + //获取当前用户id + int currentUserId = CurrentUser.getCurrentUserId(); + account.setFkUserId(currentUserId); + return iAccountService.add(account); + } + + @ApiOperation("获取基本信息:总额,总付款,总未付款,个数") + @PostMapping(value = "getStatisticalInfo") + public ServerResponse> getStatisticalInfo(@RequestParam(value = "timestamps[0]") Long start, + @RequestParam(value = "timestamps[1]") Long end){ + return iAccountService.getStatisticalInfo(start,end,CurrentUser.getCurrentUserId()); + } + + + @ApiOperation(value = "获取搜索时间范围内账单信息") + @ApiImplicitParams({ + @ApiImplicitParam(name = "pageNum",value = "当前的页数",defaultValue = "1"), + @ApiImplicitParam(name = "pageSize",value = "页面大小",defaultValue = "10") + }) + @PostMapping(value = "getAccounts") + public ServerResponse> getAccountListBySearchTime(@RequestParam(value = "timestamps[0]") Long start, + @RequestParam(value = "timestamps[1]") Long end, + @RequestParam(value = "pageNum",defaultValue = "1") int pageNum, + @RequestParam(value = "pageSize",defaultValue = "10") int pageSize){ + return iAccountService.getAccountListBySearchTime(start,end,pageNum,pageSize,CurrentUser.getCurrentUserId()); + } +} diff --git a/src/main/java/com/mark/web/bill/controller/GoodsCateController.java b/src/main/java/com/mark/web/bill/controller/GoodsCateController.java new file mode 100644 index 0000000000000000000000000000000000000000..b4f12e03fd9f66b8e635458d18f8b2efa13fccbe --- /dev/null +++ b/src/main/java/com/mark/web/bill/controller/GoodsCateController.java @@ -0,0 +1,88 @@ +package com.mark.web.bill.controller; + +import com.mark.common.CurrentUser; +import com.mark.common.ServerResponse; +import com.mark.web.bill.entity.from.AddAccountFrom; +import com.mark.web.bill.entity.from.AddGoodsCateFrom; +import com.mark.web.bill.entity.from.EditGoodsCateFrom; +import com.mark.web.bill.entity.po.Account; +import com.mark.web.bill.entity.po.GoodsCategory; +import com.mark.web.bill.entity.vo.GoodsCategoryVo; +import com.mark.web.bill.service.IGoodsCateService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * @Description: 加工零件种类控制器 + * @Author: Mark + * @CreateDate: 2019/2/16 21:13 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +@Api(tags = "账单-加工零件种类模块") +@RestController +@RequestMapping(value = "/bill/goodsCate/") +public class GoodsCateController { + + @Autowired + private IGoodsCateService iGoodsCateService; + + @ApiOperation(value = "获取加工零件同一个父级的种类信息") + @ApiImplicitParams({ + @ApiImplicitParam(name = "parentId",value = "种类父级ID",defaultValue = "0") + }) + @PostMapping(value = "getGoodsCates") + public ServerResponse> getGoodsCateList(@RequestParam(value = "parentId",defaultValue = "0") int parentId){ + return iGoodsCateService.getGoodsCateList(parentId); + } + + @ApiOperation(value = "搜索获取加工零件同一个父级的种类信息") + @ApiImplicitParams({ + @ApiImplicitParam(name = "parentId",value = "搜索种类父级ID"), + @ApiImplicitParam(name = "CategoryName",value = "搜索种类名称") + }) + @PostMapping(value = "getSearchGoodsCates") + public ServerResponse> getGoodsCateList(Integer parentId,String CategoryName){ + return iGoodsCateService.getSearchGoodsCates(parentId,CategoryName); + } + + @ApiOperation(value = "获取渲染种类Cascader级联选择器的数据") + @GetMapping(value = "getGoodsCateCascader") + public ServerResponse>> getGoodsCateCascader(){ + return iGoodsCateService.getGoodsCateCascader(); + } + + @ApiOperation(value = "添加种类") + @PostMapping(value = "add") + public ServerResponse add(@Valid AddGoodsCateFrom addGoodsCateFrom, BindingResult result){ + if(result.hasErrors()){ + return ServerResponse.createByErrorMessage(Objects.requireNonNull(result.getFieldError()).getDefaultMessage()); + } + GoodsCategory goodsCategory = new GoodsCategory(); + BeanUtils.copyProperties(addGoodsCateFrom,goodsCategory); + return iGoodsCateService.add(goodsCategory); + } + + @ApiOperation(value = "编辑种类") + @PostMapping(value = "edit") + public ServerResponse edit(@Valid EditGoodsCateFrom editGoodsCateFrom, BindingResult result){ + if(result.hasErrors()){ + return ServerResponse.createByErrorMessage(Objects.requireNonNull(result.getFieldError()).getDefaultMessage()); + } + GoodsCategory goodsCategory = new GoodsCategory(); + BeanUtils.copyProperties(editGoodsCateFrom,goodsCategory); + return iGoodsCateService.edit(goodsCategory); + } +} diff --git a/src/main/java/com/mark/web/bill/controller/GoodsController.java b/src/main/java/com/mark/web/bill/controller/GoodsController.java new file mode 100644 index 0000000000000000000000000000000000000000..efee05c9aa1eca3b05a98e5eace6a94afb24f777 --- /dev/null +++ b/src/main/java/com/mark/web/bill/controller/GoodsController.java @@ -0,0 +1,79 @@ +package com.mark.web.bill.controller; + +import com.github.pagehelper.PageInfo; +import com.mark.common.CurrentUser; +import com.mark.common.ServerResponse; +import com.mark.web.bill.entity.from.AddGoodsFrom; +import com.mark.web.bill.entity.po.Goods; +import com.mark.web.bill.entity.vo.GoodsDetailVo; +import com.mark.web.bill.service.IGoodsService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.Valid; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * @Description: 记账模块的加工零件控制 + * @Author: Mark + * @CreateDate: 2019/2/2 22:39 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +@Api(tags = "账单-加工零件模块") +@RestController +@RequestMapping(value = "/bill/goods/") +public class GoodsController { + + @Autowired + private IGoodsService iGoodsService; + + @ApiOperation(value = "添加加工零件") + @PostMapping(value = "add") + public ServerResponse add(@Valid AddGoodsFrom addGoodsFrom, BindingResult result, + @RequestParam(value = "goodsImage",required = false)MultipartFile goodsImage){ + if(result.hasErrors()){ + return ServerResponse.createByErrorMessage(Objects.requireNonNull(result.getFieldError()).getDefaultMessage()); + } + Goods goods = new Goods(); + BeanUtils.copyProperties(addGoodsFrom,goods); + int currentUserId = CurrentUser.getCurrentUserId(); + goods.setFkOwnerId(currentUserId); + return iGoodsService.add(goods,goodsImage); + } + + /** + * 根据种类ID获取加工零件列表 + * @param categoryId :种类ID,非必传,是查询所有的加工零件不想指定类型则传null + * @return : + */ + @ApiOperation(value = "获取加工零件名称和对应ID") + @GetMapping(value = "getOptionInfo") + public ServerResponse>> getOptionInfo(Integer categoryId){ + return iGoodsService.getOptionInfo(categoryId); + } + + @ApiOperation(value = "分页筛选加工零件列表信息") + @ApiImplicitParams({ + @ApiImplicitParam(name = "pageNum",value = "当前的页数",defaultValue = "1"), + @ApiImplicitParam(name = "pageSize",value = "页面大小",defaultValue = "12") + }) + @PostMapping(value = "getGoods") + public ServerResponse> getAccountList(@RequestParam(value = "pageNum",defaultValue = "1") int pageNum, + @RequestParam(value = "pageSize",defaultValue = "12") int pageSize, + Integer categoryId,String searchGoodsName){ + return iGoodsService.getGoodsList(pageNum,pageSize,CurrentUser.getCurrentUserId(),categoryId,searchGoodsName); + } + + + +} diff --git a/src/main/java/com/mark/web/bill/doc/Todo b/src/main/java/com/mark/web/bill/doc/Todo new file mode 100644 index 0000000000000000000000000000000000000000..7b1370db9a31168a153b52bfb31502a9781d668a --- /dev/null +++ b/src/main/java/com/mark/web/bill/doc/Todo @@ -0,0 +1,3 @@ +#2019-02-21 +1.编辑加工零件 +2.删除加工零件(删除OSS中的图片) \ No newline at end of file diff --git "a/src/main/java/com/mark/web/bill/doc/\347\226\221\351\227\256" "b/src/main/java/com/mark/web/bill/doc/\347\226\221\351\227\256" new file mode 100644 index 0000000000000000000000000000000000000000..2539eb4a0043070a8da98b3a39a915303e011bc6 --- /dev/null +++ "b/src/main/java/com/mark/web/bill/doc/\347\226\221\351\227\256" @@ -0,0 +1,3 @@ +# 2019-02-16 +问题:账单信息的单价和总价,BigDecimal类型的1.10返回到前端的时候被显示为1.0? +解决:把BigDecimal转换为String类型 diff --git a/src/main/java/com/mark/web/bill/entity/dto/GoodsDetail.java b/src/main/java/com/mark/web/bill/entity/dto/GoodsDetail.java new file mode 100644 index 0000000000000000000000000000000000000000..226037b760cea1e499f95814c75937feb4bc277e --- /dev/null +++ b/src/main/java/com/mark/web/bill/entity/dto/GoodsDetail.java @@ -0,0 +1,71 @@ +package com.mark.web.bill.entity.dto; + + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.Date; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class GoodsDetail { + + /** + * id + */ + private Integer id; + + /** + * 逻辑外键,拥有者id + */ + private Integer fkOwnerId; + + /** + * 逻辑外键,加工零件id + */ + private Integer fkCategoryId; + + /** + * 加工零件所属的种类名称 + */ + private String categoryName; + + /** + * 商品名称 + */ + private String goodsName; + + /** + * 单价,单位-元保留两位小数 + */ + private BigDecimal price; + + /** + * 排序权重 + */ + private Integer priority; + + /** + * 状态:1-可用,2-禁用 + */ + private Integer enableStatus; + + /** + * 加工零件的图片地址 + */ + private String imgAddr; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 最后一次更新时间 + */ + private Date lastEditTime; + +} diff --git a/src/main/java/com/mark/web/bill/entity/from/AddAccountFrom.java b/src/main/java/com/mark/web/bill/entity/from/AddAccountFrom.java new file mode 100644 index 0000000000000000000000000000000000000000..1c5617353c509f64771715ea5249b2b6164450d1 --- /dev/null +++ b/src/main/java/com/mark/web/bill/entity/from/AddAccountFrom.java @@ -0,0 +1,45 @@ +package com.mark.web.bill.entity.from; + +import io.swagger.annotations.ApiModel; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.util.Date; + +/** + * @Description: 新增账单时表单实体 + * @Author: Mark + * @CreateDate: 2019/01/31 18:32 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +@Data +@ApiModel(value = "账单新增表单") +public class AddAccountFrom { + + /** + * 该账单的所属时间 + */ + private long createTime; + + /** + * 逻辑外键,用户id + */ + private Integer fkGoodsId; + + /** + * 商品数量 + */ + private Integer quantity; + + /** + * 账单的状态:1:未结算,2:已结算 + */ + private Integer enableStatus; + + /** + * 账单的描述 + */ + private String description; + +} diff --git a/src/main/java/com/mark/web/bill/entity/from/AddGoodsCateFrom.java b/src/main/java/com/mark/web/bill/entity/from/AddGoodsCateFrom.java new file mode 100644 index 0000000000000000000000000000000000000000..4e74cee776d6ef507c8547a34e6a8adfcf96a7cf --- /dev/null +++ b/src/main/java/com/mark/web/bill/entity/from/AddGoodsCateFrom.java @@ -0,0 +1,34 @@ +package com.mark.web.bill.entity.from; + +import io.swagger.annotations.ApiModel; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @Description: 新增加工零件种类 + * @Author: Mark + * @CreateDate: 2019/2/17 11:03 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +@Data +@ApiModel(value = "种类新增表单") +public class AddGoodsCateFrom { + /** + * 父级种类Id + */ + private Integer parentId; + + /** + * 种类名 + */ + @NotBlank(message = "加工零件种类名称必填") + private String goodsCategoryName; + + /** + * 权重 + */ + private Integer priority; + +} diff --git a/src/main/java/com/mark/web/bill/entity/from/AddGoodsFrom.java b/src/main/java/com/mark/web/bill/entity/from/AddGoodsFrom.java new file mode 100644 index 0000000000000000000000000000000000000000..f0ed96855887e11e87efa7e5ce401621fa7eebfa --- /dev/null +++ b/src/main/java/com/mark/web/bill/entity/from/AddGoodsFrom.java @@ -0,0 +1,44 @@ +package com.mark.web.bill.entity.from; + +import io.swagger.annotations.ApiModel; +import lombok.Data; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import java.math.BigDecimal; + +/** + * @Description: 添加加工零件的表单验证 + * @Author: Mark + * @CreateDate: 2019/2/2 22:41 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +@Data +@ApiModel(value = "账单新增表单") +public class AddGoodsFrom { + + /** + * 商品名称 + */ + @NotBlank(message = "输入的商品名称不能空!") + private String goodsName; + + /** + * 单价,单位-元保留两位小数 + */ + @Min(value = 0,message = "单价应该大于0") + private BigDecimal price; + + /** + * 排序权重 + */ + @Min(value = 1,message = "权重值应该大于1") + private Integer priority; + + /** + * 逻辑外键,加工零件id + */ + @Min(value = 0,message = "输入种类id应大于0") + private Integer fkCategoryId = 1; +} diff --git a/src/main/java/com/mark/web/bill/entity/from/EditGoodsCateFrom.java b/src/main/java/com/mark/web/bill/entity/from/EditGoodsCateFrom.java new file mode 100644 index 0000000000000000000000000000000000000000..68ee806f5e2ef3f75e6fe6e9a7b51e777b5c989c --- /dev/null +++ b/src/main/java/com/mark/web/bill/entity/from/EditGoodsCateFrom.java @@ -0,0 +1,42 @@ +package com.mark.web.bill.entity.from; + +import lombok.Data; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; + +/** + * @Description: 编辑种类的验证表单 + * @Author: Mark + * @CreateDate: 2019/2/18 21:16 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +@Data +public class EditGoodsCateFrom { + + /** + * 编辑记录的id + */ + @Min(value = 1,message = "编辑的种类ID应大于1") + private Integer id; + + /** + * 父级种类Id + */ + @Min(value = 0,message = "父级种类ID需要大于0") + private Integer parentId; + + /** + * 种类名 + */ + @NotBlank(message = "加工零件种类名称必填") + private String goodsCategoryName; + + /** + * 权重 + */ + @Min(value = 1,message = "权重值应该大于1") + private Integer priority; + +} diff --git a/src/main/java/com/mark/web/bill/entity/po/Account.java b/src/main/java/com/mark/web/bill/entity/po/Account.java new file mode 100644 index 0000000000000000000000000000000000000000..f22f5727ec6ded3ecb821b7283ff7ed6facae5de --- /dev/null +++ b/src/main/java/com/mark/web/bill/entity/po/Account.java @@ -0,0 +1,73 @@ +package com.mark.web.bill.entity.po; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @Description: 账单信息表对应的实体类 + * @Author: Kingsley: 08:46 + * @CreateDate: 2019/1/31 15:14 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +public class Account { + /** + * 主键ID + */ + private Integer id; + + /** + * 逻辑外键,商品id + */ + private Integer fkGoodsId; + + /** + * 逻辑外键,用户id + */ + private Integer fkUserId; + + /** + * 商品数量 + */ + private Integer quantity; + + /** + * 总价,单位是元,保留两位小数 + */ + private BigDecimal totalPrice; + + /** + * 账单的描述 + */ + private String description; + + /** + * 状态:1-未结算,2-已结算 + */ + private Integer enableStatus; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 结算时间 + */ + private Date paymentTime; + + /** + * 最后一次更新时间 + */ + private Date lastEditTime; + +} \ No newline at end of file diff --git a/src/main/java/com/mark/web/bill/entity/po/Goods.java b/src/main/java/com/mark/web/bill/entity/po/Goods.java new file mode 100644 index 0000000000000000000000000000000000000000..6315ffac91e0c65d4728e0ec0dfeac848a6e38ac --- /dev/null +++ b/src/main/java/com/mark/web/bill/entity/po/Goods.java @@ -0,0 +1,68 @@ +package com.mark.web.bill.entity.po; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @Description: 账单商品表对应的实体类 + * @Author: Kingsley: 08:46 + * @CreateDate: 2019/1/31 15:14 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +public class Goods { + /** + * id + */ + private Integer id; + + /** + * 逻辑外键,拥有者id + */ + private Integer fkOwnerId; + + /** + * 逻辑外键,加工零件id + */ + private Integer fkCategoryId; + + /** + * 商品名称 + */ + private String goodsName; + + /** + * 单价,单位-元保留两位小数 + */ + private BigDecimal price; + + /** + * 排序权重 + */ + private Integer priority; + + /** + * 状态:1-可用,2-禁用 + */ + private Integer enableStatus; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 最后一次更新时间 + */ + private Date lastEditTime; + +} \ No newline at end of file diff --git a/src/main/java/com/mark/web/bill/entity/po/GoodsCategory.java b/src/main/java/com/mark/web/bill/entity/po/GoodsCategory.java new file mode 100644 index 0000000000000000000000000000000000000000..ca9529da82a3ab8a2f9311f0b6167ac6373e0d69 --- /dev/null +++ b/src/main/java/com/mark/web/bill/entity/po/GoodsCategory.java @@ -0,0 +1,37 @@ +package com.mark.web.bill.entity.po; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.Date; +/** + * @Description: 加工零件种类对应的实体类 + * @Author: Kingsley: 08:46 + * @CreateDate: 2019/01/11 15:14 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +public class GoodsCategory { + + private Integer id; + + private Integer parentId; + + private String goodsCategoryName; + + private Integer enableStatus; + + private Integer level; + + private Integer priority; + + private Date createTime; + + private Date lastEditTime; +} \ No newline at end of file diff --git a/src/main/java/com/mark/web/bill/entity/po/GoodsImg.java b/src/main/java/com/mark/web/bill/entity/po/GoodsImg.java new file mode 100644 index 0000000000000000000000000000000000000000..fa6a247f37db6ccc2f1de19317cdaa679a6b221c --- /dev/null +++ b/src/main/java/com/mark/web/bill/entity/po/GoodsImg.java @@ -0,0 +1,53 @@ +package com.mark.web.bill.entity.po; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.Date; + +/** + * @Description: 商品资源图片表对应的实体类 + * @Author: Kingsley: 08:46 + * @CreateDate: 2019/1/31 15:14 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +public class GoodsImg { + + /** + * 主键ID + */ + private Integer id; + + /** + * 商品ID + */ + private Integer goodsId; + + /** + * 图片地址 + */ + private String imgAddr; + + /** + * 排序权重 + */ + private Integer priority; + + /** + * 状态 + */ + private Integer enableStatus; + + /** + * 创建时间 + */ + private Date createTime; + +} \ No newline at end of file diff --git a/src/main/java/com/mark/web/bill/entity/vo/AccountVo.java b/src/main/java/com/mark/web/bill/entity/vo/AccountVo.java new file mode 100644 index 0000000000000000000000000000000000000000..ee7ac329187692733d3fd507117f212aab4655bc --- /dev/null +++ b/src/main/java/com/mark/web/bill/entity/vo/AccountVo.java @@ -0,0 +1,96 @@ +package com.mark.web.bill.entity.vo; + +import com.mark.common.utils.BigDecimalUtil; +import com.mark.common.utils.DateTimeUtil; +import com.mark.web.bill.entity.po.Account; +import com.mark.web.bill.entity.po.Goods; +import com.mark.web.bill.enums.AccountEnum; +import lombok.Data; +import org.apache.commons.lang3.StringUtils; + +/** + * @Description: 我的账单vo实体 + * @Author: Mark + * @CreateDate: 2019/2/3 12:00 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +@Data +public class AccountVo { + /** + * 主键ID + */ + private Integer id; + + /** + * 逻辑外键,商品id + */ + private Integer fkGoodsId; + + /** + * 加工的零件名称 + */ + private String goodsName; + + /** + * 加工零件的单价 + */ + private String price; + + /** + * 加工零件的数量 + */ + private Integer quantity; + + /** + * 总价,单位是元,保留两位小数 + */ + private String totalPrice; + + /** + * 账单的描述 + */ + private String description; + + /** + * 状态:1-未结算,2-已结算 + */ + private String enableStatus; + + /** + * 创建时间 + */ + private String createTime; + + /** + * 结算时间 + */ + private String paymentTime; + + public AccountVo(Account account, Goods goods){ + this.id = account.getId(); + this.fkGoodsId = account.getFkGoodsId(); + this.goodsName = goods.getGoodsName(); + this.price = BigDecimalUtil.saveScale2(goods.getPrice()).toString(); + this.quantity = account.getQuantity(); + this.totalPrice = BigDecimalUtil.saveScale2(account.getTotalPrice()).toString(); + this.description = account.getDescription(); + this.enableStatus = AccountEnum.stateOf(account.getEnableStatus()); + this.createTime = DateTimeUtil.dateToStr2(account.getCreateTime()); + + //支持时间的赋值 + String paymentTimeStr = DateTimeUtil.dateToStr2(account.getPaymentTime()); + if(StringUtils.isBlank(paymentTimeStr)) { + paymentTimeStr = "未定"; + } + this.paymentTime = paymentTimeStr; + + //描述属性赋值 + String descriptionStr = account.getDescription(); + if(StringUtils.isBlank(descriptionStr)){ + descriptionStr = "无"; + } + this.description = descriptionStr; + } + +} diff --git a/src/main/java/com/mark/web/bill/entity/vo/GoodsCategoryVo.java b/src/main/java/com/mark/web/bill/entity/vo/GoodsCategoryVo.java new file mode 100644 index 0000000000000000000000000000000000000000..1ec8f9693a46134e04a4a646a26f9bd6741714d3 --- /dev/null +++ b/src/main/java/com/mark/web/bill/entity/vo/GoodsCategoryVo.java @@ -0,0 +1,48 @@ +package com.mark.web.bill.entity.vo; + +import com.mark.common.utils.DateTimeUtil; +import com.mark.web.bill.entity.po.GoodsCategory; +import com.mark.web.bill.enums.GoodsCategoryEnum; +import lombok.Data; + +/** + * @Description: 用户头像POJO类 + * @Author: Mark + * @CreateDate: 2019/2/16 21:06 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +@Data +public class GoodsCategoryVo { + + private Integer id; + + private Integer parentId; + + private String goodsCategoryName; + + private String enableStatus; + + private Integer level; + + private Integer priority; + + private boolean hasParent; + + private String createTime; + + private String lastEditTime; + + public GoodsCategoryVo(GoodsCategory goodsCategory){ + this.id = goodsCategory.getId(); + this.parentId = goodsCategory.getParentId(); + //如果父级ID为0,则表示该种类没有父类,为种类信息的根种类 + this.hasParent = this.parentId == 0; + this.goodsCategoryName = goodsCategory.getGoodsCategoryName(); + this.enableStatus = GoodsCategoryEnum.stateOf(goodsCategory.getEnableStatus()); + this.level = goodsCategory.getLevel(); + this.priority = goodsCategory.getPriority(); + this.createTime = DateTimeUtil.dateToStr(goodsCategory.getCreateTime()); + this.lastEditTime = DateTimeUtil.dateToStr(goodsCategory.getLastEditTime()); + } +} diff --git a/src/main/java/com/mark/web/bill/entity/vo/GoodsDetailVo.java b/src/main/java/com/mark/web/bill/entity/vo/GoodsDetailVo.java new file mode 100644 index 0000000000000000000000000000000000000000..74618e7085707be68d46e07f99dae85be569a71c --- /dev/null +++ b/src/main/java/com/mark/web/bill/entity/vo/GoodsDetailVo.java @@ -0,0 +1,90 @@ +package com.mark.web.bill.entity.vo; + +import com.mark.common.utils.DateTimeUtil; +import com.mark.web.bill.entity.dto.GoodsDetail; +import com.mark.web.bill.enums.GoodsEnum; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @Description: 我的加工零件vo实体 + * @Author: Mark + * @CreateDate: 2019/2/12 12:00 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +@Data +public class GoodsDetailVo { + + /** + * id + */ + private Integer id; + + /** + * 逻辑外键,拥有者id + */ + private Integer fkOwnerId; + + /** + * 逻辑外键,加工零件id + */ + private Integer fkCategoryId; + + /** + * 加工零件所属的种类名称 + */ + private String categoryName; + + /** + * 商品名称 + */ + private String goodsName; + + /** + * 单价,单位-元保留两位小数 + */ + private BigDecimal price; + + /** + * 排序权重 + */ + private Integer priority; + + /** + * 状态:1-可用,2-禁用 + */ + private String enableStatus; + + /** + * 加工零件的图片地址 + */ + private String imgAddr; + + /** + * 创建时间 + */ + private String createTime; + + /** + * 最后一次更新时间 + */ + private String lastEditTime; + + public GoodsDetailVo(GoodsDetail goodsDetail) { + this.id = goodsDetail.getId(); + this.fkCategoryId = goodsDetail.getFkCategoryId(); + this.fkOwnerId = goodsDetail.getFkOwnerId(); + this.categoryName = goodsDetail.getCategoryName(); + this.goodsName = goodsDetail.getGoodsName(); + this.price = goodsDetail.getPrice(); + this.priority = goodsDetail.getPriority(); + this.enableStatus = GoodsEnum.stateOf(goodsDetail.getEnableStatus()); + this.imgAddr = goodsDetail.getImgAddr(); + this.createTime = DateTimeUtil.dateToStr2(goodsDetail.getCreateTime()); + this.lastEditTime = DateTimeUtil.dateToStr2(goodsDetail.getLastEditTime()); + } + +} diff --git a/src/main/java/com/mark/web/bill/enums/AccountEnum.java b/src/main/java/com/mark/web/bill/enums/AccountEnum.java new file mode 100644 index 0000000000000000000000000000000000000000..2c03dae04eded6b55bfbdab3363d81308e7ff2a6 --- /dev/null +++ b/src/main/java/com/mark/web/bill/enums/AccountEnum.java @@ -0,0 +1,47 @@ +package com.mark.web.bill.enums; + +/** + * @Description: 账单信息的枚举值 + * @Author: Mark + * @CreateDate: 2019/2/2 22:53 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +public enum AccountEnum { + + UN_PAYMENT(1, "未结算"), + PAYMENT_ED(2,"已结算"); + private int state; + private String desc; + + AccountEnum(int state, String desc) { + this.state = state; + this.desc = desc; + } + + public static String stateOf(int state){ + for(AccountEnum accountEnum :values()){ + if(accountEnum.getState() == state){ + return accountEnum.getDesc(); + } + } + return "未知!"; + } + + public int getState() { + return state; + } + + public void setState(int state) { + this.state = state; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + +} diff --git a/src/main/java/com/mark/web/bill/enums/GoodsCategoryEnum.java b/src/main/java/com/mark/web/bill/enums/GoodsCategoryEnum.java new file mode 100644 index 0000000000000000000000000000000000000000..49056ed65d846603189cd7bf38bbb196b5fd6382 --- /dev/null +++ b/src/main/java/com/mark/web/bill/enums/GoodsCategoryEnum.java @@ -0,0 +1,46 @@ +package com.mark.web.bill.enums; + +/** + * @Description: 加工零件种类的枚举信息 + * @Author: Mark + * @CreateDate: 2019/2/16 21:08 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +public enum GoodsCategoryEnum { + AVAILABLE(1, "可用"), + FORBIDDEN(2,"禁用"); + + private int state; + private String desc; + + GoodsCategoryEnum(int state, String desc) { + this.state = state; + this.desc = desc; + } + + public int getState() { + return state; + } + + public void setState(int state) { + this.state = state; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public static String stateOf(int state){ + for(GoodsCategoryEnum goodsCategoryEnum :values()){ + if(goodsCategoryEnum.getState() == state){ + return goodsCategoryEnum.getDesc(); + } + } + return "未知!"; + } +} diff --git a/src/main/java/com/mark/web/bill/enums/GoodsEnum.java b/src/main/java/com/mark/web/bill/enums/GoodsEnum.java new file mode 100644 index 0000000000000000000000000000000000000000..912e5dc5d54b124db15754f695f2690c8855205f --- /dev/null +++ b/src/main/java/com/mark/web/bill/enums/GoodsEnum.java @@ -0,0 +1,47 @@ +package com.mark.web.bill.enums; + +/** + * @Description: 加工零件商品的枚举值 + * @Author: Mark + * @CreateDate: 2019/2/2 22:53 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +public enum GoodsEnum { + + AVAILABLE(1, "可用"), + FORBIDDEN(2,"禁用"); + + private int state; + private String desc; + + GoodsEnum(int state, String desc) { + this.state = state; + this.desc = desc; + } + + public int getState() { + return state; + } + + public void setState(int state) { + this.state = state; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public static String stateOf(int state){ + for(GoodsEnum goodsEnum :values()){ + if(goodsEnum.getState() == state){ + return goodsEnum.getDesc(); + } + } + return "未知!"; + } +} diff --git a/src/main/java/com/mark/web/bill/exception/BillException.java b/src/main/java/com/mark/web/bill/exception/BillException.java new file mode 100644 index 0000000000000000000000000000000000000000..0ae167f60a38ca463a802583476b07a4cfdfb9eb --- /dev/null +++ b/src/main/java/com/mark/web/bill/exception/BillException.java @@ -0,0 +1,8 @@ +package com.mark.web.bill.exception; + + +public class BillException extends RuntimeException{ + public BillException(String msg){ + super(msg); + } +} diff --git a/src/main/java/com/mark/web/bill/mapper/AccountMapper.java b/src/main/java/com/mark/web/bill/mapper/AccountMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..7a2406933f93346b9f4fad215e5fad7d66e59a3d --- /dev/null +++ b/src/main/java/com/mark/web/bill/mapper/AccountMapper.java @@ -0,0 +1,47 @@ +package com.mark.web.bill.mapper; + +import com.mark.web.bill.entity.po.Account; +import org.apache.ibatis.annotations.Param; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * @Description: 账号到dao接口定义 + * @Author: Kingsley: 08:46 + * @CreateDate: 2019/1/31 15:14 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +public interface AccountMapper { + int deleteByPrimaryKey(Integer id); + + int insert(Account record); + + Account selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(Account record); + + /** + * 根据搜索的时间戳获取个人的账单信息 + * @param startDate :开始时间 + * @param endDate : 结束时间 + * @param currentUserId :当用用户id + * @return : + */ + List selectAccountsBySearchTime(@Param("startDate") Date startDate, + @Param("endDate") Date endDate, + @Param("currentUserId") int currentUserId); + + + BigDecimal getTotalPrice(@Param("startDate") Date startDate, + @Param("endDate") Date endDate, + @Param("state") Integer state, + @Param("currentUserId") int currentUserId); + + Integer getTotalQuantity(@Param("startDate") Date startDate, + @Param("endDate") Date endDate, + @Param("currentUserId") int currentUserId); + +} \ No newline at end of file diff --git a/src/main/java/com/mark/web/bill/mapper/GoodsCategoryMapper.java b/src/main/java/com/mark/web/bill/mapper/GoodsCategoryMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..49a35d6af795a3804a55f017f3b9e9806cf49bd8 --- /dev/null +++ b/src/main/java/com/mark/web/bill/mapper/GoodsCategoryMapper.java @@ -0,0 +1,36 @@ +package com.mark.web.bill.mapper; + +import com.mark.web.bill.entity.po.GoodsCategory; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface GoodsCategoryMapper { + + int insert(GoodsCategory record); + + int deleteByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(GoodsCategory record); + + GoodsCategory selectByPrimaryKey(Integer id); + + + + /** + * 根据父级种类的ID以及种类名称模糊搜索 获取子加工零件种类列表信息 + * @param parentId :父级ID + * @return : + */ + List selectSubGoodsCatesByParentId(@Param("parentId") Integer parentId, + @Param("categoryName") String categoryName); + + /** + * 获取所有可用种类 + * @return :状态为可用的种类 + */ + List selectAllGoodsCates(); + + + +} \ No newline at end of file diff --git a/src/main/java/com/mark/web/bill/mapper/GoodsImgMapper.java b/src/main/java/com/mark/web/bill/mapper/GoodsImgMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..3e6f29f3a228cc263a60448abbfde72294debc00 --- /dev/null +++ b/src/main/java/com/mark/web/bill/mapper/GoodsImgMapper.java @@ -0,0 +1,21 @@ +package com.mark.web.bill.mapper; + +import com.mark.web.bill.entity.po.GoodsImg; + +/** + * @Description: 商品资源图片的dao接口定义 + * @Author: Kingsley: 08:46 + * @CreateDate: 2019/1/31 15:14 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +public interface GoodsImgMapper { + int deleteByPrimaryKey(Integer id); + + int insert(GoodsImg record); + + GoodsImg selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(GoodsImg record); + +} \ No newline at end of file diff --git a/src/main/java/com/mark/web/bill/mapper/GoodsMapper.java b/src/main/java/com/mark/web/bill/mapper/GoodsMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..09fecf4ea2f4c672794636718dcb270abad1c17b --- /dev/null +++ b/src/main/java/com/mark/web/bill/mapper/GoodsMapper.java @@ -0,0 +1,32 @@ +package com.mark.web.bill.mapper; + +import com.mark.web.bill.entity.dto.GoodsDetail; +import com.mark.web.bill.entity.po.Goods; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * @Description: 商品dao接口定义 + * @Author: Kingsley: 08:46 + * @CreateDate: 2019/1/31 15:14 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +public interface GoodsMapper { + int deleteByPrimaryKey(Integer id); + + int insert(Goods record); + + Goods selectByPrimaryKey(Integer id); + + List> selectAllGoodsByCate(@Param("categoryId") Integer categoryId); + + List searchGoodsDetailList(@Param("categoryId") Integer categoryId, + @Param("currentUserId") Integer currentUserId, + @Param("searchGoodsName") String searchGoodsName); + + int updateByPrimaryKeySelective(Goods record); + +} \ No newline at end of file diff --git a/src/main/java/com/mark/web/bill/service/IAccountService.java b/src/main/java/com/mark/web/bill/service/IAccountService.java new file mode 100644 index 0000000000000000000000000000000000000000..532f468969daaea117ce1314adea9375b572187c --- /dev/null +++ b/src/main/java/com/mark/web/bill/service/IAccountService.java @@ -0,0 +1,39 @@ +package com.mark.web.bill.service; + +import com.github.pagehelper.PageInfo; +import com.mark.common.ServerResponse; +import com.mark.web.bill.entity.po.Account; +import com.mark.web.bill.entity.vo.AccountVo; + +import java.util.Map; + +public interface IAccountService { + + /** + * 添加一条个人账单信息 + * @param account :个人账单信息 + * @return : + */ + ServerResponse add(Account account); + + /** + * 查找搜索时间范围内的账单信息列表 + * @param start :搜索开始时间戳 + * @param end :搜索结束时间戳 + * @param pageNum :页数 + * @param pageSize :页面大小 + * @param currentUserId :当前用户ID + * @return :返回当前用户的在搜索时间范围内的个人账单信息列表 + */ + ServerResponse> getAccountListBySearchTime(Long start, Long end, int pageNum, int pageSize, int currentUserId); + + /** + * 查找搜索时间范围内的账单统计信息(总额,已经结算总额,未结算总额,总加工零件数量) + * @param start :搜索开始时间 + * @param end :搜索结束时间 + * @param currentUserId :当前用户ID + * @return :找搜索时间范围内的账单统计信息 + */ + ServerResponse> getStatisticalInfo(Long start, Long end, int currentUserId); +} + diff --git a/src/main/java/com/mark/web/bill/service/IGoodsCateService.java b/src/main/java/com/mark/web/bill/service/IGoodsCateService.java new file mode 100644 index 0000000000000000000000000000000000000000..ef5f7aaaad46abd1eb3f903530333c489e31acd3 --- /dev/null +++ b/src/main/java/com/mark/web/bill/service/IGoodsCateService.java @@ -0,0 +1,29 @@ +package com.mark.web.bill.service; + +import com.mark.common.ServerResponse; +import com.mark.web.bill.entity.po.GoodsCategory; +import com.mark.web.bill.entity.vo.GoodsCategoryVo; + +import java.util.List; +import java.util.Map; + +/** + * @Description: 加工零件种类业务接口定义 + * @Author: Mark + * @CreateDate: 2019/2/16 21:14 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +public interface IGoodsCateService { + + ServerResponse> getGoodsCateList(int parentId); + + ServerResponse>> getGoodsCateCascader(); + + ServerResponse add(GoodsCategory goodsCategory); + + ServerResponse> getSearchGoodsCates(Integer parentId, String categoryName); + + ServerResponse edit(GoodsCategory goodsCategory); + +} diff --git a/src/main/java/com/mark/web/bill/service/IGoodsImgService.java b/src/main/java/com/mark/web/bill/service/IGoodsImgService.java new file mode 100644 index 0000000000000000000000000000000000000000..ce69ab62242f8cd19ea1da1a347ddde25892a717 --- /dev/null +++ b/src/main/java/com/mark/web/bill/service/IGoodsImgService.java @@ -0,0 +1,18 @@ +package com.mark.web.bill.service; + +/** + * @Description: 加工零件的业务层接口定义 + * @Author: Mark + * @CreateDate: 2019/2/11 23:21 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +public interface IGoodsImgService { + + /** + * 新增一条加工零件图片的记录信息 + * @param url :图片资源保存到OSS的url地址 + * @param goodsId :加工零件的Id + */ + void add(String url, Integer goodsId); +} diff --git a/src/main/java/com/mark/web/bill/service/IGoodsService.java b/src/main/java/com/mark/web/bill/service/IGoodsService.java new file mode 100644 index 0000000000000000000000000000000000000000..2bd02ab6dae6a26a35c8890191e223689b73da8e --- /dev/null +++ b/src/main/java/com/mark/web/bill/service/IGoodsService.java @@ -0,0 +1,49 @@ +package com.mark.web.bill.service; + +import com.github.pagehelper.PageInfo; +import com.mark.common.ServerResponse; +import com.mark.web.bill.entity.po.Goods; +import com.mark.web.bill.entity.vo.GoodsDetailVo; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; +import java.util.Map; + +/** + * @Description: 加工零件管理的service业务层接口定义 + * @Author: Mark + * @CreateDate: 2019/2/2 22:42 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +public interface IGoodsService { + + /** + * 添加一条加工零件 + * @param goods :加工零件记录 + * @param goodsImage :加工零件图片 + * @return : + */ + ServerResponse add(Goods goods, MultipartFile goodsImage); + + + /** + * 根据种类id查询加工零件列表信息,如果categoryId为null查询的是所有的零件信息 + * @param categoryId :种类id,非必传 + * @return : + */ + ServerResponse>> getOptionInfo(Integer categoryId); + + /** + * 分页查询加工零件列表信息 + * @param pageNum :当前页数 + * @param pageSize :页面大小 + * @param currentUserId :当前用户id + * @param categoryId :种类id + * @param searchGoodsName :搜索的加工零件的名称 + * @return : + */ + ServerResponse> getGoodsList(int pageNum, int pageSize, int currentUserId, + Integer categoryId,String searchGoodsName); + +} diff --git a/src/main/java/com/mark/web/bill/service/impl/AccountServiceImpl.java b/src/main/java/com/mark/web/bill/service/impl/AccountServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..473850625009ca3168e016181d3ad285e954f4cf --- /dev/null +++ b/src/main/java/com/mark/web/bill/service/impl/AccountServiceImpl.java @@ -0,0 +1,107 @@ +package com.mark.web.bill.service.impl; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.mark.common.Constant; +import com.mark.common.ServerResponse; +import com.mark.common.utils.BigDecimalUtil; +import com.mark.web.bill.entity.po.Account; +import com.mark.web.bill.entity.po.Goods; +import com.mark.web.bill.entity.vo.AccountVo; +import com.mark.web.bill.enums.AccountEnum; +import com.mark.web.bill.mapper.AccountMapper; +import com.mark.web.bill.mapper.GoodsMapper; +import com.mark.web.bill.service.IAccountService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import java.util.Map; + +@Service +public class AccountServiceImpl implements IAccountService { + private final AccountMapper accountMapper; + private final GoodsMapper goodsMapper; + + @Autowired + public AccountServiceImpl(AccountMapper accountMapper, GoodsMapper goodsMapper) { + this.accountMapper = accountMapper; + this.goodsMapper = goodsMapper; + } + + //region 添加一条个人账单信息 + @Override + public ServerResponse add(Account account) { + //通过商品ID获取商品信息 + Goods goods = goodsMapper.selectByPrimaryKey(account.getFkGoodsId()); + if(goods == null){ + return ServerResponse.createByErrorMessage("账单中的加工零件不存在!"); + } + if(account.getEnableStatus() == null){ + account.setEnableStatus(AccountEnum.UN_PAYMENT.getState()); + } + + //如果账单的创建时间为空,则默认为今天 + if(account.getCreateTime() == null){ + account.setCreateTime(new Date()); + } + //计算总价 + BigDecimal price = goods.getPrice(); + Integer quantity = account.getQuantity(); + BigDecimal total = BigDecimalUtil.mul(price.doubleValue(), quantity.doubleValue()); + account.setTotalPrice(total); + int effectNum = accountMapper.insert(account); + if(effectNum != Constant.SUCCESS){ + ServerResponse.createByErrorMessage("保存信息失败!"); + } + return ServerResponse.createBySuccessMessage("添加账单记录成功!"); + } + //endregion + + //region 查找时间范围内的账单信息列表 + @Override + public ServerResponse> getAccountListBySearchTime(Long start, Long end, int pageNum, int pageSize, int currentUserId) { + PageHelper.startPage(pageNum, pageSize); + Date startDate = new Date(start); + Date endDate = new Date(end); + List accountList = accountMapper.selectAccountsBySearchTime(startDate,endDate,currentUserId); + List accountVoList = Lists.newArrayList(); + for(Account account : accountList){ + Goods goods = goodsMapper.selectByPrimaryKey(account.getFkGoodsId()); + AccountVo accountVo = new AccountVo(account, goods); + accountVoList.add(accountVo); + } + PageInfo result = new PageInfo<>(accountVoList); + result.setTotal(new PageInfo<>(accountList).getTotal()); + return ServerResponse.createBySuccess(result); + } + //endregion + + //region 查找搜索时间范围内的账单统计信息(总额,已经结算总额,未结算总额,总加工零件数量) + @Override + public ServerResponse> getStatisticalInfo(Long start, Long end, int currentUserId) { + Date startDate = new Date(start); + Date endDate = new Date(end); + BigDecimal totalPrice = accountMapper.getTotalPrice(startDate, endDate, null, currentUserId); + BigDecimal unPayTotalPrice = accountMapper.getTotalPrice(startDate, endDate, AccountEnum.UN_PAYMENT.getState(), currentUserId); + BigDecimal payTotalPrice = accountMapper.getTotalPrice(startDate, endDate, AccountEnum.PAYMENT_ED.getState(), currentUserId); + Integer totalQuantity = accountMapper.getTotalQuantity(startDate, endDate, currentUserId); + + Map resultMap = Maps.newHashMap(); + //总额 + resultMap.put("totalPrice",totalPrice == null ? 0.00 : totalPrice); + //未支付总额 + resultMap.put("unPayPrice",unPayTotalPrice == null ? 0.00 : unPayTotalPrice); + //已支付总额 + resultMap.put("payedPrice",payTotalPrice == null ? 0.00 : payTotalPrice); + //总加工零件个数 + resultMap.put("totalQuantity",totalQuantity == null ? 0.00 : totalQuantity); + return ServerResponse.createBySuccess(resultMap); + } + //endregion + +} diff --git a/src/main/java/com/mark/web/bill/service/impl/GoodsCateServiceImpl.java b/src/main/java/com/mark/web/bill/service/impl/GoodsCateServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..a0a74f1abbcdd8dd880dcd4d0a09a941e3112d3b --- /dev/null +++ b/src/main/java/com/mark/web/bill/service/impl/GoodsCateServiceImpl.java @@ -0,0 +1,135 @@ +package com.mark.web.bill.service.impl; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.mark.common.Constant; +import com.mark.common.ServerResponse; +import com.mark.web.bill.entity.po.GoodsCategory; +import com.mark.web.bill.entity.vo.GoodsCategoryVo; +import com.mark.web.bill.enums.GoodsCategoryEnum; +import com.mark.web.bill.exception.BillException; +import com.mark.web.bill.mapper.GoodsCategoryMapper; +import com.mark.web.bill.service.IGoodsCateService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * @Description: 加工零件种类的业务实现 + * @Author: Mark + * @CreateDate: 2019/2/16 21:18 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +@Service +public class GoodsCateServiceImpl implements IGoodsCateService { + private final GoodsCategoryMapper goodsCategoryMapper; + + @Autowired + public GoodsCateServiceImpl(GoodsCategoryMapper goodsCategoryMapper) { + this.goodsCategoryMapper = goodsCategoryMapper; + } + + //region 获取同一个父级的零件种类 + @Override + public ServerResponse> getGoodsCateList(int parentId) { + List goodsCategoryList = goodsCategoryMapper.selectSubGoodsCatesByParentId(parentId,null); + List result = Lists.newArrayList(); + goodsCategoryList.forEach(goodsCategory -> result.add(new GoodsCategoryVo(goodsCategory))); + return ServerResponse.createBySuccess(result); + } + //endregion + + //region 获取渲染Cascader组件的属性数据 + @Override + public ServerResponse>> getGoodsCateCascader() { + List goodsCategoryList = goodsCategoryMapper.selectSubGoodsCatesByParentId(0,null); + + List> result = buildGoodsCateCascader(0,goodsCategoryList); + return ServerResponse.createBySuccess(result); + } + + private List> buildGoodsCateCascader(int parentId, List goodsCategoryList) { + List> result = Lists.newArrayList(); + for(GoodsCategory goodsCategory : goodsCategoryList){ + if(goodsCategory.getParentId() == parentId){ + Map childrenMap = Maps.newHashMap(); + childrenMap.put("value", goodsCategory.getId()); + childrenMap.put("label", goodsCategory.getGoodsCategoryName()); + List subGoodsCategoryList = goodsCategoryMapper.selectSubGoodsCatesByParentId(goodsCategory.getId(),null); + if(subGoodsCategoryList != null && subGoodsCategoryList.size() > 0){ + List> children = buildGoodsCateCascader(goodsCategory.getId(), subGoodsCategoryList); + childrenMap.put("children", children); + } + result.add(childrenMap); + } + } + return result; + } + //endregion + + //region 新增一条种类记录 + @Override + public ServerResponse add(GoodsCategory goodsCategory) { + //状态默认为可用 + goodsCategory.setEnableStatus(GoodsCategoryEnum.AVAILABLE.getState()); + + //层级属性的设置:如果父级ID为0,则level为1。否则取父级种类的level+1 + setCategoryLevel(goodsCategory); + + //插入数据库 + int insert = goodsCategoryMapper.insert(goodsCategory); + if(insert != Constant.SUCCESS){ + return ServerResponse.createByErrorMessage("新增种类失败!"); + } + return ServerResponse.createBySuccessMessage("新增种类成功!"); + } + //endregion + + //region 根据父级种类ID和种类名称模糊搜索 + @Override + public ServerResponse> getSearchGoodsCates(Integer parentId, String categoryName) { + List goodsCategoryList = goodsCategoryMapper.selectSubGoodsCatesByParentId(parentId, categoryName); + List result = Lists.newArrayList(); + goodsCategoryList.forEach(goodsCategory -> result.add(new GoodsCategoryVo(goodsCategory))); + return ServerResponse.createBySuccess(result); + } + //endregion + + //region 编辑种类 + @Override + public ServerResponse edit(GoodsCategory goodsCategory) { + //层级属性的设置:如果父级ID为0,则level为1。否则取父级种类的level+1 + setCategoryLevel(goodsCategory); + int update = goodsCategoryMapper.updateByPrimaryKeySelective(goodsCategory); + if(update != Constant.SUCCESS){ + return ServerResponse.createByErrorMessage("更新种类失败!"); + } + return ServerResponse.createBySuccessMessage("更新种类成功!"); + } + //endregion + + /* + * ------------------------------------------- 公用私用方法抽取 -------------------------------------------------------------------- + */ + //region 新增或者编辑时种类等级的设置 + /** + * 层级属性的设置:如果父级ID为0,则level为1。否则取父级种类的level+1 + * @param goodsCategory : + */ + private void setCategoryLevel(GoodsCategory goodsCategory) { + if(goodsCategory.getParentId() == 0 || goodsCategory.getParentId()==null){ + goodsCategory.setLevel(1); + }else{ + GoodsCategory parentCate = goodsCategoryMapper.selectByPrimaryKey(goodsCategory.getParentId()); + if(parentCate == null){ + throw new BillException("父级种类不存在!"); + } + goodsCategory.setLevel(parentCate.getLevel()); + } + } + //endregion +} diff --git a/src/main/java/com/mark/web/bill/service/impl/GoodsImgServiceImpl.java b/src/main/java/com/mark/web/bill/service/impl/GoodsImgServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..004eeddc277bcfc8c13f8f10c944f62cc6958244 --- /dev/null +++ b/src/main/java/com/mark/web/bill/service/impl/GoodsImgServiceImpl.java @@ -0,0 +1,35 @@ +package com.mark.web.bill.service.impl; + +import com.mark.common.Constant; +import com.mark.web.bill.entity.po.GoodsImg; +import com.mark.web.bill.exception.BillException; +import com.mark.web.bill.mapper.GoodsImgMapper; +import com.mark.web.bill.service.IGoodsImgService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @Description: 加工零件图片资源的业务实现 + * @Author: Mark + * @CreateDate: 2019/2/11 23:38 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +@Service +public class GoodsImgServiceImpl implements IGoodsImgService { + @Autowired + private GoodsImgMapper goodsImgMapper; + + @Override + public void add(String url, Integer goodsId) { + GoodsImg goodsImg = new GoodsImg(); + goodsImg.setGoodsId(goodsId); + goodsImg.setImgAddr(url); + goodsImg.setPriority(0); + goodsImg.setEnableStatus(1); + int effectNum = goodsImgMapper.insert(goodsImg); + if(effectNum != Constant.SUCCESS){ + throw new BillException("保存加工零件图片数据失败!"); + } + } +} diff --git a/src/main/java/com/mark/web/bill/service/impl/GoodsServiceImpl.java b/src/main/java/com/mark/web/bill/service/impl/GoodsServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..4fdeb18f989735065099bc2a0e2f162558f8fb3e --- /dev/null +++ b/src/main/java/com/mark/web/bill/service/impl/GoodsServiceImpl.java @@ -0,0 +1,86 @@ +package com.mark.web.bill.service.impl; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.google.common.collect.Lists; +import com.mark.common.Constant; +import com.mark.common.ServerResponse; +import com.mark.common.utils.OSSClientUtil; +import com.mark.web.bill.entity.dto.GoodsDetail; +import com.mark.web.bill.entity.po.Goods; +import com.mark.web.bill.entity.vo.GoodsDetailVo; +import com.mark.web.bill.enums.GoodsEnum; +import com.mark.web.bill.mapper.GoodsMapper; +import com.mark.web.bill.service.IGoodsImgService; +import com.mark.web.bill.service.IGoodsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; +import java.util.Map; + +/** + * @Description: 商品加工零件的业务层接口实现 + * @Author: Mark + * @CreateDate: 2019/2/2 22:51 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +@Service +public class GoodsServiceImpl implements IGoodsService { + private final GoodsMapper goodsMapper; + private final IGoodsImgService iGoodsImgService; + + @Autowired + public GoodsServiceImpl(GoodsMapper goodsMapper, IGoodsImgService iGoodsImgService) { + this.goodsMapper = goodsMapper; + this.iGoodsImgService = iGoodsImgService; + } + + + //region 添加一个加工零件记录 + @Override + public ServerResponse add(Goods goods, MultipartFile goodsImage) { + //账单的状态默认为可用 + goods.setEnableStatus(GoodsEnum.AVAILABLE.getState()); + int affectNum = goodsMapper.insert(goods); + if (affectNum != Constant.SUCCESS) { + ServerResponse.createByErrorMessage("保存信息失败!"); + } + if(goodsImage != null){ + //上传图片到OSS服务器 + String url = OSSClientUtil.uploadImg2Oss(goodsImage, "Goods", goods.getId()); + //保存加工零件的图片数据到DB + iGoodsImgService.add(url,goods.getId()); + } + return ServerResponse.createBySuccessMessage("添加加工零件成功!"); + } + //endregion + + //region 根据种类id查询加工零件列表信息 + @Override + public ServerResponse>> getOptionInfo(Integer categoryId) { + List> result = goodsMapper.selectAllGoodsByCate(categoryId); + return ServerResponse.createBySuccess(result); + } + //endregion + + //region 分页查询加工零件信息 + @Override + public ServerResponse> getGoodsList(int pageNum, int pageSize, + int currentUserId, Integer categoryId,String searchGoodsName) { + PageHelper.startPage(pageNum, pageSize); + List goodsDetailList = goodsMapper.searchGoodsDetailList(categoryId, currentUserId,searchGoodsName); + List goodsDetailVoList = Lists.newArrayList(); + for(GoodsDetail goodsDetail : goodsDetailList){ + GoodsDetailVo goodsDetailVo = new GoodsDetailVo(goodsDetail); + goodsDetailVoList.add(goodsDetailVo); + } + PageInfo result = new PageInfo<>(goodsDetailVoList); + result.setTotal(new PageInfo<>(goodsDetailList).getTotal()); + return ServerResponse.createBySuccess(result); + } + //endregion + +} diff --git a/src/main/java/com/mark/web/common/controller/FileDownloadController.java b/src/main/java/com/mark/web/common/controller/FileDownloadController.java new file mode 100644 index 0000000000000000000000000000000000000000..b52c0ada681bd64ada970fac01eaa4cb967df57d --- /dev/null +++ b/src/main/java/com/mark/web/common/controller/FileDownloadController.java @@ -0,0 +1,31 @@ +package com.mark.web.common.controller; + +import com.mark.common.utils.DownloadFileUtil; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.File; + +/** + * @Description: 通用文件上传类 + * @Author: Kingsley + * @CreateDate: 2019/2/21 20:22 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +@RestController() +@RequestMapping("/common/file/") +public class FileDownloadController { + + /** + * 下载文件的demo + */ + @RequestMapping(value = "download") + public void downloadFile(HttpServletRequest request, HttpServletResponse response) { + File file = new File("C:\\Users\\Mark\\Desktop\\bak\\test.png"); + String fileName = "测试文件下载.png"; + DownloadFileUtil.downloadFile(fileName,file,response,request); + } +} diff --git a/src/main/java/com/mark/web/common/service/Impl/UploadFilesServiceImpl.java b/src/main/java/com/mark/web/common/service/Impl/UploadFilesServiceImpl.java index fc4a6b9a8709b05adada8f8a975d45f2073833af..b7ec041c1695dfcf00ce569c422dd01dbf65dc02 100644 --- a/src/main/java/com/mark/web/common/service/Impl/UploadFilesServiceImpl.java +++ b/src/main/java/com/mark/web/common/service/Impl/UploadFilesServiceImpl.java @@ -3,7 +3,7 @@ package com.mark.web.common.service.Impl; import com.google.common.collect.Maps; import com.mark.common.ServerResponse; import com.mark.web.common.service.IUploadFilesService; -import com.mark.web.data.util.OSSClientUtil; +import com.mark.common.utils.OSSClientUtil; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/com/mark/web/data/service/impl/CartServiceImpl.java b/src/main/java/com/mark/web/data/service/impl/CartServiceImpl.java index 33c26bdcb6202f396865b563a27e3f6ef401998e..0298b6dd1757b5b6683d4937eb4f4b3838b06cca 100644 --- a/src/main/java/com/mark/web/data/service/impl/CartServiceImpl.java +++ b/src/main/java/com/mark/web/data/service/impl/CartServiceImpl.java @@ -10,7 +10,7 @@ import com.mark.common.exception.Campuso2oException; import com.mark.web.data.entity.po.Cart; import com.mark.web.data.entity.po.Product; import com.mark.web.data.service.ICartService; -import com.mark.web.data.util.BigDecimalUtil; +import com.mark.common.utils.BigDecimalUtil; import com.mark.common.utils.PropertiesUtil; import com.mark.web.data.entity.vo.CartProductVo; import com.mark.web.data.entity.vo.CartVo; diff --git a/src/main/java/com/mark/web/data/service/impl/OrderServiceImpl.java b/src/main/java/com/mark/web/data/service/impl/OrderServiceImpl.java index e8f789eb21574acedc9d37851045a20e1bae0fff..6f65d2ce71bb867a48aa5bf97d0d547f0a0e4fa6 100644 --- a/src/main/java/com/mark/web/data/service/impl/OrderServiceImpl.java +++ b/src/main/java/com/mark/web/data/service/impl/OrderServiceImpl.java @@ -13,7 +13,7 @@ import com.mark.common.exception.Campuso2oException; import com.mark.web.data.exception.OrderException; import com.mark.web.data.entity.po.*; import com.mark.web.data.service.IOrderService; -import com.mark.web.data.util.BigDecimalUtil; +import com.mark.common.utils.BigDecimalUtil; import com.mark.common.utils.DateTimeUtil; import com.mark.common.utils.PropertiesUtil; import com.mark.web.data.entity.vo.OrderItemVo; diff --git a/src/main/java/com/mark/web/data/service/impl/PayServiceImpl.java b/src/main/java/com/mark/web/data/service/impl/PayServiceImpl.java index dbd8fe9b25794d4b52c16d0773b23d33fa585a21..cd7f3bd405ec336e1b3b2c5f6689c779f326d2a9 100644 --- a/src/main/java/com/mark/web/data/service/impl/PayServiceImpl.java +++ b/src/main/java/com/mark/web/data/service/impl/PayServiceImpl.java @@ -13,7 +13,9 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.mark.common.Constant; import com.mark.common.ServerResponse; +import com.mark.common.utils.BigDecimalUtil; import com.mark.common.utils.DateTimeUtil; +import com.mark.common.utils.OSSClientUtil; import com.mark.common.utils.PropertiesUtil; import com.mark.web.data.mapper.OrderItemMapper; import com.mark.web.data.mapper.OrderMapper; diff --git a/src/main/resources.dev/dataSource.properties b/src/main/resources.dev/dataSource.properties index 15696e88163520600ced83614a054932ec587cb7..fcee499a558dc17594556c25cda118b2b968f564 100644 --- a/src/main/resources.dev/dataSource.properties +++ b/src/main/resources.dev/dataSource.properties @@ -1,27 +1,35 @@ -#数据库相关数据库的配置文件 -#读取配置文件:PropertiesUtil.getDataSourceProperty("shiro.redis.ip") +#\u6570\u636E\u5E93\u76F8\u5173\u6570\u636E\u5E93\u7684\u914D\u7F6E\u6587\u4EF6 +#\u8BFB\u53D6\u914D\u7F6E\u6587\u4EF6\uFF1APropertiesUtil.getDataSourceProperty("shiro.redis.ip") -#1.系統业务相关数据库 +#1.\u7CFB\u7D71\u4E1A\u52A1\u76F8\u5173\u6570\u636E\u5E93 sys.database.classname=com.mysql.jdbc.Driver sys.database.url=jdbc:mysql://47.95.13.238/campuso2o_v2?characterEncoding=utf-8&useSSL=false sys.database.username=mark sys.database.password=7561669Dong! -#系统模块的mapper.xml文件的搜扫描路径 +#\u7CFB\u7EDF\u6A21\u5757\u7684mapper.xml\u6587\u4EF6\u7684\u641C\u626B\u63CF\u8DEF\u5F84 sys.mapper.locations=classpath*:mappers/data/*.xml -#2.Shrio权限验证的数据库 +#2.Shrio\u6743\u9650\u9A8C\u8BC1\u7684\u6570\u636E\u5E93 shiro.database.classname=com.mysql.jdbc.Driver shiro.database.url=jdbc:mysql://47.95.13.238/campuso2o_sys_2.0?characterEncoding=utf-8&useSSL=false shiro.database.username=mark shiro.database.password=7561669Dong! -#shiro模块的mapper.xml文件的扫描路径 +#shiro\u6A21\u5757\u7684mapper.xml\u6587\u4EF6\u7684\u626B\u63CF\u8DEF\u5F84 shiro.mapper.locations=classpath*:mappers/sys/*.xml -#3.redis数据库的配置 -#存储shrio验证登录信息的redis数据库的配置 +#3.bill\u8D26\u5355\u6570\u636E\u5E93 +bill.database.classname=com.mysql.jdbc.Driver +bill.database.url=jdbc:mysql://47.95.13.238/campuso2o_bill_2.0?characterEncoding=utf-8&useSSL=false +bill.database.username=mark +bill.database.password=7561669Dong! +#bill\u8D26\u5355\u6A21\u5757\u7684mapper.xml\u6587\u4EF6\u7684\u626B\u63CF\u8DEF\u5F84 +bill.mapper.locations=classpath*:mappers/bill/*.xml + +#4.redis\u6570\u636E\u5E93\u7684\u914D\u7F6E +#\u5B58\u50A8shrio\u9A8C\u8BC1\u767B\u5F55\u4FE1\u606F\u7684redis\u6570\u636E\u5E93\u7684\u914D\u7F6E shiro.redis.ip=47.95.13.238 shiro.redis.port=6379 -#有效期:单位seconds +#\u6709\u6548\u671F\uFF1A\u5355\u4F4Dseconds shiro.redis.expire=1800 shiro.redis.timeout=0 diff --git a/src/main/resources/generatorConfig.xml b/src/main/resources/generatorConfig.xml index c0c1c4ccd7181a67d507a9376e596a2ad6cda6aa..f3e2588a15d398c9d73c15e547fe19114e968117 100644 --- a/src/main/resources/generatorConfig.xml +++ b/src/main/resources/generatorConfig.xml @@ -68,7 +68,7 @@ - +
diff --git a/src/main/resources/mappers/bill/AccountMapper.xml b/src/main/resources/mappers/bill/AccountMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..3ef82b6e847e93d4f066cc74cf4f6eaa0ee45a08 --- /dev/null +++ b/src/main/resources/mappers/bill/AccountMapper.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + id, fk_goods_id, fk_user_id, quantity, total_price, description, enable_status, create_time, + payment_time, last_edit_time + + + + delete from tb_bill_account + where id = #{id,jdbcType=INTEGER} + + + insert into tb_bill_account (id, fk_goods_id, fk_user_id, + quantity, total_price, description, + enable_status, create_time, payment_time, + last_edit_time) + values (#{id,jdbcType=INTEGER}, #{fkGoodsId,jdbcType=INTEGER}, #{fkUserId,jdbcType=INTEGER}, + #{quantity,jdbcType=INTEGER}, #{totalPrice,jdbcType=DECIMAL}, #{description,jdbcType=VARCHAR}, + #{enableStatus,jdbcType=INTEGER},#{createTime}, null, + NOW()) + + + + update tb_bill_account + + + fk_goods_id = #{fkGoodsId,jdbcType=INTEGER}, + + + fk_user_id = #{fkUserId,jdbcType=INTEGER}, + + + quantity = #{quantity,jdbcType=INTEGER}, + + + total_price = #{totalPrice,jdbcType=DECIMAL}, + + + description = #{description,jdbcType=VARCHAR}, + + + enable_status = #{enableStatus,jdbcType=INTEGER}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + payment_time = #{paymentTime,jdbcType=TIMESTAMP}, + + + last_edit_time = NOW() + + + where id = #{id,jdbcType=INTEGER} + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mappers/bill/GoodsCategoryMapper.xml b/src/main/resources/mappers/bill/GoodsCategoryMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..f28b1251b93c6c09a03c2d5683dbbe3ad29fa2b5 --- /dev/null +++ b/src/main/resources/mappers/bill/GoodsCategoryMapper.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + id, parent_id, goods_category_name, enable_status,level,priority, create_time, last_edit_time + + + + + insert into tb_bill_goods_category (id, parent_id, goods_category_name, + enable_status,level, priority, create_time, + last_edit_time) + values (#{id,jdbcType=INTEGER}, #{parentId,jdbcType=INTEGER}, #{goodsCategoryName,jdbcType=VARCHAR}, + #{enableStatus,jdbcType=INTEGER}, #{level,jdbcType=INTEGER},#{priority,jdbcType=INTEGER}, NOW(), + NOW()) + + + + delete from tb_bill_goods_category + where id = #{id,jdbcType=INTEGER} + + + + update tb_bill_goods_category + + + parent_id = #{parentId,jdbcType=INTEGER}, + + + goods_category_name = #{goodsCategoryName,jdbcType=VARCHAR}, + + + enable_status = #{enableStatus,jdbcType=Integer}, + + + priority = #{level,jdbcType=INTEGER}, + + + priority = #{priority,jdbcType=INTEGER}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + last_edit_time = NOW() + + where id = #{id,jdbcType=INTEGER} + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mappers/bill/GoodsImgMapper.xml b/src/main/resources/mappers/bill/GoodsImgMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..ee6ebae83cce47d3b6b1c40cdedcf959a1d72d23 --- /dev/null +++ b/src/main/resources/mappers/bill/GoodsImgMapper.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + id, goods_id, img_addr, priority, enable_status, create_time + + + + delete from tb_bill_goods_img + where id = #{id,jdbcType=INTEGER} + + + insert into tb_bill_goods_img (id, goods_id, img_addr, + priority, enable_status, create_time + ) + values (#{id,jdbcType=INTEGER}, #{goodsId,jdbcType=INTEGER}, #{imgAddr,jdbcType=VARCHAR}, + #{priority,jdbcType=INTEGER}, #{enableStatus,jdbcType=INTEGER}, NOW() + ) + + + + update tb_bill_goods_img + + + goods_id = #{goodsId,jdbcType=INTEGER}, + + + img_addr = #{imgAddr,jdbcType=VARCHAR}, + + + priority = #{priority,jdbcType=INTEGER}, + + + enable_status = #{enableStatus,jdbcType=INTEGER}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + where id = #{id,jdbcType=INTEGER} + + + \ No newline at end of file diff --git a/src/main/resources/mappers/bill/GoodsMapper.xml b/src/main/resources/mappers/bill/GoodsMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..a395965ed567a9cc5a8b55a99d298ddb9c0b5465 --- /dev/null +++ b/src/main/resources/mappers/bill/GoodsMapper.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + id, fk_owner_id,fk_category_id, goods_name, price, priority, enable_status, create_time, last_edit_time + + + + + + + + + + + + + + + + + + + + + + + + + delete from tb_bill_goods + where id = #{id,jdbcType=INTEGER} + + + + insert into tb_bill_goods (id, fk_owner_id, fk_category_id,goods_name, + price, priority, enable_status, + create_time, last_edit_time) + values (#{id,jdbcType=INTEGER}, #{fkOwnerId,jdbcType=INTEGER},#{fkCategoryId,jdbcType=INTEGER}, #{goodsName,jdbcType=VARCHAR}, + #{price,jdbcType=DECIMAL}, #{priority,jdbcType=INTEGER}, #{enableStatus,jdbcType=INTEGER}, + NOW(), NOW()) + + + + update tb_bill_goods + + + fk_owner_id = #{fkOwnerId,jdbcType=INTEGER}, + + + + fk_category_id = #{fkCategoryId,jdbcType=INTEGER}, + + + + goods_name = #{goodsName,jdbcType=VARCHAR}, + + + price = #{price,jdbcType=DECIMAL}, + + + priority = #{priority,jdbcType=INTEGER}, + + + enable_status = #{enableStatus,jdbcType=INTEGER}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + last_edit_time = NOW() + + where id = #{id,jdbcType=INTEGER} + + + \ No newline at end of file diff --git a/src/test/java/com/mark/BaseTest.java b/src/test/java/com/mark/BaseTest.java index d9f379087179d34f0e3aadace6f52079e2de0cfb..fa2223d9d84e81c97ce4b469f871bf3b2254a2d0 100644 --- a/src/test/java/com/mark/BaseTest.java +++ b/src/test/java/com/mark/BaseTest.java @@ -1,5 +1,6 @@ package com.mark; +import lombok.extern.slf4j.Slf4j; import org.junit.After; import org.junit.Before; import org.junit.runner.RunWith; diff --git a/src/test/java/com/mark/web/bill/mapper/AccountMapperTest.java b/src/test/java/com/mark/web/bill/mapper/AccountMapperTest.java new file mode 100644 index 0000000000000000000000000000000000000000..dc6085c17886c7ae019244a5523c73c57b338d72 --- /dev/null +++ b/src/test/java/com/mark/web/bill/mapper/AccountMapperTest.java @@ -0,0 +1,61 @@ +package com.mark.web.bill.mapper; + +import com.mark.BaseTest; +import com.mark.web.bill.entity.po.Account; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import java.math.BigDecimal; +import java.util.Date; + +import static org.junit.Assert.*; + +/** + * @Description: 账号的dao接口测试 + * @Author: Kingsley: 08:46 + * @CreateDate: 2019/1/31 15:14 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +public class AccountMapperTest extends BaseTest { + @Autowired + private AccountMapper accountMapper; + + @Test + public void deleteByPrimaryKey() { + } + + @Test + public void insert() { + Account account = new Account(); + account.setFkGoodsId(1); + account.setFkUserId(1); + account.setQuantity(10); + account.setTotalPrice(new BigDecimal(20)); + account.setDescription(""); + account.setEnableStatus(1); + int insert = accountMapper.insert(account); + Assert.assertNotEquals(0,insert); + } + + @Test + public void selectByPrimaryKey() { + } + + @Test + public void updateByPrimaryKeySelective() { + } + + @Test + public void getTotalPrice(){ + BigDecimal totalPrice = accountMapper.getTotalPrice(new Date(),new Date(),null,5); + Assert.assertNotNull(totalPrice); + } + + @Test + public void getTotalQuantity(){ + Integer totalQuantity = accountMapper.getTotalQuantity(new Date(),new Date(),5); + Assert.assertNotNull(totalQuantity); + } +} \ No newline at end of file diff --git a/src/test/java/com/mark/web/bill/mapper/GoodsCategoryMapperTest.java b/src/test/java/com/mark/web/bill/mapper/GoodsCategoryMapperTest.java new file mode 100644 index 0000000000000000000000000000000000000000..52be339ba76df5cb5f26d5d6b94de72b832da932 --- /dev/null +++ b/src/test/java/com/mark/web/bill/mapper/GoodsCategoryMapperTest.java @@ -0,0 +1,53 @@ +package com.mark.web.bill.mapper; + +import com.mark.BaseTest; +import com.mark.web.bill.entity.po.GoodsCategory; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; + +/** + * @Description: 加工零件种类操作数据库的dao层接口 + * @Author: Kingsley: 08:46 + * @CreateDate: 2019/2/11 16:16 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +public class GoodsCategoryMapperTest extends BaseTest { + @Autowired + private GoodsCategoryMapper goodsCategoryMapper; + + @Test + public void deleteByPrimaryKey() { + } + + @Test + public void insert() { + GoodsCategory category = new GoodsCategory(); + category.setParentId(3); + category.setGoodsCategoryName("子上丝类1"); + category.setEnableStatus(1); + category.setLevel(0); + category.setPriority(0); + int effectNum = goodsCategoryMapper.insert(category); + Assert.assertNotEquals(0,effectNum); + } + + @Test + public void selectByPrimaryKey() { + } + + @Test + public void selectSubGoodsCatesByParentId(){ + List goodsCategories = goodsCategoryMapper.selectSubGoodsCatesByParentId(null,"%类%"); + Assert.assertNotEquals(0,goodsCategories.size()); + } + + @Test + public void selectAllGoodsCates(){ + List goodsCategories = goodsCategoryMapper.selectAllGoodsCates(); + Assert.assertNotEquals(0,goodsCategories.size()); + } +} \ No newline at end of file diff --git a/src/test/java/com/mark/web/bill/mapper/GoodsImgMapperTest.java b/src/test/java/com/mark/web/bill/mapper/GoodsImgMapperTest.java new file mode 100644 index 0000000000000000000000000000000000000000..37e9879c217b945062f0fc345ec7e46a85674f80 --- /dev/null +++ b/src/test/java/com/mark/web/bill/mapper/GoodsImgMapperTest.java @@ -0,0 +1,32 @@ +package com.mark.web.bill.mapper; + +import com.mark.BaseTest; +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * @Description: 商品资源图片dao接口测试 + * @Author: Kingsley: 08:46 + * @CreateDate: 2019/1/31 15:14 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +public class GoodsImgMapperTest extends BaseTest { + + @Test + public void deleteByPrimaryKey() { + } + + @Test + public void insert() { + } + + @Test + public void selectByPrimaryKey() { + } + + @Test + public void updateByPrimaryKeySelective() { + } +} \ No newline at end of file diff --git a/src/test/java/com/mark/web/bill/mapper/GoodsMapperTest.java b/src/test/java/com/mark/web/bill/mapper/GoodsMapperTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0cbad5f2045d11e7ff849e260f8842890f0f33e7 --- /dev/null +++ b/src/test/java/com/mark/web/bill/mapper/GoodsMapperTest.java @@ -0,0 +1,50 @@ +package com.mark.web.bill.mapper; + +import com.mark.BaseTest; +import com.mark.web.bill.entity.dto.GoodsDetail; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; +import java.util.Map; + +/** + * @Description: 商品dao接口测试 + * @Author: Kingsley: 08:46 + * @CreateDate: 2019/1/31 15:14 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +public class GoodsMapperTest extends BaseTest { + @Autowired + private GoodsMapper goodsMapper; + + @Test + public void deleteByPrimaryKey() { + } + + @Test + public void insert() { + } + + @Test + public void selectByPrimaryKey() { + } + + @Test + public void updateByPrimaryKeySelective() { + } + + @Test + public void selectAllGoods(){ + List> maps = goodsMapper.selectAllGoodsByCate(1); + Assert.assertNotEquals(0,maps.size()); + } + + @Test + public void searchGoodsDetailList(){ + List goodsDetails = goodsMapper.searchGoodsDetailList(null,5,null); + Assert.assertNotEquals(0,goodsDetails.size()); + } +} \ No newline at end of file diff --git a/src/test/java/com/mark/web/bill/service/IGoodsCateServiceTest.java b/src/test/java/com/mark/web/bill/service/IGoodsCateServiceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f7798d70828165bbaa26f85b1f0227bacdd16cff --- /dev/null +++ b/src/test/java/com/mark/web/bill/service/IGoodsCateServiceTest.java @@ -0,0 +1,30 @@ +package com.mark.web.bill.service; + +import com.mark.BaseTest; +import com.mark.common.ServerResponse; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.*; + +/** + * @Description: 加工零件种类的测试 + * @Author: Mark + * @CreateDate: 2019/2/17 0:32 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +public class IGoodsCateServiceTest extends BaseTest { + @Autowired + private IGoodsCateService iGoodsCateService; + + @Test + public void getGoodsCateCascader(){ + ServerResponse>> goodsCateCascader = iGoodsCateService.getGoodsCateCascader(); + Assert.assertNotEquals(0,goodsCateCascader.getData().size()); + } +} \ No newline at end of file diff --git a/src/test/java/com/mark/web/bill/service/IGoodsServiceTest.java b/src/test/java/com/mark/web/bill/service/IGoodsServiceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..76ad6f15d0dda8f0a87443c50f93812e08fbeadf --- /dev/null +++ b/src/test/java/com/mark/web/bill/service/IGoodsServiceTest.java @@ -0,0 +1,43 @@ +package com.mark.web.bill.service; + +import com.github.pagehelper.PageInfo; +import com.mark.BaseTest; +import com.mark.common.ServerResponse; +import com.mark.web.bill.entity.po.Goods; +import com.mark.web.bill.entity.vo.GoodsDetailVo; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import java.math.BigDecimal; + +/** + * @Description: 加工零件的service层接口测试 + * @Author: Mark + * @CreateDate: 2019/2/2 23:01 + * @Version: 2.0 + * @Copyright : 豆浆油条个人非正式工作室 + */ +public class IGoodsServiceTest extends BaseTest { + + @Autowired + private IGoodsService iGoodsService; + + @Test + public void testAdd(){ + Goods goods = new Goods(); + goods.setFkOwnerId(1); + goods.setGoodsName("测试记录"); + goods.setPrice(new BigDecimal(0.02)); + goods.setPriority(1); + ServerResponse add = iGoodsService.add(goods, null); + Assert.assertNotNull(add); + } + + @Test + public void getGoodsList(){ + ServerResponse> goodsList = iGoodsService.getGoodsList(1, 1, + 1,1, "ee"); + Assert.assertNotNull(goodsList); + } +} \ No newline at end of file