diff --git a/19J06_NiuXuBin/src/main/java/niuxubin/controller/NiuXuBinController.java b/19J06_NiuXuBin/src/main/java/niuxubin/controller/NiuXuBinController.java new file mode 100644 index 0000000000000000000000000000000000000000..7747e7fc371ff528c5831129db0c92c8b98e4a41 --- /dev/null +++ b/19J06_NiuXuBin/src/main/java/niuxubin/controller/NiuXuBinController.java @@ -0,0 +1,121 @@ +package niuxubin.controller; + +import niuxubin.entity.BjEntity; +import niuxubin.entity.Page; +import niuxubin.entity.PageUtils; +import niuxubin.entity.niuxubinEntity; +import niuxubin.service.niuxubinService; + +import javax.annotation.Resource; +import java.util.List; + +public class niuxubinController { + + niuxubinEntity niuxubinEntity=null; + String name = null; + Integer pageNo = null; + Page page = null; + List bjEntity=null; + String flag = "0"; + @Resource + niuxubinService niuxuBservice; + + public String login(){ + flag = niuxuBservice.login(niuxubinEntity); + return "save"; + } + + + public String queryPage(){ + int totalCount= niuxuBservice.queryCount(name); + page = PageUtils.getPage(5,totalCount,pageNo); + List list = niuxuBservice.queryPage(page,name); + page.setData(list); + return "queryPage"; + } + + public String save(){ + niuxuBservice.save(niuxubinEntity); + flag = "1"; + return "save"; + } + public String del(){ + niuxuBservice.del(niuxubinEntity); + flag = "1"; + return "save"; + } + + public String edit(){ + niuxubinEntity =niuxuBservice.edit(niuxubinEntity); + + return "edit"; + } + + public String bj(){ + bjEntity =niuxuBservice.bj(); + return "bj"; + } + + + //@Resource @Autowired 作用相同 去spring容器中到bean实例 + //@Service @Component 向spring 容器中放入bean(类的对象)实例 + + + public List getBjEntity() { + return bjEntity; + } + + public void setBjEntity(List bjEntity) { + this.bjEntity = bjEntity; + } + + public niuxubinEntity getniuxubinEntity() { + return niuxubinEntity; + } + + public void setniuxubinEntity(niuxubinEntity niuxubinEntity) { + this.niuxubinEntity = niuxubinEntity; + } + + public niuxubinService getniuxuBservice() { + return niuxuBservice; + } + + public void setniuxuBservice(niuxubinService niuxuBservice) { + this.niuxuBservice = niuxuBservice; + } + + public String getFlag() { + return flag; + } + + public void setFlag(String flag) { + this.flag = flag; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + + public Integer getPageNo() { + return pageNo; + } + + public void setPageNo(Integer pageNo) { + this.pageNo = pageNo; + } + + public Page getPage() { + return page; + } + + public void setPage(Page page) { + this.page = page; + } +} diff --git a/19J06_NiuXuBin/src/main/java/niuxubin/dao/NiuXuBin.java b/19J06_NiuXuBin/src/main/java/niuxubin/dao/NiuXuBin.java new file mode 100644 index 0000000000000000000000000000000000000000..68676e12507a81f49f72d2e7f8bdfbb48b1a0ac0 --- /dev/null +++ b/19J06_NiuXuBin/src/main/java/niuxubin/dao/NiuXuBin.java @@ -0,0 +1,88 @@ +package niuxubin.dao; + +import org.springframework.transaction.annotation.Transactional; +import niuxubin.entity.BjEntity; +import niuxubin.entity.Page; +import niuxubin.entity.NiuBuBinEntity; + +import org.hibernate.Criteria; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.transform.Transformers; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.orm.hibernate4.HibernateTemplate; +import org.springframework.orm.hibernate4.support.HibernateDaoSupport; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component() +public class niuxubinDao extends HibernateDaoSupport { + + + public String login(niuxubinEntity niuxubinEntity) { + String sql = "select * from j03niuxubin where name =? and password=?"; + Query query=getSessionFactory().openSession().createSQLQuery(sql); + query.setParameter(0,niuxubinEntity.getName() ); + query.setParameter(1,niuxubinEntity.getPassword() ); + List list= query.list(); + + if(list.size() == 0){ + + return "0"; + }else { + + return "1"; + } + } + + + + + public void save(niuxubinEntity niuxubinEntity) { + Session session= getSessionFactory().openSession(); + session.saveOrUpdate(niuxubinEntity); + session.flush(); + } + + + + + public int queryCount(String name) { + String sql = "select * from j03niuxubin where name like ? "; + Query query=getSessionFactory().openSession().createSQLQuery(sql); + query.setParameter(0, "%" + name + "%"); + List list= query.list(); + return list.size(); + } + + public List queryPage(Page page, String name) { + String sql = "select a.name,a.id,a.url,b.bname from j03niuxubin a,j03zcclazz b where a.bid=b.id and name like ? order by systime desc limit ?,? "; + Query query=getSessionFactory().openSession().createSQLQuery(sql); + query.setParameter(0, "%" + name + "%"); + query.setParameter(1, page.getBeginIndex()); + query.setParameter(2, page.getEveryPage()); + query.setResultTransformer(Transformers.aliasToBean(niuxubinEntity.class)); + List list= query.list(); + return list; + } + + public niuxubinEntity edit(niuxubinEntity zc) { + Session session= getSessionFactory().openSession(); + return (niuxubinEntity)session.get(niuxubinEntity.class,zc.getId()); + } + + public void del(niuxubinEntity niuxubinEntity) { + Session session= getSessionFactory().openSession(); + session.delete(niuxubinEntity); + session.flush(); + } + + public List bj() { + String sql = "select * from j03zcclazz "; + Query query=getSessionFactory().openSession().createSQLQuery(sql); + query.setResultTransformer(Transformers.aliasToBean(BjEntity.class)); + List list= query.list(); + return list; + } +} diff --git a/19J06_NiuXuBin/src/main/java/niuxubin/entity/BjEntity.java b/19J06_NiuXuBin/src/main/java/niuxubin/entity/BjEntity.java new file mode 100644 index 0000000000000000000000000000000000000000..bcc0d3d428f348e2beaddbc3a10e88c958e0abd3 --- /dev/null +++ b/19J06_NiuXuBin/src/main/java/niuxubin/entity/BjEntity.java @@ -0,0 +1,22 @@ +package niuxubin.entity; + +public class BjEntity { + private Integer id; + private String bname; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getBname() { + return bname; + } + + public void setBname(String bname) { + this.bname = bname; + } +} diff --git a/19J06_NiuXuBin/src/main/java/niuxubin/entity/NiuXuBin.java b/19J06_NiuXuBin/src/main/java/niuxubin/entity/NiuXuBin.java new file mode 100644 index 0000000000000000000000000000000000000000..009a48a5a93bf8dfa84c592f2618b58a60643ee3 --- /dev/null +++ b/19J06_NiuXuBin/src/main/java/niuxubin/entity/NiuXuBin.java @@ -0,0 +1,68 @@ +package niuxubin.entity; + +public class niuxubinEntity { + + private Integer id; + private String name; + private Integer bid; + private String url; + private String bname; + private String flag; + private String password; + + public String getFlag() { + return flag; + } + + public void setFlag(String flag) { + this.flag = flag; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public Integer getId() { + return id; + } + + public Integer getBid() { + return bid; + } + + public void setBid(Integer bid) { + this.bid = bid; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getBname() { + return bname; + } + + public void setBname(String bname) { + this.bname = bname; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/19J06_NiuXuBin/src/main/java/niuxubin/entity/Page.java b/19J06_NiuXuBin/src/main/java/niuxubin/entity/Page.java new file mode 100644 index 0000000000000000000000000000000000000000..6372e7986eb6fca0bb52c7e39afa09c73e5d1813 --- /dev/null +++ b/19J06_NiuXuBin/src/main/java/niuxubin/entity/Page.java @@ -0,0 +1,111 @@ +package niuxubin.entity; + +import java.util.List; +public class Page { + // 1. 每页显示的数量 + private int everyPage; + + // 2. 总条目数 + private int totalCount; + + // 3. 总页数 + private int totalPage; + + // 4. 当前页数 + private int currentPage; + + // 5. 起始条 + private int beginIndex; + + // 6. 是否有上一页 + private boolean hasPrePage; + + // 7. 是否还有下一页 + private boolean hasNextPage; + + private List data; + + + + + + + public Page() { + } + + public Page(int everyPage, int totalCount, int totalPage, int currentPage, int beginIndex, boolean hasPrePage, + boolean hasNextPage) { + super(); + this.everyPage = everyPage; + this.totalCount = totalCount; + this.totalPage = totalPage; + this.currentPage = currentPage; + this.beginIndex = beginIndex; + this.hasPrePage = hasPrePage; + this.hasNextPage = hasNextPage; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public int getEveryPage() { + return everyPage; + } + + public void setEveryPage(int everyPage) { + this.everyPage = everyPage; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public int getTotalPage() { + return totalPage; + } + + public void setTotalPage(int totalPage) { + this.totalPage = totalPage; + } + + public int getCurrentPage() { + return currentPage; + } + + public void setCurrentPage(int currentPage) { + this.currentPage = currentPage; + } + + public int getBeginIndex() { + return beginIndex; + } + + public void setBeginIndex(int beginIndex) { + this.beginIndex = beginIndex; + } + + public boolean isHasPrePage() { + return hasPrePage; + } + + public void setHasPrePage(boolean hasPrePage) { + this.hasPrePage = hasPrePage; + } + + public boolean isHasNextPage() { + return hasNextPage; + } + + public void setHasNextPage(boolean hasNextPage) { + this.hasNextPage = hasNextPage; + } +} diff --git a/19J06_NiuXuBin/src/main/java/niuxubin/entity/PageUtils.java b/19J06_NiuXuBin/src/main/java/niuxubin/entity/PageUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..f38bdacb758fbcfc8423d704ad8397edb9c44d21 --- /dev/null +++ b/19J06_NiuXuBin/src/main/java/niuxubin/entity/PageUtils.java @@ -0,0 +1,85 @@ +package niuxubin.entity; + +public class PageUtils { + public static Page getPage(int everyPage, int totalCount, int currentPage) { + Page page = null; + //每页显示两条 + + + + //总页数 2 2 4 + //总页数 6 3 17 + int totalPage = getTotalPage(everyPage, totalCount); + + currentPage = getCurrentPage(currentPage,totalPage); + //起始条 5 2 3 + //起始条 11 5 3 + //起始条 11 3 7 + int beginIndex = getBeginIndex(everyPage, currentPage); + + + boolean hasPrePage = hasPrePage(currentPage); + boolean hasNextPage = hasNextPage(totalPage, currentPage); + return page = new Page(everyPage, totalCount, totalPage, currentPage, beginIndex, hasPrePage, hasNextPage); + } + + + + /** + * 设定当前页 + * + * @param currentPage + * @return + */ + public static int getCurrentPage(int currentPage,int totalPage) { + if(currentPage == 0) { + currentPage = 1; + }else if(currentPage > totalPage ){ + currentPage =totalPage; + } + return currentPage; + } + + /** + * 设定分页的总页数 + * + * @param everyPage + * @param totalCount + * @return + */ + public static int getTotalPage(int everyPage, int totalCount) { + int num = totalCount / everyPage; + return totalCount % everyPage == 0 ? num : num + 1; + } + + /** + * 设置起始点 + * + * @param everyPage + * @param currentPage + * @return + */ + public static int getBeginIndex(int everyPage, int currentPage) { + return (currentPage - 1) * everyPage; + } + + /** + * 设置是否有上一页 + * + * @param currentPage + * @return + */ + public static boolean hasPrePage(int currentPage) { + return currentPage == 1 ? false : true; + } + + /** + * 设置是否有下一页 + * + * @param currentPage + * @return + */ + public static boolean hasNextPage(int totalPage, int currentPage) { + return currentPage == totalPage || totalPage == 0 ? false : true; + } +} diff --git a/19J06_NiuXuBin/src/main/java/niuxubin/service/NiuXuBinService.java b/19J06_NiuXuBin/src/main/java/niuxubin/service/NiuXuBinService.java new file mode 100644 index 0000000000000000000000000000000000000000..36e2114777d4317e50449a155ed0826e47c0702d --- /dev/null +++ b/19J06_NiuXuBin/src/main/java/niuxubin/service/NiuXuBinService.java @@ -0,0 +1,28 @@ +package niuxubin.service; + +import niuxubin.entity.BjEntity; +import niuxubin.entity.Page; +import niuxubin.entity.NiuXuBinEntity; + +import java.util.List; + +public interface NiuXuBinService { + + + + + void save(niuxubinEntity niuxubinEntity); + + + int queryCount(String name); + + List queryPage(Page page, String name); + + niuxubinEntity edit(niuxubinEntity niuxubinEntity); + + void del(niuxubinEntity niuxubinEntity); + + List bj(); + + String login(niuxubinEntity niuxubinEntity); +} diff --git a/19J06_NiuXuBin/src/main/java/niuxubin/service/impl/NiuXuBinServiceImpl.java b/19J06_NiuXuBin/src/main/java/niuxubin/service/impl/NiuXuBinServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..7b044c3064710e3ad805feef0da402d1c598171f --- /dev/null +++ b/19J06_NiuXuBin/src/main/java/niuxubin/service/impl/NiuXuBinServiceImpl.java @@ -0,0 +1,57 @@ +package niuxubin.service.impl; + +import niuxubin.dao.niuxubinDao; +import niuxubin.entity.BjEntity; +import niuxubin.entity.Page; +import niuxubin.entity.niuxubinEntity; +import niuxubin.service.niuxubinService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +@Service("niuxuBservice") +public class niuxubinServiceImpl implements niuxubinService { + @Autowired + niuxubinDao niuxubinDao; + + + + @Override + public void save(niuxubinEntity niuxubinEntity) { + niuxubinDao.save(niuxubinEntity); + } + + @Override + public int queryCount(String name) { + return niuxubinDao.queryCount(name); + } + + @Override + public List queryPage(Page page, String name) { + return niuxubinDao.queryPage(page,name); + } + + @Override + public niuxubinEntity edit(niuxubinEntity niuxubinEntity) { + return niuxubinDao.edit(niuxubinEntity); + } + + @Override + public void del(niuxubinEntity niuxubinEntity) { + niuxubinDao.del(niuxubinEntity); + } + + @Override + public List bj() { + return niuxubinDao.bj(); + } + + @Override + public String login(niuxubinEntity niuxubinEntity) { + return niuxubinDao.login(niuxubinEntity); + } + + +} diff --git a/19J06_NiuXuBin/src/main/resources/applicationcontext.xml b/19J06_NiuXuBin/src/main/resources/applicationcontext.xml new file mode 100644 index 0000000000000000000000000000000000000000..337ee9ff061ec29b4819d0f4278bc63ff4695fec --- /dev/null +++ b/19J06_NiuXuBin/src/main/resources/applicationcontext.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + classpath:conf/hrb/ + + + + + org.hibernate.dialect.MySQL5InnoDBDialect + true + update + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/19J06_NiuXuBin/src/main/resources/conf/hrb/NiuXuBin.hbm.xml b/19J06_NiuXuBin/src/main/resources/conf/hrb/NiuXuBin.hbm.xml new file mode 100644 index 0000000000000000000000000000000000000000..c55ff25ce0e41f3baf873c779b683a9d97172ade --- /dev/null +++ b/19J06_NiuXuBin/src/main/resources/conf/hrb/NiuXuBin.hbm.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/19J06_NiuXuBin/src/main/resources/conf/struts/niuxubinstrust.xml b/19J06_NiuXuBin/src/main/resources/conf/struts/niuxubinstrust.xml new file mode 100644 index 0000000000000000000000000000000000000000..5f55898fff98724bd910e44889e8467f1012e375 --- /dev/null +++ b/19J06_NiuXuBin/src/main/resources/conf/struts/niuxubinstrust.xml @@ -0,0 +1,26 @@ + + + + + + + + page + + + flag + + + niuxubinEntity + + + bjEntity + + + queryPage,save,edit,del,bj,login + + + + \ No newline at end of file diff --git a/19J06_NiuXuBin/src/main/webapp/niuxuB/dept_index.html b/19J06_NiuXuBin/src/main/webapp/niuxuB/dept_index.html new file mode 100644 index 0000000000000000000000000000000000000000..bad9b7010f6081d4fce03435ba7398a65afdc202 --- /dev/null +++ b/19J06_NiuXuBin/src/main/webapp/niuxuB/dept_index.html @@ -0,0 +1,150 @@ + + + + + + + + 学生管理 + + + + + + + + + + + + + +
+ + + +
+
+ 网站首页 + + + +
+ +
+ + +
+
+ + +
+ + + + + + + + + + + + + + + + +
部门操作
+
+ + +
+
+ + + +
+ +
+
+ + + + diff --git a/19J06_NiuXuBin/src/main/webapp/niuxuB/index.html b/19J06_NiuXuBin/src/main/webapp/niuxuB/index.html new file mode 100644 index 0000000000000000000000000000000000000000..c5800702e03dace17f69a74e7855ee5de719b162 --- /dev/null +++ b/19J06_NiuXuBin/src/main/webapp/niuxuB/index.html @@ -0,0 +1,58 @@ + + + + +登录 + + + + + +
正真科技 · 用数据改变未来
+
+ +
+ + + \ No newline at end of file diff --git a/19J06_NiuXuBin/src/main/webapp/niuxuB/nxb.html b/19J06_NiuXuBin/src/main/webapp/niuxuB/nxb.html new file mode 100644 index 0000000000000000000000000000000000000000..8d163a9c6f09a279fa43f0e56ec699df11df9688 --- /dev/null +++ b/19J06_NiuXuBin/src/main/webapp/niuxuB/nxb.html @@ -0,0 +1,10 @@ + + + + + Title + + +hello zhangkun1234 + + \ No newline at end of file diff --git a/19J06_NiuXuBin/src/main/webapp/niuxuB/static/scss/_alert.scss b/19J06_NiuXuBin/src/main/webapp/niuxuB/static/scss/_alert.scss new file mode 100644 index 0000000000000000000000000000000000000000..da2a98af94e82f0a26b2a1f26e7b05afe07d3608 --- /dev/null +++ b/19J06_NiuXuBin/src/main/webapp/niuxuB/static/scss/_alert.scss @@ -0,0 +1,51 @@ +// +// Base styles +// + +.alert { + position: relative; + padding: $alert-padding-y $alert-padding-x; + margin-bottom: $alert-margin-bottom; + border: $alert-border-width solid transparent; + @include border-radius($alert-border-radius); +} + +// Headings for larger alerts +.alert-heading { + // Specified to prevent conflicts of changing $headings-color + color: inherit; +} + +// Provide class for links that match alerts +.alert-link { + font-weight: $alert-link-font-weight; +} + + +// Dismissible alerts +// +// Expand the right padding and account for the close button's positioning. + +.alert-dismissible { + padding-right: $close-font-size + $alert-padding-x * 2; + + // Adjust close link position + .close { + position: absolute; + top: 0; + right: 0; + padding: $alert-padding-y $alert-padding-x; + color: inherit; + } +} + + +// Alternate styles +// +// Generate contextual modifier classes for colorizing the alert. + +@each $color, $value in $theme-colors { + .alert-#{$color} { + @include alert-variant(theme-color-level($color, $alert-bg-level), theme-color-level($color, $alert-border-level), theme-color-level($color, $alert-color-level)); + } +} diff --git a/19J06_NiuXuBin/src/main/webapp/niuxuB/static/scss/_badge.scss b/19J06_NiuXuBin/src/main/webapp/niuxuB/static/scss/_badge.scss new file mode 100644 index 0000000000000000000000000000000000000000..42c5d08d7487c36ebbd1989020d9396f3f4880f0 --- /dev/null +++ b/19J06_NiuXuBin/src/main/webapp/niuxuB/static/scss/_badge.scss @@ -0,0 +1,54 @@ +// Base class +// +// Requires one of the contextual, color modifier classes for `color` and +// `background-color`. + +.badge { + display: inline-block; + padding: $badge-padding-y $badge-padding-x; + @include font-size($badge-font-size); + font-weight: $badge-font-weight; + line-height: 1; + text-align: center; + white-space: nowrap; + vertical-align: baseline; + @include border-radius($badge-border-radius); + @include transition($badge-transition); + + @at-root a#{&} { + @include hover-focus() { + text-decoration: none; + } + } + + // Empty badges collapse automatically + &:empty { + display: none; + } +} + +// Quick fix for badges in buttons +.btn .badge { + position: relative; + top: -1px; +} + +// Pill badges +// +// Make them extra rounded with a modifier to replace v3's badges. + +.badge-pill { + padding-right: $badge-pill-padding-x; + padding-left: $badge-pill-padding-x; + @include border-radius($badge-pill-border-radius); +} + +// Colors +// +// Contextual variations (linked badges get darker on :hover). + +@each $color, $value in $theme-colors { + .badge-#{$color} { + @include badge-variant($value); + } +} diff --git a/19J06_NiuXuBin/src/main/webapp/niuxuB/static/scss/_breadcrumb.scss b/19J06_NiuXuBin/src/main/webapp/niuxuB/static/scss/_breadcrumb.scss new file mode 100644 index 0000000000000000000000000000000000000000..d748894f96404f1b10f70dd79252f4b0d458cf00 --- /dev/null +++ b/19J06_NiuXuBin/src/main/webapp/niuxuB/static/scss/_breadcrumb.scss @@ -0,0 +1,42 @@ +.breadcrumb { + display: flex; + flex-wrap: wrap; + padding: $breadcrumb-padding-y $breadcrumb-padding-x; + margin-bottom: $breadcrumb-margin-bottom; + @include font-size($breadcrumb-font-size); + list-style: none; + background-color: $breadcrumb-bg; + @include border-radius($breadcrumb-border-radius); +} + +.breadcrumb-item { + // The separator between breadcrumbs (by default, a forward-slash: "/") + + .breadcrumb-item { + padding-left: $breadcrumb-item-padding; + + &::before { + display: inline-block; // Suppress underlining of the separator in modern browsers + padding-right: $breadcrumb-item-padding; + color: $breadcrumb-divider-color; + content: escape-svg($breadcrumb-divider); + } + } + + // IE9-11 hack to properly handle hyperlink underlines for breadcrumbs built + // without `