基于SSM的手机商城--JAVA【毕业设计、快速开发、源码、开题报告】

  

功能介绍

注册用户:收藏管理、订单管理、地址管理、安全管理、购物车管理

   管理员:商品管理、订单管理、用户管理、轮播图管理、评论管理、商品分类管理、账户管理

部分功能模块代码

package com.phonemarket.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.phonemarket.entity.Address;
import com.phonemarket.entity.Areas;
import com.phonemarket.entity.Cities;
import com.phonemarket.entity.Provinces;
import com.phonemarket.entity.Users;
import com.phonemarket.service.IAddressService;
import com.phonemarket.service.IProCityAreaService;

/**
 * @author 张贤
 *
 */
@Controller
@RequestMapping("/address")
public class AddressController {
	@Autowired
	private IAddressService addressService;
	@Autowired
	private IProCityAreaService pService;

	@RequestMapping("findAddrByUserId")
	@ResponseBody
	public List<Address> findAddrByUserId(HttpServletRequest request) {
		HttpSession session = request.getSession();
		Users user = (Users) session.getAttribute("user");
		List<Address> list = addressService.findAddressByUserId(user.getUserId());
		return list;
	}

	@RequestMapping("addAddress")
	@ResponseBody
	public String addAddress(Address addr,HttpServletRequest request) {
		String provinceId = addr.getAddrProvince();
		String cityId = addr.getAddrCity();
		String areaId = addr.getAddrArea();
		Provinces province = pService.findProvinceById(provinceId);
		Cities city = pService.findCityById(cityId);
		Areas area = pService.findAreaById(areaId);
		addr.setAddrProvince(province.getProvinceName());
		addr.setAddrCity(city.getCityName());
		addr.setAddrArea(area.getAreaName());
		HttpSession session = request.getSession();
		Users user = (Users) session.getAttribute("user");
		addr.setAddrUser(user.getUserId());
		Integer rs = addressService.addAddress(addr);
		if(rs>0){
			return "success";
		}else{
			return "fail";
		}
	}
	@RequestMapping("findAddressById")
	@ResponseBody
	public Address findAddrByAddrId(Integer addrId){
		Address addr = addressService.findAddresById(addrId);
		Provinces province = pService.findProvinceByName(addr.getAddrProvince());
		Cities city = pService.findCityByName(addr.getAddrCity(),province.getProvinceId());
		Areas area = pService.findAreaByName(addr.getAddrArea(),city.getCityId());
		addr.setAddrProvince(province.getProvinceId());
		addr.setAddrCity(city.getCityId());
		addr.setAddrArea(area.getAreaId());
		return addr;
	}
	@RequestMapping("modifyAddress")
	@ResponseBody
	public String modifyAddress(Address addr){
		String provinceId = addr.getAddrProvince();
		String cityId = addr.getAddrCity();
		String areaId = addr.getAddrArea();
		Provinces province = pService.findProvinceById(provinceId);
		Cities city = pService.findCityById(cityId);
		Areas area = pService.findAreaById(areaId);
		addr.setAddrProvince(province.getProvinceName());
		addr.setAddrCity(city.getCityName());
		addr.setAddrArea(area.getAreaName());
		Integer rs = addressService.updateAddress(addr);
		if(rs>0){
			return "success";
		}else{
			return "fail";
		}
	}
	@RequestMapping("deleteAddress")
	@ResponseBody
	public String deleteAddress(Integer addrId){
		Integer rs = addressService.deleteAddress(addrId);
		if(rs>0){
			return "success";
		}else{
			return "fail";
		}
	}
}
package com.phonemarket.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.phonemarket.entity.Address;
import com.phonemarket.entity.Areas;
import com.phonemarket.entity.Cities;
import com.phonemarket.entity.Provinces;
import com.phonemarket.mapper.AddressMapper;
import com.phonemarket.mapper.AreasMapper;
import com.phonemarket.mapper.CitiesMapper;
import com.phonemarket.mapper.ProvincesMapper;
import com.phonemarket.service.IAddressService;

/**
 * @author 张贤
 *
 */
@Service
public class AddressServiceImpl implements IAddressService {
	@Autowired
	private AddressMapper addressMapper;
	@Autowired
	private ProvincesMapper proMapper;
	@Autowired
	private CitiesMapper cityMapper;
	@Autowired
	private AreasMapper areaMapper;
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<Address> findAddressByUserId(Integer userId) {
		return addressMapper.findAddrByUserId(userId);
	}
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public Address findAddresById(Integer id) {
		return addressMapper.findAddrById(id);
	}
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public Provinces findProByProByName(String name) {
		return proMapper.findProByProName(name);
	}
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public Cities findCityByCityName(String name,String provinceId) {
		return cityMapper.findCityByCityName(name,provinceId);
	}
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public Areas findAreaByAreaName(String name,String cityId) {
		return areaMapper.findAreaByAreaName(name,cityId);
	}
	@Transactional(propagation=Propagation.REQUIRED,rollbackFor=Exception.class)
	@Override
	public Integer addAddress(Address addr) {
		return addressMapper.addAddress(addr);
	}
	@Transactional(propagation=Propagation.REQUIRED,rollbackFor=Exception.class)
	@Override
	public Integer updateAddress(Address addr) {
		return addressMapper.updateAddr(addr);
	}
	@Transactional(propagation=Propagation.REQUIRED,rollbackFor=Exception.class)
	@Override
	public Integer deleteAddress(Integer addrId) {
		return addressMapper.deleteAddr(addrId);
	}
	
}

论文目录

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值