通用文件新项目
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
@@ -267,28 +266,20 @@ public class BookLabelAndMarketController {
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/delToLable")
|
||||
public R delToLable(String lableIds) {
|
||||
if (!StringUtils.isEmpty(lableIds)) {
|
||||
String[] ids = lableIds.split(",");
|
||||
if (ids.length>0) {
|
||||
for (String id : ids) {
|
||||
toLabelService.removeById(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
public R delToLable(String lableId,String productId) {
|
||||
LambdaQueryWrapper<ShopProductToBookLabel> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(ShopProductToBookLabel::getBookLabelId,lableId);
|
||||
wrapper.eq(ShopProductToBookLabel::getProductId,productId);
|
||||
toLabelService.remove(wrapper);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/delToMarket")
|
||||
public R delToMarket(String marketds) {
|
||||
if (!StringUtils.isEmpty(marketds)) {
|
||||
String[] ids = marketds.split(",");
|
||||
if (ids.length>0) {
|
||||
for (String id : ids) {
|
||||
toMarketService.removeById(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
public R delToMarket(String marketId,String productId) {
|
||||
LambdaQueryWrapper<ShopProductToBookMarket> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(ShopProductToBookMarket::getBookMarketId,marketId);
|
||||
wrapper.eq(ShopProductToBookMarket::getProductId,productId);
|
||||
toMarketService.remove(wrapper);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.BaseAreaEntity;
|
||||
import com.peanut.modules.common.service.BaseAreaService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 国家区域管理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonBaseArea")
|
||||
@RequestMapping("common/baseArea")
|
||||
public class BaseAreaController {
|
||||
|
||||
@Autowired
|
||||
private BaseAreaService baseAreaService;
|
||||
|
||||
/**
|
||||
* 添加区域
|
||||
* @param baseArea
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/addBaseArea")
|
||||
public R addBaseArea(@RequestBody BaseAreaEntity baseArea){
|
||||
baseAreaService.save(baseArea);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除区域
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/delBaseArea")
|
||||
public R delBaseArea(@RequestBody Map<String,Object> map){
|
||||
Integer areaId = Integer.valueOf(map.get("areaId").toString());
|
||||
baseAreaService.removeById(areaId);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑区域信息
|
||||
* @param baseArea
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/editBaseArea")
|
||||
public R editBaseArea(@RequestBody BaseAreaEntity baseArea){
|
||||
baseAreaService.updateById(baseArea);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取区域列表
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getBaseAreas")
|
||||
public R getBaseAreas(@RequestBody Map<String,Object> map){
|
||||
Integer limit = Integer.valueOf(map.get("limit").toString());
|
||||
Integer page = Integer.valueOf(map.get("page").toString());
|
||||
|
||||
Page baseAreas = baseAreaService.getBaseAreas(limit, page);
|
||||
return R.ok().put("page",baseAreas);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部国家领域
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getAllBaseArea")
|
||||
public R getAllBaseArea(){
|
||||
List<BaseAreaEntity> list = baseAreaService.list();
|
||||
return R.ok().put("baseAreas",list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.City;
|
||||
import com.peanut.modules.common.entity.County;
|
||||
import com.peanut.modules.common.entity.Province;
|
||||
import com.peanut.modules.common.service.CityService;
|
||||
import com.peanut.modules.common.service.CountyService;
|
||||
import com.peanut.modules.common.service.ProvinceService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 省市区管理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonProvince")
|
||||
@RequestMapping("common/province")
|
||||
public class ProvinceController {
|
||||
|
||||
@Autowired
|
||||
private ProvinceService provinceService;
|
||||
@Autowired
|
||||
private CityService cityService;
|
||||
@Autowired
|
||||
private CountyService countyService;
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
//获取地址
|
||||
@RequestMapping("/getProvince")
|
||||
public R getProvince() {
|
||||
//优化查询速度 目录放入redis中
|
||||
String s = redisTemplate.opsForValue().get("Province");
|
||||
List<Map<String, Object>> listData = new ArrayList<>();
|
||||
if (StringUtils.isNotBlank(s)) {
|
||||
List<Object> redisData = JSONArray.parseArray(s);
|
||||
for (Object object : redisData) {
|
||||
Map<String, Object> ret = (Map<String, Object>) object;//取出list里面的值转为map
|
||||
listData.add(ret);
|
||||
}
|
||||
return R.ok().put("provinceEntity", listData);
|
||||
}
|
||||
List<Province> provinceList = provinceService.getCity();
|
||||
redisTemplate.opsForValue().set("Province", JSON.toJSONString(provinceList));
|
||||
return R.ok().put("provinceEntity", provinceList);
|
||||
}
|
||||
|
||||
//获取省列表
|
||||
@RequestMapping("/getProvinceList")
|
||||
public R getProvinceList() {
|
||||
List<Province> provinceList = provinceService.getBaseMapper().selectList(new QueryWrapper<Province>());
|
||||
return R.ok().put("provinceList", provinceList);
|
||||
}
|
||||
|
||||
//获取市列表
|
||||
@RequestMapping("/getCityList")
|
||||
public R getCityList(@RequestParam("provId") Integer provId) {
|
||||
List<City> prov = cityService.getBaseMapper().selectList(new QueryWrapper<City>()
|
||||
.eq("prov_id", provId));
|
||||
return R.ok().put("prov", prov);
|
||||
}
|
||||
|
||||
//获取区列表
|
||||
@RequestMapping("/getCountyList")
|
||||
public R getCountyList(@RequestParam("cityId") Integer cityId) {
|
||||
List<County> countyList = countyService.getBaseMapper().selectList(new QueryWrapper<County>().eq("city_id", cityId));
|
||||
return R.ok().put("countyList", countyList);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.UserAddress;
|
||||
import com.peanut.modules.common.service.UserAddressService;
|
||||
import com.peanut.modules.common.vo.UserAddressVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 收货地址管理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonUserAddress")
|
||||
@RequestMapping("common/userAddress")
|
||||
public class UserAddressController {
|
||||
|
||||
@Autowired
|
||||
private UserAddressService userAddressService;
|
||||
|
||||
/**
|
||||
* 获取地址信息
|
||||
*/
|
||||
@RequestMapping("/info/{addressId}")
|
||||
public R info(@PathVariable("addressId") Integer addressId) {
|
||||
UserAddress userAddress = userAddressService.getById(addressId);
|
||||
UserAddressVo vo = new UserAddressVo();
|
||||
BeanUtil.copyProperties(userAddress, vo);
|
||||
vo = userAddressService.getAddressName(vo, userAddress.getRegionCode());
|
||||
return R.ok().put("result", vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody UserAddress userAddress) {
|
||||
// 判断是否已经有默认的地址了
|
||||
if ((userAddressService.getUserDefaultAddressCount(userAddress.getUserId()) >= 1) && userAddress.getIsDefault() == 1) {
|
||||
return R.error("已经存在默认地址");
|
||||
}
|
||||
if(userAddress.getRegionCode()==null||userAddress.getRegionCode().equals("")){
|
||||
return R.error("地址异常添加失败!");
|
||||
}
|
||||
String str = userAddress.getConsigneeName()+userAddress.getConsigneePhone()+userAddress.getDetailAddress();
|
||||
if(str.contains("+")||str.contains("&")){
|
||||
return R.error("信息中不能含有“+”、“&”符号!");
|
||||
}
|
||||
userAddressService.save(userAddress);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody UserAddress userAddress) {
|
||||
LambdaQueryWrapper<UserAddress> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(UserAddress::getId,userAddress.getId());
|
||||
wrapper.eq(UserAddress::getIsDefault,1);
|
||||
UserAddress ua = userAddressService.getOne(wrapper);
|
||||
if (ua == null){
|
||||
if ((userAddressService.getUserDefaultAddressCount(userAddress.getUserId()) >= 1) && userAddress.getIsDefault() == 1) {
|
||||
return R.error("已经存在默认地址");
|
||||
}
|
||||
}
|
||||
String str = userAddress.getConsigneeName()+userAddress.getConsigneePhone()+userAddress.getDetailAddress();
|
||||
if(str.contains("+")||str.contains("&")){
|
||||
return R.error("信息中不能含有“+”、“&”符号!");
|
||||
}
|
||||
userAddressService.updateById(userAddress);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户地址
|
||||
*/
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.GET)
|
||||
public R delete(@RequestParam("id") Integer id) {
|
||||
userAddressService.removeById(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户收货地址列表
|
||||
*/
|
||||
@RequestMapping("/getUserAddress")
|
||||
public R getUserAddress(@RequestParam("userId") Integer userId) {
|
||||
QueryWrapper<UserAddress> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", userId);
|
||||
queryWrapper.orderByDesc("is_default");
|
||||
List<UserAddress> userAddressList = userAddressService.list(queryWrapper);
|
||||
List<UserAddressVo> result = new ArrayList<>();
|
||||
for (UserAddress userAddress : userAddressList) {
|
||||
UserAddressVo vo = new UserAddressVo();
|
||||
BeanUtil.copyProperties(userAddress, vo);
|
||||
vo = userAddressService.getAddressName(vo, userAddress.getRegionCode());
|
||||
result.add(vo);
|
||||
}
|
||||
return R.ok().put("list", result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.MD5Utils;
|
||||
import com.peanut.common.utils.MailUtil;
|
||||
import com.peanut.common.utils.R;
|
||||
@@ -21,8 +19,11 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 用户登陆注册验证码
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RestController("commonUser")
|
||||
@RequestMapping("common/user")
|
||||
public class UserController {
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.BaseAreaEntity;
|
||||
|
||||
public interface BaseAreaService extends IService<BaseAreaEntity> {
|
||||
|
||||
Page getBaseAreas(Integer limit, Integer page);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.common.entity.City;
|
||||
import java.util.Map;
|
||||
|
||||
public interface CityService extends IService<City> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.common.entity.County;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface CountyService extends IService<County> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.common.entity.Province;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ProvinceService extends IService<Province> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
List<Province> getCity();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.common.entity.UserAddress;
|
||||
import com.peanut.modules.common.vo.UserAddressVo;
|
||||
import java.util.Map;
|
||||
|
||||
public interface UserAddressService extends IService<UserAddress> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
UserAddressVo getAddressName(UserAddressVo vo, String regionCode);
|
||||
|
||||
int getUserDefaultAddressCount(Integer userId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.common.dao.BaseAreaDao;
|
||||
import com.peanut.modules.common.entity.BaseAreaEntity;
|
||||
import com.peanut.modules.common.service.BaseAreaService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("commonBaseAreaService")
|
||||
public class BaseAreaServiceImpl extends ServiceImpl<BaseAreaDao, BaseAreaEntity> implements BaseAreaService {
|
||||
|
||||
@Override
|
||||
public Page getBaseAreas(Integer limit, Integer page) {
|
||||
LambdaQueryWrapper<BaseAreaEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BaseAreaEntity::getDelFlag,0);
|
||||
Page<BaseAreaEntity> baseAreaEntityPage = getBaseMapper().selectPage(new Page<BaseAreaEntity>(page, limit), wrapper);
|
||||
return baseAreaEntityPage;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.common.dao.CityDao;
|
||||
import com.peanut.modules.common.entity.City;
|
||||
import com.peanut.modules.common.service.CityService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service("commonCityService")
|
||||
public class CityServiceImpl extends ServiceImpl<CityDao, City> implements CityService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<City> page = this.page(
|
||||
new Query<City>().getPage(params),
|
||||
new QueryWrapper<City>()
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.common.dao.CountyDao;
|
||||
import com.peanut.modules.common.entity.County;
|
||||
import com.peanut.modules.common.service.CountyService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service("commonCountyService")
|
||||
public class CountyServiceImpl extends ServiceImpl<CountyDao, County> implements CountyService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<County> page = this.page(
|
||||
new Query<County>().getPage(params),
|
||||
new QueryWrapper<County>()
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.common.dao.ProvinceDao;
|
||||
import com.peanut.modules.common.entity.City;
|
||||
import com.peanut.modules.common.entity.County;
|
||||
import com.peanut.modules.common.entity.Province;
|
||||
import com.peanut.modules.common.service.CityService;
|
||||
import com.peanut.modules.common.service.CountyService;
|
||||
import com.peanut.modules.common.service.ProvinceService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service("commonProvinceService")
|
||||
public class ProvinceServiceImpl extends ServiceImpl<ProvinceDao, Province> implements ProvinceService {
|
||||
|
||||
@Autowired
|
||||
private CityService cityService;
|
||||
@Autowired
|
||||
private CountyService countyService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<Province> page = this.page(
|
||||
new Query<Province>().getPage(params),
|
||||
new QueryWrapper<Province>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Province> getCity() {
|
||||
List<Province> provinceList = this.baseMapper.selectList(new QueryWrapper<Province>());
|
||||
for (Province province:provinceList){
|
||||
List<City> prov = cityService.getBaseMapper().selectList(new QueryWrapper<City>()
|
||||
.eq("prov_id", province.getProvId()));
|
||||
if (prov.size() > 0) {
|
||||
for (City city : prov) {
|
||||
List<County> countyList = countyService.getBaseMapper().selectList(new QueryWrapper<County>().eq("city_id", city.getCityId()));
|
||||
if (countyList != null) {
|
||||
city.setCountyList(countyList);
|
||||
}
|
||||
}
|
||||
province.setCityList(prov);
|
||||
}
|
||||
}
|
||||
return provinceList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.common.dao.UserAddressDao;
|
||||
import com.peanut.modules.common.entity.City;
|
||||
import com.peanut.modules.common.entity.County;
|
||||
import com.peanut.modules.common.entity.Province;
|
||||
import com.peanut.modules.common.entity.UserAddress;
|
||||
import com.peanut.modules.common.service.CityService;
|
||||
import com.peanut.modules.common.service.CountyService;
|
||||
import com.peanut.modules.common.service.ProvinceService;
|
||||
import com.peanut.modules.common.service.UserAddressService;
|
||||
import com.peanut.modules.common.vo.UserAddressVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service("commonUserAddressService")
|
||||
public class UserAddressServiceImpl extends ServiceImpl<UserAddressDao, UserAddress> implements UserAddressService {
|
||||
@Autowired
|
||||
private CountyService countyService;
|
||||
|
||||
@Autowired
|
||||
private CityService cityService;
|
||||
|
||||
@Autowired
|
||||
private ProvinceService provinceService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<UserAddress> page = this.page(
|
||||
new Query<UserAddress>().getPage(params),
|
||||
new QueryWrapper<>()
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserAddressVo getAddressName(UserAddressVo vo, String regionCode) {
|
||||
QueryWrapper<County> countyQueryWrapper = new QueryWrapper<>();
|
||||
countyQueryWrapper.eq("region_code", regionCode);
|
||||
County county = countyService.getOne(countyQueryWrapper);
|
||||
if(county==null){
|
||||
return null;
|
||||
}
|
||||
vo.setCounty(county.getCountyName());
|
||||
LambdaQueryWrapper<City> cityLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
cityLambdaQueryWrapper.eq(City::getCityId,county.getCityId());
|
||||
City city = cityService.getOne(cityLambdaQueryWrapper);
|
||||
vo.setCity(city.getCityName());
|
||||
LambdaQueryWrapper<Province> provinceLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
provinceLambdaQueryWrapper.eq(Province::getProvId,city.getProvId());
|
||||
Province province = provinceService.getOne(provinceLambdaQueryWrapper);
|
||||
vo.setProvince((province.getProvName()));
|
||||
return vo;
|
||||
}
|
||||
|
||||
public int getUserDefaultAddressCount(Integer userId) {
|
||||
QueryWrapper<UserAddress> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", userId);
|
||||
queryWrapper.eq("is_default", 1);
|
||||
return this.count(queryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.peanut.modules.common.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserAddressVo {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
/**
|
||||
* 会员 ID
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 收货人
|
||||
*/
|
||||
private String consigneeName;
|
||||
/**
|
||||
* 收货人手机号码
|
||||
*/
|
||||
private String consigneePhone;
|
||||
/**
|
||||
* 区域代码
|
||||
*/
|
||||
private String regionCode;
|
||||
/**
|
||||
* 详细地址
|
||||
*/
|
||||
private String detailAddress;
|
||||
/**
|
||||
* 默认
|
||||
*/
|
||||
private Integer isDefault;
|
||||
/**
|
||||
* 省
|
||||
*/
|
||||
private String province;
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
private String city;
|
||||
/**
|
||||
* 县
|
||||
*/
|
||||
private String county;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.peanut.modules.master.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.BookBuyConfigEntity;
|
||||
import com.peanut.modules.master.service.BuyConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 充值价格表单管理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("masterBookBuyConfig")
|
||||
@RequestMapping("master/bookBuyConfig")
|
||||
public class BuyConfigController {
|
||||
|
||||
@Autowired
|
||||
private BuyConfigService buyConfigService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = buyConfigService.queryPage(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{priceTypeId}")
|
||||
public R info(@PathVariable("priceTypeId") Integer priceTypeId){
|
||||
BookBuyConfigEntity bookBuyConfig = buyConfigService.getById(priceTypeId);
|
||||
return R.ok().put("bookBuyConfig", bookBuyConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody BookBuyConfigEntity bookBuyConfig){
|
||||
buyConfigService.save(bookBuyConfig);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody BookBuyConfigEntity bookBuyConfig){
|
||||
buyConfigService.updateById(bookBuyConfig);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] priceTypeIds){
|
||||
buyConfigService.removeByIds(Arrays.asList(priceTypeIds));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取VIP 金额 或者充值类型
|
||||
*/
|
||||
@RequestMapping("/getVipOrPoint")
|
||||
public R getVipOrPoint(@RequestParam("type") String type,@RequestParam("qudao") String qudao){
|
||||
List<BookBuyConfigEntity> bookBuyConfigEntities = buyConfigService.getBaseMapper().selectList(new QueryWrapper<BookBuyConfigEntity>().eq("type",type).eq("qudao",qudao));
|
||||
return R.ok().put("list",bookBuyConfigEntities);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.peanut.modules.master.controller;
|
||||
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.PayPaymentOrderEntity;
|
||||
import com.peanut.modules.master.service.PayPaymentOrderService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 充值订单表
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("masterPayPaymentOrder")
|
||||
@RequestMapping("master/payPaymentOrder")
|
||||
public class PayPaymentOrderController {
|
||||
|
||||
@Autowired
|
||||
private PayPaymentOrderService payPaymentOrderService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = payPaymentOrderService.queryPage(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
public R info(@PathVariable("id") Long id){
|
||||
PayPaymentOrderEntity payPaymentOrder = payPaymentOrderService.getById(id);
|
||||
return R.ok().put("payPaymentOrder", payPaymentOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody PayPaymentOrderEntity payPaymentOrder){
|
||||
payPaymentOrderService.save(payPaymentOrder);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody PayPaymentOrderEntity payPaymentOrder){
|
||||
payPaymentOrderService.updateById(payPaymentOrder);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
payPaymentOrderService.removeByIds(Arrays.asList(ids));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,6 +13,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 商品
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("masterShopProduct")
|
||||
@RequestMapping("master/shopProduct")
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.common.entity.BookBuyConfigEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface BuyConfigService extends IService<BookBuyConfigEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.common.entity.PayPaymentOrderEntity;
|
||||
import java.util.Map;
|
||||
|
||||
public interface PayPaymentOrderService extends IService<PayPaymentOrderEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.peanut.modules.master.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.common.dao.BookBuyConfigDao;
|
||||
import com.peanut.modules.common.entity.BookBuyConfigEntity;
|
||||
import com.peanut.modules.master.service.BuyConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service("buyConfigService")
|
||||
public class BuyConfigServiceImpl extends ServiceImpl<BookBuyConfigDao, BookBuyConfigEntity> implements BuyConfigService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<BookBuyConfigEntity> page = this.page(
|
||||
new Query<BookBuyConfigEntity>().getPage(params),
|
||||
new QueryWrapper<BookBuyConfigEntity>()
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.peanut.modules.master.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.common.dao.PayPaymentOrderDao;
|
||||
import com.peanut.modules.common.entity.PayPaymentOrderEntity;
|
||||
import com.peanut.modules.master.service.PayPaymentOrderService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service("masterPayPaymentOrderService")
|
||||
public class PayPaymentOrderServiceImpl extends ServiceImpl<PayPaymentOrderDao, PayPaymentOrderEntity> implements PayPaymentOrderService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<PayPaymentOrderEntity> page = this.page(
|
||||
new Query<PayPaymentOrderEntity>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<PayPaymentOrderEntity>()
|
||||
.eq("tel",params.get("key"))
|
||||
.or().like("user_name",params.get("key")).orderByDesc("create_time")
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user