From 63d9bbd45fa517faa6c57ed581b6b8cf1671932b Mon Sep 17 00:00:00 2001 From: macro Date: Mon, 26 Jul 2021 15:20:17 +0800 Subject: [PATCH] add mall-tiny-keycloak --- mall-tiny-keycloak/.gitignore | 29 + mall-tiny-keycloak/pom.xml | 130 +++ .../macro/mall/tiny/MallTinyApplication.java | 13 + .../mall/tiny/common/api/CommonPage.java | 71 ++ .../mall/tiny/common/api/CommonResult.java | 115 +++ .../mall/tiny/common/api/IErrorCode.java | 11 + .../mall/tiny/common/api/ResultCode.java | 28 + .../macro/mall/tiny/config/MyBatisConfig.java | 13 + .../mall/tiny/config/Swagger2Config.java | 43 + .../tiny/controller/PmsBrandController.java | 103 +++ .../macro/mall/tiny/mbg/CommentGenerator.java | 73 ++ .../com/macro/mall/tiny/mbg/Generator.java | 38 + .../mall/tiny/mbg/mapper/PmsBrandMapper.java | 36 + .../macro/mall/tiny/mbg/model/PmsBrand.java | 147 +++ .../mall/tiny/mbg/model/PmsBrandExample.java | 840 ++++++++++++++++++ .../mall/tiny/service/PmsBrandService.java | 24 + .../service/impl/PmsBrandServiceImpl.java | 53 ++ .../src/main/resources/application.yml | 37 + .../mall/tiny/mbg/mapper/PmsBrandMapper.xml | 358 ++++++++ .../src/main/resources/generator.properties | 4 + .../src/main/resources/generatorConfig.xml | 43 + .../mall/tiny/MallTiny01ApplicationTests.java | 16 + .../mall/tiny/MallTinyApplicationTests.java | 16 + 23 files changed, 2241 insertions(+) create mode 100644 mall-tiny-keycloak/.gitignore create mode 100644 mall-tiny-keycloak/pom.xml create mode 100644 mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/MallTinyApplication.java create mode 100644 mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/common/api/CommonPage.java create mode 100644 mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/common/api/CommonResult.java create mode 100644 mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/common/api/IErrorCode.java create mode 100644 mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/common/api/ResultCode.java create mode 100644 mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/config/MyBatisConfig.java create mode 100644 mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/config/Swagger2Config.java create mode 100644 mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/controller/PmsBrandController.java create mode 100644 mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/mbg/CommentGenerator.java create mode 100644 mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/mbg/Generator.java create mode 100644 mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/mbg/mapper/PmsBrandMapper.java create mode 100644 mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/mbg/model/PmsBrand.java create mode 100644 mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/mbg/model/PmsBrandExample.java create mode 100644 mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/service/PmsBrandService.java create mode 100644 mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/service/impl/PmsBrandServiceImpl.java create mode 100644 mall-tiny-keycloak/src/main/resources/application.yml create mode 100644 mall-tiny-keycloak/src/main/resources/com/macro/mall/tiny/mbg/mapper/PmsBrandMapper.xml create mode 100644 mall-tiny-keycloak/src/main/resources/generator.properties create mode 100644 mall-tiny-keycloak/src/main/resources/generatorConfig.xml create mode 100644 mall-tiny-keycloak/src/test/java/com/macro/mall/tiny/MallTiny01ApplicationTests.java create mode 100644 mall-tiny-keycloak/src/test/java/com/macro/mall/tiny/MallTinyApplicationTests.java diff --git a/mall-tiny-keycloak/.gitignore b/mall-tiny-keycloak/.gitignore new file mode 100644 index 00000000..153c9335 --- /dev/null +++ b/mall-tiny-keycloak/.gitignore @@ -0,0 +1,29 @@ +HELP.md +/target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +/build/ + +### VS Code ### +.vscode/ diff --git a/mall-tiny-keycloak/pom.xml b/mall-tiny-keycloak/pom.xml new file mode 100644 index 00000000..6bf9ecd9 --- /dev/null +++ b/mall-tiny-keycloak/pom.xml @@ -0,0 +1,130 @@ + + + 4.0.0 + com.macro.mall + mall-tiny-keycloak + 1.0-SNAPSHOT + mall-tiny-keycloak + Demo project for Spring Boot + + + UTF-8 + UTF-8 + 1.8 + true + + + + org.springframework.boot + spring-boot-starter-parent + 2.3.0.RELEASE + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-aop + + + org.springframework.boot + spring-boot-starter-test + test + + + + com.github.pagehelper + pagehelper-spring-boot-starter + 1.2.10 + + + + com.alibaba + druid-spring-boot-starter + 1.1.10 + + + + org.mybatis.generator + mybatis-generator-core + 1.3.3 + + + + mysql + mysql-connector-java + 8.0.15 + + + + io.springfox + springfox-boot-starter + 3.0.0 + + + + org.projectlombok + lombok + true + + + + cn.hutool + hutool-all + 4.5.7 + + + + org.keycloak + keycloak-spring-boot-starter + 14.0.0 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/MallTinyApplication.java b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/MallTinyApplication.java new file mode 100644 index 00000000..80f20db5 --- /dev/null +++ b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/MallTinyApplication.java @@ -0,0 +1,13 @@ +package com.macro.mall.tiny; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class MallTinyApplication { + + public static void main(String[] args) { + SpringApplication.run(MallTinyApplication.class, args); + } + +} diff --git a/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/common/api/CommonPage.java b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/common/api/CommonPage.java new file mode 100644 index 00000000..eb6c7bd9 --- /dev/null +++ b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/common/api/CommonPage.java @@ -0,0 +1,71 @@ +package com.macro.mall.tiny.common.api; + +import com.github.pagehelper.PageInfo; + +import java.util.List; + +/** + * 分页数据封装类 + * Created by macro on 2019/4/19. + */ +public class CommonPage { + private Integer pageNum; + private Integer pageSize; + private Integer totalPage; + private Long total; + private List list; + + /** + * 将PageHelper分页后的list转为分页信息 + */ + public static CommonPage restPage(List list) { + CommonPage result = new CommonPage(); + PageInfo pageInfo = new PageInfo(list); + result.setTotalPage(pageInfo.getPages()); + result.setPageNum(pageInfo.getPageNum()); + result.setPageSize(pageInfo.getPageSize()); + result.setTotal(pageInfo.getTotal()); + result.setList(pageInfo.getList()); + return result; + } + + public Integer getPageNum() { + return pageNum; + } + + public void setPageNum(Integer pageNum) { + this.pageNum = pageNum; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public Integer getTotalPage() { + return totalPage; + } + + public void setTotalPage(Integer totalPage) { + this.totalPage = totalPage; + } + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + public Long getTotal() { + return total; + } + + public void setTotal(Long total) { + this.total = total; + } +} diff --git a/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/common/api/CommonResult.java b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/common/api/CommonResult.java new file mode 100644 index 00000000..f1d580d5 --- /dev/null +++ b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/common/api/CommonResult.java @@ -0,0 +1,115 @@ +package com.macro.mall.tiny.common.api; + +/** + * 通用返回对象 + * Created by macro on 2019/4/19. + */ +public class CommonResult { + private long code; + private String message; + private T data; + + protected CommonResult() { + } + + protected CommonResult(long code, String message, T data) { + this.code = code; + this.message = message; + this.data = data; + } + + /** + * 成功返回结果 + * + * @param data 获取的数据 + */ + public static CommonResult success(T data) { + return new CommonResult(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage(), data); + } + + /** + * 成功返回结果 + * + * @param data 获取的数据 + * @param message 提示信息 + */ + public static CommonResult success(T data, String message) { + return new CommonResult(ResultCode.SUCCESS.getCode(), message, data); + } + + /** + * 失败返回结果 + * @param errorCode 错误码 + */ + public static CommonResult failed(IErrorCode errorCode) { + return new CommonResult(errorCode.getCode(), errorCode.getMessage(), null); + } + + /** + * 失败返回结果 + * @param message 提示信息 + */ + public static CommonResult failed(String message) { + return new CommonResult(ResultCode.FAILED.getCode(), message, null); + } + + /** + * 失败返回结果 + */ + public static CommonResult failed() { + return failed(ResultCode.FAILED); + } + + /** + * 参数验证失败返回结果 + */ + public static CommonResult validateFailed() { + return failed(ResultCode.VALIDATE_FAILED); + } + + /** + * 参数验证失败返回结果 + * @param message 提示信息 + */ + public static CommonResult validateFailed(String message) { + return new CommonResult(ResultCode.VALIDATE_FAILED.getCode(), message, null); + } + + /** + * 未登录返回结果 + */ + public static CommonResult unauthorized(T data) { + return new CommonResult(ResultCode.UNAUTHORIZED.getCode(), ResultCode.UNAUTHORIZED.getMessage(), data); + } + + /** + * 未授权返回结果 + */ + public static CommonResult forbidden(T data) { + return new CommonResult(ResultCode.FORBIDDEN.getCode(), ResultCode.FORBIDDEN.getMessage(), data); + } + + public long getCode() { + return code; + } + + public void setCode(long code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } +} diff --git a/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/common/api/IErrorCode.java b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/common/api/IErrorCode.java new file mode 100644 index 00000000..cfdf47ed --- /dev/null +++ b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/common/api/IErrorCode.java @@ -0,0 +1,11 @@ +package com.macro.mall.tiny.common.api; + +/** + * 封装API的错误码 + * Created by macro on 2019/4/19. + */ +public interface IErrorCode { + long getCode(); + + String getMessage(); +} diff --git a/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/common/api/ResultCode.java b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/common/api/ResultCode.java new file mode 100644 index 00000000..2e9368dd --- /dev/null +++ b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/common/api/ResultCode.java @@ -0,0 +1,28 @@ +package com.macro.mall.tiny.common.api; + +/** + * 枚举了一些常用API操作码 + * Created by macro on 2019/4/19. + */ +public enum ResultCode implements IErrorCode { + SUCCESS(200, "操作成功"), + FAILED(500, "操作失败"), + VALIDATE_FAILED(404, "参数检验失败"), + UNAUTHORIZED(401, "暂未登录或token已经过期"), + FORBIDDEN(403, "没有相关权限"); + private long code; + private String message; + + private ResultCode(long code, String message) { + this.code = code; + this.message = message; + } + + public long getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/config/MyBatisConfig.java b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/config/MyBatisConfig.java new file mode 100644 index 00000000..e680ce8a --- /dev/null +++ b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/config/MyBatisConfig.java @@ -0,0 +1,13 @@ +package com.macro.mall.tiny.config; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.context.annotation.Configuration; + +/** + * MyBatis配置类 + * Created by macro on 2019/4/8. + */ +@Configuration +@MapperScan("com.macro.mall.tiny.mbg.mapper") +public class MyBatisConfig { +} diff --git a/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/config/Swagger2Config.java b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/config/Swagger2Config.java new file mode 100644 index 00000000..f47bcaf6 --- /dev/null +++ b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/config/Swagger2Config.java @@ -0,0 +1,43 @@ +package com.macro.mall.tiny.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +/** + * Swagger2API文档的配置 + */ +@Configuration +@EnableSwagger2 +public class Swagger2Config { + @Bean + public Docket createRestApi(){ + return new Docket(DocumentationType.SWAGGER_2) + .apiInfo(apiInfo()) + .select() + //为当前包下controller生成API文档 + .apis(RequestHandlerSelectors.basePackage("com.macro.mall.tiny.controller")) + //为有@Api注解的Controller生成API文档 +// .apis(RequestHandlerSelectors.withClassAnnotation(Api.class)) + //为有@ApiOperation注解的方法生成API文档 +// .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) + .paths(PathSelectors.any()) + .build(); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("SwaggerUI演示") + .description("mall-tiny") + .contact(new Contact("macro", null, null)) + .version("1.0") + .build(); + } +} diff --git a/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/controller/PmsBrandController.java b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/controller/PmsBrandController.java new file mode 100644 index 00000000..857c9eca --- /dev/null +++ b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/controller/PmsBrandController.java @@ -0,0 +1,103 @@ +package com.macro.mall.tiny.controller; + +import com.macro.mall.tiny.common.api.CommonPage; +import com.macro.mall.tiny.common.api.CommonResult; +import com.macro.mall.tiny.mbg.model.PmsBrand; +import com.macro.mall.tiny.service.PmsBrandService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + + +/** + * 品牌管理Controller + * Created by macro on 2019/4/19. + */ +@Api(tags = "PmsBrandController", description = "商品品牌管理") +@Controller +@RequestMapping("/brand") +public class PmsBrandController { + @Autowired + private PmsBrandService brandService; + + private static final Logger LOGGER = LoggerFactory.getLogger(PmsBrandController.class); + + @ApiOperation("获取所有品牌列表") + @RequestMapping(value = "listAll", method = RequestMethod.GET) + @ResponseBody + public CommonResult> getBrandList() { + return CommonResult.success(brandService.listAllBrand()); + } + + @ApiOperation("添加品牌") + @RequestMapping(value = "/create", method = RequestMethod.POST) + @ResponseBody + public CommonResult createBrand(@RequestBody PmsBrand pmsBrand) { + CommonResult commonResult; + int count = brandService.createBrand(pmsBrand); + if (count == 1) { + commonResult = CommonResult.success(pmsBrand); + LOGGER.debug("createBrand success:{}", pmsBrand); + } else { + commonResult = CommonResult.failed("操作失败"); + LOGGER.debug("createBrand failed:{}", pmsBrand); + } + return commonResult; + } + + @ApiOperation("更新指定id品牌信息") + @RequestMapping(value = "/update/{id}", method = RequestMethod.POST) + @ResponseBody + public CommonResult updateBrand(@PathVariable("id") Long id, @RequestBody PmsBrand pmsBrandDto, BindingResult result) { + CommonResult commonResult; + int count = brandService.updateBrand(id, pmsBrandDto); + if (count == 1) { + commonResult = CommonResult.success(pmsBrandDto); + LOGGER.debug("updateBrand success:{}", pmsBrandDto); + } else { + commonResult = CommonResult.failed("操作失败"); + LOGGER.debug("updateBrand failed:{}", pmsBrandDto); + } + return commonResult; + } + + @ApiOperation("删除指定id的品牌") + @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET) + @ResponseBody + public CommonResult deleteBrand(@PathVariable("id") Long id) { + int count = brandService.deleteBrand(id); + if (count == 1) { + LOGGER.debug("deleteBrand success :id={}", id); + return CommonResult.success(null); + } else { + LOGGER.debug("deleteBrand failed :id={}", id); + return CommonResult.failed("操作失败"); + } + } + + @ApiOperation("分页查询品牌列表") + @RequestMapping(value = "/list", method = RequestMethod.GET) + @ResponseBody + public CommonResult> listBrand(@RequestParam(value = "pageNum", defaultValue = "1") + @ApiParam("页码") Integer pageNum, + @RequestParam(value = "pageSize", defaultValue = "3") + @ApiParam("每页数量") Integer pageSize) { + List brandList = brandService.listBrand(pageNum, pageSize); + return CommonResult.success(CommonPage.restPage(brandList)); + } + + @ApiOperation("获取指定id的品牌详情") + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ResponseBody + public CommonResult brand(@PathVariable("id") Long id) { + return CommonResult.success(brandService.getBrand(id)); + } +} diff --git a/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/mbg/CommentGenerator.java b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/mbg/CommentGenerator.java new file mode 100644 index 00000000..162458af --- /dev/null +++ b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/mbg/CommentGenerator.java @@ -0,0 +1,73 @@ +package com.macro.mall.tiny.mbg; + +import org.mybatis.generator.api.IntrospectedColumn; +import org.mybatis.generator.api.IntrospectedTable; +import org.mybatis.generator.api.dom.java.CompilationUnit; +import org.mybatis.generator.api.dom.java.Field; +import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType; +import org.mybatis.generator.internal.DefaultCommentGenerator; +import org.mybatis.generator.internal.util.StringUtility; + +import java.util.Properties; + +/** + * 自定义注释生成器 + * Created by macro on 2018/4/26. + */ +public class CommentGenerator extends DefaultCommentGenerator { + private boolean addRemarkComments = false; + private static final String EXAMPLE_SUFFIX="Example"; + private static final String API_MODEL_PROPERTY_FULL_CLASS_NAME="io.swagger.annotations.ApiModelProperty"; + + /** + * 设置用户配置的参数 + */ + @Override + public void addConfigurationProperties(Properties properties) { + super.addConfigurationProperties(properties); + this.addRemarkComments = StringUtility.isTrue(properties.getProperty("addRemarkComments")); + } + + /** + * 给字段添加注释 + */ + @Override + public void addFieldComment(Field field, IntrospectedTable introspectedTable, + IntrospectedColumn introspectedColumn) { + String remarks = introspectedColumn.getRemarks(); + //根据参数和备注信息判断是否添加备注信息 + if(addRemarkComments&&StringUtility.stringHasValue(remarks)){ +// addFieldJavaDoc(field, remarks); + //数据库中特殊字符需要转义 + if(remarks.contains("\"")){ + remarks = remarks.replace("\"","'"); + } + //给model的字段添加swagger注解 + field.addJavaDocLine("@ApiModelProperty(value = \""+remarks+"\")"); + } + } + + /** + * 给model的字段添加注释 + */ + private void addFieldJavaDoc(Field field, String remarks) { + //文档注释开始 + field.addJavaDocLine("/**"); + //获取数据库字段的备注信息 + String[] remarkLines = remarks.split(System.getProperty("line.separator")); + for(String remarkLine:remarkLines){ + field.addJavaDocLine(" * "+remarkLine); + } + addJavadocTag(field, false); + field.addJavaDocLine(" */"); + } + + @Override + public void addJavaFileComment(CompilationUnit compilationUnit) { + super.addJavaFileComment(compilationUnit); + //只在model中添加swagger注解类的导入 + if(!compilationUnit.isJavaInterface()&&!compilationUnit.getType().getFullyQualifiedName().contains(EXAMPLE_SUFFIX)){ + compilationUnit.addImportedType(new FullyQualifiedJavaType(API_MODEL_PROPERTY_FULL_CLASS_NAME)); + } + } +} diff --git a/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/mbg/Generator.java b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/mbg/Generator.java new file mode 100644 index 00000000..f7851362 --- /dev/null +++ b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/mbg/Generator.java @@ -0,0 +1,38 @@ +package com.macro.mall.tiny.mbg; + +import org.mybatis.generator.api.MyBatisGenerator; +import org.mybatis.generator.config.Configuration; +import org.mybatis.generator.config.xml.ConfigurationParser; +import org.mybatis.generator.internal.DefaultShellCallback; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +/** + * 用于生产MBG的代码 + * Created by macro on 2018/4/26. + */ +public class Generator { + public static void main(String[] args) throws Exception { + //MBG 执行过程中的警告信息 + List warnings = new ArrayList(); + //当生成的代码重复时,覆盖原代码 + boolean overwrite = true; + //读取我们的 MBG 配置文件 + InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml"); + ConfigurationParser cp = new ConfigurationParser(warnings); + Configuration config = cp.parseConfiguration(is); + is.close(); + + DefaultShellCallback callback = new DefaultShellCallback(overwrite); + //创建 MBG + MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings); + //执行生成代码 + myBatisGenerator.generate(null); + //输出警告信息 + for (String warning : warnings) { + System.out.println(warning); + } + } +} diff --git a/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/mbg/mapper/PmsBrandMapper.java b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/mbg/mapper/PmsBrandMapper.java new file mode 100644 index 00000000..617584fb --- /dev/null +++ b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/mbg/mapper/PmsBrandMapper.java @@ -0,0 +1,36 @@ +package com.macro.mall.tiny.mbg.mapper; + +import com.macro.mall.tiny.mbg.model.PmsBrand; +import com.macro.mall.tiny.mbg.model.PmsBrandExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface PmsBrandMapper { + int countByExample(PmsBrandExample example); + + int deleteByExample(PmsBrandExample example); + + int deleteByPrimaryKey(Long id); + + int insert(PmsBrand record); + + int insertSelective(PmsBrand record); + + List selectByExampleWithBLOBs(PmsBrandExample example); + + List selectByExample(PmsBrandExample example); + + PmsBrand selectByPrimaryKey(Long id); + + int updateByExampleSelective(@Param("record") PmsBrand record, @Param("example") PmsBrandExample example); + + int updateByExampleWithBLOBs(@Param("record") PmsBrand record, @Param("example") PmsBrandExample example); + + int updateByExample(@Param("record") PmsBrand record, @Param("example") PmsBrandExample example); + + int updateByPrimaryKeySelective(PmsBrand record); + + int updateByPrimaryKeyWithBLOBs(PmsBrand record); + + int updateByPrimaryKey(PmsBrand record); +} \ No newline at end of file diff --git a/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/mbg/model/PmsBrand.java b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/mbg/model/PmsBrand.java new file mode 100644 index 00000000..0d5dde95 --- /dev/null +++ b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/mbg/model/PmsBrand.java @@ -0,0 +1,147 @@ +package com.macro.mall.tiny.mbg.model; + +import io.swagger.annotations.ApiModelProperty; +import java.io.Serializable; + +public class PmsBrand implements Serializable { + private Long id; + + private String name; + + @ApiModelProperty(value = "首字母") + private String firstLetter; + + private Integer sort; + + @ApiModelProperty(value = "是否为品牌制造商:0->不是;1->是") + private Integer factoryStatus; + + private Integer showStatus; + + @ApiModelProperty(value = "产品数量") + private Integer productCount; + + @ApiModelProperty(value = "产品评论数量") + private Integer productCommentCount; + + @ApiModelProperty(value = "品牌logo") + private String logo; + + @ApiModelProperty(value = "专区大图") + private String bigPic; + + @ApiModelProperty(value = "品牌故事") + private String brandStory; + + private static final long serialVersionUID = 1L; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getFirstLetter() { + return firstLetter; + } + + public void setFirstLetter(String firstLetter) { + this.firstLetter = firstLetter; + } + + public Integer getSort() { + return sort; + } + + public void setSort(Integer sort) { + this.sort = sort; + } + + public Integer getFactoryStatus() { + return factoryStatus; + } + + public void setFactoryStatus(Integer factoryStatus) { + this.factoryStatus = factoryStatus; + } + + public Integer getShowStatus() { + return showStatus; + } + + public void setShowStatus(Integer showStatus) { + this.showStatus = showStatus; + } + + public Integer getProductCount() { + return productCount; + } + + public void setProductCount(Integer productCount) { + this.productCount = productCount; + } + + public Integer getProductCommentCount() { + return productCommentCount; + } + + public void setProductCommentCount(Integer productCommentCount) { + this.productCommentCount = productCommentCount; + } + + public String getLogo() { + return logo; + } + + public void setLogo(String logo) { + this.logo = logo; + } + + public String getBigPic() { + return bigPic; + } + + public void setBigPic(String bigPic) { + this.bigPic = bigPic; + } + + public String getBrandStory() { + return brandStory; + } + + public void setBrandStory(String brandStory) { + this.brandStory = brandStory; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", name=").append(name); + sb.append(", firstLetter=").append(firstLetter); + sb.append(", sort=").append(sort); + sb.append(", factoryStatus=").append(factoryStatus); + sb.append(", showStatus=").append(showStatus); + sb.append(", productCount=").append(productCount); + sb.append(", productCommentCount=").append(productCommentCount); + sb.append(", logo=").append(logo); + sb.append(", bigPic=").append(bigPic); + sb.append(", brandStory=").append(brandStory); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/mbg/model/PmsBrandExample.java b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/mbg/model/PmsBrandExample.java new file mode 100644 index 00000000..4e4a1108 --- /dev/null +++ b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/mbg/model/PmsBrandExample.java @@ -0,0 +1,840 @@ +package com.macro.mall.tiny.mbg.model; + +import java.util.ArrayList; +import java.util.List; + +public class PmsBrandExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public PmsBrandExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andNameIsNull() { + addCriterion("name is null"); + return (Criteria) this; + } + + public Criteria andNameIsNotNull() { + addCriterion("name is not null"); + return (Criteria) this; + } + + public Criteria andNameEqualTo(String value) { + addCriterion("name =", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotEqualTo(String value) { + addCriterion("name <>", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThan(String value) { + addCriterion("name >", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThanOrEqualTo(String value) { + addCriterion("name >=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThan(String value) { + addCriterion("name <", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThanOrEqualTo(String value) { + addCriterion("name <=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLike(String value) { + addCriterion("name like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotLike(String value) { + addCriterion("name not like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameIn(List values) { + addCriterion("name in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameNotIn(List values) { + addCriterion("name not in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameBetween(String value1, String value2) { + addCriterion("name between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andNameNotBetween(String value1, String value2) { + addCriterion("name not between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andFirstLetterIsNull() { + addCriterion("first_letter is null"); + return (Criteria) this; + } + + public Criteria andFirstLetterIsNotNull() { + addCriterion("first_letter is not null"); + return (Criteria) this; + } + + public Criteria andFirstLetterEqualTo(String value) { + addCriterion("first_letter =", value, "firstLetter"); + return (Criteria) this; + } + + public Criteria andFirstLetterNotEqualTo(String value) { + addCriterion("first_letter <>", value, "firstLetter"); + return (Criteria) this; + } + + public Criteria andFirstLetterGreaterThan(String value) { + addCriterion("first_letter >", value, "firstLetter"); + return (Criteria) this; + } + + public Criteria andFirstLetterGreaterThanOrEqualTo(String value) { + addCriterion("first_letter >=", value, "firstLetter"); + return (Criteria) this; + } + + public Criteria andFirstLetterLessThan(String value) { + addCriterion("first_letter <", value, "firstLetter"); + return (Criteria) this; + } + + public Criteria andFirstLetterLessThanOrEqualTo(String value) { + addCriterion("first_letter <=", value, "firstLetter"); + return (Criteria) this; + } + + public Criteria andFirstLetterLike(String value) { + addCriterion("first_letter like", value, "firstLetter"); + return (Criteria) this; + } + + public Criteria andFirstLetterNotLike(String value) { + addCriterion("first_letter not like", value, "firstLetter"); + return (Criteria) this; + } + + public Criteria andFirstLetterIn(List values) { + addCriterion("first_letter in", values, "firstLetter"); + return (Criteria) this; + } + + public Criteria andFirstLetterNotIn(List values) { + addCriterion("first_letter not in", values, "firstLetter"); + return (Criteria) this; + } + + public Criteria andFirstLetterBetween(String value1, String value2) { + addCriterion("first_letter between", value1, value2, "firstLetter"); + return (Criteria) this; + } + + public Criteria andFirstLetterNotBetween(String value1, String value2) { + addCriterion("first_letter not between", value1, value2, "firstLetter"); + return (Criteria) this; + } + + public Criteria andSortIsNull() { + addCriterion("sort is null"); + return (Criteria) this; + } + + public Criteria andSortIsNotNull() { + addCriterion("sort is not null"); + return (Criteria) this; + } + + public Criteria andSortEqualTo(Integer value) { + addCriterion("sort =", value, "sort"); + return (Criteria) this; + } + + public Criteria andSortNotEqualTo(Integer value) { + addCriterion("sort <>", value, "sort"); + return (Criteria) this; + } + + public Criteria andSortGreaterThan(Integer value) { + addCriterion("sort >", value, "sort"); + return (Criteria) this; + } + + public Criteria andSortGreaterThanOrEqualTo(Integer value) { + addCriterion("sort >=", value, "sort"); + return (Criteria) this; + } + + public Criteria andSortLessThan(Integer value) { + addCriterion("sort <", value, "sort"); + return (Criteria) this; + } + + public Criteria andSortLessThanOrEqualTo(Integer value) { + addCriterion("sort <=", value, "sort"); + return (Criteria) this; + } + + public Criteria andSortIn(List values) { + addCriterion("sort in", values, "sort"); + return (Criteria) this; + } + + public Criteria andSortNotIn(List values) { + addCriterion("sort not in", values, "sort"); + return (Criteria) this; + } + + public Criteria andSortBetween(Integer value1, Integer value2) { + addCriterion("sort between", value1, value2, "sort"); + return (Criteria) this; + } + + public Criteria andSortNotBetween(Integer value1, Integer value2) { + addCriterion("sort not between", value1, value2, "sort"); + return (Criteria) this; + } + + public Criteria andFactoryStatusIsNull() { + addCriterion("factory_status is null"); + return (Criteria) this; + } + + public Criteria andFactoryStatusIsNotNull() { + addCriterion("factory_status is not null"); + return (Criteria) this; + } + + public Criteria andFactoryStatusEqualTo(Integer value) { + addCriterion("factory_status =", value, "factoryStatus"); + return (Criteria) this; + } + + public Criteria andFactoryStatusNotEqualTo(Integer value) { + addCriterion("factory_status <>", value, "factoryStatus"); + return (Criteria) this; + } + + public Criteria andFactoryStatusGreaterThan(Integer value) { + addCriterion("factory_status >", value, "factoryStatus"); + return (Criteria) this; + } + + public Criteria andFactoryStatusGreaterThanOrEqualTo(Integer value) { + addCriterion("factory_status >=", value, "factoryStatus"); + return (Criteria) this; + } + + public Criteria andFactoryStatusLessThan(Integer value) { + addCriterion("factory_status <", value, "factoryStatus"); + return (Criteria) this; + } + + public Criteria andFactoryStatusLessThanOrEqualTo(Integer value) { + addCriterion("factory_status <=", value, "factoryStatus"); + return (Criteria) this; + } + + public Criteria andFactoryStatusIn(List values) { + addCriterion("factory_status in", values, "factoryStatus"); + return (Criteria) this; + } + + public Criteria andFactoryStatusNotIn(List values) { + addCriterion("factory_status not in", values, "factoryStatus"); + return (Criteria) this; + } + + public Criteria andFactoryStatusBetween(Integer value1, Integer value2) { + addCriterion("factory_status between", value1, value2, "factoryStatus"); + return (Criteria) this; + } + + public Criteria andFactoryStatusNotBetween(Integer value1, Integer value2) { + addCriterion("factory_status not between", value1, value2, "factoryStatus"); + return (Criteria) this; + } + + public Criteria andShowStatusIsNull() { + addCriterion("show_status is null"); + return (Criteria) this; + } + + public Criteria andShowStatusIsNotNull() { + addCriterion("show_status is not null"); + return (Criteria) this; + } + + public Criteria andShowStatusEqualTo(Integer value) { + addCriterion("show_status =", value, "showStatus"); + return (Criteria) this; + } + + public Criteria andShowStatusNotEqualTo(Integer value) { + addCriterion("show_status <>", value, "showStatus"); + return (Criteria) this; + } + + public Criteria andShowStatusGreaterThan(Integer value) { + addCriterion("show_status >", value, "showStatus"); + return (Criteria) this; + } + + public Criteria andShowStatusGreaterThanOrEqualTo(Integer value) { + addCriterion("show_status >=", value, "showStatus"); + return (Criteria) this; + } + + public Criteria andShowStatusLessThan(Integer value) { + addCriterion("show_status <", value, "showStatus"); + return (Criteria) this; + } + + public Criteria andShowStatusLessThanOrEqualTo(Integer value) { + addCriterion("show_status <=", value, "showStatus"); + return (Criteria) this; + } + + public Criteria andShowStatusIn(List values) { + addCriterion("show_status in", values, "showStatus"); + return (Criteria) this; + } + + public Criteria andShowStatusNotIn(List values) { + addCriterion("show_status not in", values, "showStatus"); + return (Criteria) this; + } + + public Criteria andShowStatusBetween(Integer value1, Integer value2) { + addCriterion("show_status between", value1, value2, "showStatus"); + return (Criteria) this; + } + + public Criteria andShowStatusNotBetween(Integer value1, Integer value2) { + addCriterion("show_status not between", value1, value2, "showStatus"); + return (Criteria) this; + } + + public Criteria andProductCountIsNull() { + addCriterion("product_count is null"); + return (Criteria) this; + } + + public Criteria andProductCountIsNotNull() { + addCriterion("product_count is not null"); + return (Criteria) this; + } + + public Criteria andProductCountEqualTo(Integer value) { + addCriterion("product_count =", value, "productCount"); + return (Criteria) this; + } + + public Criteria andProductCountNotEqualTo(Integer value) { + addCriterion("product_count <>", value, "productCount"); + return (Criteria) this; + } + + public Criteria andProductCountGreaterThan(Integer value) { + addCriterion("product_count >", value, "productCount"); + return (Criteria) this; + } + + public Criteria andProductCountGreaterThanOrEqualTo(Integer value) { + addCriterion("product_count >=", value, "productCount"); + return (Criteria) this; + } + + public Criteria andProductCountLessThan(Integer value) { + addCriterion("product_count <", value, "productCount"); + return (Criteria) this; + } + + public Criteria andProductCountLessThanOrEqualTo(Integer value) { + addCriterion("product_count <=", value, "productCount"); + return (Criteria) this; + } + + public Criteria andProductCountIn(List values) { + addCriterion("product_count in", values, "productCount"); + return (Criteria) this; + } + + public Criteria andProductCountNotIn(List values) { + addCriterion("product_count not in", values, "productCount"); + return (Criteria) this; + } + + public Criteria andProductCountBetween(Integer value1, Integer value2) { + addCriterion("product_count between", value1, value2, "productCount"); + return (Criteria) this; + } + + public Criteria andProductCountNotBetween(Integer value1, Integer value2) { + addCriterion("product_count not between", value1, value2, "productCount"); + return (Criteria) this; + } + + public Criteria andProductCommentCountIsNull() { + addCriterion("product_comment_count is null"); + return (Criteria) this; + } + + public Criteria andProductCommentCountIsNotNull() { + addCriterion("product_comment_count is not null"); + return (Criteria) this; + } + + public Criteria andProductCommentCountEqualTo(Integer value) { + addCriterion("product_comment_count =", value, "productCommentCount"); + return (Criteria) this; + } + + public Criteria andProductCommentCountNotEqualTo(Integer value) { + addCriterion("product_comment_count <>", value, "productCommentCount"); + return (Criteria) this; + } + + public Criteria andProductCommentCountGreaterThan(Integer value) { + addCriterion("product_comment_count >", value, "productCommentCount"); + return (Criteria) this; + } + + public Criteria andProductCommentCountGreaterThanOrEqualTo(Integer value) { + addCriterion("product_comment_count >=", value, "productCommentCount"); + return (Criteria) this; + } + + public Criteria andProductCommentCountLessThan(Integer value) { + addCriterion("product_comment_count <", value, "productCommentCount"); + return (Criteria) this; + } + + public Criteria andProductCommentCountLessThanOrEqualTo(Integer value) { + addCriterion("product_comment_count <=", value, "productCommentCount"); + return (Criteria) this; + } + + public Criteria andProductCommentCountIn(List values) { + addCriterion("product_comment_count in", values, "productCommentCount"); + return (Criteria) this; + } + + public Criteria andProductCommentCountNotIn(List values) { + addCriterion("product_comment_count not in", values, "productCommentCount"); + return (Criteria) this; + } + + public Criteria andProductCommentCountBetween(Integer value1, Integer value2) { + addCriterion("product_comment_count between", value1, value2, "productCommentCount"); + return (Criteria) this; + } + + public Criteria andProductCommentCountNotBetween(Integer value1, Integer value2) { + addCriterion("product_comment_count not between", value1, value2, "productCommentCount"); + return (Criteria) this; + } + + public Criteria andLogoIsNull() { + addCriterion("logo is null"); + return (Criteria) this; + } + + public Criteria andLogoIsNotNull() { + addCriterion("logo is not null"); + return (Criteria) this; + } + + public Criteria andLogoEqualTo(String value) { + addCriterion("logo =", value, "logo"); + return (Criteria) this; + } + + public Criteria andLogoNotEqualTo(String value) { + addCriterion("logo <>", value, "logo"); + return (Criteria) this; + } + + public Criteria andLogoGreaterThan(String value) { + addCriterion("logo >", value, "logo"); + return (Criteria) this; + } + + public Criteria andLogoGreaterThanOrEqualTo(String value) { + addCriterion("logo >=", value, "logo"); + return (Criteria) this; + } + + public Criteria andLogoLessThan(String value) { + addCriterion("logo <", value, "logo"); + return (Criteria) this; + } + + public Criteria andLogoLessThanOrEqualTo(String value) { + addCriterion("logo <=", value, "logo"); + return (Criteria) this; + } + + public Criteria andLogoLike(String value) { + addCriterion("logo like", value, "logo"); + return (Criteria) this; + } + + public Criteria andLogoNotLike(String value) { + addCriterion("logo not like", value, "logo"); + return (Criteria) this; + } + + public Criteria andLogoIn(List values) { + addCriterion("logo in", values, "logo"); + return (Criteria) this; + } + + public Criteria andLogoNotIn(List values) { + addCriterion("logo not in", values, "logo"); + return (Criteria) this; + } + + public Criteria andLogoBetween(String value1, String value2) { + addCriterion("logo between", value1, value2, "logo"); + return (Criteria) this; + } + + public Criteria andLogoNotBetween(String value1, String value2) { + addCriterion("logo not between", value1, value2, "logo"); + return (Criteria) this; + } + + public Criteria andBigPicIsNull() { + addCriterion("big_pic is null"); + return (Criteria) this; + } + + public Criteria andBigPicIsNotNull() { + addCriterion("big_pic is not null"); + return (Criteria) this; + } + + public Criteria andBigPicEqualTo(String value) { + addCriterion("big_pic =", value, "bigPic"); + return (Criteria) this; + } + + public Criteria andBigPicNotEqualTo(String value) { + addCriterion("big_pic <>", value, "bigPic"); + return (Criteria) this; + } + + public Criteria andBigPicGreaterThan(String value) { + addCriterion("big_pic >", value, "bigPic"); + return (Criteria) this; + } + + public Criteria andBigPicGreaterThanOrEqualTo(String value) { + addCriterion("big_pic >=", value, "bigPic"); + return (Criteria) this; + } + + public Criteria andBigPicLessThan(String value) { + addCriterion("big_pic <", value, "bigPic"); + return (Criteria) this; + } + + public Criteria andBigPicLessThanOrEqualTo(String value) { + addCriterion("big_pic <=", value, "bigPic"); + return (Criteria) this; + } + + public Criteria andBigPicLike(String value) { + addCriterion("big_pic like", value, "bigPic"); + return (Criteria) this; + } + + public Criteria andBigPicNotLike(String value) { + addCriterion("big_pic not like", value, "bigPic"); + return (Criteria) this; + } + + public Criteria andBigPicIn(List values) { + addCriterion("big_pic in", values, "bigPic"); + return (Criteria) this; + } + + public Criteria andBigPicNotIn(List values) { + addCriterion("big_pic not in", values, "bigPic"); + return (Criteria) this; + } + + public Criteria andBigPicBetween(String value1, String value2) { + addCriterion("big_pic between", value1, value2, "bigPic"); + return (Criteria) this; + } + + public Criteria andBigPicNotBetween(String value1, String value2) { + addCriterion("big_pic not between", value1, value2, "bigPic"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/service/PmsBrandService.java b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/service/PmsBrandService.java new file mode 100644 index 00000000..7171412b --- /dev/null +++ b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/service/PmsBrandService.java @@ -0,0 +1,24 @@ +package com.macro.mall.tiny.service; + + +import com.macro.mall.tiny.mbg.model.PmsBrand; + +import java.util.List; + +/** + * PmsBrandService + * Created by macro on 2019/4/19. + */ +public interface PmsBrandService { + List listAllBrand(); + + int createBrand(PmsBrand brand); + + int updateBrand(Long id, PmsBrand brand); + + int deleteBrand(Long id); + + List listBrand(int pageNum, int pageSize); + + PmsBrand getBrand(Long id); +} diff --git a/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/service/impl/PmsBrandServiceImpl.java b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/service/impl/PmsBrandServiceImpl.java new file mode 100644 index 00000000..2a2b102e --- /dev/null +++ b/mall-tiny-keycloak/src/main/java/com/macro/mall/tiny/service/impl/PmsBrandServiceImpl.java @@ -0,0 +1,53 @@ +package com.macro.mall.tiny.service.impl; + +import com.github.pagehelper.PageHelper; +import com.macro.mall.tiny.mbg.mapper.PmsBrandMapper; +import com.macro.mall.tiny.mbg.model.PmsBrand; +import com.macro.mall.tiny.mbg.model.PmsBrandExample; +import com.macro.mall.tiny.service.PmsBrandService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * PmsBrandService实现类 + * Created by macro on 2019/4/19. + */ +@Service +public class PmsBrandServiceImpl implements PmsBrandService { + @Autowired + private PmsBrandMapper brandMapper; + + @Override + public List listAllBrand() { + return brandMapper.selectByExample(new PmsBrandExample()); + } + + @Override + public int createBrand(PmsBrand brand) { + return brandMapper.insertSelective(brand); + } + + @Override + public int updateBrand(Long id, PmsBrand brand) { + brand.setId(id); + return brandMapper.updateByPrimaryKeySelective(brand); + } + + @Override + public int deleteBrand(Long id) { + return brandMapper.deleteByPrimaryKey(id); + } + + @Override + public List listBrand(int pageNum, int pageSize) { + PageHelper.startPage(pageNum, pageSize); + return brandMapper.selectByExample(new PmsBrandExample()); + } + + @Override + public PmsBrand getBrand(Long id) { + return brandMapper.selectByPrimaryKey(id); + } +} diff --git a/mall-tiny-keycloak/src/main/resources/application.yml b/mall-tiny-keycloak/src/main/resources/application.yml new file mode 100644 index 00000000..a03fcd65 --- /dev/null +++ b/mall-tiny-keycloak/src/main/resources/application.yml @@ -0,0 +1,37 @@ +server: + port: 8088 + +spring: + datasource: + url: jdbc:mysql://localhost:3306/mall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai + username: root + password: root + +mybatis: + mapper-locations: + - classpath:mapper/*.xml + - classpath*:com/**/mapper/*.xml + +springfox: + documentation: + enabled: true + +# Keycloak相关配置 +keycloak: + # 设置客户端所在领域 + realm: macrozheng + # 设置Keycloak认证服务访问路径 + auth-server-url: http://192.168.7.142:8080/auth + # 设置客户端ID + resource: mall-tiny-keycloak + # 设置为公开客户端,不需要秘钥即可访问 + public-client: true + # 配置角色与可访问路径的对应关系 + security-constraints: + - auth-roles: + - mall-tiny + security-collections: + - patterns: + - '/brand/*' + - '/swagger-ui/*' + diff --git a/mall-tiny-keycloak/src/main/resources/com/macro/mall/tiny/mbg/mapper/PmsBrandMapper.xml b/mall-tiny-keycloak/src/main/resources/com/macro/mall/tiny/mbg/mapper/PmsBrandMapper.xml new file mode 100644 index 00000000..1842e269 --- /dev/null +++ b/mall-tiny-keycloak/src/main/resources/com/macro/mall/tiny/mbg/mapper/PmsBrandMapper.xml @@ -0,0 +1,358 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, name, first_letter, sort, factory_status, show_status, product_count, product_comment_count, + logo, big_pic + + + brand_story + + + + + + delete from pms_brand + where id = #{id,jdbcType=BIGINT} + + + delete from pms_brand + + + + + + + SELECT LAST_INSERT_ID() + + insert into pms_brand (name, first_letter, sort, + factory_status, show_status, product_count, + product_comment_count, logo, big_pic, + brand_story) + values (#{name,jdbcType=VARCHAR}, #{firstLetter,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER}, + #{factoryStatus,jdbcType=INTEGER}, #{showStatus,jdbcType=INTEGER}, #{productCount,jdbcType=INTEGER}, + #{productCommentCount,jdbcType=INTEGER}, #{logo,jdbcType=VARCHAR}, #{bigPic,jdbcType=VARCHAR}, + #{brandStory,jdbcType=LONGVARCHAR}) + + + + SELECT LAST_INSERT_ID() + + insert into pms_brand + + + name, + + + first_letter, + + + sort, + + + factory_status, + + + show_status, + + + product_count, + + + product_comment_count, + + + logo, + + + big_pic, + + + brand_story, + + + + + #{name,jdbcType=VARCHAR}, + + + #{firstLetter,jdbcType=VARCHAR}, + + + #{sort,jdbcType=INTEGER}, + + + #{factoryStatus,jdbcType=INTEGER}, + + + #{showStatus,jdbcType=INTEGER}, + + + #{productCount,jdbcType=INTEGER}, + + + #{productCommentCount,jdbcType=INTEGER}, + + + #{logo,jdbcType=VARCHAR}, + + + #{bigPic,jdbcType=VARCHAR}, + + + #{brandStory,jdbcType=LONGVARCHAR}, + + + + + + update pms_brand + + + id = #{record.id,jdbcType=BIGINT}, + + + name = #{record.name,jdbcType=VARCHAR}, + + + first_letter = #{record.firstLetter,jdbcType=VARCHAR}, + + + sort = #{record.sort,jdbcType=INTEGER}, + + + factory_status = #{record.factoryStatus,jdbcType=INTEGER}, + + + show_status = #{record.showStatus,jdbcType=INTEGER}, + + + product_count = #{record.productCount,jdbcType=INTEGER}, + + + product_comment_count = #{record.productCommentCount,jdbcType=INTEGER}, + + + logo = #{record.logo,jdbcType=VARCHAR}, + + + big_pic = #{record.bigPic,jdbcType=VARCHAR}, + + + brand_story = #{record.brandStory,jdbcType=LONGVARCHAR}, + + + + + + + + update pms_brand + set id = #{record.id,jdbcType=BIGINT}, + name = #{record.name,jdbcType=VARCHAR}, + first_letter = #{record.firstLetter,jdbcType=VARCHAR}, + sort = #{record.sort,jdbcType=INTEGER}, + factory_status = #{record.factoryStatus,jdbcType=INTEGER}, + show_status = #{record.showStatus,jdbcType=INTEGER}, + product_count = #{record.productCount,jdbcType=INTEGER}, + product_comment_count = #{record.productCommentCount,jdbcType=INTEGER}, + logo = #{record.logo,jdbcType=VARCHAR}, + big_pic = #{record.bigPic,jdbcType=VARCHAR}, + brand_story = #{record.brandStory,jdbcType=LONGVARCHAR} + + + + + + update pms_brand + set id = #{record.id,jdbcType=BIGINT}, + name = #{record.name,jdbcType=VARCHAR}, + first_letter = #{record.firstLetter,jdbcType=VARCHAR}, + sort = #{record.sort,jdbcType=INTEGER}, + factory_status = #{record.factoryStatus,jdbcType=INTEGER}, + show_status = #{record.showStatus,jdbcType=INTEGER}, + product_count = #{record.productCount,jdbcType=INTEGER}, + product_comment_count = #{record.productCommentCount,jdbcType=INTEGER}, + logo = #{record.logo,jdbcType=VARCHAR}, + big_pic = #{record.bigPic,jdbcType=VARCHAR} + + + + + + update pms_brand + + + name = #{name,jdbcType=VARCHAR}, + + + first_letter = #{firstLetter,jdbcType=VARCHAR}, + + + sort = #{sort,jdbcType=INTEGER}, + + + factory_status = #{factoryStatus,jdbcType=INTEGER}, + + + show_status = #{showStatus,jdbcType=INTEGER}, + + + product_count = #{productCount,jdbcType=INTEGER}, + + + product_comment_count = #{productCommentCount,jdbcType=INTEGER}, + + + logo = #{logo,jdbcType=VARCHAR}, + + + big_pic = #{bigPic,jdbcType=VARCHAR}, + + + brand_story = #{brandStory,jdbcType=LONGVARCHAR}, + + + where id = #{id,jdbcType=BIGINT} + + + update pms_brand + set name = #{name,jdbcType=VARCHAR}, + first_letter = #{firstLetter,jdbcType=VARCHAR}, + sort = #{sort,jdbcType=INTEGER}, + factory_status = #{factoryStatus,jdbcType=INTEGER}, + show_status = #{showStatus,jdbcType=INTEGER}, + product_count = #{productCount,jdbcType=INTEGER}, + product_comment_count = #{productCommentCount,jdbcType=INTEGER}, + logo = #{logo,jdbcType=VARCHAR}, + big_pic = #{bigPic,jdbcType=VARCHAR}, + brand_story = #{brandStory,jdbcType=LONGVARCHAR} + where id = #{id,jdbcType=BIGINT} + + + update pms_brand + set name = #{name,jdbcType=VARCHAR}, + first_letter = #{firstLetter,jdbcType=VARCHAR}, + sort = #{sort,jdbcType=INTEGER}, + factory_status = #{factoryStatus,jdbcType=INTEGER}, + show_status = #{showStatus,jdbcType=INTEGER}, + product_count = #{productCount,jdbcType=INTEGER}, + product_comment_count = #{productCommentCount,jdbcType=INTEGER}, + logo = #{logo,jdbcType=VARCHAR}, + big_pic = #{bigPic,jdbcType=VARCHAR} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/mall-tiny-keycloak/src/main/resources/generator.properties b/mall-tiny-keycloak/src/main/resources/generator.properties new file mode 100644 index 00000000..173547bb --- /dev/null +++ b/mall-tiny-keycloak/src/main/resources/generator.properties @@ -0,0 +1,4 @@ +jdbc.driverClass=com.mysql.cj.jdbc.Driver +jdbc.connectionURL=jdbc:mysql://localhost:3306/mall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai +jdbc.userId=root +jdbc.password=root \ No newline at end of file diff --git a/mall-tiny-keycloak/src/main/resources/generatorConfig.xml b/mall-tiny-keycloak/src/main/resources/generatorConfig.xml new file mode 100644 index 00000000..661ed4da --- /dev/null +++ b/mall-tiny-keycloak/src/main/resources/generatorConfig.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
\ No newline at end of file diff --git a/mall-tiny-keycloak/src/test/java/com/macro/mall/tiny/MallTiny01ApplicationTests.java b/mall-tiny-keycloak/src/test/java/com/macro/mall/tiny/MallTiny01ApplicationTests.java new file mode 100644 index 00000000..861094e9 --- /dev/null +++ b/mall-tiny-keycloak/src/test/java/com/macro/mall/tiny/MallTiny01ApplicationTests.java @@ -0,0 +1,16 @@ +package com.macro.mall.tiny; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class MallTiny01ApplicationTests { + + @Test + public void contextLoads() { + } + +} diff --git a/mall-tiny-keycloak/src/test/java/com/macro/mall/tiny/MallTinyApplicationTests.java b/mall-tiny-keycloak/src/test/java/com/macro/mall/tiny/MallTinyApplicationTests.java new file mode 100644 index 00000000..fa6880cf --- /dev/null +++ b/mall-tiny-keycloak/src/test/java/com/macro/mall/tiny/MallTinyApplicationTests.java @@ -0,0 +1,16 @@ +package com.macro.mall.tiny; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class MallTinyApplicationTests { + + @Test + public void contextLoads() { + } + +}