parent
3640480dfd
commit
c7ce82334b
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
<!--
|
||||
Mapping file autogenerated by MyEclipse Persistence Tools
|
||||
-->
|
||||
<hibernate-mapping>
|
||||
<class name="com.Xztype" table="xztype" catalog="postgres">
|
||||
<id name="id" type="java.lang.Integer">
|
||||
<column name="id" />
|
||||
<generator class="identity" />
|
||||
</id>
|
||||
<property name="name" type="java.lang.String">
|
||||
<column name="name" length="45" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
@ -1,340 +0,0 @@
|
||||
package action;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import model.Admin;
|
||||
import model.Classify;
|
||||
import model.PageBean;
|
||||
import model.Product;
|
||||
import model.User;
|
||||
import model.UserAndAdmin;
|
||||
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import service.IAdminInfoService;
|
||||
import service.ILoginService;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ModelDriven;
|
||||
|
||||
public class AdminAction extends ActionSupport implements ModelDriven<Admin>{
|
||||
|
||||
Admin admin=new Admin();
|
||||
@Override
|
||||
public Admin getModel() {
|
||||
return admin;
|
||||
}
|
||||
|
||||
ILoginService iLoginService;
|
||||
public void setiLoginService(ILoginService iLoginService) {
|
||||
this.iLoginService = iLoginService;
|
||||
}
|
||||
|
||||
IAdminInfoService iAdminInfoService;
|
||||
public void setiAdminInfoService(IAdminInfoService iAdminInfoService) {
|
||||
this.iAdminInfoService = iAdminInfoService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 管理员登录
|
||||
*/
|
||||
public String AdminLogin(){
|
||||
HttpServletRequest req=ServletActionContext.getRequest();
|
||||
if(admin==null){
|
||||
this.addActionError("请输入账号和密码!");
|
||||
return "adminLogin";
|
||||
}
|
||||
Admin a=this.iLoginService.findByAdmin(admin);
|
||||
if(a==null){
|
||||
this.addActionError("管理员帐户或密码错误!");
|
||||
return "adminLogin";
|
||||
}else{
|
||||
req.getSession().setAttribute("Admin", admin);
|
||||
return "adminIndex";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 注销登录
|
||||
*/
|
||||
public String Exitlogin(){
|
||||
HttpServletRequest req=ServletActionContext.getRequest();
|
||||
req.getSession().removeAttribute("Admin");
|
||||
return "adminLogin";
|
||||
}
|
||||
|
||||
private int currPage=1;//当前页
|
||||
|
||||
public void setCurrPage(int currPage) {
|
||||
this.currPage = currPage;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有管理员
|
||||
*/
|
||||
public String findAllAdminInfo(){
|
||||
PageBean<Admin> pageBean=this.iAdminInfoService.findAllAdminInfo(currPage);
|
||||
if(pageBean!=null){
|
||||
ActionContext.getContext().getValueStack().push(pageBean);
|
||||
}
|
||||
return "adminList";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有用户
|
||||
*/
|
||||
public String findAllUserInfo(){
|
||||
HttpServletRequest req=ServletActionContext.getRequest();
|
||||
String name=req.getParameter("userName");
|
||||
if(name==null){
|
||||
name="";
|
||||
}
|
||||
PageBean<User> pageBean=this.iAdminInfoService.findAllUserInfo(currPage,name);
|
||||
if(pageBean!=null){
|
||||
ActionContext.getContext().getValueStack().push(pageBean);
|
||||
}
|
||||
return "userList";
|
||||
|
||||
}
|
||||
/**
|
||||
* 查询所有分类
|
||||
*/
|
||||
public String findAllCateInfo(){
|
||||
HttpServletRequest req=ServletActionContext.getRequest();
|
||||
String name=req.getParameter("classifyName");
|
||||
if(name==null){
|
||||
name="";
|
||||
}
|
||||
PageBean<Classify> pageBean=this.iAdminInfoService.findAllCateInfo(currPage,name);
|
||||
if(pageBean!=null){
|
||||
ActionContext.getContext().getValueStack().push(pageBean);
|
||||
}
|
||||
return "cateList";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有商品
|
||||
*/
|
||||
public String findAllProductInfo(){
|
||||
HttpServletRequest req=ServletActionContext.getRequest();
|
||||
String name=req.getParameter("proName");
|
||||
String cate=req.getParameter("select_class");
|
||||
String type=req.getParameter("select_type");
|
||||
int cate1=0;
|
||||
int type1=2;
|
||||
if(name==null){
|
||||
name="";
|
||||
}
|
||||
if(cate!=null&&cate!=""){
|
||||
cate1=Integer.parseInt(req.getParameter("select_class"));
|
||||
}
|
||||
if(type!=null&&type!=""){
|
||||
type1=Integer.parseInt(req.getParameter("select_type"));
|
||||
}
|
||||
PageBean<Product> pageBean=this.iAdminInfoService.findAllProductInfo(currPage,name,cate1,type1);
|
||||
if(pageBean!=null){
|
||||
ActionContext.getContext().getValueStack().push(pageBean);
|
||||
}
|
||||
List<Classify> cateList=this.iAdminInfoService.findAllCateList();
|
||||
if(cateList!=null){
|
||||
ActionContext.getContext().put("cateList", cateList);
|
||||
}
|
||||
return "productList";
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询单个商品详情信息
|
||||
*/
|
||||
public String searchProductDetail(){
|
||||
HttpServletRequest req=ServletActionContext.getRequest();
|
||||
int pid=Integer.parseInt(req.getParameter("id"));
|
||||
Product product=this.iAdminInfoService.searchProductDetail(pid);
|
||||
if(product!=null){
|
||||
ActionContext.getContext().put("product", product);
|
||||
}
|
||||
return "productDetail";
|
||||
}
|
||||
/**
|
||||
* 根据id删除单个商品
|
||||
*/
|
||||
public String delectProductById(){
|
||||
HttpServletRequest req=ServletActionContext.getRequest();
|
||||
int pid=Integer.parseInt(req.getParameter("id"));
|
||||
Product p=this.iAdminInfoService.searchProductDetail(pid);
|
||||
this.iAdminInfoService.delectProductById(pid);
|
||||
Admin admin=(Admin) req.getSession().getAttribute("Admin");
|
||||
UserAndAdmin uaa=new UserAndAdmin();
|
||||
uaa.setAdminId(admin.getAid());
|
||||
uaa.setCreateTime(new Date());
|
||||
uaa.setStatus(0);
|
||||
uaa.setUserId(p.getUser().getUid());
|
||||
uaa.setMessage("您的商品【"+p.getTitle()+"】违反本网站的规章制度,已被管理员删除!");
|
||||
this.iAdminInfoService.saveSystemMessage(uaa);
|
||||
return "success";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户详情信息
|
||||
* @return
|
||||
*/
|
||||
public String searchUserDetail(){
|
||||
HttpServletRequest req=ServletActionContext.getRequest();
|
||||
int uid=Integer.parseInt(req.getParameter("uid"));
|
||||
User user=this.iAdminInfoService.searchUserDetail(uid);
|
||||
if(user!=null){
|
||||
ActionContext.getContext().put("user", user);
|
||||
}
|
||||
return "userDetail";
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id删除分类
|
||||
*/
|
||||
public String delectCateById(){
|
||||
HttpServletRequest req=ServletActionContext.getRequest();
|
||||
int id=Integer.parseInt(req.getParameter("id"));
|
||||
this.iAdminInfoService.delectCateById(id);
|
||||
return "delCatesuccess";
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id删除管理员
|
||||
*/
|
||||
public String delectAdminById(){
|
||||
HttpServletRequest req=ServletActionContext.getRequest();
|
||||
int id=Integer.parseInt(req.getParameter("id"));
|
||||
this.iAdminInfoService.delectAdminById(id);
|
||||
return "delAdminsuccess";
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增管理员
|
||||
*/
|
||||
public String addAdmin(){
|
||||
Admin a=this.iAdminInfoService.findAdminByName(admin.getName());
|
||||
if(a!=null){
|
||||
this.addActionError("该账号已存在!");
|
||||
return "addAdminFail";
|
||||
}
|
||||
this.iAdminInfoService.addAdmin(admin);
|
||||
return "addAdminSucess";
|
||||
}
|
||||
/**
|
||||
* 管理员修改前回显内容
|
||||
*/
|
||||
public String findAdminById(){
|
||||
admin=this.iAdminInfoService.findAdminById(admin.getAid());
|
||||
ActionContext.getContext().put("admin", admin);
|
||||
return "findAdminSuccess";
|
||||
}
|
||||
/**
|
||||
* 管理员修改
|
||||
*/
|
||||
public String updateAdmin(){
|
||||
/*Admin a=this.iAdminInfoService.findAdminByName(admin.getName());
|
||||
if(a!=null){
|
||||
this.addActionError("该账号已存在!");
|
||||
return "updateAdminFail";
|
||||
}*/
|
||||
this.iAdminInfoService.updateAdmin(admin);
|
||||
return "updateAdminSuccess";
|
||||
|
||||
}
|
||||
|
||||
|
||||
Classify cassify=new Classify();
|
||||
|
||||
public Classify getCassify() {
|
||||
return cassify;
|
||||
}
|
||||
|
||||
public void setCassify(Classify cassify) {
|
||||
this.cassify = cassify;
|
||||
}
|
||||
|
||||
private String classifyName;
|
||||
private Integer classifySort;
|
||||
private Integer cid;
|
||||
public String getClassifyName() {
|
||||
return classifyName;
|
||||
}
|
||||
|
||||
public void setClassifyName(String classifyName) {
|
||||
this.classifyName = classifyName;
|
||||
}
|
||||
|
||||
public Integer getClassifySort() {
|
||||
return classifySort;
|
||||
}
|
||||
|
||||
public void setClassifySort(Integer classifySort) {
|
||||
this.classifySort = classifySort;
|
||||
}
|
||||
|
||||
|
||||
public Integer getCid() {
|
||||
return cid;
|
||||
}
|
||||
|
||||
|
||||
public void setCid(Integer cid) {
|
||||
this.cid = cid;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增分类
|
||||
*/
|
||||
public String addCate(){
|
||||
cassify.setClassifyName(classifyName);
|
||||
cassify.setClassifySort(classifySort);
|
||||
Classify c=this.iAdminInfoService.findCateByName(classifyName);
|
||||
if(c!=null){
|
||||
this.addActionError("该分类已存在!");
|
||||
return "addCateFail";
|
||||
}
|
||||
this.iAdminInfoService.addCate(cassify);
|
||||
return "addCateSucess";
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改分类前回显
|
||||
*/
|
||||
public String findCateByName(){
|
||||
HttpServletRequest req=ServletActionContext.getRequest();
|
||||
String cname=req.getParameter("cname");
|
||||
Classify c=this.iAdminInfoService.findCateByName(cname);
|
||||
ActionContext.getContext().put("cate", c);
|
||||
return "findCateSuccess";
|
||||
}
|
||||
/**
|
||||
* 修改分类
|
||||
*/
|
||||
public String updateCate(){
|
||||
/*Classify c=this.iAdminInfoService.findCateByName(classifyName);
|
||||
if(c!=null){
|
||||
this.addActionError("该分类已存在!");
|
||||
return "updateCateFail";
|
||||
}*/
|
||||
cassify.setCid(cid);
|
||||
cassify.setClassifyName(classifyName);
|
||||
cassify.setClassifySort(classifySort);
|
||||
this.iAdminInfoService.updateCate(cassify);
|
||||
return "updateCateSuccess";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,165 +0,0 @@
|
||||
package action;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import service.ILoginService;
|
||||
import util.AddJson;
|
||||
import model.User;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ModelDriven;
|
||||
|
||||
public class UserAction extends ActionSupport implements ModelDriven<User>{
|
||||
|
||||
User user=new User();
|
||||
@Override
|
||||
public User getModel() {
|
||||
return user;
|
||||
}
|
||||
|
||||
ILoginService iLoginService;
|
||||
public void setiLoginService(ILoginService iLoginService) {
|
||||
this.iLoginService = iLoginService;
|
||||
}
|
||||
|
||||
|
||||
HttpServletRequest req=ServletActionContext.getRequest();
|
||||
|
||||
/**
|
||||
* 用户登录
|
||||
* @return
|
||||
*/
|
||||
public String UserLogin(){
|
||||
//HttpServletRequest req=ServletActionContext.getRequest();
|
||||
if(user==null){
|
||||
this.addActionError("请输入账号和密码!");
|
||||
return "login";
|
||||
}
|
||||
|
||||
User u=this.iLoginService.findByUser(user);
|
||||
if(u==null){
|
||||
this.addActionError("用户名或密码错误!");
|
||||
return "login";
|
||||
}else{
|
||||
req.getSession().setAttribute("User", u);
|
||||
return "index";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
*/
|
||||
public String userRegister(){
|
||||
//通过用户名先查询该用户是否已经注册
|
||||
User u=this.iLoginService.findUserByName(user.getUserName());
|
||||
if(u!=null){
|
||||
this.addActionError("该用户已被注册!");
|
||||
return "registerFail";
|
||||
}
|
||||
//user.setHeadPic("images/logo-s.jpg");
|
||||
this.iLoginService.saveUser(user);
|
||||
return "registerSuccess";
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过账号找回密码步骤1
|
||||
*/
|
||||
public String forgetPwd(){
|
||||
//HttpServletRequest req=ServletActionContext.getRequest();
|
||||
String userName=req.getParameter("userName");
|
||||
User u=this.iLoginService.findUserByName(userName);
|
||||
if(u==null){
|
||||
this.addFieldError(userName, "用户名错误!");
|
||||
return "getPwdFail";
|
||||
}
|
||||
if(u.getQusetion()==null){
|
||||
this.addActionError("抱歉!你没有设置问题和密码!");
|
||||
return "getPwdFail";
|
||||
}
|
||||
req.getSession().setAttribute("User", u);
|
||||
return "getPwdSuccess";
|
||||
|
||||
}
|
||||
/**
|
||||
* 提交问题2
|
||||
*/
|
||||
public String checkAnswer(){
|
||||
//HttpServletRequest req=ServletActionContext.getRequest();
|
||||
String answertext=req.getParameter("answer");
|
||||
User u=this.iLoginService.findUserByName(user.getUserName());
|
||||
if(u!=null){
|
||||
String answer=u.getAnswer();
|
||||
if(!answer.equals(answertext)){
|
||||
this.addActionError("抱歉!回答错误!");
|
||||
return "answerFalse";
|
||||
}
|
||||
}
|
||||
req.getSession().setAttribute("User", u);
|
||||
return "answerTrue";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新设置密码3
|
||||
*/
|
||||
public String updatePwd(){
|
||||
this.iLoginService.updatePed(user);
|
||||
return "updatePwdSuccess";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户账号信息
|
||||
* @throws Exception
|
||||
*/
|
||||
public void searchPersonalInfo() throws Exception{
|
||||
//HttpServletRequest req=ServletActionContext.getRequest();
|
||||
int uid=Integer.parseInt(req.getParameter("uid"));
|
||||
if(uid==0){
|
||||
throw new Exception("用户不存在!");
|
||||
}
|
||||
user=this.iLoginService.searchUserInfoById(uid);
|
||||
AddJson json=new AddJson();
|
||||
json.toJson(user);
|
||||
//return "findUserInfoSuccess";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户信息
|
||||
*/
|
||||
public void updateUserInfoById(){
|
||||
int uid=Integer.parseInt(req.getParameter("uid"));
|
||||
String uname=req.getParameter("userName");
|
||||
String pass=req.getParameter("password");
|
||||
String uclass=req.getParameter("schoolClass");
|
||||
String address=req.getParameter("address");
|
||||
String phone=req.getParameter("phone");
|
||||
String qusetion=req.getParameter("qusetion");
|
||||
String answer=req.getParameter("answer");
|
||||
int sex=Integer.parseInt(req.getParameter("sex"));
|
||||
User uu=new User();
|
||||
//uu.setAddress(address);
|
||||
uu.setAnswer(answer);
|
||||
uu.setPassword(pass);
|
||||
uu.setPhone(phone);
|
||||
uu.setUid(uid);
|
||||
uu.setUserName(uname);
|
||||
uu.setQusetion(qusetion);
|
||||
uu.setSex(sex);
|
||||
this.iLoginService.updateUser(uu);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户退出的登录
|
||||
*/
|
||||
public String userExitLogin(){
|
||||
req.getSession().removeAttribute("User");
|
||||
return "UserexitSuccess";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,168 +0,0 @@
|
||||
package dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import model.Admin;
|
||||
import model.Classify;
|
||||
import model.Product;
|
||||
import model.User;
|
||||
import model.UserAndAdmin;
|
||||
|
||||
public interface IAdminInfoDao {
|
||||
|
||||
/**
|
||||
* 查询管理员数量
|
||||
* @return
|
||||
*/
|
||||
int findAdminCount();
|
||||
|
||||
/**
|
||||
* 分页查询管理员列表
|
||||
* @param begin
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
List<Admin> findAllAdminInfo(int begin, int pageSize);
|
||||
|
||||
/**
|
||||
* 查询用户数量
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
int findUserCount(String name);
|
||||
|
||||
/**
|
||||
* 分页查询用户列表
|
||||
* @param begin
|
||||
* @param pageSize
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
List<User> findAllUserInfo(int begin, int pageSize,String name);
|
||||
|
||||
/**
|
||||
* 查询分类数量
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
int findCateCount(String name);
|
||||
|
||||
/**
|
||||
* 分页查询分类列表
|
||||
* @param begin
|
||||
* @param pageSize
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
List<Classify> findAllCateInfo(int begin, int pageSize, String name);
|
||||
|
||||
/**
|
||||
* 查询商品数量
|
||||
* @param name
|
||||
* @param cate
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
int findProductCount(String name, int cate, int type);
|
||||
|
||||
/**
|
||||
* 查询商品列表
|
||||
* @param begin
|
||||
* @param pageSize
|
||||
* @param name
|
||||
* @param cate
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
List<Product> findAllProductInfo(int begin, int pageSize, String name, int cate, int type);
|
||||
|
||||
/**
|
||||
* 分类列表查询
|
||||
* @return
|
||||
*/
|
||||
List<Classify> findAllCateList();
|
||||
|
||||
/**
|
||||
* 查询商品详情
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
Product searchProductDetail(int pid);
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
* @param pid
|
||||
*/
|
||||
void delectProductById(int pid);
|
||||
|
||||
/**
|
||||
* 查询用户详情
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
User searchUserDetail(int uid);
|
||||
|
||||
/**
|
||||
* 删除分类
|
||||
* @param id
|
||||
*/
|
||||
void delectCateById(int id);
|
||||
|
||||
/**
|
||||
* 删除管理员
|
||||
* @param id
|
||||
*/
|
||||
void delectAdminById(int id);
|
||||
|
||||
/**
|
||||
* 新增管理员
|
||||
* @param admin
|
||||
*/
|
||||
void addAdmin(Admin admin);
|
||||
|
||||
/**
|
||||
* 通过管理员帐户查询
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
Admin findAdminByName(String name);
|
||||
|
||||
/**
|
||||
* 通过id查询管理员信息
|
||||
* @param aid
|
||||
* @return
|
||||
*/
|
||||
Admin findAdminById(Integer aid);
|
||||
|
||||
/**
|
||||
* 修改管理员
|
||||
* @param admin
|
||||
*/
|
||||
void updateAdmin(Admin admin);
|
||||
|
||||
/**
|
||||
* 根据分类名称查询分类信息
|
||||
* @param classifyName
|
||||
* @return
|
||||
*/
|
||||
Classify findCateByName(String classifyName);
|
||||
|
||||
/**
|
||||
* 新增分类
|
||||
* @param cassify
|
||||
*/
|
||||
void addCate(Classify cassify);
|
||||
|
||||
/**
|
||||
* 修改分类
|
||||
* @param cassify
|
||||
*/
|
||||
void updateCate(Classify cassify);
|
||||
|
||||
/**
|
||||
* <p>Description: 后台删除商品发送通知给用户</p>
|
||||
* @param uaa
|
||||
*/
|
||||
void saveSystemMessage(UserAndAdmin uaa);
|
||||
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
package dao;
|
||||
|
||||
import model.Admin;
|
||||
import model.User;
|
||||
|
||||
public interface ILoginDao {
|
||||
|
||||
/**
|
||||
* 通过用户名和密码查询用户
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
User findByUser(User user);
|
||||
|
||||
/**
|
||||
* 通过账号和密码查询管理员
|
||||
* @param admin
|
||||
* @return
|
||||
*/
|
||||
Admin findByAdmin(Admin admin);
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
User findUserByName(String userName);
|
||||
|
||||
/**
|
||||
* 保存用户信息
|
||||
* @param user
|
||||
*/
|
||||
void saveUser(User user);
|
||||
|
||||
/**
|
||||
* 修改用户密码
|
||||
* @param user
|
||||
*/
|
||||
void updatePed(User user);
|
||||
|
||||
/**
|
||||
* 通过用户id查询用户信息
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
User searchUserInfoById(int uid);
|
||||
|
||||
/**
|
||||
* 修改用户信息
|
||||
* @param user
|
||||
*/
|
||||
void updateUser(User user);
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
package dao;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import model.Classify;
|
||||
import model.Product;
|
||||
import model.User;
|
||||
import model.UserAndAdmin;
|
||||
|
||||
public interface IUserDao {
|
||||
|
||||
/**
|
||||
* 发布供求信息
|
||||
* @param product
|
||||
*/
|
||||
void saveProduct(Product product);
|
||||
|
||||
/**
|
||||
* 查询分类列表
|
||||
* @return
|
||||
*/
|
||||
List<Classify> searchClassifyList();
|
||||
|
||||
/**
|
||||
* 查询商品
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
List<Product> searchProductList(Map<Object, String> map);
|
||||
|
||||
/**
|
||||
* 查询商品数量
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
int searchProductCount(Map<Object, String> map);
|
||||
|
||||
/**
|
||||
* 查询商品详情
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Product getProductDetail(String id);
|
||||
|
||||
|
||||
/**
|
||||
* 通过分类id获取分类信息
|
||||
* @param classifyId
|
||||
*/
|
||||
Classify getClassifyById(Integer classifyId);
|
||||
|
||||
User getUserById(Integer creatorId);
|
||||
|
||||
void updateProduct(Product product);
|
||||
|
||||
|
||||
/**
|
||||
* <p>Description: 查询我发布的商品列表数量</p>
|
||||
* @param parseInt
|
||||
* @return
|
||||
*/
|
||||
int searchMyProductCount(int parseInt);
|
||||
|
||||
/**
|
||||
* <p>Description: 查询我发布的商品列表信息</p>
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
List<Product> getMyProductList(Map<Object, String> map);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Description: 删除我发布的商品</p>
|
||||
* @param pid
|
||||
*/
|
||||
void delectProductById(int pid);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Description: 保存用户消息</p>
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
void saveUserMessage(UserAndAdmin uaa);
|
||||
|
||||
/**
|
||||
* <p>Description: 保存用户消息数量</p>
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
int searchMessageCount(int uid, String flag);
|
||||
|
||||
/**
|
||||
* <p>Description: 保存用户消息</p>
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
List<UserAndAdmin> getMessageList(Map<Object, String> map);
|
||||
|
||||
/**
|
||||
* 通过id删除消息
|
||||
*/
|
||||
void deleteMessage(int id);
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,269 +0,0 @@
|
||||
package dao.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import model.Admin;
|
||||
import model.Classify;
|
||||
import model.Product;
|
||||
import model.User;
|
||||
import model.UserAndAdmin;
|
||||
|
||||
import org.hibernate.criterion.DetachedCriteria;
|
||||
import org.hibernate.criterion.MatchMode;
|
||||
import org.hibernate.criterion.Order;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
|
||||
import dao.IAdminInfoDao;
|
||||
|
||||
public class AdminInfoDao extends HibernateDaoSupport implements IAdminInfoDao {
|
||||
|
||||
@Override
|
||||
public List<Admin> findAllAdminInfo(int begin, int pageSize) {
|
||||
DetachedCriteria dc=DetachedCriteria.forClass(Admin.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Admin> list=this.getHibernateTemplate().findByCriteria(dc, begin, pageSize);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int findAdminCount() {
|
||||
String hql="select count(*) from Admin";
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Long> list=this.getHibernateTemplate().find(hql);
|
||||
if(list.size()>0){
|
||||
return list.get(0).intValue();
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int findUserCount(String name) {
|
||||
StringBuffer br=new StringBuffer();
|
||||
|
||||
String hql="select count(*) from User " ;
|
||||
if(name!=null){
|
||||
String uname="%"+name+"%";
|
||||
br.append("where userName like '"+uname+"'");
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Long> list=this.getHibernateTemplate().find(hql+br.toString());
|
||||
if(list.size()>0){
|
||||
return list.get(0).intValue();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> findAllUserInfo(int begin, int pageSize,String name) {
|
||||
String uname="%"+name+"%";
|
||||
DetachedCriteria dc=DetachedCriteria.forClass(User.class)
|
||||
.add(Restrictions.like("userName", uname, MatchMode.ANYWHERE))
|
||||
.addOrder(Order.desc("uid"));
|
||||
@SuppressWarnings("unchecked")
|
||||
List<User> list=this.getHibernateTemplate().findByCriteria(dc, begin, pageSize);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int findCateCount(String name) {
|
||||
StringBuffer br=new StringBuffer();
|
||||
String hql="select count(*) from Classify";
|
||||
if(name!=null){
|
||||
String uname="%"+name+"%";
|
||||
br.append(" where classifyName like '"+uname+"'");
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Long> list=this.getHibernateTemplate().find(hql+br.toString());
|
||||
if(list.size()>0){
|
||||
return list.get(0).intValue();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Classify> findAllCateInfo(int begin, int pageSize, String name) {
|
||||
String uname="%"+name+"%";
|
||||
DetachedCriteria dc=DetachedCriteria.forClass(Classify.class)
|
||||
.add(Restrictions.like("classifyName", uname, MatchMode.ANYWHERE))
|
||||
.addOrder(Order.asc("ClassifySort"));;
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Classify> list=this.getHibernateTemplate().findByCriteria(dc,begin,pageSize);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int findProductCount(String name,int cate,int type) {
|
||||
StringBuffer br=new StringBuffer();
|
||||
String hql="select count(*) from Product p where 1=1";
|
||||
if(name!=""){
|
||||
String uname="%"+name+"%";
|
||||
br.append(" and p.proName like '"+uname+"'");
|
||||
}
|
||||
if(cate!=0){
|
||||
br.append(" and p.classify.cid ='"+cate+"'");
|
||||
}
|
||||
if(type!=2){
|
||||
br.append(" and p.type ='"+type+"'");
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Long> list=this.getHibernateTemplate().find(hql+br.toString());
|
||||
if(list.size()>0){
|
||||
return list.get(0).intValue();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Product> findAllProductInfo(int begin, int pageSize, String name,int cate,int type) {
|
||||
String uname="%"+name+"%";
|
||||
|
||||
DetachedCriteria dc=DetachedCriteria.forClass(Product.class,"p")
|
||||
.add(Restrictions.like("p.proName", uname, MatchMode.ANYWHERE));
|
||||
if(cate!=0){
|
||||
dc.add(Restrictions.eq("p.classify.cid", cate));
|
||||
}
|
||||
if(type!=2){
|
||||
dc.add(Restrictions.eq("p.type", type));
|
||||
}
|
||||
dc.addOrder(Order.desc("p.createTime"));
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Product> list=this.getHibernateTemplate().findByCriteria(dc,begin,pageSize);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Classify> findAllCateList() {
|
||||
String hql="from Classify";
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Classify> cateList=this.getHibernateTemplate().find(hql);
|
||||
return cateList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Product searchProductDetail(int pid) {
|
||||
String hql=" from Product p where p.id=? ";
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Product> list=this.getHibernateTemplate().find(hql,pid);
|
||||
if(list.size()>0){
|
||||
Product p=list.get(0);
|
||||
return p;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delectProductById(int pid) {
|
||||
Product product=this.getHibernateTemplate().get(Product.class, pid);
|
||||
if(product!=null){
|
||||
this.getHibernateTemplate().delete(product);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public User searchUserDetail(int uid) {
|
||||
User user=this.getHibernateTemplate().get(User.class, uid);
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delectCateById(int id) {
|
||||
Classify c=this.getHibernateTemplate().get(Classify.class, id);
|
||||
if(c!=null){
|
||||
this.getHibernateTemplate().delete(c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delectAdminById(int id) {
|
||||
Admin a=this.getHibernateTemplate().get(Admin.class, id);
|
||||
if(a!=null){
|
||||
this.getHibernateTemplate().delete(a);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAdmin(Admin admin) {
|
||||
this.getHibernateTemplate().save(admin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Admin findAdminByName(String name) {
|
||||
String hql="from Admin where name=?";
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Admin> a=this.getHibernateTemplate().find(hql,name);
|
||||
if(a.size()>0){
|
||||
return a.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Admin findAdminById(Integer aid) {
|
||||
return this.getHibernateTemplate().get(Admin.class, aid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改管理员
|
||||
* @param admin
|
||||
*/
|
||||
@Override
|
||||
public void updateAdmin(Admin admin) {
|
||||
this.getHibernateTemplate().update(admin);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分类名称查询分类信息
|
||||
* @param classifyName
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Classify findCateByName(String classifyName) {
|
||||
String hql="from Classify where classifyName=?";
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Classify> list=this.getHibernateTemplate().find(hql,classifyName);
|
||||
if(list.size()>0){
|
||||
return list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增分类
|
||||
* @param cassify
|
||||
*/
|
||||
@Override
|
||||
public void addCate(Classify cassify) {
|
||||
this.getHibernateTemplate().save(cassify);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改分类
|
||||
* @param cassify
|
||||
*/
|
||||
@Override
|
||||
public void updateCate(Classify cassify) {
|
||||
this.getHibernateTemplate().update(cassify);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Description: 后台删除商品发送通知给用户</p>
|
||||
* @param uaa
|
||||
*/
|
||||
@Override
|
||||
public void saveSystemMessage(UserAndAdmin uaa) {
|
||||
this.getHibernateTemplate().save(uaa);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
package dao.impl;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
import model.Admin;
|
||||
import model.User;
|
||||
import dao.ILoginDao;
|
||||
|
||||
public class LoginDao extends HibernateDaoSupport implements ILoginDao {
|
||||
|
||||
/**
|
||||
* 通过账号和密码查询用户
|
||||
*/
|
||||
@Override
|
||||
public User findByUser(User user) {
|
||||
String hql="from User u where u.userName=? and u.password=?";
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
List<User> list=this.getHibernateTemplate().find(hql,user.getUserName(),user.getPassword());
|
||||
if(list.size()>0){
|
||||
return list.get(0);
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过账号和密码查询管理员
|
||||
*/
|
||||
@Override
|
||||
public Admin findByAdmin(Admin admin) {
|
||||
String hql="from Admin a where a.name=? and a.password=?";
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Admin> list=this.getHibernateTemplate().find(hql, admin.getName(),admin.getPassword());
|
||||
if(list.size()>0){
|
||||
return list.get(0);
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*/
|
||||
@Override
|
||||
public User findUserByName(String userName) {
|
||||
String hql="from User where userName=?";
|
||||
@SuppressWarnings("unchecked")
|
||||
List<User> list=this.getHibernateTemplate().find(hql,userName);
|
||||
if(list.size()>0){
|
||||
return list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存用户信息
|
||||
*/
|
||||
@Override
|
||||
public void saveUser(User user) {
|
||||
this.getHibernateTemplate().save(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户密码
|
||||
*/
|
||||
@Override
|
||||
public void updatePed(User user) {
|
||||
User u=this.getHibernateTemplate().get(User.class, user.getUid());
|
||||
u.setPassword(user.getPassword());
|
||||
this.getHibernateTemplate().update(u);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户id查询用户信息
|
||||
*/
|
||||
@Override
|
||||
public User searchUserInfoById(int uid) {
|
||||
User u=this.getHibernateTemplate().get(User.class, uid);
|
||||
return u;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户信息
|
||||
*/
|
||||
@Override
|
||||
public void updateUser(User user) {
|
||||
this.getHibernateTemplate().update(user);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package model;
|
||||
|
||||
public class Classify {
|
||||
|
||||
private Integer cid;
|
||||
private java.lang.String classifyName;//分类名称
|
||||
private Integer ClassifySort;//分类排序
|
||||
|
||||
public Classify() {
|
||||
}
|
||||
public Integer getCid() {
|
||||
return cid;
|
||||
}
|
||||
public void setCid(Integer cid) {
|
||||
this.cid = cid;
|
||||
}
|
||||
public java.lang.String getClassifyName() {
|
||||
return classifyName;
|
||||
}
|
||||
public void setClassifyName(java.lang.String classifyName) {
|
||||
this.classifyName = classifyName;
|
||||
}
|
||||
public Integer getClassifySort() {
|
||||
return ClassifySort;
|
||||
}
|
||||
public void setClassifySort(Integer classifySort) {
|
||||
ClassifySort = classifySort;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,135 +0,0 @@
|
||||
package service;
|
||||
import java.util.List;
|
||||
|
||||
import model.Admin;
|
||||
import model.Classify;
|
||||
import model.PageBean;
|
||||
import model.Product;
|
||||
import model.User;
|
||||
import model.UserAndAdmin;
|
||||
|
||||
public interface IAdminInfoService {
|
||||
|
||||
/**
|
||||
* 查询管理员列表
|
||||
* @param currPage
|
||||
* @return
|
||||
*/
|
||||
PageBean<Admin> findAllAdminInfo(int currPage);
|
||||
|
||||
/**
|
||||
* 查询用户列表
|
||||
* @param currPage
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
PageBean<User> findAllUserInfo(int currPage,String name);
|
||||
|
||||
/**
|
||||
* 查询分类列表
|
||||
* @param currPage
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
PageBean<Classify> findAllCateInfo(int currPage, String name);
|
||||
|
||||
/**
|
||||
* 查询商品列表
|
||||
* @param currPage
|
||||
* @param name
|
||||
* @param cate
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
PageBean<Product> findAllProductInfo(int currPage, String name, int cate, int type);
|
||||
|
||||
/**
|
||||
* 分类列表查询
|
||||
* @return
|
||||
*/
|
||||
List<Classify> findAllCateList();
|
||||
|
||||
/**
|
||||
* 查询商品详情
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
Product searchProductDetail(int pid);
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
* @param pid
|
||||
*/
|
||||
void delectProductById(int pid);
|
||||
|
||||
/**
|
||||
* 查询用户详情
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
User searchUserDetail(int uid);
|
||||
|
||||
/**
|
||||
* 删除分类
|
||||
* @param id
|
||||
*/
|
||||
void delectCateById(int id);
|
||||
|
||||
/**
|
||||
* 删除管理员
|
||||
* @param id
|
||||
*/
|
||||
void delectAdminById(int id);
|
||||
|
||||
/**
|
||||
* 新增管理员
|
||||
* @param admin
|
||||
*/
|
||||
void addAdmin(Admin admin);
|
||||
|
||||
/**
|
||||
* 通过账号查询管理员信息
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
Admin findAdminByName(String name);
|
||||
|
||||
/**
|
||||
* 通过id查询管理员信息
|
||||
* @param aid
|
||||
* @return
|
||||
*/
|
||||
Admin findAdminById(Integer aid);
|
||||
|
||||
/**
|
||||
* 修改管理员
|
||||
* @param admin
|
||||
*/
|
||||
void updateAdmin(Admin admin);
|
||||
|
||||
/**
|
||||
* 根据分类名称查询分类信息
|
||||
* @param classifyName
|
||||
* @return
|
||||
*/
|
||||
Classify findCateByName(String classifyName);
|
||||
|
||||
/**
|
||||
* 新增分类
|
||||
* @param cassify
|
||||
*/
|
||||
void addCate(Classify cassify);
|
||||
|
||||
/**
|
||||
* 修改分类
|
||||
* @param cassify
|
||||
*/
|
||||
void updateCate(Classify cassify);
|
||||
|
||||
/**
|
||||
* <p>Description: 后台删除商品发送通知给用户</p>
|
||||
* @param uaa
|
||||
*/
|
||||
void saveSystemMessage(UserAndAdmin uaa);
|
||||
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
package service;
|
||||
|
||||
import model.Admin;
|
||||
import model.User;
|
||||
|
||||
public interface ILoginService {
|
||||
|
||||
/**
|
||||
* 通过用户名和密码查询用户
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
User findByUser(User user);
|
||||
|
||||
/**
|
||||
* 通过管理员帐户和密码查询管理员
|
||||
* @param admin
|
||||
* @return
|
||||
*/
|
||||
Admin findByAdmin(Admin admin);
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
User findUserByName(String userName);
|
||||
|
||||
/**
|
||||
* 保存用户信息
|
||||
* @param user
|
||||
*/
|
||||
void saveUser(User user);
|
||||
|
||||
/**
|
||||
* 修改用户密码
|
||||
* @param user
|
||||
*/
|
||||
void updatePed(User user);
|
||||
|
||||
/**
|
||||
* 通过用户id查询用户信息
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
User searchUserInfoById(int uid);
|
||||
|
||||
/**
|
||||
* 修改用户信息
|
||||
* @param user
|
||||
*/
|
||||
void updateUser(User user);
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
package service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import model.Classify;
|
||||
import model.PageBean;
|
||||
import model.Product;
|
||||
import model.User;
|
||||
import model.UserAndAdmin;
|
||||
|
||||
public interface IUserService {
|
||||
|
||||
/**
|
||||
* 发布供求信息
|
||||
* @param product
|
||||
*/
|
||||
void saveProduct(Product product);
|
||||
|
||||
/**
|
||||
* 查询分类列表
|
||||
* @return
|
||||
*/
|
||||
List<Classify> searchClassifyList();
|
||||
|
||||
/**
|
||||
* 查询商品
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
PageBean<Product> searchProductList(Map<Object, String> map);
|
||||
|
||||
/**
|
||||
* 查询商品详情
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Product getProductDetail(String id);
|
||||
|
||||
|
||||
/**
|
||||
* 通过分类id获取分类信息
|
||||
* @param classifyId
|
||||
*/
|
||||
Classify getClassifyById(Integer classifyId);
|
||||
|
||||
User getUserById(Integer creatorId);
|
||||
|
||||
void updateProduct(Product product);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Description: 查询我发布的商品列表信息</p>
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
PageBean<Product> searchMyProductByPage(Map<Object, String> map);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Description: 删除我发布的商品</p>
|
||||
* @param pid
|
||||
*/
|
||||
void delectProductById(int pid);
|
||||
|
||||
|
||||
/**
|
||||
* 保存用户消息
|
||||
* @param uaa
|
||||
*/
|
||||
void saveUserMessage(UserAndAdmin uaa);
|
||||
|
||||
/**
|
||||
* 分页消息
|
||||
* @throws Exception
|
||||
* @param flag 0系统消息,1用户消息
|
||||
*/
|
||||
PageBean<UserAndAdmin> searchMessageByPage(Map<Object, String> map);
|
||||
|
||||
/**
|
||||
* 通过id删除消息
|
||||
* @param parseInt
|
||||
*/
|
||||
void deleteMessage(int id);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
package service.impl;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import dao.ILoginDao;
|
||||
import model.Admin;
|
||||
import model.User;
|
||||
import service.ILoginService;
|
||||
@Transactional
|
||||
public class LoginService implements ILoginService{
|
||||
|
||||
private ILoginDao iLoginDao;
|
||||
|
||||
public void setiLoginDao(ILoginDao iLoginDao) {
|
||||
this.iLoginDao = iLoginDao;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户帐户和密码查询用户
|
||||
*/
|
||||
@Override
|
||||
public User findByUser(User user) {
|
||||
return iLoginDao.findByUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过管理员帐户和密码查询管理员
|
||||
*/
|
||||
@Override
|
||||
public Admin findByAdmin(Admin admin) {
|
||||
return iLoginDao.findByAdmin(admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*/
|
||||
@Override
|
||||
public User findUserByName(String userName) {
|
||||
return this.iLoginDao.findUserByName(userName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存用户信息
|
||||
*/
|
||||
@Override
|
||||
public void saveUser(User user) {
|
||||
this.iLoginDao.saveUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户密码
|
||||
*/
|
||||
@Override
|
||||
public void updatePed(User user) {
|
||||
this.iLoginDao.updatePed(user);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户id查询用户信息
|
||||
*/
|
||||
@Override
|
||||
public User searchUserInfoById(int uid) {
|
||||
|
||||
return this.iLoginDao.searchUserInfoById(uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户信息
|
||||
*/
|
||||
@Override
|
||||
public void updateUser(User user) {
|
||||
this.iLoginDao.updateUser(user);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,210 +0,0 @@
|
||||
package service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import model.Classify;
|
||||
import model.PageBean;
|
||||
import model.Product;
|
||||
import model.User;
|
||||
import model.UserAndAdmin;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import service.IUserService;
|
||||
import dao.IUserDao;
|
||||
@Transactional
|
||||
public class UserService implements IUserService {
|
||||
|
||||
private IUserDao iUserDao;
|
||||
|
||||
public void setiUserDao(IUserDao iUserDao) {
|
||||
this.iUserDao = iUserDao;
|
||||
}
|
||||
Integer currPage=1;
|
||||
/**
|
||||
* 发布供求信息
|
||||
*/
|
||||
@Override
|
||||
public void saveProduct(Product product) {
|
||||
this.iUserDao.saveProduct(product);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分类列表
|
||||
*/
|
||||
@Override
|
||||
public List<Classify> searchClassifyList() {
|
||||
|
||||
return this.iUserDao.searchClassifyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询商品
|
||||
*/
|
||||
@Override
|
||||
public PageBean<Product> searchProductList(Map<Object, String> map) {
|
||||
PageBean<Product> pageBean=new PageBean<Product>();
|
||||
//封装当前页
|
||||
currPage=Integer.parseInt(map.get("currPage"));
|
||||
pageBean.setCurrPage(currPage);
|
||||
//封装每页记录数
|
||||
int pageSize=12;
|
||||
pageBean.setPageSize(pageSize);
|
||||
//封装总记录数
|
||||
int totalCount=this.iUserDao.searchProductCount(map);
|
||||
pageBean.setTotalCount(totalCount);
|
||||
//封装总页数
|
||||
double tc=totalCount;
|
||||
Double num=Math.ceil(tc/pageSize);
|
||||
if(num==0){
|
||||
num=(double) 1;
|
||||
}
|
||||
pageBean.setTotalPage(num.intValue());
|
||||
//封装每页显示的数据
|
||||
int begin=(currPage-1)*pageSize;
|
||||
map.put("begin", begin+"");
|
||||
map.put("pageSize", pageSize+"");
|
||||
List<Product> list=this.iUserDao.searchProductList(map);
|
||||
pageBean.setList(list);
|
||||
return pageBean;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询商品详情
|
||||
*/
|
||||
@Override
|
||||
public Product getProductDetail(String id) {
|
||||
|
||||
return this.iUserDao.getProductDetail(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Classify getClassifyById(Integer classifyId) {
|
||||
return this.iUserDao.getClassifyById(classifyId);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getUserById(Integer creatorId) {
|
||||
|
||||
return this.iUserDao.getUserById(creatorId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProduct(Product product) {
|
||||
this.iUserDao.updateProduct(product);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Description: 查询我发布的商品列表信息</p>
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PageBean<Product> searchMyProductByPage(Map<Object, String> map) {
|
||||
PageBean<Product> pageBean=new PageBean<Product>();
|
||||
//封装当前页
|
||||
currPage=Integer.parseInt(map.get("currPage"));
|
||||
pageBean.setCurrPage(currPage);
|
||||
//封装每页记录数
|
||||
int pageSize=5;
|
||||
pageBean.setPageSize(pageSize);
|
||||
//封装总记录数
|
||||
int totalCount=this.iUserDao.searchMyProductCount(Integer.parseInt(map.get("userId")));
|
||||
pageBean.setTotalCount(totalCount);
|
||||
//封装总页数
|
||||
double tc=totalCount;
|
||||
Double num=Math.ceil(tc/pageSize);
|
||||
if(num==0){
|
||||
num=(double) 1;
|
||||
}
|
||||
pageBean.setTotalPage(num.intValue());
|
||||
//封装每页显示的数据
|
||||
int begin=(currPage-1)*pageSize;
|
||||
map.put("begin", begin+"");
|
||||
map.put("pageSize", pageSize+"");
|
||||
List<Product> list=this.iUserDao.getMyProductList(map);
|
||||
pageBean.setList(list);
|
||||
return pageBean;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Description: 删除我发布的商品</p>
|
||||
* @param pid
|
||||
*/
|
||||
@Override
|
||||
public void delectProductById(int pid) {
|
||||
this.iUserDao.delectProductById(pid);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 保存用户消息
|
||||
* @param uaa
|
||||
*/
|
||||
@Override
|
||||
public void saveUserMessage(UserAndAdmin uaa) {
|
||||
this.iUserDao.saveUserMessage(uaa);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页消息
|
||||
* @throws Exception
|
||||
* @param flag 0系统消息,1用户消息
|
||||
*/
|
||||
@Override
|
||||
public PageBean<UserAndAdmin> searchMessageByPage(Map<Object, String> map) {
|
||||
PageBean<UserAndAdmin> pageBean=new PageBean<UserAndAdmin>();
|
||||
//封装当前页
|
||||
currPage=Integer.parseInt(map.get("currPage"));
|
||||
pageBean.setCurrPage(currPage);
|
||||
//封装每页记录数
|
||||
int pageSize=10;
|
||||
pageBean.setPageSize(pageSize);
|
||||
//封装总记录数
|
||||
int totalCount=this.iUserDao.searchMessageCount(Integer.parseInt(map.get("userId")),map.get("flag"));
|
||||
pageBean.setTotalCount(totalCount);
|
||||
//封装总页数
|
||||
double tc=totalCount;
|
||||
Double num=Math.ceil(tc/pageSize);
|
||||
if(num==0){
|
||||
num=(double) 1;
|
||||
}
|
||||
pageBean.setTotalPage(num.intValue());
|
||||
//封装每页显示的数据
|
||||
int begin=(currPage-1)*pageSize;
|
||||
map.put("begin", begin+"");
|
||||
map.put("pageSize", pageSize+"");
|
||||
List<UserAndAdmin> list=this.iUserDao.getMessageList(map);
|
||||
pageBean.setList(list);
|
||||
return pageBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除消息
|
||||
*/
|
||||
@Override
|
||||
public void deleteMessage(int id) {
|
||||
this.iUserDao.deleteMessage(id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
package util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.alibaba.fastjson.serializer.ValueFilter;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
/**
|
||||
* 将数据转成json数据格式
|
||||
*
|
||||
*/
|
||||
public class AddJson extends ActionSupport{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static ValueFilter filter = new ValueFilter() {
|
||||
@Override
|
||||
public Object process(Object obj, String s, Object v) {
|
||||
if (v == null)
|
||||
return "";
|
||||
return v;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* 将JavaBean序列化为JSON文本
|
||||
* @param str
|
||||
* @throws IOException
|
||||
*/
|
||||
public void toJson(Object str) throws IOException{
|
||||
HttpServletResponse response=ServletActionContext.getResponse();
|
||||
response.setHeader("Cache-Control", "no-cache");
|
||||
response.setHeader("Pragma", "no-cache");
|
||||
response.setDateHeader("Expires", 0);
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
|
||||
String responseStr = JSON.toJSONString(str,filter,SerializerFeature.WriteNullStringAsEmpty);
|
||||
Writer writer = response.getWriter();
|
||||
writer.write(responseStr);
|
||||
writer.flush();
|
||||
}
|
||||
/**
|
||||
* 将JavaBean转换为JSONObject
|
||||
* @param str
|
||||
* @throws IOException
|
||||
*/
|
||||
public void toJsonObj(Object str) throws IOException{
|
||||
HttpServletResponse response=ServletActionContext.getResponse();
|
||||
response.setHeader("Cache-Control", "no-cache");
|
||||
response.setHeader("Pragma", "no-cache");
|
||||
response.setDateHeader("Expires", 0);
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
|
||||
Object responseStr = JSON.toJSON(str);
|
||||
Writer writer = response.getWriter();
|
||||
writer.write(responseStr.toString());
|
||||
writer.flush();
|
||||
}
|
||||
/**
|
||||
* 将JavaBean转换为JSONArray
|
||||
* @param list
|
||||
* @throws IOException
|
||||
*/
|
||||
public <T> void toJsonArray(List<T> list) throws IOException{
|
||||
HttpServletResponse response=ServletActionContext.getResponse();
|
||||
response.setHeader("Cache-Control", "no-cache");
|
||||
response.setHeader("Pragma", "no-cache");
|
||||
response.setDateHeader("Expires", 0);
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
|
||||
Object obj = JSON.toJSON(list);
|
||||
Writer writer = response.getWriter();
|
||||
writer.write("{\"length\":"+list.size()+" ,");
|
||||
writer.write("\"data\":"+obj.toString()+"}");
|
||||
writer.flush();
|
||||
}
|
||||
|
||||
public <T> void toJsonList(int len,List<T> list) throws IOException{
|
||||
HttpServletResponse response=ServletActionContext.getResponse();
|
||||
response.setHeader("Cache-Control", "no-cache");
|
||||
response.setHeader("Pragma", "no-cache");
|
||||
response.setDateHeader("Expires", 0);
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
|
||||
String responseStr = JSON.toJSONString(list,filter);
|
||||
Writer writer = response.getWriter();
|
||||
//writer.write(responseStr);
|
||||
writer.write("{\"length\":"+len+" ,");
|
||||
writer.write("\"data\":"+responseStr+"}");
|
||||
writer.flush();
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.Xztype;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
|
||||
import com.HibernateSessionFactory;
|
||||
import com.Xz;
|
||||
|
||||
|
||||
public class NavigationServlet extends HttpServlet {
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
navigate( request, response);
|
||||
}
|
||||
|
||||
public void navigate(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
int xtid=Integer.parseInt(request.getParameter("id"));
|
||||
/* try{
|
||||
xid=Integer.parseInt(request.getParameter("id"));
|
||||
}catch(NumberFormatException e){
|
||||
}*/
|
||||
Session session=HibernateSessionFactory.getSession();
|
||||
Transaction tx=null;
|
||||
List<Xztype> xztype=null;
|
||||
try{
|
||||
tx=session.beginTransaction();
|
||||
Query query=session.createQuery("FROM Xztype xztype where xztype.id=:xtid");
|
||||
query.setParameter("xtid", Integer.parseInt(request.getParameter("id")));
|
||||
xztype=query.list();
|
||||
tx.commit();
|
||||
}catch(HibernateException e){
|
||||
if(tx!=null) tx.rollback();
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
session.close();
|
||||
}
|
||||
if(xztype!=null){
|
||||
request.setAttribute("xztype", xztype);
|
||||
RequestDispatcher rd=request.getRequestDispatcher("ckxz.jsp");
|
||||
rd.forward(request, response);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com;
|
||||
|
||||
/**
|
||||
* AbstractXztype entity provides the base persistence definition of the Xztype
|
||||
* entity. @author MyEclipse Persistence Tools
|
||||
*/
|
||||
|
||||
public abstract class AbstractXztype implements java.io.Serializable {
|
||||
|
||||
// Fields
|
||||
|
||||
private Integer id;
|
||||
private String name;
|
||||
|
||||
// Constructors
|
||||
|
||||
/** default constructor */
|
||||
public AbstractXztype() {
|
||||
}
|
||||
|
||||
/** full constructor */
|
||||
public AbstractXztype(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
// Property accessors
|
||||
|
||||
public Integer getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
<!--
|
||||
Mapping file autogenerated by MyEclipse Persistence Tools
|
||||
-->
|
||||
<hibernate-mapping>
|
||||
<class name="com.Xztype" table="xztype" catalog="postgres">
|
||||
<id name="id" type="java.lang.Integer">
|
||||
<column name="id" />
|
||||
<generator class="identity" />
|
||||
</id>
|
||||
<property name="name" type="java.lang.String">
|
||||
<column name="name" length="45" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
@ -0,0 +1,19 @@
|
||||
package com;
|
||||
|
||||
/**
|
||||
* Xztype entity. @author MyEclipse Persistence Tools
|
||||
*/
|
||||
public class Xztype extends AbstractXztype implements java.io.Serializable {
|
||||
|
||||
// Constructors
|
||||
|
||||
/** default constructor */
|
||||
public Xztype() {
|
||||
}
|
||||
|
||||
/** full constructor */
|
||||
public Xztype(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue