@ -3,24 +3,34 @@ package org.jeecg.modules.system.controller;
import com.alibaba.fastjson.JSON ;
import com.alibaba.fastjson.JSONObject ;
import com.google.common.base.Joiner ;
import lombok.extern.slf4j.Slf4j ;
import org.apache.commons.lang3.StringUtils ;
import org.apache.shiro.SecurityUtils ;
import org.aspectj.apache.bcel.generic.RET ;
import org.jeecg.common.api.vo.Result ;
import org.jeecg.common.constant.CommonConstant ;
import org.jeecg.common.system.vo.LoginUser ;
import org.jeecg.modules.base.service.BaseCommonService ;
import org.jeecg.modules.demo.customercollectgoods.entity.Customercollectgoods ;
import org.jeecg.modules.demo.customercollectgoods.service.ICustomercollectgoodsService ;
import org.jeecg.modules.demo.customershoppingcart.entity.CustomerShoppingCart ;
import org.jeecg.modules.demo.customershoppingcart.service.ICustomerShoppingCartService ;
import org.jeecg.modules.demo.zygoods.entity.ZyGoods ;
import org.jeecg.modules.demo.zygoods.service.IZyGoodsService ;
import org.jeecg.modules.system.entity.SysUser ;
import org.jeecg.modules.system.service.ISysUserService ;
import org.jeecg.modules.system.vo.Grzx1 ;
import org.jeecg.modules.system.vo.Grzx2 ;
import org.jeecg.modules.system.vo.Grzx3 ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.http.HttpRequest ;
import org.springframework.web.bind.annotation.* ;
import javax.annotation.Resource ;
import java.lang.reflect.Field ;
import java.util.Date ;
import java.util.HashMap ;
import java.util.Map ;
import java.util.* ;
import java.util.stream.Collectors ;
/ *
这个是个人中心专用控制器 , 之前全都写在SysUserController ( 用户控制器里面 , 感觉不妥 ) 因此就专门拖出来一个
@ -34,6 +44,15 @@ public class ApeopersionController {
@Autowired
private ISysUserService sysUserService ;
@Autowired
private ICustomercollectgoodsService customercollectgoodsService ;
@Autowired
private IZyGoodsService zyGoodsService ;
@Autowired
private ICustomerShoppingCartService customerShoppingCartService ;
/ *
个人中心 , 我的账户的数据获取
@ -44,15 +63,15 @@ public class ApeopersionController {
String id = loginUser . getId ( ) ;
SysUser syu = new SysUser ( ) ;
syu = sysUserService . getneeduser ( id ) ;
findgoods ( ) ;
return Result . ok ( syu ) ;
}
//个人中心的我的账户页面需要的数据
@RequestMapping ( value = "/updateneeduser" , method = RequestMethod . GET )
public Result < ? > updateneeduser ( @RequestParam ( name = "form" , required = true ) String form ) {
Map map = JSON . parseObject ( form , Map . class ) ;
System . out . println ( map ) ;
String id = ( String ) map . get ( "id" ) ;
String sex = map . get ( "sex" ) . toString ( ) ;
String birthday = ( String ) map . get ( "birthday" ) ;
@ -60,6 +79,80 @@ public class ApeopersionController {
String phone = ( String ) map . get ( "phone" ) ;
String email = ( String ) map . get ( "email" ) ;
sysUserService . updateneed ( id , sex , birthday , realname , phone , email ) ;
return Result . ok ( "success" ) ;
}
//个人中心的我的收藏的首页需要的数据
@RequestMapping ( value = "/findallcg" , method = RequestMethod . GET )
public Result < ? > findgoods ( ) {
//获取当前登人的信息
LoginUser loginUser = ( LoginUser ) SecurityUtils . getSubject ( ) . getPrincipal ( ) ;
String userid = loginUser . getUsername ( ) ;
List < Grzx1 > g3 = new ArrayList < > ( ) ;
//根据当前登的人获取收藏夹里面的搜藏的商品的名称及其款式
g3 = sysUserService . getscgoods ( userid ) ;
//获取的是辅料
List < String > s1 = new ArrayList < > ( ) ;
//获取的是面料
List < String > s2 = new ArrayList < > ( ) ;
//把获取的商品信息导入到新的list里面
for ( int i = 0 ; i < g3 . size ( ) ; i + + ) {
if ( g3 . get ( i ) ! = null ) {
s1 = sysUserService . getscgoodfi ( g3 . get ( i ) . getId ( ) ) ;
s2 = sysUserService . getscgoodml ( g3 . get ( i ) . getId ( ) ) ;
g3 . get ( i ) . setOrdersNum ( s2 . toString ( ) ) ;
if ( s2 . get ( 0 ) = = null ) {
} else {
if ( s2 . size ( ) = = 1 ) {
g3 . get ( i ) . setAddress ( s2 . get ( 0 ) . toString ( ) . replace ( "[" , "" ) . replace ( "]" , "" ) ) ;
} else {
g3 . get ( i ) . setAddress ( StringUtils . join ( s2 , "," ) ) ;
}
}
if ( s1 . get ( 0 ) = = null ) {
} else {
if ( s1 . size ( ) = = 1 ) {
g3 . get ( i ) . setOrdersNum ( s1 . get ( 0 ) . toString ( ) . replace ( "[" , "" ) . replace ( "]" , "" ) ) ;
} else {
g3 . get ( i ) . setOrdersNum ( StringUtils . join ( s1 , "," ) ) ;
}
}
}
}
return Result . ok ( g3 ) ;
}
//个人中心的我的收藏的首页需要的数据
@RequestMapping ( value = "/ingwc" , method = RequestMethod . GET )
public Result < ? > findgoods ( @RequestParam ( name = "id" , required = true ) String id ) {
//这里方便获取当前登陆信息
LoginUser loginUser = ( LoginUser ) SecurityUtils . getSubject ( ) . getPrincipal ( ) ;
//这里获取当前登陆的id
String userid = loginUser . getId ( ) ;
//这里获取当前登陆的真实姓名
String rlname = loginUser . getRealname ( ) ;
//这个是根据goodid查询收藏的场频的信息
Customercollectgoods ccs = customercollectgoodsService . getById ( id ) ;
String goodid = ccs . getGoodsId ( ) ;
//根据goodid查询goods的对象
ZyGoods zyd = zyGoodsService . getById ( goodid ) ;
//初始化购物车对象
CustomerShoppingCart cst = new CustomerShoppingCart ( ) ;
//开始组装购物车对象
cst . setUserId ( userid ) ;
cst . setUsername ( rlname ) ;
cst . setGoodsId ( zyd . getId ( ) ) ;
cst . setGoodsname ( zyd . getGoodsName ( ) ) ;
cst . setNumber ( 1 ) ;
cst . setPrice ( zyd . getPromotionPrice ( ) ) ;
cst . setZj ( zyd . getPromotionPrice ( ) * 1 ) ;
cst . setPlaceorigin ( zyd . getPlaceOrigin ( ) ) ;
cst . setGoodimg ( zyd . getDefaultPicture ( ) ) ;
cst . setStyleId ( zyd . getStyleId ( ) ) ;
/* customerShoppingCartService.save(cst);*/
System . out . println ( cst ) ;
return Result . ok ( "添加完成" ) ;
}
}