商场项目:https://github.com/macrozheng/mall-tiny
参考:https://macrozheng.github.io/mall-learning/#/architect/mall_arch_01?id=springboot
具体学习:https://macrozheng.github.io/mall-learning/#/architect/mall_arch_01
https://blog.csdn.net/weixin_40753536/article/details/81285046
一、数据库创建表
二、根据表生成文件
使用MyBatisGenerator生成代码
运行com.macro.mall.tiny.mbg.Generator类的main方法来生成代码,生成完后会有以下几个文件。
之后提示文件不存在,如
The specified target project directory mall-tiny\src\main\resources does not exist
The specified target project directory mall-tiny\src\main\java does not exist
The specified target project directory mall-tiny\src\main\java does not exist
The specified target project directory mall-tiny\src\main\java does not exist
配置为:
<!--指定生成model的路径-->
<javaModelGenerator targetPackage="com.macro.mall.tiny.mbg.model" targetProject="mall-tiny\src\main\java"/>
<!--指定生成mapper.xml的路径-->
<sqlMapGenerator targetPackage="com.macro.mall.tiny.mbg.mapper" targetProject="mall-tiny\src\main\resources"/>
<!--指定生成mapper接口的的路径-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.macro.mall.tiny.mbg.mapper"
targetProject="mall-tiny\src\main\java"/>
直接修改为绝对路径即可:
<!--指定生成mapper接口的的路径-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.macro.mall.tiny.mbg.mapper"
targetProject="E:\project\ideaWork\mall-tiny-master\src\main\java"/>
一、技术为:SpringBoot+Mybatis
注解说明:
1、@SpringBootApplication:申明让spring boot自动给程序进行必要的配置
1、PmsBrandController
@Controller:用于定义控制器类,在spring项目中由控制器负责将用户发来的URL请求转发到对应的服务接口
(service层),一般这个注解在类中,通常方法需要配合注解@RequestMapping。
@RequestMapping:提供路由信息,负责URL到Controller中的具体函数的映射。
@ResponseBody:表示该方法的返回结果直接写入HTTP response body中,一般在异步获取数据时使用,用于构建RESTful的api。在使用@RequestMapping后,返回值通常解析为跳转路径,加上@esponsebody后返回结果不会被解析为跳转路径,而是直接写入HTTP response body中。比如异步获取json数据,加上@Responsebody后,会直接返回json数据。该注解一般会配合@RequestMapping一起使用。
@Autowired:自动导入依赖的bean
@Controller
@RequestMapping("/brand")
public class PmsBrandController {
@Autowired
private PmsBrandService demoService;
private static final Logger LOGGER = LoggerFactory.getLogger(PmsBrandController.class);
@RequestMapping(value = "listAll", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<PmsBrand>> getBrandList() {
return CommonResult.success(demoService.listAllBrand());
}
2、PmsBrandServiceImpl
@Autowired:自动导入依赖的bean
@Service:一般用于修饰service层的组件,一般用来修饰 具体的实现类
@Service
public class PmsBrandServiceImpl implements PmsBrandService {
@Autowired
private PmsBrandMapper brandMapper;
3、
@Configuration:相当于传统的xml配置文件,如果有些第三方库需要用到xml文件,建议仍然通过@Configuration类作为项目的配置主类——可以使用@ImportResource注解加载xml配置文件。
@MapperScan("com.demo.mapper"):扫描指定包中的接口
@Configuration
@MapperScan("com.macro.mall.tiny.mbg.mapper")
public class MyBatisConfig {
}
其他:
@Resource(name=”name”,type=”type”):没有括号内内容的话,默认byName。与@Autowired干类似的事。
@RestController:用于标注控制层组件(如struts中的action),@ResponseBody和@Controller的合集。
@EnableAutoConfiguration:SpringBoot自动配置(auto-configuration):尝试根据你添加的jar依赖自动配置你的Spring应用。例如,如果你的classpath下存在HSQLDB,并且你没有手动配置任何数据库连接beans,那么我们将自动配置一个内存型(in-memory)数据库”。你可以将@EnableAutoConfiguration或者@SpringBootApplication注解添加到一个@Configuration类上来选择自动配置。如果发现应用了你不想要的特定自动配置类,你可以使用@EnableAutoConfiguration注解的排除属性来禁用它们。
@ComponentScan:表示将该类自动发现扫描组件。个人理解相当于,如果扫描到有@Component、@Controller、@Service等这些注解的类,并注册为Bean,可以自动收集所有的Spring组件,包括@Configuration类。我们经常使用@ComponentScan注解搜索beans,并结合@Autowired注解导入。可以自动收集所有的Spring组件,包括@Configuration类。我们经常使用@ComponentScan注解搜索beans,并结合@Autowired注解导入。如果没有配置的话,Spring Boot会扫描启动类所在包下以及子包下的使用了@Service,@Repository等注解的类。
@Import:用来导入其他配置类。
@ImportResource:用来加载xml配置文件。
@Autowired:自动导入依赖的bean
@Repository:使用@Repository注解可以确保DAO或者repositories提供异常转译,这个注解修饰的DAO或者repositories类会被ComponetScan发现并配置,同时也不需要为它们提供XML配置项。
@Bean:用@Bean标注方法等价于XML中配置的bean。
@Value:注入Spring boot application.properties配置的属性的值。
@Inject:等价于默认的@Autowired,只是没有required属性;
@Component:泛指组件,当组件不好归类的时候,我们可以使用这个注解进行标注。
@AutoWired:自动导入依赖的bean。byType方式。把配置好的Bean拿来用,完成属性、方法的组装,它可以对类成员变量、方法及构造函数进行标注,完成自动装配的工作。当加上(required=false)时,就算找不到bean也不报错。
@Qualifier:当有多个同一类型的Bean时,可以用@Qualifier(“name”)来指定。与@Autowired配合使用。@Qualifier限定描述符除了能根据名字进行注入,但能进行更细粒度的控制如何选择候选者,具体使用方式如下:
@Resource(name=”name”,type=”type”):没有括号内内容的话,默认byName。与@Autowired干类似的事。
- @Api:用于修饰Controller类,生成Controller相关文档信息
- @ApiOperation:用于修饰Controller类中的方法,生成接口方法相关文档信息
- @ApiParam:用于修饰接口中的参数,生成接口参数相关文档信息
- @ApiModelProperty:用于修饰实体类的属性,当实体类是请求参数或返回结果时,直接生成相关文档信息
@PathVariable:获取参数。
@Api(tags = "PmsBrandController", description = "商品品牌管理")
@Controller
@RequestMapping("/brand")
public class PmsBrandController {
@Autowired
private PmsBrandService brandService;
@ApiOperation("添加品牌")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasAuthority('pms:brand:create')")
public CommonResult create(@RequestBody PmsBrand brand) {
public CommonResult update(@PathVariable("id") Long id, @RequestBody PmsBrand brand) {
@SpringBootApplication
public class MallTinyApplication {
public static void main(String[] args) {
SpringApplication.run(MallTinyApplication.class, args);
}
在application.yml中添加数据源配置和MyBatis的mapper.xml的路径配置。
server:
port: 8080
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
流程为:Controller,代码如下:
/**
* 品牌管理Controller
* Created by macro on 2019/4/19.
*/
@Controller
@RequestMapping("/brand")
public class PmsBrandController {
@Autowired
private PmsBrandService demoService;
private static final Logger LOGGER = LoggerFactory.getLogger(PmsBrandController.class);
@RequestMapping(value = "listAll", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<PmsBrand>> getBrandList() {
return CommonResult.success(demoService.listAllBrand());
}
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult createBrand(@RequestBody PmsBrand pmsBrand) {
CommonResult commonResult;
int count = demoService.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;
}
;;;
}
Service接口为:PmsBrandService
public interface PmsBrandService {
List<PmsBrand> listAllBrand();
int createBrand(PmsBrand brand);
}
实现Service接口,PmsBrandServiceImpl
@Service
public class PmsBrandServiceImpl implements PmsBrandService {
@Autowired
private PmsBrandMapper brandMapper;
@Override
public List<PmsBrand> listAllBrand() {
return brandMapper.selectByExample(new PmsBrandExample());
}
@Override
public int createBrand(PmsBrand brand) {
return brandMapper.insertSelective(brand);
}
}
因 brandMapper需要Ioc依赖注入PmsBrandMapper接口:
public interface PmsBrandMapper {
int insert(PmsBrand record);
List<PmsBrand> selectByExample(PmsBrandExample example);
}
MyBatisConfig.java
@Configuration
@MapperScan({"com.macro.mall.tiny.mbg.mapper","com.macro.mall.tiny.dao"})
public class MyBatisConfig {
}
PmsBrandExample.java
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<Criteria> oredCriteria;
public PmsBrandExample() {
oredCriteria = new ArrayList<Criteria>();
}
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<Criteria> 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<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> 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<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> 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<String> values) {
addCriterion("name in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> 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<String> values) {
addCriterion("first_letter in", values, "firstLetter");
return (Criteria) this;
}
public Criteria andFirstLetterNotIn(List<String> 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<Integer> values) {
addCriterion("sort in", values, "sort");
return (Criteria) this;
}
public Criteria andSortNotIn(List<Integer> 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<Integer> values) {
addCriterion("factory_status in", values, "factoryStatus");
return (Criteria) this;
}
public Criteria andFactoryStatusNotIn(List<Integer> 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<Integer> values) {
addCriterion("show_status in", values, "showStatus");
return (Criteria) this;
}
public Criteria andShowStatusNotIn(List<Integer> 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<Integer> values) {
addCriterion("product_count in", values, "productCount");
return (Criteria) this;
}
public Criteria andProductCountNotIn(List<Integer> 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<Integer> values) {
addCriterion("product_comment_count in", values, "productCommentCount");
return (Criteria) this;
}
public Criteria andProductCommentCountNotIn(List<Integer> 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<String> values) {
addCriterion("logo in", values, "logo");
return (Criteria) this;
}
public Criteria andLogoNotIn(List<String> 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<String> values) {
addCriterion("big_pic in", values, "bigPic");
return (Criteria) this;
}
public Criteria andBigPicNotIn(List<String> 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);
}
}
}
PmsBrand.java
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();
}
}
其他:PmsBrandMapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.macro.mall.tiny.mbg.mapper.PmsBrandMapper">
<resultMap id="BaseResultMap" type="com.macro.mall.tiny.mbg.model.PmsBrand">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="first_letter" jdbcType="VARCHAR" property="firstLetter" />
<result column="sort" jdbcType="INTEGER" property="sort" />
<result column="factory_status" jdbcType="INTEGER" property="factoryStatus" />
<result column="show_status" jdbcType="INTEGER" property="showStatus" />
<result column="product_count" jdbcType="INTEGER" property="productCount" />
<result column="product_comment_count" jdbcType="INTEGER" property="productCommentCount" />
<result column="logo" jdbcType="VARCHAR" property="logo" />
<result column="big_pic" jdbcType="VARCHAR" property="bigPic" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.macro.mall.tiny.mbg.model.PmsBrand">
<result column="brand_story" jdbcType="LONGVARCHAR" property="brandStory" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<insert id="insert" parameterType="com.macro.mall.tiny.mbg.model.PmsBrand">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
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})
</insert>
</mapper>