- Dao层
package com.wfy.pojo;?public class Brand { //id 主键 private Integer id; //brandName 品牌名称 private String brandName; //企业名称 private String companyName; //排序字段 private Integer ordered; //描述信息 private String description; //状态: 0:禁用1:启动 private Integer status; private String statusStr;? public Integer getId() { return id; }? public void setId(Integer id) { this.id = id; }? public String getBrandName() { return brandName; }? public void setBrandName(String brandName) { this.brandName = brandName; }? public String getCompanyName() { return companyName; }? public void setCompanyName(String companyName) { this.companyName = companyName; }? public Integer getOrdered() { return ordered; }? public void setOrdered(Integer ordered) { this.ordered = ordered; }? public String getDescription() { return description; }? public void setDescription(String description) { this.description = description; }? public Integer getStatus() { return status; }? //逻辑视图 public String getStatusStr(){ if(status==1){ return "启用"; } return status==0 ?"禁用":"启用"; }? public void setStatus(Integer status) { this.status = status; }? @Override public String toString() { return "Brand{" + "id=" + id + ", brandName='" + brandName + '\'' + ", companyName='" + companyName + '\'' + ", ordered=" + ordered + ", description='" + description + '\'' + ", status=" + status + '}'; }}
package com.wfy.pojo;?import java.util.List;?//分页查询的JavaBeanpublic class PageBean<T> {? //总记录数 private int totalCount;? //当前业数据 private List<T> rows;? public int getTotalCount() { return totalCount; }? public void setTotalCount(int totalCount) { this.totalCount = totalCount; }? public List<T> getRows() { return rows; }? public void setRows(List<T> rows) { this.rows = rows; }}
package com.wfy.mapper;?import com.wfy.pojo.Brand;import org.apache.ibatis.annotations.*;?import java.util.List;?public interface BrandMapper {? //查询所有 @Select("select * from brand") @ResultMap("brandResultMap") List<Brand> SelectAll();? //新增品牌 @Insert("insert into brand values (null,#{brandName},#{companyName},#{ordered},#{description},#{status})") void AddBrand(Brand brand);? //根据id来获取指定品牌信息,实现数据的回显操作 @Select("select * from brand where id = #{id}") @ResultMap("brandResultMap") Brand SelectById(int id); //更改品牌信息 @Update("updatebrand set brand_name=#{brandName},company_name=#{companyName},ordered=#{ordered},description=#{description} where id=#{id} ") void UpdateBrand(Brand brand);? //删除指定品牌数据 @Delete("delete from brand where id =#{id}") void deleteById(int id);? //删除多条数据 void DeleteByIds( @Param("ids") int[] ids);? //分页查询begin--开始的索引size--获取信息的条目数 @Select("select * from brand limit #{begin},#{size} ") @ResultMap("brandResultMap") List<Brand> SelectByPage(@Param("begin") int begin,@Param("size") int size);? //查询总信息条数 @Select("selectcount(*) from brand") int SelectTotalCount();? //分页条件查询begin--开始的索引size--获取信息的条目数 List<Brand> SelectByPageAndCondition(@Param("begin") int begin,@Param("size") int size,@Param("brand")Brand brand);? //条件查询总信息条数 int SelectTotalCountByCondition(Brand brand);}
经验总结扩展阅读
-
-
-
-
女女们|40左右的女人头发粗硬,这样剪不烫更好看,比波波头好看10倍
-
-
-
运动 冬天是减肥关键期,牢记4个“技巧”,或许养成易瘦体质也并不难
-
-
-
-
|对谈|贫穷并不是作家的缪斯,作家也没有爱情谜题的答案
-
-
2023年10月12日训马吉日一览表 2023年10月12日训马黄道吉日
-
-
-
-
网上有这样一个问题:“人是怎样废掉的?”其中有一条高赞回答说:“低层次水平里追求稳定 “差不多”的态度,失去成长突破的机会
-
2500元预算就买这4款 2500手机排行榜前几名
-
-