parent
a0c415d702
commit
423ea65748
@ -0,0 +1,226 @@
|
||||
package com.controller;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.entity.Admin;
|
||||
import com.service.AdminService;
|
||||
import com.util.PageHelper;
|
||||
import com.util.VeDate;
|
||||
//定义为控制器
|
||||
@Controller
|
||||
// 设置路径
|
||||
@RequestMapping(value = "/admin" , produces = "text/plain;charset=utf-8")
|
||||
public class AdminController extends BaseController {
|
||||
// @Autowired的作用是自动注入依赖的ServiceBean
|
||||
@Autowired
|
||||
private AdminService adminService;
|
||||
|
||||
// 管理员准备
|
||||
@RequestMapping("index.action")
|
||||
public String index() {
|
||||
return "admin/index";
|
||||
}
|
||||
|
||||
// 管理员登录 1 验证用户名是否存在 2 验证密码是否正确
|
||||
@RequestMapping("login.action")
|
||||
public String login() {
|
||||
String username = this.getRequest().getParameter("username");
|
||||
String password = this.getRequest().getParameter("password");
|
||||
Admin adminEntity = new Admin();
|
||||
adminEntity.setUsername(username);
|
||||
List<Admin> adminlist = this.adminService.getAdminByCond(adminEntity);
|
||||
if (adminlist.size() == 0) {
|
||||
this.getRequest().setAttribute("message", "用户名不存在");
|
||||
return "redirect:/admin/index.action";
|
||||
} else {
|
||||
Admin admin = adminlist.get(0);
|
||||
if (password.equals(admin.getPassword())) {
|
||||
this.getSession().setAttribute("adminid", admin.getAdminid());
|
||||
this.getSession().setAttribute("adminname", admin.getUsername());
|
||||
this.getSession().setAttribute("realname", admin.getRealname());
|
||||
this.getSession().setAttribute("role", "管理员");
|
||||
} else {
|
||||
this.getRequest().setAttribute("message", "密码错误");
|
||||
return "redirect:/admin/index.action";
|
||||
}
|
||||
}
|
||||
return "admin/main";
|
||||
}
|
||||
|
||||
// 管理员准备修改密码
|
||||
@RequestMapping("prePwd.action")
|
||||
public String prePwd() {
|
||||
return "admin/editpwd";
|
||||
}
|
||||
// 修改密码
|
||||
@RequestMapping("editpwd.action")
|
||||
public String editpwd() {
|
||||
String adminid = (String) this.getSession().getAttribute("adminid");
|
||||
String password = this.getRequest().getParameter("password");
|
||||
String repassword = this.getRequest().getParameter("repassword");
|
||||
Admin admin = this.adminService.getAdminById(adminid);
|
||||
if (password.equals(admin.getPassword())) {
|
||||
admin.setPassword(repassword);
|
||||
this.adminService.updateAdmin(admin);
|
||||
} else {
|
||||
this.getRequest().setAttribute("message", "旧密码错误");
|
||||
}
|
||||
return "redirect:/admin/prePwd.action";
|
||||
}
|
||||
|
||||
// 管理员退出登录
|
||||
@RequestMapping("exit.action")
|
||||
public String exit() {
|
||||
this.getSession().removeAttribute("adminid");
|
||||
this.getSession().removeAttribute("adminname");
|
||||
this.getSession().removeAttribute("realname");
|
||||
return "redirect:/admin/index.action";
|
||||
}
|
||||
// 准备添加数据
|
||||
@RequestMapping("createAdmin.action")
|
||||
public String createAdmin() {
|
||||
return "admin/addadmin";
|
||||
}
|
||||
// 添加数据
|
||||
@RequestMapping("addAdmin.action")
|
||||
public String addAdmin(Admin admin) {
|
||||
admin.setAddtime(VeDate.getStringDateShort());
|
||||
this.adminService.insertAdmin(admin);
|
||||
return "redirect:/admin/createAdmin.action";
|
||||
}
|
||||
|
||||
// AJAX添加数据
|
||||
@RequestMapping("xaddAdmin.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xaddAdmin(Admin admin) {
|
||||
admin.setAddtime(VeDate.getStringDateShort());
|
||||
int x = this.adminService.insertAdmin(admin);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
// 通过主键删除数据
|
||||
@RequestMapping("deleteAdmin.action")
|
||||
public String deleteAdmin(String id) {
|
||||
this.adminService.deleteAdmin(id);
|
||||
return "redirect:/admin/getAllAdmin.action";
|
||||
}
|
||||
|
||||
// AJAX通过主键删除数据
|
||||
@RequestMapping("xdeleteAdmin.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xdeleteAdmin(String id) {
|
||||
int x = this.adminService.deleteAdmin(id);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
// 批量删除数据
|
||||
@RequestMapping("deleteAdminByIds.action")
|
||||
public String deleteAdminByIds() {
|
||||
String[] ids = this.getRequest().getParameterValues("adminid");
|
||||
if (ids != null) {
|
||||
for (String adminid : ids) {
|
||||
this.adminService.deleteAdmin(adminid);
|
||||
}
|
||||
}
|
||||
return "redirect:/admin/getAllAdmin.action";
|
||||
}
|
||||
|
||||
// 更新数据
|
||||
@RequestMapping("updateAdmin.action")
|
||||
public String updateAdmin(Admin admin) {
|
||||
this.adminService.updateAdmin(admin);
|
||||
return "redirect:/admin/getAllAdmin.action";
|
||||
}
|
||||
|
||||
// AJAX更新数据
|
||||
@RequestMapping("xupdateAdmin.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xupdateAdmin(Admin admin) {
|
||||
int x = this.adminService.updateAdmin(admin);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
// 显示全部数据
|
||||
@RequestMapping("getAllAdmin.action")
|
||||
public String getAllAdmin(String number) {
|
||||
List<Admin> adminList = this.adminService.getAllAdmin();
|
||||
PageHelper.getUserPage(adminList, "admin", "getAllAdmin", 10, number, this.getRequest());
|
||||
return "admin/listadmin";
|
||||
}
|
||||
|
||||
// AJAX显示全部数据
|
||||
@RequestMapping(value = "getDataList.action", produces = "application/json; charset=utf-8")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public Map<String, Object> getDataList(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer limit) {
|
||||
// 定义一个Map对象 用来返回数据
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Page<Admin> pager = com.github.pagehelper.PageHelper.startPage(page, limit);// 定义当前页和分页条数
|
||||
List<Admin> list = this.adminService.getAllAdmin();
|
||||
// 返回的map中定义Layui的数据格式
|
||||
map.put("count", pager.getTotal());
|
||||
map.put("data", list);
|
||||
map.put("code", 0);
|
||||
map.put("msg", "");
|
||||
return map;
|
||||
}
|
||||
|
||||
// 按条件查询数据 (模糊查询)
|
||||
@RequestMapping("queryAdminByCond.action")
|
||||
public String queryAdminByCond(String cond, String name, String number) {
|
||||
Admin admin = new Admin();
|
||||
if(cond != null){
|
||||
if ("username".equals(cond)) {
|
||||
admin.setUsername(name);
|
||||
}
|
||||
if ("password".equals(cond)) {
|
||||
admin.setPassword(name);
|
||||
}
|
||||
if ("realname".equals(cond)) {
|
||||
admin.setRealname(name);
|
||||
}
|
||||
if ("contact".equals(cond)) {
|
||||
admin.setContact(name);
|
||||
}
|
||||
if ("addtime".equals(cond)) {
|
||||
admin.setAddtime(name);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> nameList = new ArrayList<String>();
|
||||
List<String> valueList = new ArrayList<String>();
|
||||
nameList.add(cond);
|
||||
valueList.add(name);
|
||||
PageHelper.getPage(this.adminService.getAdminByLike(admin), "admin", nameList, valueList, 10, number, this.getRequest(), "query");
|
||||
name = null;
|
||||
cond = null;
|
||||
return "admin/queryadmin";
|
||||
}
|
||||
|
||||
// 按主键查询数据
|
||||
@RequestMapping("getAdminById.action")
|
||||
public String getAdminById(String id) {
|
||||
Admin admin = this.adminService.getAdminById(id);
|
||||
this.getRequest().setAttribute("admin", admin);
|
||||
return "admin/editadmin";
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,184 @@
|
||||
package com.controller;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.entity.Article;
|
||||
import com.service.ArticleService;
|
||||
import com.entity.Banner;
|
||||
import com.service.BannerService;
|
||||
import com.util.PageHelper;
|
||||
import com.util.VeDate;
|
||||
//定义为控制器
|
||||
@Controller
|
||||
// 设置路径
|
||||
@RequestMapping(value = "/article" , produces = "text/plain;charset=utf-8")
|
||||
public class ArticleController extends BaseController {
|
||||
// @Autowired的作用是自动注入依赖的ServiceBean
|
||||
@Autowired
|
||||
private ArticleService articleService;
|
||||
@Autowired
|
||||
private BannerService bannerService;
|
||||
|
||||
// 准备添加数据
|
||||
@RequestMapping("createArticle.action")
|
||||
public String createArticle() {
|
||||
List<Banner> bannerList = this.bannerService.getAllBanner();
|
||||
this.getRequest().setAttribute("bannerList", bannerList);
|
||||
return "admin/addarticle";
|
||||
}
|
||||
// 添加数据
|
||||
@RequestMapping("addArticle.action")
|
||||
public String addArticle(Article article) {
|
||||
article.setAddtime(VeDate.getStringDateShort());
|
||||
article.setHits("0");
|
||||
this.articleService.insertArticle(article);
|
||||
return "redirect:/article/createArticle.action";
|
||||
}
|
||||
|
||||
// AJAX添加数据
|
||||
@RequestMapping("xaddArticle.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xaddArticle(Article article) {
|
||||
article.setAddtime(VeDate.getStringDateShort());
|
||||
article.setHits("0");
|
||||
int x = this.articleService.insertArticle(article);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
// 通过主键删除数据
|
||||
@RequestMapping("deleteArticle.action")
|
||||
public String deleteArticle(String id) {
|
||||
this.articleService.deleteArticle(id);
|
||||
return "redirect:/article/getAllArticle.action";
|
||||
}
|
||||
|
||||
// AJAX通过主键删除数据
|
||||
@RequestMapping("xdeleteArticle.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xdeleteArticle(String id) {
|
||||
int x = this.articleService.deleteArticle(id);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
// 批量删除数据
|
||||
@RequestMapping("deleteArticleByIds.action")
|
||||
public String deleteArticleByIds() {
|
||||
String[] ids = this.getRequest().getParameterValues("articleid");
|
||||
if (ids != null) {
|
||||
for (String articleid : ids) {
|
||||
this.articleService.deleteArticle(articleid);
|
||||
}
|
||||
}
|
||||
return "redirect:/article/getAllArticle.action";
|
||||
}
|
||||
|
||||
// 更新数据
|
||||
@RequestMapping("updateArticle.action")
|
||||
public String updateArticle(Article article) {
|
||||
this.articleService.updateArticle(article);
|
||||
return "redirect:/article/getAllArticle.action";
|
||||
}
|
||||
|
||||
// AJAX更新数据
|
||||
@RequestMapping("xupdateArticle.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xupdateArticle(Article article) {
|
||||
int x = this.articleService.updateArticle(article);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
// 显示全部数据
|
||||
@RequestMapping("getAllArticle.action")
|
||||
public String getAllArticle(String number) {
|
||||
List<Article> articleList = this.articleService.getAllArticle();
|
||||
PageHelper.getUserPage(articleList, "article", "getAllArticle", 10, number, this.getRequest());
|
||||
return "admin/listarticle";
|
||||
}
|
||||
|
||||
// AJAX显示全部数据
|
||||
@RequestMapping(value = "getDataList.action", produces = "application/json; charset=utf-8")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public Map<String, Object> getDataList(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer limit) {
|
||||
// 定义一个Map对象 用来返回数据
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Page<Article> pager = com.github.pagehelper.PageHelper.startPage(page, limit);// 定义当前页和分页条数
|
||||
List<Article> list = this.articleService.getAllArticle();
|
||||
// 返回的map中定义Layui的数据格式
|
||||
map.put("count", pager.getTotal());
|
||||
map.put("data", list);
|
||||
map.put("code", 0);
|
||||
map.put("msg", "");
|
||||
return map;
|
||||
}
|
||||
|
||||
// 按条件查询数据 (模糊查询)
|
||||
@RequestMapping("queryArticleByCond.action")
|
||||
public String queryArticleByCond(String cond, String name, String number) {
|
||||
Article article = new Article();
|
||||
if(cond != null){
|
||||
if ("title".equals(cond)) {
|
||||
article.setTitle(name);
|
||||
}
|
||||
if ("bannerid".equals(cond)) {
|
||||
article.setBannerid(name);
|
||||
}
|
||||
if ("image".equals(cond)) {
|
||||
article.setImage(name);
|
||||
}
|
||||
if ("istop".equals(cond)) {
|
||||
article.setIstop(name);
|
||||
}
|
||||
if ("isflv".equals(cond)) {
|
||||
article.setIsflv(name);
|
||||
}
|
||||
if ("contents".equals(cond)) {
|
||||
article.setContents(name);
|
||||
}
|
||||
if ("addtime".equals(cond)) {
|
||||
article.setAddtime(name);
|
||||
}
|
||||
if ("hits".equals(cond)) {
|
||||
article.setHits(name);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> nameList = new ArrayList<String>();
|
||||
List<String> valueList = new ArrayList<String>();
|
||||
nameList.add(cond);
|
||||
valueList.add(name);
|
||||
PageHelper.getPage(this.articleService.getArticleByLike(article), "article", nameList, valueList, 10, number, this.getRequest(), "query");
|
||||
name = null;
|
||||
cond = null;
|
||||
return "admin/queryarticle";
|
||||
}
|
||||
|
||||
// 按主键查询数据
|
||||
@RequestMapping("getArticleById.action")
|
||||
public String getArticleById(String id) {
|
||||
Article article = this.articleService.getArticleById(id);
|
||||
this.getRequest().setAttribute("article", article);
|
||||
List<Banner> bannerList = this.bannerService.getAllBanner();
|
||||
this.getRequest().setAttribute("bannerList", bannerList);
|
||||
return "admin/editarticle";
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,159 @@
|
||||
package com.controller;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.entity.Asks;
|
||||
import com.service.AsksService;
|
||||
import com.util.PageHelper;
|
||||
import com.util.VeDate;
|
||||
//定义为控制器
|
||||
@Controller
|
||||
// 设置路径
|
||||
@RequestMapping(value = "/asks" , produces = "text/plain;charset=utf-8")
|
||||
public class AsksController extends BaseController {
|
||||
// @Autowired的作用是自动注入依赖的ServiceBean
|
||||
@Autowired
|
||||
private AsksService asksService;
|
||||
|
||||
// 准备添加数据
|
||||
@RequestMapping("createAsks.action")
|
||||
public String createAsks() {
|
||||
return "admin/addasks";
|
||||
}
|
||||
// 添加数据
|
||||
@RequestMapping("addAsks.action")
|
||||
public String addAsks(Asks asks) {
|
||||
asks.setAddtime(VeDate.getStringDateShort());
|
||||
this.asksService.insertAsks(asks);
|
||||
return "redirect:/asks/createAsks.action";
|
||||
}
|
||||
|
||||
// AJAX添加数据
|
||||
@RequestMapping("xaddAsks.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xaddAsks(Asks asks) {
|
||||
asks.setAddtime(VeDate.getStringDateShort());
|
||||
int x = this.asksService.insertAsks(asks);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
// 通过主键删除数据
|
||||
@RequestMapping("deleteAsks.action")
|
||||
public String deleteAsks(String id) {
|
||||
this.asksService.deleteAsks(id);
|
||||
return "redirect:/asks/getAllAsks.action";
|
||||
}
|
||||
|
||||
// AJAX通过主键删除数据
|
||||
@RequestMapping("xdeleteAsks.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xdeleteAsks(String id) {
|
||||
int x = this.asksService.deleteAsks(id);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
// 批量删除数据
|
||||
@RequestMapping("deleteAsksByIds.action")
|
||||
public String deleteAsksByIds() {
|
||||
String[] ids = this.getRequest().getParameterValues("asksid");
|
||||
if (ids != null) {
|
||||
for (String asksid : ids) {
|
||||
this.asksService.deleteAsks(asksid);
|
||||
}
|
||||
}
|
||||
return "redirect:/asks/getAllAsks.action";
|
||||
}
|
||||
|
||||
// 更新数据
|
||||
@RequestMapping("updateAsks.action")
|
||||
public String updateAsks(Asks asks) {
|
||||
this.asksService.updateAsks(asks);
|
||||
return "redirect:/asks/getAllAsks.action";
|
||||
}
|
||||
|
||||
// AJAX更新数据
|
||||
@RequestMapping("xupdateAsks.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xupdateAsks(Asks asks) {
|
||||
int x = this.asksService.updateAsks(asks);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
// 显示全部数据
|
||||
@RequestMapping("getAllAsks.action")
|
||||
public String getAllAsks(String number) {
|
||||
List<Asks> asksList = this.asksService.getAllAsks();
|
||||
PageHelper.getUserPage(asksList, "asks", "getAllAsks", 10, number, this.getRequest());
|
||||
return "admin/listasks";
|
||||
}
|
||||
|
||||
// AJAX显示全部数据
|
||||
@RequestMapping(value = "getDataList.action", produces = "application/json; charset=utf-8")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public Map<String, Object> getDataList(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer limit) {
|
||||
// 定义一个Map对象 用来返回数据
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Page<Asks> pager = com.github.pagehelper.PageHelper.startPage(page, limit);// 定义当前页和分页条数
|
||||
List<Asks> list = this.asksService.getAllAsks();
|
||||
// 返回的map中定义Layui的数据格式
|
||||
map.put("count", pager.getTotal());
|
||||
map.put("data", list);
|
||||
map.put("code", 0);
|
||||
map.put("msg", "");
|
||||
return map;
|
||||
}
|
||||
|
||||
// 按条件查询数据 (模糊查询)
|
||||
@RequestMapping("queryAsksByCond.action")
|
||||
public String queryAsksByCond(String cond, String name, String number) {
|
||||
Asks asks = new Asks();
|
||||
if(cond != null){
|
||||
if ("question".equals(cond)) {
|
||||
asks.setQuestion(name);
|
||||
}
|
||||
if ("addtime".equals(cond)) {
|
||||
asks.setAddtime(name);
|
||||
}
|
||||
if ("memo".equals(cond)) {
|
||||
asks.setMemo(name);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> nameList = new ArrayList<String>();
|
||||
List<String> valueList = new ArrayList<String>();
|
||||
nameList.add(cond);
|
||||
valueList.add(name);
|
||||
PageHelper.getPage(this.asksService.getAsksByLike(asks), "asks", nameList, valueList, 10, number, this.getRequest(), "query");
|
||||
name = null;
|
||||
cond = null;
|
||||
return "admin/queryasks";
|
||||
}
|
||||
|
||||
// 按主键查询数据
|
||||
@RequestMapping("getAsksById.action")
|
||||
public String getAsksById(String id) {
|
||||
Asks asks = this.asksService.getAsksById(id);
|
||||
this.getRequest().setAttribute("asks", asks);
|
||||
return "admin/editasks";
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,159 @@
|
||||
package com.controller;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.entity.Banner;
|
||||
import com.service.BannerService;
|
||||
import com.util.PageHelper;
|
||||
import com.util.VeDate;
|
||||
//定义为控制器
|
||||
@Controller
|
||||
// 设置路径
|
||||
@RequestMapping(value = "/banner" , produces = "text/plain;charset=utf-8")
|
||||
public class BannerController extends BaseController {
|
||||
// @Autowired的作用是自动注入依赖的ServiceBean
|
||||
@Autowired
|
||||
private BannerService bannerService;
|
||||
|
||||
// 准备添加数据
|
||||
@RequestMapping("createBanner.action")
|
||||
public String createBanner() {
|
||||
return "admin/addbanner";
|
||||
}
|
||||
// 添加数据
|
||||
@RequestMapping("addBanner.action")
|
||||
public String addBanner(Banner banner) {
|
||||
banner.setAddtime(VeDate.getStringDateShort());
|
||||
this.bannerService.insertBanner(banner);
|
||||
return "redirect:/banner/createBanner.action";
|
||||
}
|
||||
|
||||
// AJAX添加数据
|
||||
@RequestMapping("xaddBanner.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xaddBanner(Banner banner) {
|
||||
banner.setAddtime(VeDate.getStringDateShort());
|
||||
int x = this.bannerService.insertBanner(banner);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
// 通过主键删除数据
|
||||
@RequestMapping("deleteBanner.action")
|
||||
public String deleteBanner(String id) {
|
||||
this.bannerService.deleteBanner(id);
|
||||
return "redirect:/banner/getAllBanner.action";
|
||||
}
|
||||
|
||||
// AJAX通过主键删除数据
|
||||
@RequestMapping("xdeleteBanner.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xdeleteBanner(String id) {
|
||||
int x = this.bannerService.deleteBanner(id);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
// 批量删除数据
|
||||
@RequestMapping("deleteBannerByIds.action")
|
||||
public String deleteBannerByIds() {
|
||||
String[] ids = this.getRequest().getParameterValues("bannerid");
|
||||
if (ids != null) {
|
||||
for (String bannerid : ids) {
|
||||
this.bannerService.deleteBanner(bannerid);
|
||||
}
|
||||
}
|
||||
return "redirect:/banner/getAllBanner.action";
|
||||
}
|
||||
|
||||
// 更新数据
|
||||
@RequestMapping("updateBanner.action")
|
||||
public String updateBanner(Banner banner) {
|
||||
this.bannerService.updateBanner(banner);
|
||||
return "redirect:/banner/getAllBanner.action";
|
||||
}
|
||||
|
||||
// AJAX更新数据
|
||||
@RequestMapping("xupdateBanner.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xupdateBanner(Banner banner) {
|
||||
int x = this.bannerService.updateBanner(banner);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
// 显示全部数据
|
||||
@RequestMapping("getAllBanner.action")
|
||||
public String getAllBanner(String number) {
|
||||
List<Banner> bannerList = this.bannerService.getAllBanner();
|
||||
PageHelper.getUserPage(bannerList, "banner", "getAllBanner", 10, number, this.getRequest());
|
||||
return "admin/listbanner";
|
||||
}
|
||||
|
||||
// AJAX显示全部数据
|
||||
@RequestMapping(value = "getDataList.action", produces = "application/json; charset=utf-8")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public Map<String, Object> getDataList(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer limit) {
|
||||
// 定义一个Map对象 用来返回数据
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Page<Banner> pager = com.github.pagehelper.PageHelper.startPage(page, limit);// 定义当前页和分页条数
|
||||
List<Banner> list = this.bannerService.getAllBanner();
|
||||
// 返回的map中定义Layui的数据格式
|
||||
map.put("count", pager.getTotal());
|
||||
map.put("data", list);
|
||||
map.put("code", 0);
|
||||
map.put("msg", "");
|
||||
return map;
|
||||
}
|
||||
|
||||
// 按条件查询数据 (模糊查询)
|
||||
@RequestMapping("queryBannerByCond.action")
|
||||
public String queryBannerByCond(String cond, String name, String number) {
|
||||
Banner banner = new Banner();
|
||||
if(cond != null){
|
||||
if ("bannername".equals(cond)) {
|
||||
banner.setBannername(name);
|
||||
}
|
||||
if ("addtime".equals(cond)) {
|
||||
banner.setAddtime(name);
|
||||
}
|
||||
if ("memo".equals(cond)) {
|
||||
banner.setMemo(name);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> nameList = new ArrayList<String>();
|
||||
List<String> valueList = new ArrayList<String>();
|
||||
nameList.add(cond);
|
||||
valueList.add(name);
|
||||
PageHelper.getPage(this.bannerService.getBannerByLike(banner), "banner", nameList, valueList, 10, number, this.getRequest(), "query");
|
||||
name = null;
|
||||
cond = null;
|
||||
return "admin/querybanner";
|
||||
}
|
||||
|
||||
// 按主键查询数据
|
||||
@RequestMapping("getBannerById.action")
|
||||
public String getBannerById(String id) {
|
||||
Banner banner = this.bannerService.getBannerById(id);
|
||||
this.getRequest().setAttribute("banner", banner);
|
||||
return "admin/editbanner";
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.controller;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
/**
|
||||
* Controller 基类
|
||||
* 其他Controller继承此类的同时也继承了此类里面的各个方法
|
||||
* 省掉了重新定义 实例化的麻烦
|
||||
*/
|
||||
@Controller
|
||||
public class BaseController {
|
||||
|
||||
/* 日志 */
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
/* 获取基本环境 */
|
||||
public Map<String, String[]> getParameters() {// 封装为Map的requestParameters
|
||||
ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
return attrs.getRequest().getParameterMap();
|
||||
}
|
||||
|
||||
public HttpServletRequest getRequest() {
|
||||
ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
return attrs.getRequest();
|
||||
}
|
||||
|
||||
public HttpSession getSession() {
|
||||
HttpSession session = null;
|
||||
try {
|
||||
session = this.getRequest().getSession();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
package com.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import com.entity.Complains;
|
||||
import com.service.ComplainsService;
|
||||
import com.entity.Users;
|
||||
import com.service.UsersService;
|
||||
import com.util.PageHelper;
|
||||
|
||||
//定义为控制器
|
||||
@Controller
|
||||
// 设置路径
|
||||
@RequestMapping(value = "/complains", produces = "text/plain;charset=utf-8")
|
||||
public class ComplainsController extends BaseController {
|
||||
// @Autowired的作用是自动注入依赖的ServiceBean
|
||||
@Autowired
|
||||
private ComplainsService complainsService;
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
|
||||
// 准备添加数据
|
||||
@RequestMapping("createComplains.action")
|
||||
public String createComplains() {
|
||||
List<Users> usersList = this.usersService.getAllUsers();
|
||||
this.getRequest().setAttribute("usersList", usersList);
|
||||
return "admin/addcomplains";
|
||||
}
|
||||
|
||||
// 添加数据
|
||||
@RequestMapping("addComplains.action")
|
||||
public String addComplains(Complains complains) {
|
||||
this.complainsService.insertComplains(complains);
|
||||
return "redirect:/complains/createComplains.action";
|
||||
}
|
||||
|
||||
// 通过主键删除数据
|
||||
@RequestMapping("deleteComplains.action")
|
||||
public String deleteComplains(String id) {
|
||||
this.complainsService.deleteComplains(id);
|
||||
return "redirect:/complains/getAllComplains.action";
|
||||
}
|
||||
|
||||
// 批量删除数据
|
||||
@RequestMapping("deleteComplainsByIds.action")
|
||||
public String deleteComplainsByIds() {
|
||||
String[] ids = this.getRequest().getParameterValues("complainsid");
|
||||
if (ids != null) {
|
||||
for (String complainsid : ids) {
|
||||
this.complainsService.deleteComplains(complainsid);
|
||||
}
|
||||
}
|
||||
return "redirect:/complains/getAllComplains.action";
|
||||
}
|
||||
|
||||
// 更新数据
|
||||
@RequestMapping("updateComplains.action")
|
||||
public String updateComplains(Complains complains) {
|
||||
this.complainsService.updateComplains(complains);
|
||||
return "redirect:/complains/getAllComplains.action";
|
||||
}
|
||||
|
||||
// 更新状态
|
||||
@RequestMapping("status.action")
|
||||
public String status(String id) {
|
||||
String status = "";
|
||||
Complains complains = this.complainsService.getComplainsById(id);
|
||||
if (status.equals(complains.getStatus())) {
|
||||
status = "";
|
||||
}
|
||||
complains.setStatus(status);
|
||||
this.complainsService.updateComplains(complains);
|
||||
return "redirect:/complains/getAllComplains.action";
|
||||
}
|
||||
|
||||
// 显示全部数据
|
||||
@RequestMapping("getAllComplains.action")
|
||||
public String getAllComplains(String number) {
|
||||
List<Complains> complainsList = this.complainsService.getAllComplains();
|
||||
PageHelper.getPage(complainsList, "complains", null, null, 10, number, this.getRequest(), null);
|
||||
return "admin/listcomplains";
|
||||
}
|
||||
|
||||
// 按条件查询数据 (模糊查询)
|
||||
@RequestMapping("queryComplainsByCond.action")
|
||||
public String queryComplainsByCond(String cond, String name, String number) {
|
||||
Complains complains = new Complains();
|
||||
if (cond != null) {
|
||||
if ("usersid".equals(cond)) {
|
||||
complains.setUsersid(name);
|
||||
}
|
||||
if ("title".equals(cond)) {
|
||||
complains.setTitle(name);
|
||||
}
|
||||
if ("contents".equals(cond)) {
|
||||
complains.setContents(name);
|
||||
}
|
||||
if ("addtime".equals(cond)) {
|
||||
complains.setAddtime(name);
|
||||
}
|
||||
if ("status".equals(cond)) {
|
||||
complains.setStatus(name);
|
||||
}
|
||||
if ("reps".equals(cond)) {
|
||||
complains.setReps(name);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> nameList = new ArrayList<String>();
|
||||
List<String> valueList = new ArrayList<String>();
|
||||
nameList.add(cond);
|
||||
valueList.add(name);
|
||||
PageHelper.getPage(this.complainsService.getComplainsByLike(complains), "complains", nameList, valueList, 10, number, this.getRequest(),
|
||||
"query");
|
||||
name = null;
|
||||
cond = null;
|
||||
return "admin/querycomplains";
|
||||
}
|
||||
|
||||
// 按主键查询数据
|
||||
@RequestMapping("getComplainsById.action")
|
||||
public String getComplainsById(String id) {
|
||||
Complains complains = this.complainsService.getComplainsById(id);
|
||||
this.getRequest().setAttribute("complains", complains);
|
||||
List<Users> usersList = this.usersService.getAllUsers();
|
||||
this.getRequest().setAttribute("usersList", usersList);
|
||||
return "admin/editcomplains";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,175 @@
|
||||
package com.controller;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.entity.Fav;
|
||||
import com.service.FavService;
|
||||
import com.entity.Users;
|
||||
import com.entity.Article;
|
||||
import com.service.UsersService;
|
||||
import com.service.ArticleService;
|
||||
import com.util.PageHelper;
|
||||
import com.util.VeDate;
|
||||
//定义为控制器
|
||||
@Controller
|
||||
// 设置路径
|
||||
@RequestMapping(value = "/fav" , produces = "text/plain;charset=utf-8")
|
||||
public class FavController extends BaseController {
|
||||
// @Autowired的作用是自动注入依赖的ServiceBean
|
||||
@Autowired
|
||||
private FavService favService;
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
@Autowired
|
||||
private ArticleService articleService;
|
||||
|
||||
// 准备添加数据
|
||||
@RequestMapping("createFav.action")
|
||||
public String createFav() {
|
||||
List<Users> usersList = this.usersService.getAllUsers();
|
||||
this.getRequest().setAttribute("usersList", usersList);
|
||||
List<Article> articleList = this.articleService.getAllArticle();
|
||||
this.getRequest().setAttribute("articleList", articleList);
|
||||
return "admin/addfav";
|
||||
}
|
||||
// 添加数据
|
||||
@RequestMapping("addFav.action")
|
||||
public String addFav(Fav fav) {
|
||||
fav.setAddtime(VeDate.getStringDateShort());
|
||||
this.favService.insertFav(fav);
|
||||
return "redirect:/fav/createFav.action";
|
||||
}
|
||||
|
||||
// AJAX添加数据
|
||||
@RequestMapping("xaddFav.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xaddFav(Fav fav) {
|
||||
fav.setAddtime(VeDate.getStringDateShort());
|
||||
int x = this.favService.insertFav(fav);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
// 通过主键删除数据
|
||||
@RequestMapping("deleteFav.action")
|
||||
public String deleteFav(String id) {
|
||||
this.favService.deleteFav(id);
|
||||
return "redirect:/fav/getAllFav.action";
|
||||
}
|
||||
|
||||
// AJAX通过主键删除数据
|
||||
@RequestMapping("xdeleteFav.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xdeleteFav(String id) {
|
||||
int x = this.favService.deleteFav(id);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
// 批量删除数据
|
||||
@RequestMapping("deleteFavByIds.action")
|
||||
public String deleteFavByIds() {
|
||||
String[] ids = this.getRequest().getParameterValues("favid");
|
||||
if (ids != null) {
|
||||
for (String favid : ids) {
|
||||
this.favService.deleteFav(favid);
|
||||
}
|
||||
}
|
||||
return "redirect:/fav/getAllFav.action";
|
||||
}
|
||||
|
||||
// 更新数据
|
||||
@RequestMapping("updateFav.action")
|
||||
public String updateFav(Fav fav) {
|
||||
this.favService.updateFav(fav);
|
||||
return "redirect:/fav/getAllFav.action";
|
||||
}
|
||||
|
||||
// AJAX更新数据
|
||||
@RequestMapping("xupdateFav.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xupdateFav(Fav fav) {
|
||||
int x = this.favService.updateFav(fav);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
// 显示全部数据
|
||||
@RequestMapping("getAllFav.action")
|
||||
public String getAllFav(String number) {
|
||||
List<Fav> favList = this.favService.getAllFav();
|
||||
PageHelper.getUserPage(favList, "fav", "getAllFav", 10, number, this.getRequest());
|
||||
return "admin/listfav";
|
||||
}
|
||||
|
||||
// AJAX显示全部数据
|
||||
@RequestMapping(value = "getDataList.action", produces = "application/json; charset=utf-8")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public Map<String, Object> getDataList(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer limit) {
|
||||
// 定义一个Map对象 用来返回数据
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Page<Fav> pager = com.github.pagehelper.PageHelper.startPage(page, limit);// 定义当前页和分页条数
|
||||
List<Fav> list = this.favService.getAllFav();
|
||||
// 返回的map中定义Layui的数据格式
|
||||
map.put("count", pager.getTotal());
|
||||
map.put("data", list);
|
||||
map.put("code", 0);
|
||||
map.put("msg", "");
|
||||
return map;
|
||||
}
|
||||
|
||||
// 按条件查询数据 (模糊查询)
|
||||
@RequestMapping("queryFavByCond.action")
|
||||
public String queryFavByCond(String cond, String name, String number) {
|
||||
Fav fav = new Fav();
|
||||
if(cond != null){
|
||||
if ("usersid".equals(cond)) {
|
||||
fav.setUsersid(name);
|
||||
}
|
||||
if ("articleid".equals(cond)) {
|
||||
fav.setArticleid(name);
|
||||
}
|
||||
if ("addtime".equals(cond)) {
|
||||
fav.setAddtime(name);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> nameList = new ArrayList<String>();
|
||||
List<String> valueList = new ArrayList<String>();
|
||||
nameList.add(cond);
|
||||
valueList.add(name);
|
||||
PageHelper.getPage(this.favService.getFavByLike(fav), "fav", nameList, valueList, 10, number, this.getRequest(), "query");
|
||||
name = null;
|
||||
cond = null;
|
||||
return "admin/queryfav";
|
||||
}
|
||||
|
||||
// 按主键查询数据
|
||||
@RequestMapping("getFavById.action")
|
||||
public String getFavById(String id) {
|
||||
Fav fav = this.favService.getFavById(id);
|
||||
this.getRequest().setAttribute("fav", fav);
|
||||
List<Users> usersList = this.usersService.getAllUsers();
|
||||
this.getRequest().setAttribute("usersList", usersList);
|
||||
List<Article> articleList = this.articleService.getAllArticle();
|
||||
this.getRequest().setAttribute("articleList", articleList);
|
||||
return "admin/editfav";
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,397 @@
|
||||
package com.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.entity.Article;
|
||||
import com.entity.Asks;
|
||||
import com.entity.Banner;
|
||||
import com.entity.Complains;
|
||||
import com.entity.Fav;
|
||||
import com.entity.Topic;
|
||||
import com.entity.Users;
|
||||
import com.service.ArticleService;
|
||||
import com.service.AsksService;
|
||||
import com.service.BannerService;
|
||||
import com.service.ComplainsService;
|
||||
import com.service.FavService;
|
||||
import com.service.TopicService;
|
||||
import com.service.UsersService;
|
||||
import com.util.PageHelper;
|
||||
import com.util.VeDate;
|
||||
|
||||
//定义为控制器
|
||||
@Controller
|
||||
// 设置路径
|
||||
@RequestMapping("/index")
|
||||
public class IndexController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
@Autowired
|
||||
private BannerService bannerService;
|
||||
@Autowired
|
||||
private ArticleService articleService;
|
||||
@Autowired
|
||||
private FavService favService;
|
||||
@Autowired
|
||||
private TopicService topicService;
|
||||
@Autowired
|
||||
private ComplainsService complainsService;
|
||||
@Autowired
|
||||
private AsksService asksService;
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
// 公共方法 提供公共查询数据
|
||||
private void front() {
|
||||
this.getRequest().setAttribute("title", "新闻发布管理系统");
|
||||
List<Banner> bannerList = this.bannerService.getAllBanner();
|
||||
this.getRequest().setAttribute("bannerList", bannerList);
|
||||
}
|
||||
|
||||
// 首页显示
|
||||
@RequestMapping("index.action")
|
||||
public String index() {
|
||||
this.front();
|
||||
List<Banner> bannerList = this.bannerService.getAllBanner();
|
||||
List<Banner> frontList = new ArrayList<Banner>();
|
||||
for (Banner banner : bannerList) {
|
||||
List<Article> articleList = this.articleService.getArticleByBanner(banner.getBannerid());
|
||||
banner.setArticleList(articleList);
|
||||
frontList.add(banner);
|
||||
}
|
||||
this.getRequest().setAttribute("frontList", frontList);
|
||||
List<Article> topList = this.articleService.getTopArticle();
|
||||
List<Article> favList = this.articleService.getFlvArticle();
|
||||
this.getRequest().setAttribute("topList", topList);
|
||||
this.getRequest().setAttribute("favList", favList);
|
||||
return "users/index";
|
||||
}
|
||||
|
||||
// 新闻公告
|
||||
@RequestMapping("article.action")
|
||||
public String article(String id, String number) {
|
||||
this.front();
|
||||
Article article = new Article();
|
||||
article.setBannerid(id);
|
||||
List<Article> articleList = this.articleService.getArticleByCond(article);
|
||||
PageHelper.getIndexPage(articleList, "article", "article", id, 10, number, this.getRequest());
|
||||
Banner banner = this.bannerService.getBannerById(id);
|
||||
this.getRequest().setAttribute("banner", banner);
|
||||
return "users/article";
|
||||
}
|
||||
|
||||
// 阅读公告
|
||||
@RequestMapping("read.action")
|
||||
public String read(String id) {
|
||||
this.front();
|
||||
Article article = this.articleService.getArticleById(id);
|
||||
article.setHits("" + (Integer.parseInt(article.getHits()) + 1));
|
||||
this.articleService.updateArticle(article);
|
||||
this.getRequest().setAttribute("article", article);
|
||||
Topic topic = new Topic();
|
||||
topic.setArticleid(id);
|
||||
List<Topic> topicList = this.topicService.getTopicByCond(topic);
|
||||
this.getRequest().setAttribute("topicList", topicList);
|
||||
this.getRequest().setAttribute("tnum", topicList.size());
|
||||
return "users/read";
|
||||
}
|
||||
|
||||
// 准备登录
|
||||
@RequestMapping("preLogin.action")
|
||||
public String prelogin() {
|
||||
this.front();
|
||||
return "users/login";
|
||||
}
|
||||
|
||||
// 用户登录
|
||||
@RequestMapping("login.action")
|
||||
public String login() {
|
||||
this.front();
|
||||
String username = this.getRequest().getParameter("username");
|
||||
String password = this.getRequest().getParameter("password");
|
||||
Users u = new Users();
|
||||
u.setUsername(username);
|
||||
List<Users> usersList = this.usersService.getUsersByCond(u);
|
||||
if (usersList.size() == 0) {
|
||||
this.getSession().setAttribute("message", "用户名不存在");
|
||||
return "redirect:/index/preLogin.action";
|
||||
} else {
|
||||
Users users = usersList.get(0);
|
||||
if (password.equals(users.getPassword())) {
|
||||
this.getSession().setAttribute("userid", users.getUsersid());
|
||||
this.getSession().setAttribute("username", users.getUsername());
|
||||
this.getSession().setAttribute("users", users);
|
||||
return "redirect:/index/index.action";
|
||||
} else {
|
||||
this.getSession().setAttribute("message", "密码错误");
|
||||
return "redirect:/index/preLogin.action";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 准备注册
|
||||
@RequestMapping("preReg.action")
|
||||
public String preReg() {
|
||||
this.front();
|
||||
List<Asks> asksList = this.asksService.getAllAsks();
|
||||
this.getRequest().setAttribute("asksList", asksList);
|
||||
return "users/register";
|
||||
}
|
||||
|
||||
// 用户注册
|
||||
@RequestMapping("register.action")
|
||||
public String register(Users users) {
|
||||
this.front();
|
||||
Users u = new Users();
|
||||
u.setUsername(users.getUsername());
|
||||
List<Users> usersList = this.usersService.getUsersByCond(u);
|
||||
if (usersList.size() == 0) {
|
||||
users.setRegdate(VeDate.getStringDateShort());
|
||||
this.usersService.insertUsers(users);
|
||||
} else {
|
||||
this.getSession().setAttribute("message", "用户名已存在");
|
||||
return "redirect:/index/preReg.action";
|
||||
}
|
||||
|
||||
return "redirect:/index/preLogin.action";
|
||||
}
|
||||
|
||||
// 退出登录
|
||||
@RequestMapping("exit.action")
|
||||
public String exit() {
|
||||
this.front();
|
||||
this.getSession().removeAttribute("userid");
|
||||
this.getSession().removeAttribute("username");
|
||||
this.getSession().removeAttribute("users");
|
||||
return "redirect:/index/index.action";
|
||||
}
|
||||
|
||||
// 准备修改密码
|
||||
@RequestMapping("prePwd.action")
|
||||
public String prePwd() {
|
||||
this.front();
|
||||
if (this.getSession().getAttribute("userid") == null) {
|
||||
return "redirect:/index/preLogin.action";
|
||||
}
|
||||
return "users/editpwd";
|
||||
}
|
||||
|
||||
// 修改密码
|
||||
@RequestMapping("editpwd.action")
|
||||
public String editpwd() {
|
||||
this.front();
|
||||
if (this.getSession().getAttribute("userid") == null) {
|
||||
return "redirect:/index/preLogin.action";
|
||||
}
|
||||
String userid = (String) this.getSession().getAttribute("userid");
|
||||
String password = this.getRequest().getParameter("password");
|
||||
String repassword = this.getRequest().getParameter("repassword");
|
||||
Users users = this.usersService.getUsersById(userid);
|
||||
if (password.equals(users.getPassword())) {
|
||||
users.setPassword(repassword);
|
||||
this.usersService.updateUsers(users);
|
||||
} else {
|
||||
this.getSession().setAttribute("message", "旧密码错误");
|
||||
return "redirect:/index/prePwd.action";
|
||||
}
|
||||
this.getSession().setAttribute("message", "修改成功");
|
||||
return "redirect:/index/prePwd.action";
|
||||
}
|
||||
|
||||
@RequestMapping("forget.action")
|
||||
public String forget() {
|
||||
this.front();
|
||||
return "users/forget";
|
||||
}
|
||||
|
||||
@RequestMapping("step1.action")
|
||||
public String step1() {
|
||||
this.front();
|
||||
String username = this.getRequest().getParameter("username");
|
||||
Users u = new Users();
|
||||
u.setUsername(username);
|
||||
List<Users> usersList = this.usersService.getUsersByCond(u);
|
||||
if (usersList.size() == 0) {
|
||||
this.getSession().setAttribute("message", "用户名不存在");
|
||||
return "redirect:/index/preLogin.action";
|
||||
} else {
|
||||
Users x = usersList.get(0);
|
||||
String questions = x.getAsks().getQuestion();
|
||||
this.getRequest().setAttribute("questions", questions);
|
||||
this.getRequest().setAttribute("username", username);
|
||||
this.getRequest().setAttribute("userid", x.getUsersid());
|
||||
}
|
||||
return "users/step1";
|
||||
}
|
||||
|
||||
@RequestMapping("step2.action")
|
||||
public String step2() {
|
||||
this.front();
|
||||
String userid = this.getRequest().getParameter("userid");
|
||||
String answer = this.getRequest().getParameter("answer");
|
||||
Users u = this.usersService.getUsersById(userid);
|
||||
if (u.getAnswer().equals(answer)) {
|
||||
this.getRequest().setAttribute("userid", userid);
|
||||
this.getRequest().setAttribute("username", u.getUsername());
|
||||
} else {
|
||||
this.getSession().setAttribute("message", "答案错误");
|
||||
return "redirect:/index/preLogin.action";
|
||||
}
|
||||
return "users/step2";
|
||||
}
|
||||
|
||||
@RequestMapping("updatePwd.action")
|
||||
public String updatePwd() {
|
||||
this.front();
|
||||
String userid = this.getRequest().getParameter("userid");
|
||||
String password = this.getRequest().getParameter("repassword");
|
||||
Users u = this.usersService.getUsersById(userid);
|
||||
u.setPassword(password);
|
||||
this.usersService.updateUsers(u);
|
||||
this.getSession().setAttribute("message", "密码已重置");
|
||||
return "redirect:/index/preLogin.action";
|
||||
}
|
||||
|
||||
@RequestMapping("usercenter.action")
|
||||
public String usercenter() {
|
||||
this.front();
|
||||
if (this.getSession().getAttribute("userid") == null) {
|
||||
return "redirect:/index/preLogin.action";
|
||||
}
|
||||
return "users/usercenter";
|
||||
}
|
||||
|
||||
@RequestMapping("userinfo.action")
|
||||
public String userinfo() {
|
||||
this.front();
|
||||
if (this.getSession().getAttribute("userid") == null) {
|
||||
return "redirect:/index/preLogin.action";
|
||||
}
|
||||
String userid = (String) this.getSession().getAttribute("userid");
|
||||
this.getSession().setAttribute("users", this.usersService.getUsersById(userid));
|
||||
return "users/userinfo";
|
||||
}
|
||||
|
||||
@RequestMapping("personal.action")
|
||||
public String personal(Users users) {
|
||||
this.front();
|
||||
if (this.getSession().getAttribute("userid") == null) {
|
||||
return "redirect:/index/preLogin.action";
|
||||
}
|
||||
this.usersService.updateUsers(users);
|
||||
this.getSession().setAttribute("message", "修改成功");
|
||||
return "redirect:/index/userinfo.action";
|
||||
}
|
||||
|
||||
@RequestMapping("preComplains.action")
|
||||
public String preComplains() {
|
||||
this.front();
|
||||
if (this.getSession().getAttribute("userid") == null) {
|
||||
return "redirect:/index/preLogin.action";
|
||||
}
|
||||
return "users/addComplains";
|
||||
}
|
||||
|
||||
@RequestMapping("addComplains.action")
|
||||
public String addComplains(Complains complains) {
|
||||
this.front();
|
||||
if (this.getSession().getAttribute("userid") == null) {
|
||||
return "redirect:/index/preLogin.action";
|
||||
}
|
||||
String userid = (String) this.getSession().getAttribute("userid");
|
||||
complains.setAddtime(VeDate.getStringDateShort());
|
||||
complains.setStatus("未回复");
|
||||
complains.setUsersid(userid);
|
||||
this.complainsService.insertComplains(complains);
|
||||
return "redirect:/index/preComplains.action";
|
||||
}
|
||||
|
||||
@RequestMapping("myComplains.action")
|
||||
public String myComplains(String number) {
|
||||
this.front();
|
||||
if (this.getSession().getAttribute("userid") == null) {
|
||||
return "redirect:/index/preLogin.action";
|
||||
}
|
||||
String userid = (String) this.getSession().getAttribute("userid");
|
||||
Complains complains = new Complains();
|
||||
complains.setUsersid(userid);
|
||||
List<Complains> complainsList = this.complainsService.getComplainsByCond(complains);
|
||||
PageHelper.getIndexPage(complainsList, "complains", "myComplains", null, 10, number, this.getRequest());
|
||||
return "users/myComplains";
|
||||
}
|
||||
|
||||
@RequestMapping("addTopic.action")
|
||||
public String addTopic(Topic topic) {
|
||||
this.front();
|
||||
if (this.getSession().getAttribute("userid") == null) {
|
||||
return "redirect:/index/preLogin.action";
|
||||
}
|
||||
String userid = (String) this.getSession().getAttribute("userid");
|
||||
topic.setAddtime(VeDate.getStringDateShort());
|
||||
topic.setUsersid(userid);
|
||||
this.topicService.insertTopic(topic);
|
||||
return "redirect:/index/read.action?id=" + topic.getArticleid();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "addfav.action", produces = "text/plain;charset=utf-8")
|
||||
@ResponseBody
|
||||
public String addfav(String id) {
|
||||
this.front();
|
||||
JSONObject json = new JSONObject();
|
||||
if (this.getSession().getAttribute("userid") == null) {
|
||||
json.put("status", "login");
|
||||
json.put("message", "请登录");
|
||||
System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
String userid = (String) this.getSession().getAttribute("userid");
|
||||
Fav fav = new Fav();
|
||||
fav.setArticleid(id);
|
||||
fav.setUsersid(userid);
|
||||
List<Fav> favList = this.favService.getFavByCond(fav);
|
||||
if (favList.size() == 0) {
|
||||
fav.setAddtime(VeDate.getStringDateShort());
|
||||
this.favService.insertFav(fav);
|
||||
json.put("status", "success");
|
||||
json.put("message", "收藏成功");
|
||||
} else {
|
||||
json.put("status", "fail");
|
||||
json.put("message", "收藏失败");
|
||||
}
|
||||
System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
@RequestMapping("myFav.action")
|
||||
public String myFav(String number) {
|
||||
this.front();
|
||||
if (this.getSession().getAttribute("userid") == null) {
|
||||
return "redirect:/index/preLogin.action";
|
||||
}
|
||||
String userid = (String) this.getSession().getAttribute("userid");
|
||||
Fav fav = new Fav();
|
||||
fav.setUsersid(userid);
|
||||
List<Fav> favList = this.favService.getFavByCond(fav);
|
||||
PageHelper.getIndexPage(favList, "fav", "myFav", null, 10, number, this.getRequest());
|
||||
return "users/myFav";
|
||||
}
|
||||
|
||||
@RequestMapping("deleteFav.action")
|
||||
public String deleteFav(String id) {
|
||||
this.front();
|
||||
if (this.getSession().getAttribute("userid") == null) {
|
||||
return "redirect:/index/preLogin.action";
|
||||
}
|
||||
this.favService.deleteFav(id);
|
||||
return "redirect:/index/myFav.action";
|
||||
}
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
}
|
@ -0,0 +1,178 @@
|
||||
package com.controller;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.entity.Topic;
|
||||
import com.service.TopicService;
|
||||
import com.entity.Users;
|
||||
import com.entity.Article;
|
||||
import com.service.UsersService;
|
||||
import com.service.ArticleService;
|
||||
import com.util.PageHelper;
|
||||
import com.util.VeDate;
|
||||
//定义为控制器
|
||||
@Controller
|
||||
// 设置路径
|
||||
@RequestMapping(value = "/topic" , produces = "text/plain;charset=utf-8")
|
||||
public class TopicController extends BaseController {
|
||||
// @Autowired的作用是自动注入依赖的ServiceBean
|
||||
@Autowired
|
||||
private TopicService topicService;
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
@Autowired
|
||||
private ArticleService articleService;
|
||||
|
||||
// 准备添加数据
|
||||
@RequestMapping("createTopic.action")
|
||||
public String createTopic() {
|
||||
List<Users> usersList = this.usersService.getAllUsers();
|
||||
this.getRequest().setAttribute("usersList", usersList);
|
||||
List<Article> articleList = this.articleService.getAllArticle();
|
||||
this.getRequest().setAttribute("articleList", articleList);
|
||||
return "admin/addtopic";
|
||||
}
|
||||
// 添加数据
|
||||
@RequestMapping("addTopic.action")
|
||||
public String addTopic(Topic topic) {
|
||||
topic.setAddtime(VeDate.getStringDateShort());
|
||||
this.topicService.insertTopic(topic);
|
||||
return "redirect:/topic/createTopic.action";
|
||||
}
|
||||
|
||||
// AJAX添加数据
|
||||
@RequestMapping("xaddTopic.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xaddTopic(Topic topic) {
|
||||
topic.setAddtime(VeDate.getStringDateShort());
|
||||
int x = this.topicService.insertTopic(topic);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
// 通过主键删除数据
|
||||
@RequestMapping("deleteTopic.action")
|
||||
public String deleteTopic(String id) {
|
||||
this.topicService.deleteTopic(id);
|
||||
return "redirect:/topic/getAllTopic.action";
|
||||
}
|
||||
|
||||
// AJAX通过主键删除数据
|
||||
@RequestMapping("xdeleteTopic.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xdeleteTopic(String id) {
|
||||
int x = this.topicService.deleteTopic(id);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
// 批量删除数据
|
||||
@RequestMapping("deleteTopicByIds.action")
|
||||
public String deleteTopicByIds() {
|
||||
String[] ids = this.getRequest().getParameterValues("topicid");
|
||||
if (ids != null) {
|
||||
for (String topicid : ids) {
|
||||
this.topicService.deleteTopic(topicid);
|
||||
}
|
||||
}
|
||||
return "redirect:/topic/getAllTopic.action";
|
||||
}
|
||||
|
||||
// 更新数据
|
||||
@RequestMapping("updateTopic.action")
|
||||
public String updateTopic(Topic topic) {
|
||||
this.topicService.updateTopic(topic);
|
||||
return "redirect:/topic/getAllTopic.action";
|
||||
}
|
||||
|
||||
// AJAX更新数据
|
||||
@RequestMapping("xupdateTopic.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xupdateTopic(Topic topic) {
|
||||
int x = this.topicService.updateTopic(topic);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
// 显示全部数据
|
||||
@RequestMapping("getAllTopic.action")
|
||||
public String getAllTopic(String number) {
|
||||
List<Topic> topicList = this.topicService.getAllTopic();
|
||||
PageHelper.getUserPage(topicList, "topic", "getAllTopic", 10, number, this.getRequest());
|
||||
return "admin/listtopic";
|
||||
}
|
||||
|
||||
// AJAX显示全部数据
|
||||
@RequestMapping(value = "getDataList.action", produces = "application/json; charset=utf-8")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public Map<String, Object> getDataList(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer limit) {
|
||||
// 定义一个Map对象 用来返回数据
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Page<Topic> pager = com.github.pagehelper.PageHelper.startPage(page, limit);// 定义当前页和分页条数
|
||||
List<Topic> list = this.topicService.getAllTopic();
|
||||
// 返回的map中定义Layui的数据格式
|
||||
map.put("count", pager.getTotal());
|
||||
map.put("data", list);
|
||||
map.put("code", 0);
|
||||
map.put("msg", "");
|
||||
return map;
|
||||
}
|
||||
|
||||
// 按条件查询数据 (模糊查询)
|
||||
@RequestMapping("queryTopicByCond.action")
|
||||
public String queryTopicByCond(String cond, String name, String number) {
|
||||
Topic topic = new Topic();
|
||||
if(cond != null){
|
||||
if ("usersid".equals(cond)) {
|
||||
topic.setUsersid(name);
|
||||
}
|
||||
if ("articleid".equals(cond)) {
|
||||
topic.setArticleid(name);
|
||||
}
|
||||
if ("contents".equals(cond)) {
|
||||
topic.setContents(name);
|
||||
}
|
||||
if ("addtime".equals(cond)) {
|
||||
topic.setAddtime(name);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> nameList = new ArrayList<String>();
|
||||
List<String> valueList = new ArrayList<String>();
|
||||
nameList.add(cond);
|
||||
valueList.add(name);
|
||||
PageHelper.getPage(this.topicService.getTopicByLike(topic), "topic", nameList, valueList, 10, number, this.getRequest(), "query");
|
||||
name = null;
|
||||
cond = null;
|
||||
return "admin/querytopic";
|
||||
}
|
||||
|
||||
// 按主键查询数据
|
||||
@RequestMapping("getTopicById.action")
|
||||
public String getTopicById(String id) {
|
||||
Topic topic = this.topicService.getTopicById(id);
|
||||
this.getRequest().setAttribute("topic", topic);
|
||||
List<Users> usersList = this.usersService.getAllUsers();
|
||||
this.getRequest().setAttribute("usersList", usersList);
|
||||
List<Article> articleList = this.articleService.getAllArticle();
|
||||
this.getRequest().setAttribute("articleList", articleList);
|
||||
return "admin/edittopic";
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package com.controller;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.util.VeDate;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/upload")
|
||||
public class UploadController extends BaseController {
|
||||
|
||||
@RequestMapping("preUpload.action")
|
||||
public String preUpload() {
|
||||
return "page/saveimage";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/image.action")
|
||||
public String upload(@RequestParam(value = "image", required = false) MultipartFile file,
|
||||
HttpServletRequest request, ModelMap model) {
|
||||
String path = request.getSession().getServletContext().getRealPath("/") + "upfiles/";
|
||||
String fileName = file.getOriginalFilename();
|
||||
int i = fileName.lastIndexOf(".");
|
||||
String name = String.valueOf(VeDate.getStringDatex());
|
||||
String type = fileName.substring(i + 1);
|
||||
fileName = name + "." + type;
|
||||
File targetFile = new File(path, fileName);
|
||||
if (!targetFile.exists()) {
|
||||
targetFile.mkdirs();
|
||||
}
|
||||
|
||||
// 保存
|
||||
try {
|
||||
file.transferTo(targetFile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
model.addAttribute("imageFileName", fileName);
|
||||
return "page/saveimage";
|
||||
}
|
||||
|
||||
@RequestMapping("preFile.action")
|
||||
public String preFile() {
|
||||
return "page/savefile";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/files.action")
|
||||
public String files(@RequestParam(value = "image", required = false) MultipartFile file, HttpServletRequest request,
|
||||
ModelMap model) {
|
||||
String path = request.getSession().getServletContext().getRealPath("/") + "upfiles/";
|
||||
String fileName = file.getOriginalFilename();
|
||||
int i = fileName.lastIndexOf(".");
|
||||
String name = String.valueOf(VeDate.getStringDatex());
|
||||
String type = fileName.substring(i + 1);
|
||||
fileName = name + "." + type;
|
||||
File targetFile = new File(path, fileName);
|
||||
if (!targetFile.exists()) {
|
||||
targetFile.mkdirs();
|
||||
}
|
||||
|
||||
// 保存
|
||||
try {
|
||||
file.transferTo(targetFile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
model.addAttribute("imageFileName", fileName);
|
||||
return "page/savefile";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,171 @@
|
||||
package com.controller;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.entity.Users;
|
||||
import com.service.UsersService;
|
||||
import com.util.PageHelper;
|
||||
import com.util.VeDate;
|
||||
//定义为控制器
|
||||
@Controller
|
||||
// 设置路径
|
||||
@RequestMapping(value = "/users" , produces = "text/plain;charset=utf-8")
|
||||
public class UsersController extends BaseController {
|
||||
// @Autowired的作用是自动注入依赖的ServiceBean
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
|
||||
// 准备添加数据
|
||||
@RequestMapping("createUsers.action")
|
||||
public String createUsers() {
|
||||
return "admin/addusers";
|
||||
}
|
||||
// 添加数据
|
||||
@RequestMapping("addUsers.action")
|
||||
public String addUsers(Users users) {
|
||||
users.setRegdate(VeDate.getStringDateShort());
|
||||
this.usersService.insertUsers(users);
|
||||
return "redirect:/users/createUsers.action";
|
||||
}
|
||||
|
||||
// AJAX添加数据
|
||||
@RequestMapping("xaddUsers.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xaddUsers(Users users) {
|
||||
users.setRegdate(VeDate.getStringDateShort());
|
||||
int x = this.usersService.insertUsers(users);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
// 通过主键删除数据
|
||||
@RequestMapping("deleteUsers.action")
|
||||
public String deleteUsers(String id) {
|
||||
this.usersService.deleteUsers(id);
|
||||
return "redirect:/users/getAllUsers.action";
|
||||
}
|
||||
|
||||
// AJAX通过主键删除数据
|
||||
@RequestMapping("xdeleteUsers.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xdeleteUsers(String id) {
|
||||
int x = this.usersService.deleteUsers(id);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
// 批量删除数据
|
||||
@RequestMapping("deleteUsersByIds.action")
|
||||
public String deleteUsersByIds() {
|
||||
String[] ids = this.getRequest().getParameterValues("usersid");
|
||||
if (ids != null) {
|
||||
for (String usersid : ids) {
|
||||
this.usersService.deleteUsers(usersid);
|
||||
}
|
||||
}
|
||||
return "redirect:/users/getAllUsers.action";
|
||||
}
|
||||
|
||||
// 更新数据
|
||||
@RequestMapping("updateUsers.action")
|
||||
public String updateUsers(Users users) {
|
||||
this.usersService.updateUsers(users);
|
||||
return "redirect:/users/getAllUsers.action";
|
||||
}
|
||||
|
||||
// AJAX更新数据
|
||||
@RequestMapping("xupdateUsers.action")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public String xupdateUsers(Users users) {
|
||||
int x = this.usersService.updateUsers(users);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("result", x);
|
||||
//System.out.println(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
// 显示全部数据
|
||||
@RequestMapping("getAllUsers.action")
|
||||
public String getAllUsers(String number) {
|
||||
List<Users> usersList = this.usersService.getAllUsers();
|
||||
PageHelper.getUserPage(usersList, "users", "getAllUsers", 10, number, this.getRequest());
|
||||
return "admin/listusers";
|
||||
}
|
||||
|
||||
// AJAX显示全部数据
|
||||
@RequestMapping(value = "getDataList.action", produces = "application/json; charset=utf-8")
|
||||
@ResponseBody //将java对象转为json格式的数据
|
||||
public Map<String, Object> getDataList(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer limit) {
|
||||
// 定义一个Map对象 用来返回数据
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Page<Users> pager = com.github.pagehelper.PageHelper.startPage(page, limit);// 定义当前页和分页条数
|
||||
List<Users> list = this.usersService.getAllUsers();
|
||||
// 返回的map中定义Layui的数据格式
|
||||
map.put("count", pager.getTotal());
|
||||
map.put("data", list);
|
||||
map.put("code", 0);
|
||||
map.put("msg", "");
|
||||
return map;
|
||||
}
|
||||
|
||||
// 按条件查询数据 (模糊查询)
|
||||
@RequestMapping("queryUsersByCond.action")
|
||||
public String queryUsersByCond(String cond, String name, String number) {
|
||||
Users users = new Users();
|
||||
if(cond != null){
|
||||
if ("username".equals(cond)) {
|
||||
users.setUsername(name);
|
||||
}
|
||||
if ("password".equals(cond)) {
|
||||
users.setPassword(name);
|
||||
}
|
||||
if ("realname".equals(cond)) {
|
||||
users.setRealname(name);
|
||||
}
|
||||
if ("sex".equals(cond)) {
|
||||
users.setSex(name);
|
||||
}
|
||||
if ("birthday".equals(cond)) {
|
||||
users.setBirthday(name);
|
||||
}
|
||||
if ("contact".equals(cond)) {
|
||||
users.setContact(name);
|
||||
}
|
||||
if ("regdate".equals(cond)) {
|
||||
users.setRegdate(name);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> nameList = new ArrayList<String>();
|
||||
List<String> valueList = new ArrayList<String>();
|
||||
nameList.add(cond);
|
||||
valueList.add(name);
|
||||
PageHelper.getPage(this.usersService.getUsersByLike(users), "users", nameList, valueList, 10, number, this.getRequest(), "query");
|
||||
name = null;
|
||||
cond = null;
|
||||
return "admin/queryusers";
|
||||
}
|
||||
|
||||
// 按主键查询数据
|
||||
@RequestMapping("getUsersById.action")
|
||||
public String getUsersById(String id) {
|
||||
Users users = this.usersService.getUsersById(id);
|
||||
this.getRequest().setAttribute("users", users);
|
||||
return "admin/editusers";
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.dao;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import com.entity.Admin;
|
||||
|
||||
@Repository("adminDAO") // Repository标签定义数据库连接的访问 Spring中直接扫描加载
|
||||
@Mapper // 不需要在spring配置中设置扫描地址 spring将动态的生成Bean后注入到AdminServiceImpl中
|
||||
public interface AdminDAO {
|
||||
|
||||
/**
|
||||
* AdminDAO 接口 可以按名称直接调用admin.xml配置文件的SQL语句
|
||||
*/
|
||||
|
||||
// 插入管理员表数据 调用mapper包admin.xml里的insertAdmin配置 返回值0(失败),1(成功)
|
||||
public int insertAdmin(Admin admin);
|
||||
|
||||
// 更新管理员表数据 调用mapper包admin.xml里的updateAdmin配置 返回值0(失败),1(成功)
|
||||
public int updateAdmin(Admin admin);
|
||||
|
||||
// 按主键删除管理员表数据 调用mapper包admin.xml里的deleteAdmin配置 返回值0(失败),1(成功)
|
||||
public int deleteAdmin(String adminid);
|
||||
|
||||
// 批量删除管理员表数据 调用mapper包admin.xml里的deleteAdminByIds配置 返回值0(失败),大于0(成功)
|
||||
public int deleteAdminByIds(String[] ids);
|
||||
|
||||
// 查询管理员表全部数据 调用mapper包admin.xml里的getAllAdmin配置 返回List<Admin>类型的数据
|
||||
public List<Admin> getAllAdmin();
|
||||
|
||||
// 按照Admin类里面的值精确查询 调用mapper包admin.xml里的getAdminByCond配置 返回List<Admin>类型的数据
|
||||
public List<Admin> getAdminByCond(Admin admin);
|
||||
|
||||
// 按照Admin类里面的值模糊查询 调用mapper包admin.xml里的getAdminByLike配置 返回List<Admin>类型的数据
|
||||
public List<Admin> getAdminByLike(Admin admin);
|
||||
|
||||
// 按主键查询管理员表返回单一的Admin实例 调用mapper包admin.xml里的getAdminById配置
|
||||
public Admin getAdminById(String adminid);
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,43 @@
|
||||
package com.dao;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import com.entity.Article;
|
||||
|
||||
@Repository("articleDAO") // Repository标签定义数据库连接的访问 Spring中直接
|
||||
@Mapper
|
||||
public interface ArticleDAO {
|
||||
|
||||
/**
|
||||
* ArticleDAO 接口 可以按名称直接调用article.xml配置文件的SQL语句
|
||||
*/
|
||||
|
||||
// 插入数据 调用entity包article.xml里的insertArticle配置 返回值0(失败),1(成功)
|
||||
public int insertArticle(Article article);
|
||||
|
||||
// 更新数据 调用entity包article.xml里的updateArticle配置 返回值0(失败),1(成功)
|
||||
public int updateArticle(Article article);
|
||||
|
||||
// 删除数据 调用entity包article.xml里的deleteArticle配置 返回值0(失败),1(成功)
|
||||
public int deleteArticle(String articleid);
|
||||
|
||||
// 查询全部数据 调用entity包article.xml里的getAllArticle配置 返回List类型的数据
|
||||
public List<Article> getAllArticle();
|
||||
|
||||
public List<Article> getFlvArticle();
|
||||
|
||||
public List<Article> getTopArticle();
|
||||
|
||||
public List<Article> getArticleByBanner(String bannerid);
|
||||
|
||||
// 按照Article类里面的值精确查询 调用entity包article.xml里的getArticleByCond配置 返回List类型的数据
|
||||
public List<Article> getArticleByCond(Article article);
|
||||
|
||||
// 按照Article类里面的值模糊查询 调用entity包article.xml里的getArticleByLike配置 返回List类型的数据
|
||||
public List<Article> getArticleByLike(Article article);
|
||||
|
||||
// 按主键查询表返回单一的Article实例 调用entity包article.xml里的getArticleById配置
|
||||
public Article getArticleById(String articleid);
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.dao;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import com.entity.Asks;
|
||||
|
||||
@Repository("asksDAO") // Repository标签定义数据库连接的访问 Spring中直接扫描加载
|
||||
@Mapper // 不需要在spring配置中设置扫描地址 spring将动态的生成Bean后注入到AsksServiceImpl中
|
||||
public interface AsksDAO {
|
||||
|
||||
/**
|
||||
* AsksDAO 接口 可以按名称直接调用asks.xml配置文件的SQL语句
|
||||
*/
|
||||
|
||||
// 插入提示问题表数据 调用mapper包asks.xml里的insertAsks配置 返回值0(失败),1(成功)
|
||||
public int insertAsks(Asks asks);
|
||||
|
||||
// 更新提示问题表数据 调用mapper包asks.xml里的updateAsks配置 返回值0(失败),1(成功)
|
||||
public int updateAsks(Asks asks);
|
||||
|
||||
// 按主键删除提示问题表数据 调用mapper包asks.xml里的deleteAsks配置 返回值0(失败),1(成功)
|
||||
public int deleteAsks(String asksid);
|
||||
|
||||
// 批量删除提示问题表数据 调用mapper包asks.xml里的deleteAsksByIds配置 返回值0(失败),大于0(成功)
|
||||
public int deleteAsksByIds(String[] ids);
|
||||
|
||||
// 查询提示问题表全部数据 调用mapper包asks.xml里的getAllAsks配置 返回List<Asks>类型的数据
|
||||
public List<Asks> getAllAsks();
|
||||
|
||||
// 按照Asks类里面的值精确查询 调用mapper包asks.xml里的getAsksByCond配置 返回List<Asks>类型的数据
|
||||
public List<Asks> getAsksByCond(Asks asks);
|
||||
|
||||
// 按照Asks类里面的值模糊查询 调用mapper包asks.xml里的getAsksByLike配置 返回List<Asks>类型的数据
|
||||
public List<Asks> getAsksByLike(Asks asks);
|
||||
|
||||
// 按主键查询提示问题表返回单一的Asks实例 调用mapper包asks.xml里的getAsksById配置
|
||||
public Asks getAsksById(String asksid);
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,38 @@
|
||||
package com.dao;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import com.entity.Banner;
|
||||
|
||||
@Repository("bannerDAO") // Repository标签定义数据库连接的访问 Spring中直接
|
||||
@Mapper
|
||||
public interface BannerDAO {
|
||||
|
||||
/**
|
||||
* BannerDAO 接口 可以按名称直接调用banner.xml配置文件的SQL语句
|
||||
*/
|
||||
|
||||
// 插入数据 调用entity包banner.xml里的insertBanner配置 返回值0(失败),1(成功)
|
||||
public int insertBanner(Banner banner);
|
||||
|
||||
// 更新数据 调用entity包banner.xml里的updateBanner配置 返回值0(失败),1(成功)
|
||||
public int updateBanner(Banner banner);
|
||||
|
||||
// 删除数据 调用entity包banner.xml里的deleteBanner配置 返回值0(失败),1(成功)
|
||||
public int deleteBanner(String bannerid);
|
||||
|
||||
// 查询全部数据 调用entity包banner.xml里的getAllBanner配置 返回List类型的数据
|
||||
public List<Banner> getAllBanner();
|
||||
|
||||
// 按照Banner类里面的值精确查询 调用entity包banner.xml里的getBannerByCond配置 返回List类型的数据
|
||||
public List<Banner> getBannerByCond(Banner banner);
|
||||
|
||||
// 按照Banner类里面的值模糊查询 调用entity包banner.xml里的getBannerByLike配置 返回List类型的数据
|
||||
public List<Banner> getBannerByLike(Banner banner);
|
||||
|
||||
// 按主键查询表返回单一的Banner实例 调用entity包banner.xml里的getBannerById配置
|
||||
public Banner getBannerById(String bannerid);
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,41 @@
|
||||
package com.dao;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import com.entity.Complains;
|
||||
|
||||
@Repository("complainsDAO") // Repository标签定义数据库连接的访问 Spring中直接扫描加载
|
||||
@Mapper // 不需要在spring配置中设置扫描地址 spring将动态的生成Bean后注入到ComplainsServiceImpl中
|
||||
public interface ComplainsDAO {
|
||||
|
||||
/**
|
||||
* ComplainsDAO 接口 可以按名称直接调用complains.xml配置文件的SQL语句
|
||||
*/
|
||||
|
||||
// 插入意见反馈表数据 调用mapper包complains.xml里的insertComplains配置 返回值0(失败),1(成功)
|
||||
public int insertComplains(Complains complains);
|
||||
|
||||
// 更新意见反馈表数据 调用mapper包complains.xml里的updateComplains配置 返回值0(失败),1(成功)
|
||||
public int updateComplains(Complains complains);
|
||||
|
||||
// 按主键删除意见反馈表数据 调用mapper包complains.xml里的deleteComplains配置 返回值0(失败),1(成功)
|
||||
public int deleteComplains(String complainsid);
|
||||
|
||||
// 批量删除意见反馈表数据 调用mapper包complains.xml里的deleteComplainsByIds配置 返回值0(失败),大于0(成功)
|
||||
public int deleteComplainsByIds(String[] ids);
|
||||
|
||||
// 查询意见反馈表全部数据 调用mapper包complains.xml里的getAllComplains配置 返回List<Complains>类型的数据
|
||||
public List<Complains> getAllComplains();
|
||||
|
||||
// 按照Complains类里面的值精确查询 调用mapper包complains.xml里的getComplainsByCond配置 返回List<Complains>类型的数据
|
||||
public List<Complains> getComplainsByCond(Complains complains);
|
||||
|
||||
// 按照Complains类里面的值模糊查询 调用mapper包complains.xml里的getComplainsByLike配置 返回List<Complains>类型的数据
|
||||
public List<Complains> getComplainsByLike(Complains complains);
|
||||
|
||||
// 按主键查询意见反馈表返回单一的Complains实例 调用mapper包complains.xml里的getComplainsById配置
|
||||
public Complains getComplainsById(String complainsid);
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,41 @@
|
||||
package com.dao;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import com.entity.Fav;
|
||||
|
||||
@Repository("favDAO") // Repository标签定义数据库连接的访问 Spring中直接扫描加载
|
||||
@Mapper // 不需要在spring配置中设置扫描地址 spring将动态的生成Bean后注入到FavServiceImpl中
|
||||
public interface FavDAO {
|
||||
|
||||
/**
|
||||
* FavDAO 接口 可以按名称直接调用fav.xml配置文件的SQL语句
|
||||
*/
|
||||
|
||||
// 插入用户收藏表数据 调用mapper包fav.xml里的insertFav配置 返回值0(失败),1(成功)
|
||||
public int insertFav(Fav fav);
|
||||
|
||||
// 更新用户收藏表数据 调用mapper包fav.xml里的updateFav配置 返回值0(失败),1(成功)
|
||||
public int updateFav(Fav fav);
|
||||
|
||||
// 按主键删除用户收藏表数据 调用mapper包fav.xml里的deleteFav配置 返回值0(失败),1(成功)
|
||||
public int deleteFav(String favid);
|
||||
|
||||
// 批量删除用户收藏表数据 调用mapper包fav.xml里的deleteFavByIds配置 返回值0(失败),大于0(成功)
|
||||
public int deleteFavByIds(String[] ids);
|
||||
|
||||
// 查询用户收藏表全部数据 调用mapper包fav.xml里的getAllFav配置 返回List<Fav>类型的数据
|
||||
public List<Fav> getAllFav();
|
||||
|
||||
// 按照Fav类里面的值精确查询 调用mapper包fav.xml里的getFavByCond配置 返回List<Fav>类型的数据
|
||||
public List<Fav> getFavByCond(Fav fav);
|
||||
|
||||
// 按照Fav类里面的值模糊查询 调用mapper包fav.xml里的getFavByLike配置 返回List<Fav>类型的数据
|
||||
public List<Fav> getFavByLike(Fav fav);
|
||||
|
||||
// 按主键查询用户收藏表返回单一的Fav实例 调用mapper包fav.xml里的getFavById配置
|
||||
public Fav getFavById(String favid);
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,41 @@
|
||||
package com.dao;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import com.entity.Topic;
|
||||
|
||||
@Repository("topicDAO") // Repository标签定义数据库连接的访问 Spring中直接扫描加载
|
||||
@Mapper // 不需要在spring配置中设置扫描地址 spring将动态的生成Bean后注入到TopicServiceImpl中
|
||||
public interface TopicDAO {
|
||||
|
||||
/**
|
||||
* TopicDAO 接口 可以按名称直接调用topic.xml配置文件的SQL语句
|
||||
*/
|
||||
|
||||
// 插入用户评论表数据 调用mapper包topic.xml里的insertTopic配置 返回值0(失败),1(成功)
|
||||
public int insertTopic(Topic topic);
|
||||
|
||||
// 更新用户评论表数据 调用mapper包topic.xml里的updateTopic配置 返回值0(失败),1(成功)
|
||||
public int updateTopic(Topic topic);
|
||||
|
||||
// 按主键删除用户评论表数据 调用mapper包topic.xml里的deleteTopic配置 返回值0(失败),1(成功)
|
||||
public int deleteTopic(String topicid);
|
||||
|
||||
// 批量删除用户评论表数据 调用mapper包topic.xml里的deleteTopicByIds配置 返回值0(失败),大于0(成功)
|
||||
public int deleteTopicByIds(String[] ids);
|
||||
|
||||
// 查询用户评论表全部数据 调用mapper包topic.xml里的getAllTopic配置 返回List<Topic>类型的数据
|
||||
public List<Topic> getAllTopic();
|
||||
|
||||
// 按照Topic类里面的值精确查询 调用mapper包topic.xml里的getTopicByCond配置 返回List<Topic>类型的数据
|
||||
public List<Topic> getTopicByCond(Topic topic);
|
||||
|
||||
// 按照Topic类里面的值模糊查询 调用mapper包topic.xml里的getTopicByLike配置 返回List<Topic>类型的数据
|
||||
public List<Topic> getTopicByLike(Topic topic);
|
||||
|
||||
// 按主键查询用户评论表返回单一的Topic实例 调用mapper包topic.xml里的getTopicById配置
|
||||
public Topic getTopicById(String topicid);
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,41 @@
|
||||
package com.dao;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import com.entity.Users;
|
||||
|
||||
@Repository("usersDAO") // Repository标签定义数据库连接的访问 Spring中直接扫描加载
|
||||
@Mapper // 不需要在spring配置中设置扫描地址 spring将动态的生成Bean后注入到UsersServiceImpl中
|
||||
public interface UsersDAO {
|
||||
|
||||
/**
|
||||
* UsersDAO 接口 可以按名称直接调用users.xml配置文件的SQL语句
|
||||
*/
|
||||
|
||||
// 插入网站用户表数据 调用mapper包users.xml里的insertUsers配置 返回值0(失败),1(成功)
|
||||
public int insertUsers(Users users);
|
||||
|
||||
// 更新网站用户表数据 调用mapper包users.xml里的updateUsers配置 返回值0(失败),1(成功)
|
||||
public int updateUsers(Users users);
|
||||
|
||||
// 按主键删除网站用户表数据 调用mapper包users.xml里的deleteUsers配置 返回值0(失败),1(成功)
|
||||
public int deleteUsers(String usersid);
|
||||
|
||||
// 批量删除网站用户表数据 调用mapper包users.xml里的deleteUsersByIds配置 返回值0(失败),大于0(成功)
|
||||
public int deleteUsersByIds(String[] ids);
|
||||
|
||||
// 查询网站用户表全部数据 调用mapper包users.xml里的getAllUsers配置 返回List<Users>类型的数据
|
||||
public List<Users> getAllUsers();
|
||||
|
||||
// 按照Users类里面的值精确查询 调用mapper包users.xml里的getUsersByCond配置 返回List<Users>类型的数据
|
||||
public List<Users> getUsersByCond(Users users);
|
||||
|
||||
// 按照Users类里面的值模糊查询 调用mapper包users.xml里的getUsersByLike配置 返回List<Users>类型的数据
|
||||
public List<Users> getUsersByLike(Users users);
|
||||
|
||||
// 按主键查询网站用户表返回单一的Users实例 调用mapper包users.xml里的getUsersById配置
|
||||
public Users getUsersById(String usersid);
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,89 @@
|
||||
package com.entity;
|
||||
|
||||
import com.util.VeDate;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
// 管理员表的实体类
|
||||
public class Admin {
|
||||
private String adminid = "A"+VeDate.getStringId(); // 生成主键编号
|
||||
private String username; // 用户名
|
||||
private String password; // 密码
|
||||
private String realname; // 姓名
|
||||
private String contact; // 联系方式
|
||||
private String addtime; // 创建日期
|
||||
|
||||
public String getAdminid() {
|
||||
return this.adminid;
|
||||
}
|
||||
|
||||
public void setAdminid(String adminid) {
|
||||
this.adminid = adminid;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getRealname() {
|
||||
return this.realname;
|
||||
}
|
||||
|
||||
public void setRealname(String realname) {
|
||||
this.realname = realname;
|
||||
}
|
||||
|
||||
public String getContact() {
|
||||
return this.contact;
|
||||
}
|
||||
|
||||
public void setContact(String contact) {
|
||||
this.contact = contact;
|
||||
}
|
||||
|
||||
public String getAddtime() {
|
||||
return this.addtime;
|
||||
}
|
||||
|
||||
public void setAddtime(String addtime) {
|
||||
this.addtime = addtime;
|
||||
}
|
||||
|
||||
|
||||
// 重载方法 生成JSON类型字符串
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.toJsonString();
|
||||
}
|
||||
|
||||
//直接转换成JSON字符串
|
||||
private String toJsonString() {
|
||||
JSONObject jsonString = new JSONObject();
|
||||
jsonString.put("adminid", this.adminid); // 主键编号
|
||||
jsonString.put("username", this.username); // 用户名
|
||||
jsonString.put("password", this.password); // 密码
|
||||
jsonString.put("realname", this.realname); // 姓名
|
||||
jsonString.put("contact", this.contact); // 联系方式
|
||||
jsonString.put("addtime", this.addtime); // 创建日期
|
||||
return jsonString.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,105 @@
|
||||
package com.entity;
|
||||
|
||||
import com.util.VeDate;
|
||||
|
||||
public class Article {
|
||||
private String articleid = "A" + VeDate.getStringId();// 生成主键编号
|
||||
private String title;// 标题
|
||||
private String bannerid;// 分类
|
||||
private String image;// 图片
|
||||
private String istop;// 是否置顶
|
||||
private String isflv;// 是否轮播
|
||||
private String contents;// 内容
|
||||
private String addtime;// 发布日期
|
||||
private String hits;// 点击数
|
||||
private String bannername;// 映射数据
|
||||
|
||||
public String getArticleid() {
|
||||
return articleid;
|
||||
}
|
||||
|
||||
public void setArticleid(String articleid) {
|
||||
this.articleid = articleid;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getBannerid() {
|
||||
return this.bannerid;
|
||||
}
|
||||
|
||||
public void setBannerid(String bannerid) {
|
||||
this.bannerid = bannerid;
|
||||
}
|
||||
|
||||
public String getImage() {
|
||||
return this.image;
|
||||
}
|
||||
|
||||
public void setImage(String image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public String getIstop() {
|
||||
return this.istop;
|
||||
}
|
||||
|
||||
public void setIstop(String istop) {
|
||||
this.istop = istop;
|
||||
}
|
||||
|
||||
public String getIsflv() {
|
||||
return this.isflv;
|
||||
}
|
||||
|
||||
public void setIsflv(String isflv) {
|
||||
this.isflv = isflv;
|
||||
}
|
||||
|
||||
public String getContents() {
|
||||
return this.contents;
|
||||
}
|
||||
|
||||
public void setContents(String contents) {
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
public String getAddtime() {
|
||||
return this.addtime;
|
||||
}
|
||||
|
||||
public void setAddtime(String addtime) {
|
||||
this.addtime = addtime;
|
||||
}
|
||||
|
||||
public String getHits() {
|
||||
return this.hits;
|
||||
}
|
||||
|
||||
public void setHits(String hits) {
|
||||
this.hits = hits;
|
||||
}
|
||||
|
||||
public String getBannername() {
|
||||
return this.bannername;
|
||||
}
|
||||
|
||||
public void setBannername(String bannername) {
|
||||
this.bannername = bannername;
|
||||
}
|
||||
|
||||
// 重载方法 生成JSON类型字符串
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Article [articleid=" + this.articleid + ", title=" + this.title + ", bannerid=" + this.bannerid + ", image=" + this.image
|
||||
+ ", istop=" + this.istop + ", isflv=" + this.isflv + ", contents=" + this.contents + ", addtime=" + this.addtime + ", hits="
|
||||
+ this.hits + ", bannername=" + this.bannername + "]";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package com.entity;
|
||||
|
||||
import com.util.VeDate;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
// 提示问题表的实体类
|
||||
public class Asks {
|
||||
private String asksid = "A"+VeDate.getStringId(); // 生成主键编号
|
||||
private String question; // 问题
|
||||
private String addtime; // 创建日期
|
||||
private String memo; // 备注
|
||||
public String getAsksid() {
|
||||
return this.asksid;
|
||||
}
|
||||
|
||||
public void setAsksid(String asksid) {
|
||||
this.asksid = asksid;
|
||||
}
|
||||
|
||||
public String getQuestion() {
|
||||
return this.question;
|
||||
}
|
||||
|
||||
public void setQuestion(String question) {
|
||||
this.question = question;
|
||||
}
|
||||
|
||||
public String getAddtime() {
|
||||
return this.addtime;
|
||||
}
|
||||
|
||||
public void setAddtime(String addtime) {
|
||||
this.addtime = addtime;
|
||||
}
|
||||
|
||||
public String getMemo() {
|
||||
return this.memo;
|
||||
}
|
||||
|
||||
public void setMemo(String memo) {
|
||||
this.memo = memo;
|
||||
}
|
||||
|
||||
|
||||
// 重载方法 生成JSON类型字符串
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.toJsonString();
|
||||
}
|
||||
|
||||
//直接转换成JSON字符串
|
||||
private String toJsonString() {
|
||||
JSONObject jsonString = new JSONObject();
|
||||
jsonString.put("asksid", this.asksid); // 主键编号
|
||||
jsonString.put("question", this.question); // 问题
|
||||
jsonString.put("addtime", this.addtime); // 创建日期
|
||||
jsonString.put("memo", this.memo); // 备注
|
||||
return jsonString.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,62 @@
|
||||
package com.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.util.VeDate;
|
||||
|
||||
public class Banner {
|
||||
private String bannerid = "B" + VeDate.getStringId();// 生成主键编号
|
||||
private String bannername;// 分类名称
|
||||
private String addtime;// 创建日期
|
||||
private String memo;// 备注
|
||||
|
||||
public String getBannerid() {
|
||||
return bannerid;
|
||||
}
|
||||
|
||||
public void setBannerid(String bannerid) {
|
||||
this.bannerid = bannerid;
|
||||
}
|
||||
|
||||
public String getBannername() {
|
||||
return this.bannername;
|
||||
}
|
||||
|
||||
public void setBannername(String bannername) {
|
||||
this.bannername = bannername;
|
||||
}
|
||||
|
||||
public String getAddtime() {
|
||||
return this.addtime;
|
||||
}
|
||||
|
||||
public void setAddtime(String addtime) {
|
||||
this.addtime = addtime;
|
||||
}
|
||||
|
||||
public String getMemo() {
|
||||
return this.memo;
|
||||
}
|
||||
|
||||
public void setMemo(String memo) {
|
||||
this.memo = memo;
|
||||
}
|
||||
|
||||
private List<Article> articleList = new ArrayList<Article>();
|
||||
|
||||
public List<Article> getArticleList() {
|
||||
return articleList;
|
||||
}
|
||||
|
||||
public void setArticleList(List<Article> articleList) {
|
||||
this.articleList = articleList;
|
||||
}
|
||||
|
||||
// 重载方法 生成JSON类型字符串
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Banner [bannerid=" + this.bannerid + ", bannername=" + this.bannername + ", addtime=" + this.addtime + ", memo=" + this.memo
|
||||
+ "]";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
package com.entity;
|
||||
|
||||
import com.util.VeDate;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
// 意见反馈表的实体类
|
||||
public class Complains {
|
||||
private String complainsid = "C"+VeDate.getStringId(); // 生成主键编号
|
||||
private String usersid; // 用户
|
||||
private String title; // 标题
|
||||
private String contents; // 内容
|
||||
private String addtime; // 日期
|
||||
private String status; // 状态
|
||||
private String reps; // 管理员回复
|
||||
private String username; // 映射数据
|
||||
private Users users;// 多对一映射类
|
||||
public String getComplainsid() {
|
||||
return this.complainsid;
|
||||
}
|
||||
|
||||
public void setComplainsid(String complainsid) {
|
||||
this.complainsid = complainsid;
|
||||
}
|
||||
|
||||
public String getUsersid() {
|
||||
return this.usersid;
|
||||
}
|
||||
|
||||
public void setUsersid(String usersid) {
|
||||
this.usersid = usersid;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getContents() {
|
||||
return this.contents;
|
||||
}
|
||||
|
||||
public void setContents(String contents) {
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
public String getAddtime() {
|
||||
return this.addtime;
|
||||
}
|
||||
|
||||
public void setAddtime(String addtime) {
|
||||
this.addtime = addtime;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getReps() {
|
||||
return this.reps;
|
||||
}
|
||||
|
||||
public void setReps(String reps) {
|
||||
this.reps = reps;
|
||||
}
|
||||
|
||||
public Users getUsers() {
|
||||
return this.users;
|
||||
}
|
||||
|
||||
public void setUsers(Users users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
|
||||
// 重载方法 生成JSON类型字符串
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.toJsonString();
|
||||
}
|
||||
|
||||
//直接转换成JSON字符串
|
||||
private String toJsonString() {
|
||||
JSONObject jsonString = new JSONObject();
|
||||
jsonString.put("complainsid", this.complainsid); // 主键编号
|
||||
jsonString.put("usersid", this.usersid); // 用户
|
||||
jsonString.put("title", this.title); // 标题
|
||||
jsonString.put("contents", this.contents); // 内容
|
||||
jsonString.put("addtime", this.addtime); // 日期
|
||||
jsonString.put("status", this.status); // 状态
|
||||
jsonString.put("reps", this.reps); // 管理员回复
|
||||
jsonString.put("Users", this.users); // 多对一映射类
|
||||
jsonString.put("username", this.username); // 映射数据
|
||||
return jsonString.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,109 @@
|
||||
package com.entity;
|
||||
|
||||
import com.util.VeDate;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
// 用户收藏表的实体类
|
||||
public class Fav {
|
||||
private String favid = "F"+VeDate.getStringId(); // 生成主键编号
|
||||
private String usersid; // 用户
|
||||
private String articleid; // 新闻
|
||||
private String addtime; // 收藏日期
|
||||
private String username; // 映射数据
|
||||
private String title; // 映射数据
|
||||
private Users users;// 多对一映射类
|
||||
private Article article;// 多对一映射类
|
||||
|
||||
public String getFavid() {
|
||||
return this.favid;
|
||||
}
|
||||
|
||||
public void setFavid(String favid) {
|
||||
this.favid = favid;
|
||||
}
|
||||
|
||||
public String getUsersid() {
|
||||
return this.usersid;
|
||||
}
|
||||
|
||||
public void setUsersid(String usersid) {
|
||||
this.usersid = usersid;
|
||||
}
|
||||
|
||||
public String getArticleid() {
|
||||
return this.articleid;
|
||||
}
|
||||
|
||||
public void setArticleid(String articleid) {
|
||||
this.articleid = articleid;
|
||||
}
|
||||
|
||||
public String getAddtime() {
|
||||
return this.addtime;
|
||||
}
|
||||
|
||||
public void setAddtime(String addtime) {
|
||||
this.addtime = addtime;
|
||||
}
|
||||
|
||||
public Users getUsers() {
|
||||
return this.users;
|
||||
}
|
||||
|
||||
public void setUsers(Users users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
public Article getArticle() {
|
||||
return this.article;
|
||||
}
|
||||
|
||||
public void setArticle(Article article) {
|
||||
this.article = article;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
|
||||
// 重载方法 生成JSON类型字符串
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.toJsonString();
|
||||
}
|
||||
|
||||
//直接转换成JSON字符串
|
||||
private String toJsonString() {
|
||||
JSONObject jsonString = new JSONObject();
|
||||
jsonString.put("favid", this.favid); // 主键编号
|
||||
jsonString.put("usersid", this.usersid); // 用户
|
||||
jsonString.put("articleid", this.articleid); // 新闻
|
||||
jsonString.put("addtime", this.addtime); // 收藏日期
|
||||
jsonString.put("Users", this.users); // 多对一映射类
|
||||
jsonString.put("Article", this.article); // 多对一映射类
|
||||
jsonString.put("username", this.username); // 映射数据
|
||||
jsonString.put("title", this.title); // 映射数据
|
||||
return jsonString.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,119 @@
|
||||
package com.entity;
|
||||
|
||||
import com.util.VeDate;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
// 用户评论表的实体类
|
||||
public class Topic {
|
||||
private String topicid = "T"+VeDate.getStringId(); // 生成主键编号
|
||||
private String usersid; // 用户
|
||||
private String articleid; // 新闻
|
||||
private String contents; // 内容
|
||||
private String addtime; // 日期
|
||||
private String username; // 映射数据
|
||||
private String title; // 映射数据
|
||||
private Users users;// 多对一映射类
|
||||
private Article article;// 多对一映射类
|
||||
|
||||
public String getTopicid() {
|
||||
return this.topicid;
|
||||
}
|
||||
|
||||
public void setTopicid(String topicid) {
|
||||
this.topicid = topicid;
|
||||
}
|
||||
|
||||
public String getUsersid() {
|
||||
return this.usersid;
|
||||
}
|
||||
|
||||
public void setUsersid(String usersid) {
|
||||
this.usersid = usersid;
|
||||
}
|
||||
|
||||
public String getArticleid() {
|
||||
return this.articleid;
|
||||
}
|
||||
|
||||
public void setArticleid(String articleid) {
|
||||
this.articleid = articleid;
|
||||
}
|
||||
|
||||
public String getContents() {
|
||||
return this.contents;
|
||||
}
|
||||
|
||||
public void setContents(String contents) {
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
public String getAddtime() {
|
||||
return this.addtime;
|
||||
}
|
||||
|
||||
public void setAddtime(String addtime) {
|
||||
this.addtime = addtime;
|
||||
}
|
||||
|
||||
public Users getUsers() {
|
||||
return this.users;
|
||||
}
|
||||
|
||||
public void setUsers(Users users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
public Article getArticle() {
|
||||
return this.article;
|
||||
}
|
||||
|
||||
public void setArticle(Article article) {
|
||||
this.article = article;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
|
||||
// 重载方法 生成JSON类型字符串
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.toJsonString();
|
||||
}
|
||||
|
||||
//直接转换成JSON字符串
|
||||
private String toJsonString() {
|
||||
JSONObject jsonString = new JSONObject();
|
||||
jsonString.put("topicid", this.topicid); // 主键编号
|
||||
jsonString.put("usersid", this.usersid); // 用户
|
||||
jsonString.put("articleid", this.articleid); // 新闻
|
||||
jsonString.put("contents", this.contents); // 内容
|
||||
jsonString.put("addtime", this.addtime); // 日期
|
||||
jsonString.put("Users", this.users); // 多对一映射类
|
||||
jsonString.put("Article", this.article); // 多对一映射类
|
||||
jsonString.put("username", this.username); // 映射数据
|
||||
jsonString.put("title", this.title); // 映射数据
|
||||
return jsonString.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,137 @@
|
||||
package com.entity;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.util.VeDate;
|
||||
|
||||
// 网站用户表的实体类
|
||||
public class Users {
|
||||
private String usersid = "U" + VeDate.getStringId(); // 生成主键编号
|
||||
private String username; // 用户名
|
||||
private String password; // 密码
|
||||
private String realname; // 姓名
|
||||
private String sex; // 性别
|
||||
private String birthday; // 出生日期
|
||||
private String contact; // 联系方式
|
||||
private String regdate; // 注册日期
|
||||
private String asksid; // 提示问题
|
||||
private String answer; // 问题答案
|
||||
private Asks asks;// 多对一映射类
|
||||
private String questions;
|
||||
|
||||
public String getQuestions() {
|
||||
return questions;
|
||||
}
|
||||
|
||||
public void setQuestions(String questions) {
|
||||
this.questions = questions;
|
||||
}
|
||||
|
||||
public String getAsksid() {
|
||||
return asksid;
|
||||
}
|
||||
|
||||
public void setAsksid(String asksid) {
|
||||
this.asksid = asksid;
|
||||
}
|
||||
|
||||
public String getAnswer() {
|
||||
return answer;
|
||||
}
|
||||
|
||||
public void setAnswer(String answer) {
|
||||
this.answer = answer;
|
||||
}
|
||||
|
||||
public Asks getAsks() {
|
||||
return asks;
|
||||
}
|
||||
|
||||
public void setAsks(Asks asks) {
|
||||
this.asks = asks;
|
||||
}
|
||||
|
||||
public String getUsersid() {
|
||||
return this.usersid;
|
||||
}
|
||||
|
||||
public void setUsersid(String usersid) {
|
||||
this.usersid = usersid;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getRealname() {
|
||||
return this.realname;
|
||||
}
|
||||
|
||||
public void setRealname(String realname) {
|
||||
this.realname = realname;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return this.sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getBirthday() {
|
||||
return this.birthday;
|
||||
}
|
||||
|
||||
public void setBirthday(String birthday) {
|
||||
this.birthday = birthday;
|
||||
}
|
||||
|
||||
public String getContact() {
|
||||
return this.contact;
|
||||
}
|
||||
|
||||
public void setContact(String contact) {
|
||||
this.contact = contact;
|
||||
}
|
||||
|
||||
public String getRegdate() {
|
||||
return this.regdate;
|
||||
}
|
||||
|
||||
public void setRegdate(String regdate) {
|
||||
this.regdate = regdate;
|
||||
}
|
||||
|
||||
// 重载方法 生成JSON类型字符串
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.toJsonString();
|
||||
}
|
||||
|
||||
// 直接转换成JSON字符串
|
||||
private String toJsonString() {
|
||||
JSONObject jsonString = new JSONObject();
|
||||
jsonString.put("usersid", this.usersid); // 主键编号
|
||||
jsonString.put("username", this.username); // 用户名
|
||||
jsonString.put("password", this.password); // 密码
|
||||
jsonString.put("realname", this.realname); // 姓名
|
||||
jsonString.put("sex", this.sex); // 性别
|
||||
jsonString.put("birthday", this.birthday); // 出生日期
|
||||
jsonString.put("contact", this.contact); // 联系方式
|
||||
jsonString.put("regdate", this.regdate); // 注册日期
|
||||
return jsonString.toString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.service;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.entity.Article;
|
||||
|
||||
@Service("articleService")
|
||||
public interface ArticleService {
|
||||
// 插入数据 调用articleDAO里的insertArticle配置
|
||||
public int insertArticle(Article article);
|
||||
|
||||
// 更新数据 调用articleDAO里的updateArticle配置
|
||||
public int updateArticle(Article article);
|
||||
|
||||
// 删除数据 调用articleDAO里的deleteArticle配置
|
||||
public int deleteArticle(String articleid);
|
||||
|
||||
// 查询全部数据 调用articleDAO里的getAllArticle配置
|
||||
public List<Article> getAllArticle();
|
||||
|
||||
public List<Article> getFlvArticle();
|
||||
|
||||
public List<Article> getTopArticle();
|
||||
|
||||
public List<Article> getArticleByBanner(String bannerid);
|
||||
|
||||
// 按照Article类里面的字段名称精确查询 调用articleDAO里的getArticleByCond配置
|
||||
public List<Article> getArticleByCond(Article article);
|
||||
|
||||
// 按照Article类里面的字段名称模糊查询 调用articleDAO里的getArticleByLike配置
|
||||
public List<Article> getArticleByLike(Article article);
|
||||
|
||||
// 按主键查询表返回单一的Article实例 调用articleDAO里的getArticleById配置
|
||||
public Article getArticleById(String articleid);
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.service;
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.entity.Banner;
|
||||
@Service("bannerService")
|
||||
public interface BannerService {
|
||||
// 插入数据 调用bannerDAO里的insertBanner配置
|
||||
public int insertBanner(Banner banner);
|
||||
|
||||
// 更新数据 调用bannerDAO里的updateBanner配置
|
||||
public int updateBanner(Banner banner);
|
||||
|
||||
// 删除数据 调用bannerDAO里的deleteBanner配置
|
||||
public int deleteBanner(String bannerid);
|
||||
|
||||
// 查询全部数据 调用bannerDAO里的getAllBanner配置
|
||||
public List<Banner> getAllBanner();
|
||||
|
||||
// 按照Banner类里面的字段名称精确查询 调用bannerDAO里的getBannerByCond配置
|
||||
public List<Banner> getBannerByCond(Banner banner);
|
||||
|
||||
// 按照Banner类里面的字段名称模糊查询 调用bannerDAO里的getBannerByLike配置
|
||||
public List<Banner> getBannerByLike(Banner banner);
|
||||
|
||||
// 按主键查询表返回单一的Banner实例 调用bannerDAO里的getBannerById配置
|
||||
public Banner getBannerById(String bannerid);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
package com.service.impl;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.dao.AdminDAO;
|
||||
import com.entity.Admin;
|
||||
import com.service.AdminService;
|
||||
|
||||
@Service("adminService") //
|
||||
public class AdminServiceImpl implements AdminService {
|
||||
@Autowired // 它可以对类成员变量、方法及构造函数进行标注,完成自动装配的工作
|
||||
private AdminDAO adminDAO;
|
||||
@Override // 继承接口的新增管理员表数据 返回值0(失败),1(成功)
|
||||
public int insertAdmin(Admin admin) {
|
||||
return this.adminDAO.insertAdmin(admin);
|
||||
}
|
||||
|
||||
@Override // 继承接口的更新管理员表数据 返回值0(失败),1(成功)
|
||||
public int updateAdmin(Admin admin) {
|
||||
return this.adminDAO.updateAdmin(admin);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按主键删除管理员表数据 返回值0(失败),1(成功)
|
||||
public int deleteAdmin(String adminid) {
|
||||
return this.adminDAO.deleteAdmin(adminid);
|
||||
}
|
||||
|
||||
@Override // 继承接口的批量删除管理员表数据 返回值0(失败),大于0(成功)
|
||||
public int deleteAdminByIds(String[] ids) {
|
||||
return this.adminDAO.deleteAdminByIds(ids);
|
||||
}
|
||||
|
||||
@Override // 继承接口的查询管理员表全部数据
|
||||
public List<Admin> getAllAdmin() {
|
||||
return this.adminDAO.getAllAdmin();
|
||||
}
|
||||
|
||||
@Override // 继承接口的按条件精确查询管理员表数据
|
||||
public List<Admin> getAdminByCond(Admin admin) {
|
||||
return this.adminDAO.getAdminByCond(admin);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按条件模糊查询管理员表数据
|
||||
public List<Admin> getAdminByLike(Admin admin) {
|
||||
return this.adminDAO.getAdminByLike(admin);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按主键查询管理员表数据 返回Entity实例
|
||||
public Admin getAdminById(String adminid) {
|
||||
return this.adminDAO.getAdminById(adminid);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,65 @@
|
||||
package com.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.dao.ArticleDAO;
|
||||
import com.entity.Article;
|
||||
import com.service.ArticleService;
|
||||
|
||||
@Service("articleService")
|
||||
public class ArticleServiceImpl implements ArticleService {
|
||||
@Autowired
|
||||
private ArticleDAO articleDAO;
|
||||
|
||||
@Override // 继承接口的新增 返回值0(失败),1(成功)
|
||||
public int insertArticle(Article article) {
|
||||
return this.articleDAO.insertArticle(article);
|
||||
}
|
||||
|
||||
@Override // 继承接口的更新 返回值0(失败),1(成功)
|
||||
public int updateArticle(Article article) {
|
||||
return this.articleDAO.updateArticle(article);
|
||||
}
|
||||
|
||||
@Override // 继承接口的删除 返回值0(失败),1(成功)
|
||||
public int deleteArticle(String articleid) {
|
||||
return this.articleDAO.deleteArticle(articleid);
|
||||
}
|
||||
|
||||
@Override // 继承接口的查询全部
|
||||
public List<Article> getAllArticle() {
|
||||
return this.articleDAO.getAllArticle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Article> getFlvArticle() {
|
||||
return this.articleDAO.getFlvArticle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Article> getTopArticle() {
|
||||
return this.articleDAO.getTopArticle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Article> getArticleByBanner(String bannerid) {
|
||||
return this.articleDAO.getArticleByBanner(bannerid);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按条件精确查询
|
||||
public List<Article> getArticleByCond(Article article) {
|
||||
return this.articleDAO.getArticleByCond(article);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按条件模糊查询
|
||||
public List<Article> getArticleByLike(Article article) {
|
||||
return this.articleDAO.getArticleByLike(article);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按主键查询 返回Entity实例
|
||||
public Article getArticleById(String articleid) {
|
||||
return this.articleDAO.getArticleById(articleid);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.service.impl;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.dao.AsksDAO;
|
||||
import com.entity.Asks;
|
||||
import com.service.AsksService;
|
||||
|
||||
@Service("asksService") //
|
||||
public class AsksServiceImpl implements AsksService {
|
||||
@Autowired // 它可以对类成员变量、方法及构造函数进行标注,完成自动装配的工作
|
||||
private AsksDAO asksDAO;
|
||||
@Override // 继承接口的新增提示问题表数据 返回值0(失败),1(成功)
|
||||
public int insertAsks(Asks asks) {
|
||||
return this.asksDAO.insertAsks(asks);
|
||||
}
|
||||
|
||||
@Override // 继承接口的更新提示问题表数据 返回值0(失败),1(成功)
|
||||
public int updateAsks(Asks asks) {
|
||||
return this.asksDAO.updateAsks(asks);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按主键删除提示问题表数据 返回值0(失败),1(成功)
|
||||
public int deleteAsks(String asksid) {
|
||||
return this.asksDAO.deleteAsks(asksid);
|
||||
}
|
||||
|
||||
@Override // 继承接口的批量删除提示问题表数据 返回值0(失败),大于0(成功)
|
||||
public int deleteAsksByIds(String[] ids) {
|
||||
return this.asksDAO.deleteAsksByIds(ids);
|
||||
}
|
||||
|
||||
@Override // 继承接口的查询提示问题表全部数据
|
||||
public List<Asks> getAllAsks() {
|
||||
return this.asksDAO.getAllAsks();
|
||||
}
|
||||
|
||||
@Override // 继承接口的按条件精确查询提示问题表数据
|
||||
public List<Asks> getAsksByCond(Asks asks) {
|
||||
return this.asksDAO.getAsksByCond(asks);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按条件模糊查询提示问题表数据
|
||||
public List<Asks> getAsksByLike(Asks asks) {
|
||||
return this.asksDAO.getAsksByLike(asks);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按主键查询提示问题表数据 返回Entity实例
|
||||
public Asks getAsksById(String asksid) {
|
||||
return this.asksDAO.getAsksById(asksid);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,49 @@
|
||||
package com.service.impl;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.dao.BannerDAO;
|
||||
import com.entity.Banner;
|
||||
import com.service.BannerService;
|
||||
|
||||
@Service("bannerService")
|
||||
public class BannerServiceImpl implements BannerService {
|
||||
@Autowired
|
||||
private BannerDAO bannerDAO;
|
||||
@Override // 继承接口的新增 返回值0(失败),1(成功)
|
||||
public int insertBanner(Banner banner) {
|
||||
return this.bannerDAO.insertBanner(banner);
|
||||
}
|
||||
|
||||
@Override // 继承接口的更新 返回值0(失败),1(成功)
|
||||
public int updateBanner(Banner banner) {
|
||||
return this.bannerDAO.updateBanner(banner);
|
||||
}
|
||||
|
||||
@Override // 继承接口的删除 返回值0(失败),1(成功)
|
||||
public int deleteBanner(String bannerid) {
|
||||
return this.bannerDAO.deleteBanner(bannerid);
|
||||
}
|
||||
|
||||
@Override // 继承接口的查询全部
|
||||
public List<Banner> getAllBanner() {
|
||||
return this.bannerDAO.getAllBanner();
|
||||
}
|
||||
|
||||
@Override // 继承接口的按条件精确查询
|
||||
public List<Banner> getBannerByCond(Banner banner) {
|
||||
return this.bannerDAO.getBannerByCond(banner);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按条件模糊查询
|
||||
public List<Banner> getBannerByLike(Banner banner) {
|
||||
return this.bannerDAO.getBannerByLike(banner);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按主键查询 返回Entity实例
|
||||
public Banner getBannerById(String bannerid) {
|
||||
return this.bannerDAO.getBannerById(bannerid);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
package com.service.impl;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.dao.ComplainsDAO;
|
||||
import com.entity.Complains;
|
||||
import com.service.ComplainsService;
|
||||
|
||||
@Service("complainsService") //
|
||||
public class ComplainsServiceImpl implements ComplainsService {
|
||||
@Autowired // 它可以对类成员变量、方法及构造函数进行标注,完成自动装配的工作
|
||||
private ComplainsDAO complainsDAO;
|
||||
@Override // 继承接口的新增意见反馈表数据 返回值0(失败),1(成功)
|
||||
public int insertComplains(Complains complains) {
|
||||
return this.complainsDAO.insertComplains(complains);
|
||||
}
|
||||
|
||||
@Override // 继承接口的更新意见反馈表数据 返回值0(失败),1(成功)
|
||||
public int updateComplains(Complains complains) {
|
||||
return this.complainsDAO.updateComplains(complains);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按主键删除意见反馈表数据 返回值0(失败),1(成功)
|
||||
public int deleteComplains(String complainsid) {
|
||||
return this.complainsDAO.deleteComplains(complainsid);
|
||||
}
|
||||
|
||||
@Override // 继承接口的批量删除意见反馈表数据 返回值0(失败),大于0(成功)
|
||||
public int deleteComplainsByIds(String[] ids) {
|
||||
return this.complainsDAO.deleteComplainsByIds(ids);
|
||||
}
|
||||
|
||||
@Override // 继承接口的查询意见反馈表全部数据
|
||||
public List<Complains> getAllComplains() {
|
||||
return this.complainsDAO.getAllComplains();
|
||||
}
|
||||
|
||||
@Override // 继承接口的按条件精确查询意见反馈表数据
|
||||
public List<Complains> getComplainsByCond(Complains complains) {
|
||||
return this.complainsDAO.getComplainsByCond(complains);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按条件模糊查询意见反馈表数据
|
||||
public List<Complains> getComplainsByLike(Complains complains) {
|
||||
return this.complainsDAO.getComplainsByLike(complains);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按主键查询意见反馈表数据 返回Entity实例
|
||||
public Complains getComplainsById(String complainsid) {
|
||||
return this.complainsDAO.getComplainsById(complainsid);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
package com.service.impl;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.dao.FavDAO;
|
||||
import com.entity.Fav;
|
||||
import com.service.FavService;
|
||||
|
||||
@Service("favService") //
|
||||
public class FavServiceImpl implements FavService {
|
||||
@Autowired // 它可以对类成员变量、方法及构造函数进行标注,完成自动装配的工作
|
||||
private FavDAO favDAO;
|
||||
@Override // 继承接口的新增用户收藏表数据 返回值0(失败),1(成功)
|
||||
public int insertFav(Fav fav) {
|
||||
return this.favDAO.insertFav(fav);
|
||||
}
|
||||
|
||||
@Override // 继承接口的更新用户收藏表数据 返回值0(失败),1(成功)
|
||||
public int updateFav(Fav fav) {
|
||||
return this.favDAO.updateFav(fav);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按主键删除用户收藏表数据 返回值0(失败),1(成功)
|
||||
public int deleteFav(String favid) {
|
||||
return this.favDAO.deleteFav(favid);
|
||||
}
|
||||
|
||||
@Override // 继承接口的批量删除用户收藏表数据 返回值0(失败),大于0(成功)
|
||||
public int deleteFavByIds(String[] ids) {
|
||||
return this.favDAO.deleteFavByIds(ids);
|
||||
}
|
||||
|
||||
@Override // 继承接口的查询用户收藏表全部数据
|
||||
public List<Fav> getAllFav() {
|
||||
return this.favDAO.getAllFav();
|
||||
}
|
||||
|
||||
@Override // 继承接口的按条件精确查询用户收藏表数据
|
||||
public List<Fav> getFavByCond(Fav fav) {
|
||||
return this.favDAO.getFavByCond(fav);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按条件模糊查询用户收藏表数据
|
||||
public List<Fav> getFavByLike(Fav fav) {
|
||||
return this.favDAO.getFavByLike(fav);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按主键查询用户收藏表数据 返回Entity实例
|
||||
public Fav getFavById(String favid) {
|
||||
return this.favDAO.getFavById(favid);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
package com.service.impl;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.dao.TopicDAO;
|
||||
import com.entity.Topic;
|
||||
import com.service.TopicService;
|
||||
|
||||
@Service("topicService") //
|
||||
public class TopicServiceImpl implements TopicService {
|
||||
@Autowired // 它可以对类成员变量、方法及构造函数进行标注,完成自动装配的工作
|
||||
private TopicDAO topicDAO;
|
||||
@Override // 继承接口的新增用户评论表数据 返回值0(失败),1(成功)
|
||||
public int insertTopic(Topic topic) {
|
||||
return this.topicDAO.insertTopic(topic);
|
||||
}
|
||||
|
||||
@Override // 继承接口的更新用户评论表数据 返回值0(失败),1(成功)
|
||||
public int updateTopic(Topic topic) {
|
||||
return this.topicDAO.updateTopic(topic);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按主键删除用户评论表数据 返回值0(失败),1(成功)
|
||||
public int deleteTopic(String topicid) {
|
||||
return this.topicDAO.deleteTopic(topicid);
|
||||
}
|
||||
|
||||
@Override // 继承接口的批量删除用户评论表数据 返回值0(失败),大于0(成功)
|
||||
public int deleteTopicByIds(String[] ids) {
|
||||
return this.topicDAO.deleteTopicByIds(ids);
|
||||
}
|
||||
|
||||
@Override // 继承接口的查询用户评论表全部数据
|
||||
public List<Topic> getAllTopic() {
|
||||
return this.topicDAO.getAllTopic();
|
||||
}
|
||||
|
||||
@Override // 继承接口的按条件精确查询用户评论表数据
|
||||
public List<Topic> getTopicByCond(Topic topic) {
|
||||
return this.topicDAO.getTopicByCond(topic);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按条件模糊查询用户评论表数据
|
||||
public List<Topic> getTopicByLike(Topic topic) {
|
||||
return this.topicDAO.getTopicByLike(topic);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按主键查询用户评论表数据 返回Entity实例
|
||||
public Topic getTopicById(String topicid) {
|
||||
return this.topicDAO.getTopicById(topicid);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
package com.service.impl;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.dao.UsersDAO;
|
||||
import com.entity.Users;
|
||||
import com.service.UsersService;
|
||||
|
||||
@Service("usersService") //
|
||||
public class UsersServiceImpl implements UsersService {
|
||||
@Autowired // 它可以对类成员变量、方法及构造函数进行标注,完成自动装配的工作
|
||||
private UsersDAO usersDAO;
|
||||
@Override // 继承接口的新增网站用户表数据 返回值0(失败),1(成功)
|
||||
public int insertUsers(Users users) {
|
||||
return this.usersDAO.insertUsers(users);
|
||||
}
|
||||
|
||||
@Override // 继承接口的更新网站用户表数据 返回值0(失败),1(成功)
|
||||
public int updateUsers(Users users) {
|
||||
return this.usersDAO.updateUsers(users);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按主键删除网站用户表数据 返回值0(失败),1(成功)
|
||||
public int deleteUsers(String usersid) {
|
||||
return this.usersDAO.deleteUsers(usersid);
|
||||
}
|
||||
|
||||
@Override // 继承接口的批量删除网站用户表数据 返回值0(失败),大于0(成功)
|
||||
public int deleteUsersByIds(String[] ids) {
|
||||
return this.usersDAO.deleteUsersByIds(ids);
|
||||
}
|
||||
|
||||
@Override // 继承接口的查询网站用户表全部数据
|
||||
public List<Users> getAllUsers() {
|
||||
return this.usersDAO.getAllUsers();
|
||||
}
|
||||
|
||||
@Override // 继承接口的按条件精确查询网站用户表数据
|
||||
public List<Users> getUsersByCond(Users users) {
|
||||
return this.usersDAO.getUsersByCond(users);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按条件模糊查询网站用户表数据
|
||||
public List<Users> getUsersByLike(Users users) {
|
||||
return this.usersDAO.getUsersByLike(users);
|
||||
}
|
||||
|
||||
@Override // 继承接口的按主键查询网站用户表数据 返回Entity实例
|
||||
public Users getUsersById(String usersid) {
|
||||
return this.usersDAO.getUsersById(usersid);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
package com.test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
import com.dao.AdminDAO;
|
||||
import com.entity.Admin;
|
||||
import com.util.VeDate;
|
||||
|
||||
public class AdminTest {
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public static void main(String[] args) {
|
||||
ApplicationContext resource = new ClassPathXmlApplicationContext("springmvc-servlet.xml");
|
||||
AdminDAO adminDAO = (AdminDAO) resource.getBean(AdminDAO.class);
|
||||
for (int i = 0; i < 45; i++) {
|
||||
Admin admin = new Admin();
|
||||
admin.setAdminid(UUID.randomUUID().toString().replace("-", ""));
|
||||
admin.setUsername("admin" + i);
|
||||
admin.setPassword("admin" + i);
|
||||
admin.setRealname("admin" + i);
|
||||
admin.setContact("-" + i + i * i);
|
||||
admin.setAddtime(VeDate.getStringDateShort());
|
||||
adminDAO.insertAdmin(admin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,78 @@
|
||||
package com.test;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
import com.dao.UsersDAO;
|
||||
import com.entity.Users;
|
||||
import com.util.VeDate;
|
||||
|
||||
//用于生成测试用户的类
|
||||
public class UserTest {
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public static void main(String[] args) {
|
||||
ApplicationContext resource = new ClassPathXmlApplicationContext("springmvc-servlet.xml");
|
||||
UsersDAO usersDAO = (UsersDAO) resource.getBean(UsersDAO.class);
|
||||
String[] realname = { "郑伊雯", "雷进宝", "吴美隆", "吴心真", "王美珠", "郭芳天", "李雅惠", "陈文婷", "曹敏侑", "王依婷", "陈婉璇", "吴美玉", "蔡依婷",
|
||||
"郑昌梦", "林家纶", "黄丽昆", "李育泉", "黄芸欢", "吴韵如", "李肇芬", "卢木仲", "李成白", "方兆玉", "刘翊惠", "丁汉臻", "吴佳瑞", "舒绿珮", "周白芷",
|
||||
"张姿妤", "张虹伦", "周琼玟", "倪怡芳", "郭贵妃", "杨佩芳", "黄文旺", "黄盛玫", "郑丽青", "许智云", "张孟涵", "李小爱", "王恩龙", "朱政廷", "邓诗涵",
|
||||
"陈政倩", "吴俊伯", "阮馨学", "翁惠珠", "吴思翰", "林佩玲", "邓海来", "陈翊依", "李建智", "武淑芬", "金雅琪", "赖怡宜", "黄育霖", "张仪湖", "王俊民",
|
||||
"张诗刚", "林慧颖", "沈俊君", "陈淑妤", "李姿伶", "高咏钰", "黄彦宜", "周孟儒", "潘欣臻", "李祯韵", "叶洁启", "梁哲宇", "黄晓萍", "杨雅萍", "卢志铭",
|
||||
"张茂以", "林婉婷", "蔡宜芸", "林珮瑜", "黄柏仪", "周逸珮", "夏雅惠", "王采珮", "林孟霖", "林竹水", "王怡乐", "王爱乐", "金佳蓉", "韩健毓", "李士杰",
|
||||
"陈萱珍", "苏姿婷", "张政霖", "李志宏", "陈素达", "陈虹荣", "何美玲", "李仪琳", "张俞幸", "黄秋萍", "潘吉维", "陈智筠", "蔡国伟", "连俊达", "李雅婷",
|
||||
"李礼娇", "李忆孝", "黄静雯", "陈淳宝", "李文育", "林佳蓉", "罗依茂", "李淑佩", "谢怡君", "王美玲", "黄慧学", "邓幸韵", "陈秀琬", "许岳平", "许爱礼",
|
||||
"谢一忠", "简志雪", "赵若喜", "许承翰", "姚哲维", "苏俊安", "郭礼钰", "姜佩珊", "张鸿信", "秦欣瑜", "李旺劭", "陈怡爱", "陈秀德", "张佳伶", "郑凯婷",
|
||||
"郑雅任", "黄国妹", "林芳江", "江骏生", "黄儒纯", "王培伦", "陈蕙侑", "蔡宜慧", "陈信意", "陈惠雯", "张琇纶", "黄碧仪", "陈志文", "谢懿富", "杨凡靖",
|
||||
"蔡秀琴", "温惠玲", "林宗其", "林绍泰", "何佳慧", "蔡辰纶", "王雅雯", "叶怡财", "冯雅筑", "李伦圣", "彭正仁", "刘小紫", "温燕达", "刘佳雨", "吴婷婷",
|
||||
"杨怡君", "黄康刚", "林辰和", "陈世人", "吴佩霖", "张伟杰", "刘友淳", "张瑞群", "洪紫芬", "邓家伟", "谢佩任", "戎郁文", "李治火", "林石美", "郑雅茜",
|
||||
"胡台泰", "陈怡盈", "阙石意", "林盈威", "林志嘉", "李秀玲", "王彦霖", "叶惟芷", "郑星钰", "邱贞伟", "姚扬云", "涂武盛", "王雅顺", "唐欣仪", "陈政圣",
|
||||
"陈育福", "吴惠雯", "李淑淑", "黄莉秋", "赖俊军", "荆彦璋", "白怡均", "林姿辛", "林雅慧", "詹允坚", "赖淑珍", "吴惠美", "李凯婷", "林承辰", "刘亭宝",
|
||||
"宋慧元", "连书忠", "余仪礼", "袁哲仪", "杜怡臻", "潘孝东", "周志合", "刘力霞", "林钰婷", "林怡紫", "林俊凯", "蔡于纬", "蔡雅惠", "汪喜祥", "陈铭侑",
|
||||
"郭子珠", "许伦吉", "陈佳雨", "赖英贤", "吴嘉茹", "陈永桂", "张文宏", "唐欣怡", "丁绍燕", "王雅谕", "叶柏宇", "王婉萍", "王宗清", "刘心霖", "吴柏廷",
|
||||
"陈怡臻", "杜士豪", "李春勋", "黄雅慧", "吴乔茂", "郑婉如", "李育坚", "黄静雯", "赵一蓉", "邱萱俐", "周立妹", "李宝其", "张信豪", "李昆霖", "陈俊安",
|
||||
"林建志", "黄韦伶", "李美麟", "张政达", "郑惠玲", "柳忠廷", "黄美娟", "许怡君", "吴崇南", "邱承芷", "叶得梅", "陈祯月", "杨宛儒", "阮肇宪", "杨益霞",
|
||||
"唐盛人", "许平纬", "许雅如", "林秀绮", "刘昌东", "张家荣", "杨淑君", "吴俊民", "李彦瑜", "李彦文", "王崇以", "王威全", "彭琳以", "许志任", "陈嘉杰",
|
||||
"蔡志远", "陈信文", "陈思廷", "吴家毓", "李宜紫", "杨毅民", "林志平", "陈伟孝", "刘信俊", "李美治", "徐景隆", "刘怡洁", "陈钰梦", "谢静宜", "戴惠如",
|
||||
"王香君", "钟汉馨", "郑国玮", "张哲亚", "詹南勋", "潘秋福", "黄奕君", "郭琬婷", "冯家华", "吴佩仁", "周思颖", "张柏钧", "吴世伟", "朱佳琪", "陈宗馨",
|
||||
"黄菁坚", "郑建泉", "许金志", "平信宏", "蔡佳麟", "杨佳宏", "陈皓雅", "吴翊意", "张佩珊", "温欣桦", "王诗铭", "许宜辰", "林孟哲", "黄善宇", "王怡贵",
|
||||
"许淑玫", "张学玉", "黄美珍", "陈佳心", "宋其琪", "陈致昀", "王建福", "刘莹睿", "陈正莲", "冯萱雨", "金淑敏", "宋廷意", "吴承华", "陈家莲", "王志源",
|
||||
"张佩君", "黄志伟", "吴孟吟", "蔡玮玉", "张心怡", "吴志绿", "何武霖", "杨中惟", "王佑诚", "徐承财", "温伟伦", "萧郁婷", "陈世伟", "林敬书", "谢孟南",
|
||||
"项宜真", "崔美珠", "赖筱雯", "陈盛丰", "阮升云", "周怡季", "江佳芸", "郭惠君", "吕智文", "王琼龙", "陈姿茜", "张佩君", "李佩纬", "黄珮心", "李旭友",
|
||||
"王健以", "蔡幸弘", "刘智钧", "张佳颖", "郭东欣", "黄志忠", "李娇郁", "许欣怡", "杜劭依", "荣美君", "陈翠昆", "陈昆绍", "黄志佩", "黄舜文", "刘丽卿",
|
||||
"张倩纬", "施珮昆", "郑纬水", "林明玫", "郑琦希", "童家贤", "郭峻豪", "林雅豪", "曲祯妹", "林冠宇", "陈珍莹", "简玟君", "杜阳吟", "许雅菱", "叶木书",
|
||||
"黄文其", "陈景彦", "蒋承凯", "黄依萍", "黄珮秋", "郑文贤", "柯元燕", "李思雄", "王绍玉", "金尧珊", "李政绍", "叶法盛", "苏琪山", "邱思妤", "王若芳",
|
||||
"黎彦君", "冷翊瑜", "张明真", "李琪源", "林素侑", "孟敏宇", "怀雅惠", "吴士弘", "张世志", "袁志铭", "林千惠", "宋乐男", "黄淑贞", "王宗盛", "吴永臻",
|
||||
"陈富财", "钱孟儒", "谢百宜", "曹振豪", "陈品妃", "吴升财", "陈昀雪", "高淑娟", "林智钧", "林秋平", "王汉季", "黄仁添", "詹雅如", "蔡佳麟", "张美君",
|
||||
"孙姿吟", "陈孟善", "黄美君", "林盈秀", "王姿雯", "王旻峰", "郭淑卿", "谢盈冰", "魏淑华", "刘志宜", "张怡婷", "梁淑敏", "王白木", "方劭中", "田火劭",
|
||||
"叶佩正", "程巧欢", "陈玮弘", "张毅琳", "吴念筠", "张美惠", "陈欣白", "李怡文", "曹珊贵", "梁家豪", "洪月瑄", "李铭茹", "金杰蕙", "杨冠霖", "吴明宜",
|
||||
"陆怡雯", "黄立启", "林雅芸", "林佩毓", "李宜珊", "钱怡伶", "刘宗翰", "林台斌", "杨杰均", "连育如", "杨奕名", "郭玉婷", "王翊谦", "彭圣杰", "郑世杰",
|
||||
"吴承翰", "张琦芸", "邓淑芬", "陈佳芳", "吴秋良", "陈舜文", "蔡靖玮", "林雅舜", "张真勇", "邱益勇", "林懿淳", "郭美慧", "蔡智强", "张智苹", "陈冰茹",
|
||||
"李思纬", "郑馨仪", "程明辉", "陈弘善", "陈政勋", "卢琬杰", "黄柏菁", "刘佩儒", "陈韦贞", "许台法", "陶志祥", "吴俊宁", "李孟岳", "刘明宪", "吴耀英",
|
||||
"陈思桦", "井弘坤", "黄明萍", "陈姿颖", "张成欢", "张燕佳", "李雪鸿", "叶志伟", "王石竹", "孙心桂", "舒大钧", "林秋萍", "柯美惠", "姜上宪", "林欣淳",
|
||||
"郭雅娟", "宋采信", "韩贞仪", "李育羽", "冯玟泰", "林姿儒", "蔡敏坤", "林惠玲", "陈珮义", "林书祯", "黄政霖", "谢姿卿" };
|
||||
|
||||
for (int i = 0; i < 30; i++) {
|
||||
Users users = new Users();
|
||||
users.setUsersid("U" + VeDate.getStringDatex() + VeDate.getRandom());
|
||||
users.setUsername("" + i);
|
||||
users.setPassword("" + i);
|
||||
if (i % 2 == 0) {
|
||||
users.setSex("男");
|
||||
} else {
|
||||
users.setSex("女");
|
||||
}
|
||||
Random rand = new Random();
|
||||
int x = rand.nextInt(realname.length - 1);
|
||||
users.setRealname(realname[x]);
|
||||
users.setBirthday(VeDate.getStringDateShort());
|
||||
users.setRegdate(VeDate.getStringDateShort());
|
||||
users.setContact(VeDate.getTel());
|
||||
usersDAO.insertUsers(users);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.util;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import jxl.Workbook;
|
||||
import jxl.write.Label;
|
||||
import jxl.write.WritableSheet;
|
||||
import jxl.write.WritableWorkbook;
|
||||
/**
|
||||
* Excel报表生成工具类 使用JXL包生成Excel格式的文件
|
||||
* @param savePath 存储路径
|
||||
*/
|
||||
|
||||
public class Excel {
|
||||
|
||||
public String getExcel(List<String[]> strList, String[] strTitle, String banner, String paths) {
|
||||
String fp = "upfiles\\" + VeDate.getStringDatex() + ".xls";
|
||||
String filepath = paths + fp;
|
||||
try {
|
||||
WritableWorkbook book = Workbook.createWorkbook(new File(filepath));
|
||||
WritableSheet sheet = book.createSheet(banner, 0);
|
||||
for (int i = 0; i < strTitle.length; i++) {
|
||||
sheet.addCell(new Label(i, 0, strTitle[i]));
|
||||
}
|
||||
for (int i = 0; i < strList.size(); i++) {
|
||||
String[] str = strList.get(i);
|
||||
for (int j = 0; j < str.length; j++) {
|
||||
try {
|
||||
Label label = new Label(j, i + 1, str[j]);
|
||||
sheet.addCell(label);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
book.write();
|
||||
book.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,65 @@
|
||||
package com.util;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Random;
|
||||
/*
|
||||
* MD5 加密类
|
||||
* 通过这个类把
|
||||
* 一个字符串转化成一个16进制32位的字符串
|
||||
* */
|
||||
|
||||
public final class MD5 {
|
||||
|
||||
public final static String getMD5(String s) {
|
||||
char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; // 创建一个16进制数的数组
|
||||
try {
|
||||
byte[] strTemp = s.getBytes();// 把传入的字符串转化成数组
|
||||
MessageDigest mdTemp = MessageDigest.getInstance("MD5"); // 建立一个mdTemp
|
||||
// 类的对象
|
||||
// 对象名称叫做MD5实例
|
||||
mdTemp.update(strTemp);// 更新strTemp 数组
|
||||
byte[] md = mdTemp.digest(); // 通过digest() 方法重新定义一个数组
|
||||
int j = md.length; // md数组的长度
|
||||
char str[] = new char[j * 2]; // 定义一个字符数组 数组的长度是md数组长度的2倍
|
||||
int k = 0;
|
||||
for (int i = 0; i < j; i++) {
|
||||
byte byte0 = md[i]; // 给byte0变量赋值
|
||||
str[k++] = hexDigits[byte0 >>> 4 & 0xf]; // 通过hexDigits[]
|
||||
// 把字符串s转化成16进制32位的字符串
|
||||
str[k++] = hexDigits[byte0 & 0xf];
|
||||
}
|
||||
return new String(str); // 返回转换后的字符串
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 返回MD5加盐加密数据
|
||||
public static String getMD5BySalt(String str, String salt) {
|
||||
return getMD5(getMD5(str) + salt);
|
||||
}
|
||||
|
||||
// 生成一个10位的随机salt
|
||||
public static String getSalt() {
|
||||
String salt = "";
|
||||
Random rand = new Random();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
int num = rand.nextInt(3);
|
||||
switch (num) {
|
||||
case 0:
|
||||
char c1 = (char) (rand.nextInt(26) + 'a');//生成随机小写字母
|
||||
salt += c1;
|
||||
break;
|
||||
case 1:
|
||||
char c2 = (char) (rand.nextInt(26) + 'A');//生成随机大写字母
|
||||
salt += c2;
|
||||
break;
|
||||
case 2:
|
||||
salt += rand.nextInt(10);//生成随机数字
|
||||
}
|
||||
}
|
||||
return salt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,211 @@
|
||||
package com.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public class PageHelper {
|
||||
|
||||
public static void getPage(List<?> list, String name, List<String> nameList, List<String> valueList, int pageSize, String number,
|
||||
HttpServletRequest request, String method) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
String name2 = name.substring(0, 1).toUpperCase() + name.substring(1);
|
||||
String path = "";
|
||||
String action = "getAll" + name2 + ".action";
|
||||
if (method != null) {
|
||||
action = "query" + name2 + "ByCond.action";
|
||||
}
|
||||
|
||||
List<Object> objList = new ArrayList<Object>();
|
||||
if (nameList != null && valueList != null) {
|
||||
for (int i = 0; i < nameList.size(); i++) {
|
||||
path += "&" + nameList.get(i) + "=" + valueList.get(i);
|
||||
}
|
||||
}
|
||||
int pageNumber = list.size();
|
||||
int maxPage = pageNumber;
|
||||
if (maxPage % pageSize == 0) {
|
||||
maxPage = maxPage / pageSize;
|
||||
} else {
|
||||
maxPage = maxPage / pageSize + 1;
|
||||
}
|
||||
if (number == null) {
|
||||
number = "0";
|
||||
}
|
||||
int start = Integer.parseInt(number) * pageSize;
|
||||
int over = (Integer.parseInt(number) + 1) * pageSize;
|
||||
int count = pageNumber - over;
|
||||
if (count <= 0) {
|
||||
over = pageNumber;
|
||||
}
|
||||
for (int i = start; i < over; i++) {
|
||||
Object obj = list.get(i);
|
||||
objList.add(obj);
|
||||
}
|
||||
buffer.append(" 共为");
|
||||
buffer.append(maxPage);
|
||||
buffer.append("页 共有");
|
||||
buffer.append(pageNumber);
|
||||
buffer.append("条 当前为第");
|
||||
buffer.append((Integer.parseInt(number) + 1));
|
||||
buffer.append("页 ");
|
||||
if ((Integer.parseInt(number) + 1) == 1) {
|
||||
buffer.append("首页");
|
||||
} else {
|
||||
buffer.append("<a href=\"" + name + "/" + action + "?number=0" + path + "\">首页</a>");
|
||||
}
|
||||
buffer.append(" ");
|
||||
if ((Integer.parseInt(number) + 1) == 1) {
|
||||
buffer.append("上一页");
|
||||
} else {
|
||||
buffer.append("<a href=\"" + name + "/" + action + "?number=" + (Integer.parseInt(number) - 1) + "" + path + "\">上一页</a>");
|
||||
}
|
||||
buffer.append(" ");
|
||||
if (maxPage <= (Integer.parseInt(number) + 1)) {
|
||||
buffer.append("下一页");
|
||||
} else {
|
||||
buffer.append("<a href=\"" + name + "/" + action + "?number=" + (Integer.parseInt(number) + 1) + "" + path + "\">下一页</a>");
|
||||
}
|
||||
buffer.append(" ");
|
||||
if (maxPage <= (Integer.parseInt(number) + 1)) {
|
||||
buffer.append("尾页");
|
||||
} else {
|
||||
buffer.append("<a href=\"" + name + "/" + action + "?number=" + (maxPage - 1) + "" + path + "\">尾页</a>");
|
||||
}
|
||||
String html = buffer.toString();
|
||||
request.setAttribute("html", html);
|
||||
request.setAttribute(name + "List", objList);
|
||||
}
|
||||
|
||||
public static void getUserPage(List<?> list, String name, String actionName, int pageSize, String number, HttpServletRequest request) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
String path = "";
|
||||
String action = actionName + ".action";
|
||||
List<Object> objList = new ArrayList<Object>();
|
||||
int pageNumber = list.size();
|
||||
int maxPage = pageNumber;
|
||||
if (maxPage % pageSize == 0) {
|
||||
maxPage = maxPage / pageSize;
|
||||
} else {
|
||||
maxPage = maxPage / pageSize + 1;
|
||||
}
|
||||
if (number == null) {
|
||||
number = "0";
|
||||
}
|
||||
int start = Integer.parseInt(number) * pageSize;
|
||||
int over = (Integer.parseInt(number) + 1) * pageSize;
|
||||
int count = pageNumber - over;
|
||||
if (count <= 0) {
|
||||
over = pageNumber;
|
||||
}
|
||||
for (int i = start; i < over; i++) {
|
||||
Object obj = list.get(i);
|
||||
objList.add(obj);
|
||||
}
|
||||
buffer.append(" 共为");
|
||||
buffer.append(maxPage);
|
||||
buffer.append("页 共有");
|
||||
buffer.append(pageNumber);
|
||||
buffer.append("条 当前为第");
|
||||
buffer.append((Integer.parseInt(number) + 1));
|
||||
buffer.append("页 ");
|
||||
if ((Integer.parseInt(number) + 1) == 1) {
|
||||
buffer.append("首页");
|
||||
} else {
|
||||
buffer.append("<a href=\"" + name + "/" + action + "?number=0" + path + "\">首页</a>");
|
||||
}
|
||||
buffer.append(" ");
|
||||
if ((Integer.parseInt(number) + 1) == 1) {
|
||||
buffer.append("上一页");
|
||||
} else {
|
||||
buffer.append("<a href=\"" + name + "/" + action + "?number=" + (Integer.parseInt(number) - 1) + "" + path + "\">上一页</a>");
|
||||
}
|
||||
buffer.append(" ");
|
||||
if (maxPage <= (Integer.parseInt(number) + 1)) {
|
||||
buffer.append("下一页");
|
||||
} else {
|
||||
buffer.append("<a href=\"" + name + "/" + action + "?number=" + (Integer.parseInt(number) + 1) + "" + path + "\">下一页</a>");
|
||||
}
|
||||
buffer.append(" ");
|
||||
if (maxPage <= (Integer.parseInt(number) + 1)) {
|
||||
buffer.append("尾页");
|
||||
} else {
|
||||
buffer.append("<a href=\"" + name + "/" + action + "?number=" + (maxPage - 1) + "" + path + "\">尾页</a>");
|
||||
}
|
||||
String html = buffer.toString();
|
||||
request.setAttribute("html", html);
|
||||
request.setAttribute(name + "List", objList);
|
||||
}
|
||||
|
||||
public static void getIndexPage(List<?> list, String name, String actionName, String id, int pageSize, String number,
|
||||
HttpServletRequest request) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
String path = "";
|
||||
String action = actionName + ".action";
|
||||
if (!"".equals(id) && id != null) {
|
||||
path = "&id=" + id + "";
|
||||
}
|
||||
List<Object> objList = new ArrayList<Object>();
|
||||
int pageNumber = list.size();
|
||||
int maxPage = pageNumber;
|
||||
if (maxPage % pageSize == 0) {
|
||||
maxPage = maxPage / pageSize;
|
||||
} else {
|
||||
maxPage = maxPage / pageSize + 1;
|
||||
}
|
||||
if (number == null) {
|
||||
number = "0";
|
||||
}
|
||||
int start = Integer.parseInt(number) * pageSize;
|
||||
int over = (Integer.parseInt(number) + 1) * pageSize;
|
||||
int count = pageNumber - over;
|
||||
if (count <= 0) {
|
||||
over = pageNumber;
|
||||
}
|
||||
for (int i = start; i < over; i++) {
|
||||
Object obj = list.get(i);
|
||||
objList.add(obj);
|
||||
}
|
||||
buffer.append(" 共为");
|
||||
buffer.append(maxPage);
|
||||
buffer.append("页 共有");
|
||||
buffer.append(pageNumber);
|
||||
buffer.append("条 当前为第");
|
||||
buffer.append((Integer.parseInt(number) + 1));
|
||||
buffer.append("页 ");
|
||||
if ((Integer.parseInt(number) + 1) == 1) {
|
||||
buffer.append("首页");
|
||||
} else {
|
||||
buffer.append("<a href=\"index/" + action + "?number=0" + path + "\">首页</a>");
|
||||
}
|
||||
buffer.append(" ");
|
||||
if ((Integer.parseInt(number) + 1) == 1) {
|
||||
buffer.append("上一页");
|
||||
} else {
|
||||
buffer.append("<a href=\"index/" + action + "?number=" + (Integer.parseInt(number) - 1) + "" + path + "\">上一页</a>");
|
||||
}
|
||||
buffer.append(" ");
|
||||
if (maxPage <= (Integer.parseInt(number) + 1)) {
|
||||
buffer.append("下一页");
|
||||
} else {
|
||||
buffer.append("<a href=\"index/" + action + "?number=" + (Integer.parseInt(number) + 1) + "" + path + "\">下一页</a>");
|
||||
}
|
||||
buffer.append(" ");
|
||||
if (maxPage <= (Integer.parseInt(number) + 1)) {
|
||||
buffer.append("尾页");
|
||||
} else {
|
||||
buffer.append("<a href=\"index/" + action + "?number=" + (maxPage - 1) + "" + path + "\">尾页</a>");
|
||||
}
|
||||
String html = buffer.toString();
|
||||
request.setAttribute("html", html);
|
||||
request.setAttribute(name + "List", objList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,404 @@
|
||||
package com.util;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.ParsePosition;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
/*
|
||||
* 日期工作类
|
||||
* 能够得到一些跟日期相关的应用、返回值 方便程序开发
|
||||
* */
|
||||
|
||||
public class VeDate {
|
||||
|
||||
// 返回随机手机号码
|
||||
private static String[] telFirst = "130,131,132,133,134,135,136,137,138,139,150,151,152,157,158,159,180,181,182,183,184,185,186,187,188,189".split(",");
|
||||
|
||||
public static String getTel() {
|
||||
int index = getNum(0, telFirst.length - 1);
|
||||
String first = telFirst[index];
|
||||
String second = String.valueOf(getNum(1, 188) + 10000).substring(1);
|
||||
String third = String.valueOf(getNum(1, 9100) + 10000).substring(1);
|
||||
return first + second + third;
|
||||
}
|
||||
|
||||
public static int getNum(int start, int end) {
|
||||
return (int) (Math.random() * (end - start + 1) + start);
|
||||
}
|
||||
|
||||
public static double getDouble(double num) {
|
||||
DecimalFormat df2 = new DecimalFormat("#.00");
|
||||
return Double.parseDouble(df2.format(num));
|
||||
}
|
||||
|
||||
// 随机出三位整数
|
||||
public static int getRandom() {
|
||||
int i = (int) (Math.random() * 900) + 10;
|
||||
return i;
|
||||
}
|
||||
|
||||
public static String getStringDouble(double num) {
|
||||
DecimalFormat df2 = new DecimalFormat("#.00");
|
||||
return df2.format(num);
|
||||
}
|
||||
|
||||
public static Date getNowDate() {
|
||||
Date currentTime = new Date();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String dateString = formatter.format(currentTime);
|
||||
ParsePosition pos = new ParsePosition(8);
|
||||
Date currentTime_2 = formatter.parse(dateString, pos);
|
||||
return currentTime_2;
|
||||
}
|
||||
|
||||
public static Date getNowDateShort() {
|
||||
Date currentTime = new Date();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String dateString = formatter.format(currentTime);
|
||||
ParsePosition pos = new ParsePosition(8);
|
||||
Date currentTime_2 = formatter.parse(dateString, pos);
|
||||
return currentTime_2;
|
||||
}
|
||||
|
||||
public static String getStringDate() {
|
||||
Date currentTime = new Date();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String dateString = formatter.format(currentTime);
|
||||
return dateString;
|
||||
}
|
||||
|
||||
public static String getStringDatex() {
|
||||
Date currentTime = new Date();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String dateString = formatter.format(currentTime);
|
||||
return dateString;
|
||||
}
|
||||
|
||||
public static String getStringId() {
|
||||
Random rand = new Random();
|
||||
Date currentTime = new Date();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String dateString = formatter.format(currentTime);
|
||||
return dateString + (rand.nextInt(900) + 100);
|
||||
}
|
||||
|
||||
public static String getStringDateShort() {
|
||||
Date currentTime = new Date();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String dateString = formatter.format(currentTime);
|
||||
return dateString;
|
||||
}
|
||||
|
||||
public static String getStringTimeShort() {
|
||||
Date currentTime = new Date();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
|
||||
String dateString = formatter.format(currentTime);
|
||||
return dateString;
|
||||
}
|
||||
|
||||
public static String getYear() {
|
||||
Date currentTime = new Date();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy");
|
||||
String dateString = formatter.format(currentTime);
|
||||
return dateString;
|
||||
}
|
||||
|
||||
public static String getTimeShort() {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
|
||||
Date currentTime = new Date();
|
||||
String dateString = formatter.format(currentTime);
|
||||
return dateString;
|
||||
}
|
||||
|
||||
public static Date strToDateLong(String strDate) {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
ParsePosition pos = new ParsePosition(0);
|
||||
Date strtodate = formatter.parse(strDate, pos);
|
||||
return strtodate;
|
||||
}
|
||||
|
||||
public static String dateToStrLong(java.util.Date dateDate) {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String dateString = formatter.format(dateDate);
|
||||
return dateString;
|
||||
}
|
||||
|
||||
public static String dateToStr(java.util.Date dateDate) {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String dateString = formatter.format(dateDate);
|
||||
return dateString;
|
||||
}
|
||||
|
||||
public static Date strToDate(String strDate) {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
ParsePosition pos = new ParsePosition(0);
|
||||
Date strtodate = formatter.parse(strDate, pos);
|
||||
return strtodate;
|
||||
}
|
||||
|
||||
public static Date getNow() {
|
||||
Date currentTime = new Date();
|
||||
return currentTime;
|
||||
}
|
||||
|
||||
public static Date getLastDate(long day) {
|
||||
Date date = new Date();
|
||||
long date_3_hm = date.getTime() - 3600000 * 34 * day;
|
||||
Date date_3_hm_date = new Date(date_3_hm);
|
||||
return date_3_hm_date;
|
||||
}
|
||||
|
||||
public static String getStringToday() {
|
||||
Date currentTime = new Date();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd HHmmss");
|
||||
String dateString = formatter.format(currentTime);
|
||||
return dateString;
|
||||
}
|
||||
|
||||
public static String getHour() {
|
||||
Date currentTime = new Date();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String dateString = formatter.format(currentTime);
|
||||
String hour;
|
||||
hour = dateString.substring(11, 13);
|
||||
return hour;
|
||||
}
|
||||
|
||||
public static String getTime() {
|
||||
Date currentTime = new Date();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String dateString = formatter.format(currentTime);
|
||||
String min;
|
||||
min = dateString.substring(14, 16);
|
||||
return min;
|
||||
}
|
||||
|
||||
public static String getUserDate(String sformat) {
|
||||
Date currentTime = new Date();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat(sformat);
|
||||
String dateString = formatter.format(currentTime);
|
||||
return dateString;
|
||||
}
|
||||
|
||||
public static String getTwoHour(String st1, String st2) {
|
||||
String[] kk = null;
|
||||
String[] jj = null;
|
||||
kk = st1.split(":");
|
||||
jj = st2.split(":");
|
||||
if (Integer.parseInt(kk[0]) < Integer.parseInt(jj[0]))
|
||||
return "0";
|
||||
else {
|
||||
double y = Double.parseDouble(kk[0]) + Double.parseDouble(kk[1]) / 60;
|
||||
double u = Double.parseDouble(jj[0]) + Double.parseDouble(jj[1]) / 60;
|
||||
if ((y - u) > 0)
|
||||
return y - u + "";
|
||||
else
|
||||
return "0";
|
||||
}
|
||||
}
|
||||
|
||||
public static String getTwoDay(String sj1, String sj2) {
|
||||
SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
long day = 0;
|
||||
try {
|
||||
java.util.Date date = myFormatter.parse(sj1);
|
||||
java.util.Date mydate = myFormatter.parse(sj2);
|
||||
day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
return day + "";
|
||||
}
|
||||
|
||||
public static String getPreTime(String sj1, String jj) {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String mydate1 = "";
|
||||
try {
|
||||
Date date1 = format.parse(sj1);
|
||||
long Time = (date1.getTime() / 1000) + Integer.parseInt(jj) * 60;
|
||||
date1.setTime(Time * 1000);
|
||||
mydate1 = format.format(date1);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return mydate1;
|
||||
}
|
||||
|
||||
public static String getNextDay(String nowdate, String delay) {
|
||||
try {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String mdate = "";
|
||||
Date d = strToDate(nowdate);
|
||||
long myTime = (d.getTime() / 1000) + Integer.parseInt(delay) * 24 * 60 * 60;
|
||||
d.setTime(myTime * 1000);
|
||||
mdate = format.format(d);
|
||||
return mdate;
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isLeapYear(String ddate) {
|
||||
Date d = strToDate(ddate);
|
||||
GregorianCalendar gc = (GregorianCalendar) Calendar.getInstance();
|
||||
gc.setTime(d);
|
||||
int year = gc.get(Calendar.YEAR);
|
||||
if ((year % 400) == 0)
|
||||
return true;
|
||||
else if ((year % 4) == 0) {
|
||||
if ((year % 100) == 0)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getEDate(String str) {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
ParsePosition pos = new ParsePosition(0);
|
||||
Date strtodate = formatter.parse(str, pos);
|
||||
String j = strtodate.toString();
|
||||
String[] k = j.split(" ");
|
||||
return k[2] + k[1].toUpperCase() + k[5].substring(2, 4);
|
||||
}
|
||||
|
||||
public static String getEndDateOfMonth(String dat) {// yyyy-MM-dd
|
||||
String str = dat.substring(0, 8);
|
||||
String month = dat.substring(5, 7);
|
||||
int mon = Integer.parseInt(month);
|
||||
if (mon == 1 || mon == 3 || mon == 5 || mon == 7 || mon == 8 || mon == 10 || mon == 12) {
|
||||
str += "31";
|
||||
} else if (mon == 4 || mon == 6 || mon == 9 || mon == 11) {
|
||||
str += "30";
|
||||
} else {
|
||||
if (isLeapYear(dat)) {
|
||||
str += "29";
|
||||
} else {
|
||||
str += "28";
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public static boolean isSameWeekDates(Date date1, Date date2) {
|
||||
Calendar cal1 = Calendar.getInstance();
|
||||
Calendar cal2 = Calendar.getInstance();
|
||||
cal1.setTime(date1);
|
||||
cal2.setTime(date2);
|
||||
int subYear = cal1.get(Calendar.YEAR) - cal2.get(Calendar.YEAR);
|
||||
if (0 == subYear) {
|
||||
if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR))
|
||||
return true;
|
||||
} else if (1 == subYear && 11 == cal2.get(Calendar.MONTH)) {
|
||||
if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR))
|
||||
return true;
|
||||
} else if (-1 == subYear && 11 == cal1.get(Calendar.MONTH)) {
|
||||
if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getSeqWeek() {
|
||||
Calendar c = Calendar.getInstance(Locale.CHINA);
|
||||
String week = Integer.toString(c.get(Calendar.WEEK_OF_YEAR));
|
||||
if (week.length() == 1)
|
||||
week = "0" + week;
|
||||
String year = Integer.toString(c.get(Calendar.YEAR));
|
||||
return year + week;
|
||||
}
|
||||
|
||||
public static String getWeek(String sdate, String num) {
|
||||
Date dd = VeDate.strToDate(sdate);
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(dd);
|
||||
if (num.equals("1"))
|
||||
c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
|
||||
else if (num.equals("2"))
|
||||
c.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
|
||||
else if (num.equals("3"))
|
||||
c.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
|
||||
else if (num.equals("4"))
|
||||
c.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
|
||||
else if (num.equals("5"))
|
||||
c.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
|
||||
else if (num.equals("6"))
|
||||
c.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
|
||||
else if (num.equals("0"))
|
||||
c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
|
||||
return new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
|
||||
}
|
||||
|
||||
public static String getWeek(String sdate) {
|
||||
Date date = VeDate.strToDate(sdate);
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(date);
|
||||
return new SimpleDateFormat("EEEE").format(c.getTime());
|
||||
}
|
||||
|
||||
public static long getDays(String date1, String date2) {
|
||||
if (date1 == null || date1.equals(""))
|
||||
return 0;
|
||||
if (date2 == null || date2.equals(""))
|
||||
return 0;
|
||||
SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
java.util.Date date = null;
|
||||
java.util.Date mydate = null;
|
||||
try {
|
||||
date = myFormatter.parse(date1);
|
||||
mydate = myFormatter.parse(date2);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
long day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
|
||||
return day;
|
||||
}
|
||||
|
||||
public static String getNowMonth(String sdate) {
|
||||
sdate = sdate.substring(0, 8) + "01";
|
||||
Date date = VeDate.strToDate(sdate);
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(date);
|
||||
int u = c.get(Calendar.DAY_OF_WEEK);
|
||||
String newday = VeDate.getNextDay(sdate, (1 - u) + "");
|
||||
return newday;
|
||||
}
|
||||
|
||||
public static String getNo(int k) {
|
||||
return getUserDate("yyyyMMddhhmmss") + getRandom(k);
|
||||
}
|
||||
|
||||
public static String getRandom(int i) {
|
||||
Random jjj = new Random();
|
||||
if (i == 0)
|
||||
return "";
|
||||
String jj = "";
|
||||
for (int k = 0; k < i; k++) {
|
||||
jj = jj + jjj.nextInt(9);
|
||||
}
|
||||
return jj;
|
||||
}
|
||||
|
||||
public static boolean RightDate(String date) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||
if (date == null)
|
||||
return false;
|
||||
if (date.length() > 10) {
|
||||
sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||
} else {
|
||||
sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
}
|
||||
try {
|
||||
sdf.parse(date);
|
||||
} catch (ParseException pe) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,23 @@
|
||||
log4j.rootLogger=INFO, stdout, logfile
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
|
||||
|
||||
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.logfile.MaxFileSize=512KB
|
||||
log4j.appender.logfile.MaxBackupIndex=3
|
||||
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n
|
||||
log4j.logger.java.sql.ResultSet=INFO
|
||||
|
||||
log4j.logger.org.apache=INFO
|
||||
log4j.logger.java.sql.Connection=DEBUG
|
||||
log4j.logger.java.sql.Statement=DEBUG
|
||||
log4j.logger.java.sql.PreparedStatement=DEBUG
|
||||
log4j.logger.com.dao=DEBUG
|
||||
|
||||
#log4j 文件的作用是在控制台输出程序启动、SQL语句等程序运行时关键代码
|
||||
|
||||
|
||||
|
@ -0,0 +1,147 @@
|
||||
<?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">
|
||||
<!-- 配置Mabatis映射文件 -->
|
||||
<mapper namespace="com.dao.ArticleDAO">
|
||||
<resultMap type="article" id="articleMap">
|
||||
<id property="articleid" column="articleid" />
|
||||
<result property="title" column="title" />
|
||||
<result property="bannerid" column="bannerid" />
|
||||
<result property="image" column="image" />
|
||||
<result property="istop" column="istop" />
|
||||
<result property="isflv" column="isflv" />
|
||||
<result property="contents" column="contents" />
|
||||
<result property="addtime" column="addtime" />
|
||||
<result property="hits" column="hits" />
|
||||
<result property="bannername" column="bannername" />
|
||||
</resultMap>
|
||||
<!-- 插入语句 DAO通过id调用此配置 -->
|
||||
<insert id="insertArticle" parameterType="article">
|
||||
insert into article(articleid , title , bannerid , image , istop , isflv , contents , addtime , hits )
|
||||
values(#{articleid} , #{title} , #{bannerid} , #{image} ,
|
||||
#{istop} , #{isflv} , #{contents} , #{addtime} , #{hits} )
|
||||
</insert>
|
||||
<!-- 更新语句 DAO通过id调用此配置 -->
|
||||
<update id="updateArticle" parameterType="article">
|
||||
update article set title=#{title} , bannerid=#{bannerid} , image=#{image} , istop=#{istop} , isflv=#{isflv} ,
|
||||
contents=#{contents} , addtime=#{addtime} ,
|
||||
hits=#{hits} where articleid=#{articleid}
|
||||
</update>
|
||||
<!-- 按主键删除 DAO通过id调用此配置 -->
|
||||
<delete id="deleteArticle" parameterType="String">
|
||||
delete from article where articleid = #{articleid}
|
||||
</delete>
|
||||
<!-- 查询全部信息 DAO通过id调用此配置 -->
|
||||
<select id="getAllArticle" resultMap="articleMap">
|
||||
select a.* , b.bannername from article a , banner b where a.bannerid = b.bannerid order by articleid desc
|
||||
</select>
|
||||
<select id="getFlvArticle" resultMap="articleMap">
|
||||
select a.* , b.bannername
|
||||
from article a , banner b where a.bannerid = b.bannerid and isflv =
|
||||
'是' order by
|
||||
articleid
|
||||
desc limit 7
|
||||
</select>
|
||||
<select id="getTopArticle" resultMap="articleMap">
|
||||
select a.* , b.bannername
|
||||
from article a , banner b where a.bannerid = b.bannerid and istop = '是' order by articleid desc limit 7
|
||||
</select>
|
||||
<select id="getArticleByBanner" parameterType="String" resultMap="articleMap">
|
||||
select a.* , b.bannername from article a , banner b where
|
||||
a.bannerid =
|
||||
b.bannerid and
|
||||
a.bannerid = #{bannerid} order by
|
||||
articleid
|
||||
desc limit 7
|
||||
</select>
|
||||
<!-- 按主键查询 DAO通过id调用此配置 -->
|
||||
<select id="getArticleById" parameterType="String" resultMap="articleMap">
|
||||
select a.* , b.bannername from article a , banner b where a.bannerid = b.bannerid
|
||||
and articleid=#{articleid} order by articleid desc
|
||||
</select>
|
||||
<!-- 按条件精确查询 DAO通过id调用此配置 -->
|
||||
<select id="getArticleByCond" parameterType="article" resultMap="articleMap">
|
||||
select a.* , b.bannername from article a , banner b where a.bannerid = b.bannerid
|
||||
<if test="title != null and '' != title">
|
||||
and a.title = #{title}
|
||||
</if>
|
||||
<if test="bannerid != null and '' != bannerid">
|
||||
and a.bannerid = #{bannerid}
|
||||
</if>
|
||||
<if test="image != null and '' != image">
|
||||
and a.image = #{image}
|
||||
</if>
|
||||
<if test="istop != null and '' != istop">
|
||||
and a.istop = #{istop}
|
||||
</if>
|
||||
<if test="isflv != null and '' != isflv">
|
||||
and a.isflv = #{isflv}
|
||||
</if>
|
||||
<if test="contents != null and '' != contents">
|
||||
and a.contents = #{contents}
|
||||
</if>
|
||||
<if test="addtime != null and '' != addtime">
|
||||
and a.addtime = #{addtime}
|
||||
</if>
|
||||
<if test="hits != null and '' != hits">
|
||||
and a.hits = #{hits}
|
||||
</if>
|
||||
</select>
|
||||
<!-- 按条件模糊查询 DAO通过id调用此配置 -->
|
||||
<select id="getArticleByLike" parameterType="article" resultMap="articleMap">
|
||||
select a.* , b.bannername from article a , banner b where a.bannerid = b.bannerid
|
||||
<if test="title != null and '' != title">
|
||||
and a.title like CONCAT('%', CONCAT(#{title}, '%'))
|
||||
</if>
|
||||
<if test="bannerid != null and '' != bannerid">
|
||||
and b.bannername like CONCAT('%', CONCAT(#{bannerid}, '%'))
|
||||
</if>
|
||||
<if test="image != null and '' != image">
|
||||
and a.image like CONCAT('%', CONCAT(#{image}, '%'))
|
||||
</if>
|
||||
<if test="istop != null and '' != istop">
|
||||
and a.istop like CONCAT('%', CONCAT(#{istop}, '%'))
|
||||
</if>
|
||||
<if test="isflv != null and '' != isflv">
|
||||
and a.isflv like CONCAT('%', CONCAT(#{isflv}, '%'))
|
||||
</if>
|
||||
<if test="contents != null and '' != contents">
|
||||
and a.contents like CONCAT('%', CONCAT(#{contents}, '%'))
|
||||
</if>
|
||||
<if test="addtime != null and '' != addtime">
|
||||
and a.addtime like CONCAT('%', CONCAT(#{addtime}, '%'))
|
||||
</if>
|
||||
<if test="hits != null and '' != hits">
|
||||
and a.hits like CONCAT('%', CONCAT(#{hits}, '%'))
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,89 @@
|
||||
<?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">
|
||||
<!-- 配置Mabatis映射文件 -->
|
||||
<mapper namespace="com.dao.BannerDAO">
|
||||
<resultMap type="banner" id="bannerMap">
|
||||
<id property="bannerid" column="bannerid" />
|
||||
<result property="bannername" column="bannername" />
|
||||
<result property="addtime" column="addtime" />
|
||||
<result property="memo" column="memo" />
|
||||
</resultMap>
|
||||
<!-- 插入语句 DAO通过id调用此配置 -->
|
||||
<insert id="insertBanner" parameterType="banner">
|
||||
insert into banner(bannerid , bannername , addtime , memo ) values(#{bannerid} , #{bannername} , #{addtime} ,
|
||||
#{memo} )
|
||||
</insert>
|
||||
<!-- 更新语句 DAO通过id调用此配置 -->
|
||||
<update id="updateBanner" parameterType="banner">
|
||||
update banner set bannername=#{bannername} , addtime=#{addtime} , memo=#{memo} where bannerid=#{bannerid}
|
||||
</update>
|
||||
<!-- 按主键删除 DAO通过id调用此配置 -->
|
||||
<delete id="deleteBanner" parameterType="String">
|
||||
delete from banner where bannerid = #{bannerid}
|
||||
</delete>
|
||||
<!-- 查询全部信息 DAO通过id调用此配置 -->
|
||||
<select id="getAllBanner" resultMap="bannerMap">
|
||||
select a.* from banner a order by bannerid asc
|
||||
</select>
|
||||
|
||||
<!-- 按主键查询 DAO通过id调用此配置 -->
|
||||
<select id="getBannerById" parameterType="String" resultMap="bannerMap">
|
||||
select a.* from banner a where a.bannerid=#{bannerid} order by bannerid desc
|
||||
</select>
|
||||
<!-- 按条件精确查询 DAO通过id调用此配置 -->
|
||||
<select id="getBannerByCond" parameterType="banner" resultMap="bannerMap">
|
||||
select a.* from banner a where 1=1
|
||||
<if test="bannername != null and '' != bannername">
|
||||
and a.bannername = #{bannername}
|
||||
</if>
|
||||
<if test="addtime != null and '' != addtime">
|
||||
and a.addtime = #{addtime}
|
||||
</if>
|
||||
<if test="memo != null and '' != memo">
|
||||
and a.memo = #{memo}
|
||||
</if>
|
||||
</select>
|
||||
<!-- 按条件模糊查询 DAO通过id调用此配置 -->
|
||||
<select id="getBannerByLike" parameterType="banner" resultMap="bannerMap">
|
||||
select a.* from banner a where 1=1
|
||||
<if test="bannername != null and '' != bannername">
|
||||
and a.bannername like CONCAT('%', CONCAT(#{bannername}, '%'))
|
||||
</if>
|
||||
<if test="addtime != null and '' != addtime">
|
||||
and a.addtime like CONCAT('%', CONCAT(#{addtime}, '%'))
|
||||
</if>
|
||||
<if test="memo != null and '' != memo">
|
||||
and a.memo like CONCAT('%', CONCAT(#{memo}, '%'))
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in new issue