GitHub地址 : https://github.com/q850717441/jl
idea 如何优雅的添加.ignore 忽略不必要提交的文件
在项目所在位置打开git-bash, 在git bash交互环境输入命令: git config credential.helper store 后续正常 push,第一次要输入账号密码,以后就不用了
PD可以以图形化的形式展现数据库中表与表之间的关联关系 , 并且能够自动的生存建库建表的语句 , 以及可以非常灵活的切换数据库
安装完成之后,将破解补丁中的文件复制.替换根目录中的文件信息,就可以运行了
打开 PhysicalDataModel.pdm 文件
EasyUI官网 : http://www.jeasyui.net/
bootstrap官网 : https://www.bootcss.com/
Layui官网 : https://www.layui.com/ 当前比较流行的,收费
(1) easyui是一种基于jQuery、Angular.、Vue和React的用户界面插件集合
(2) 为创建现代化,互动,JavaScript应用程序,提供必要的功能
(3) 不需要写很多代码,你只需要通过编写一些简单HTML标记,就可以定义用户界面
(4) 完美支持HTML5网页的完整框架
(5) 节省您网页开发的时间和规模
(6) 简单且功能强大
实现通用页面跳转 特点: (1)前缀相同 (2)访问地址不同 (3)请求地址与跳转的页面相同的 方法: 参数使用/分割;参数使用{}包裹,并且设置变量名称;使用@PathVariable注解动态获取数据 注: 如果传递的参数数量众多时,使用对象封装
@Controller public class IndexController { @RequestMapping("/page/{moduleName}") public String item_add(@PathVariable String moduleName) { return moduleName; }由于前段页面接收的数据为JSON格式{"total":xxx,"rows":[{},{}}
封装数据为JSON通过ajax展示到EasyUI表格中
@Data @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor public class EasyUITable implements Serializable{ private Integer total; private List<?> rows; }来源于某东的商品页面的信息
SQL语句
create table tb_item ( id bigint(10) not null auto_increment comment '商品ID,也是商品编号', title varchar(100), sell_point varchar(150), price bigint(20) comment '单位为:分', num int(10), barcode varchar(30), image varchar(500) comment '最多5张图片', cid bigint(10), status int(1) default 1 comment '默认值为1,可选值:1正常,2下架,3删除', created datetime, updated datetime comment '列表排序时按修改时间排序,所以在新增时需要设置此值。', primary key (id) );根据商品表的设计,创建封装商品信息的对象
@JsonIgnoreProperties(ignoreUnknown = true) //表示JSON转化时忽略未知属性 @TableName("tb_item") @Data @Accessors(chain = true) public class Item extends BasePojo { @TableId(type = IdType.AUTO) private Long id; //商品id private String title; //商品标题 private String sellPoint; //商品卖点信息 private Long price; //商品价格 Long > dubbo private Integer num; //商品数量 private String barcode; //条形码 private String image; //商品图片信息 1.jpg,2.jpg,3.jpg private Long cid; //表示商品的分类id private Integer status; //1正常,2下架 //为了满足页面调用需求,添加get方法 public String[] getImages() { return image.split(","); } }对item-list.jsp 分析了解到 url:'/item/query'
得知url为/item/query 参数为 page 和 rows
在Controller编辑商品分页查询的映射方法 findItemByPage 调用service的findItemByPage方法,返回为EasyUITable对象类型的JSON格式数据
@RestController //保证返回值数据都是JSON时使用 @RequestMapping("/item") public class ItemController { @Autowired private ItemService itemService; /** * 根据条件查询数据信息. * url:http://localhost:8091/item/query?page=1&rows=20 */ @RequestMapping("/query") public EasyUITable findItemByPage(Integer page, Integer rows) { return itemService.findItemByPage(page, rows); } }Mybatis-plus方式实现分页 在ItemService和 ItemServiceImpl添加 findItemByPage方法 1.查询商品总记录数 2.进行分页查询 select * from tb_item order by desc updated limit (page-1)*rows,rows mybatis-plus分页说明 1.new Page<>(current, size); 2.current:当前页数 ; size: 每页条数
@Service public class ItemServiceImpl implements ItemService { @Autowired private ItemMapper itemMapper; @Override public EasyUITable findItemByPage(Integer page, Integer rows) { Page<Item> tempPage = new Page<>(page, rows); QueryWrapper<Item> queryWrapper = new QueryWrapper<Item>(); queryWrapper.orderByDesc("updated"); //当前查询的分页结果对象 IPage<Item> IPage = itemMapper.selectPage(tempPage, queryWrapper); //获取总记录数 int total = (int) IPage.getTotal(); //获取分页的结果 List<Item> userList = IPage.getRecords(); return new EasyUITable(total, userList); } }通过@select 注解来执行sql查询语句 参数为start 初始化位置 和 rows 数量
public interface ItemMapper extends BaseMapper<Item>{ @Select("select * from tb_item order by updated desc limit #{start},#{rows}") List<Item> findItemByPage(@Param("start") Integer start, @Param("rows") Integer rows); }定义MybatisConfig的配置类.在com.jt.config中 目的 : 加快分页查询的速度
@Configuration //配置类 public class MybatisConfig { @Bean //将对象交给Spring容器管理 public PaginationInterceptor paginationInterceptor() { return new PaginationInterceptor(); } }因为储存的价格是Long 就是为了防止小数无限 在储存的时候就放大了100倍,所以回显的时候需要缩小100倍
<th data-options="field:'price',width:70,align:'right',formatter:KindEditorUtil.formatPrice">价格</th>格式化价格 value 是数据库数据
formatPrice : function(val,row){ return (val/100).toFixed(2); }item-list页面
<th data-options="field:'created',width:130,align:'center',formatter:KindEditorUtil.formatDateTime">创建日期</th>格式化时间 按照我们需要的格式 : yyyy-MM-dd hh:mm:ss
formatDateTime : function(val,row){ var now = new Date(val); return now.format("yyyy-MM-dd hh:mm:ss"); }页面分析
<th data-options="field:'cid',width:100,align:'center',formatter:KindEditorUtil.findItemCatName">叶子类目</th>编辑common.js
findItemCatName : function(val,row){ var name; $.ajax({ type:"get", url:"/item/cat/queryItemName", data:{itemCatId:val}, cache:true, //缓存 async:false, //表示同步 默认的是异步的true dataType:"text",//表示返回值参数类型 success:function(data){ name = data; } }); return name; }编辑ItemCat POJO对象
@TableName("tb_item_cat") @Data @Accessors(chain = true) public class ItemCat extends BasePojo{ @TableId(type = IdType.AUTO) private Long id; private Long parentId; private String name; private Integer status; private Integer sortOrder; //排序号 private Boolean isParent; //是否为父级 }编辑ItemCatController 根据itemCatId查询商品分类名称 http://localhost:8091/item/cat/queryItemName?itemCatId=560
先根据id查询对象将对象中的name名称获取 @RestController @RequestMapping("/item/cat") public class ItemCatController { @Autowired private ItemCatService itemCatService; @RequestMapping("/queryItemName") public String findItemCatNameById(Long itemCatId) { //1.先根据id查询对象 ItemCat itemCat = itemCatService.findItemCatById(itemCatId); //2.将对象中的name名称获取 return itemCat.getName(); } }编辑ItemCatService
@Service public class ItemCatServiceImpl implements ItemCatService { @Autowired private ItemCatMapper itemCatMapper; @Override public ItemCat findItemCatById(Long itemCatId) { return itemCatMapper.selectById(itemCatId); } }ajax嵌套问题 当ajax进行嵌套时,一般将内部的ajax的请求方式设置为同步, 默认为异步
页面效果展现
RESTful : Representational State Transfer 传送门
(1) 每一个URI代表一种资源
(2) 客户端和服务器之间,传递这种资源的某种表现层
(3) 客户端通过四个HTTP动词,对服务器端资源进行操作,实现"表现层状态转化"
REST 就是将资源的状态以适合客户端或服务端的形式从服务端转移到客户端(或者反过来)。在 REST 中,资源通过 URL 进行识别和定位,然后通过行为(即 HTTP 方法)来定义 REST 来完成怎样的功能。来自:我没有三颗心脏
实现通用页面跳转 特点: (1)前缀相同 (2)访问地址不同 (3)请求地址与跳转的页面相同的 方法: 参数使用/分割;参数使用{}包裹,并且设置变量名称;使用@PathVariable注解动态获取数据 注: 如果传递的参数数量众多时,使用对象封装
@Controller public class IndexController { @RequestMapping("/{moduleName}") public String pageJumps(@PathVariable String moduleName) { return moduleName; }ul li 有序列表 ; ol li 无序列表
@PathVariable是映射 URL 绑定的占位符 传送门
启动mysql
cmd(管理员权限) : net start mysql
MySQL5.6(ZIP)解压版安装
VO :(value object) 值对象
通常用于业务层之间的数据传递,和PO一样也是仅仅包含数据而已。但应是抽象出的业务对象,可以和表对应,也可以不,这根据业务的需要
而PO只能用在数据层,VO用在商业逻辑层和表示层。各层操作属于该层自己的数据对象,这样就可以降低各层之间的耦合,便于以后系统的维护和扩展。
VO对象和PO对象的区别
Accessor的中文含义是存取器,用于配置getter和setter方法的生成结果
有三种属性 :fluent chain prefix 传送门
chain的中文含义是链式的,设置为true,则setter方法返回当前对象。
当映射器方法需要多个参数时,这个注解可以应用于映射器方法来给每个参数一个名字。否则,多参数将会以他们的顺序位置来命名。比如#{1}、#{2}等,这是默认的。若使用@Param(“person”),SQL中的参数应该被命名为#{person}
JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式 易于人阅读和编写,以及机器解析和生成。
(1) Object 格式
对象是一个无序的“名称/值对”集合,一个对象以{左括号开始,}右括号结束。每个"名称"后跟一个:冒号;"名称/值"对之间使用逗号分隔 {"id":"100","name":"tomcat猫"}
(2) Array 格式
数组是值( value)的有序集合。一个数组以[左中括号 开始,]右中括号 结束。值 之间使用,逗号分隔。["value1","value2","value3"]
(3) 复杂格式
json串可以进行无限层级的嵌套. 但是只有value可以嵌套 ["value1",true,["value3",{"key":"value"}]]
order by
默认为升序 asc
设置为降序 desc
@configuration 标注当前类为配置类 (替代xml)
calc 计算器 , mspaint 画图