|
|
|
@ -1,11 +1,14 @@ |
|
|
|
package cn.chjyj.szwh.controller.admin; |
|
|
|
|
|
|
|
import cn.chjyj.szwh.bean.Admin; |
|
|
|
import cn.chjyj.szwh.bean.Classify; |
|
|
|
import cn.chjyj.szwh.controller.BaseController; |
|
|
|
import cn.chjyj.szwh.mapper.AdminMapper; |
|
|
|
import cn.chjyj.szwh.service.ClassifyService; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.auth0.jwt.JWT; |
|
|
|
import com.auth0.jwt.interfaces.DecodedJWT; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
@ -14,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
@ -26,6 +30,10 @@ import java.util.Map; |
|
|
|
public class AdminGoodsClassifyController extends BaseController { |
|
|
|
@Autowired |
|
|
|
private ClassifyService classifyService; |
|
|
|
//管理员信息
|
|
|
|
@Autowired |
|
|
|
private AdminMapper adminMapper; |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/list") |
|
|
|
public JSONObject clist(@RequestBody String jsonStr){ |
|
|
|
@ -110,9 +118,40 @@ public class AdminGoodsClassifyController extends BaseController { |
|
|
|
public JSONObject getSon(HttpServletRequest request){ |
|
|
|
String topclass = request.getParameter("top_class"); |
|
|
|
List<Classify> sonclass= classifyService.getSonClass(topclass); |
|
|
|
List arr =new ArrayList(); |
|
|
|
for(Classify cf:sonclass){ |
|
|
|
arr.add(cf.getSonClass()); |
|
|
|
} |
|
|
|
jsonObject.put("code",200); |
|
|
|
jsonObject.put("msg","成功"); |
|
|
|
jsonObject.put("data",arr); |
|
|
|
return jsonObject; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 新增分类 |
|
|
|
* @param jstr |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@PostMapping("/add") |
|
|
|
public JSONObject addClass(@RequestBody String jstr,HttpServletRequest irequest){ |
|
|
|
JSONObject request = JSON.parseObject(jstr); |
|
|
|
String pullTopClass= request.getString("pull_top_class"); |
|
|
|
String topClass = request.getString("top_class"); |
|
|
|
String sonClass = request.getString("son_class"); |
|
|
|
// 获取当前用户
|
|
|
|
String token=irequest.getHeader("token"); |
|
|
|
DecodedJWT decode = JWT.decode(token); |
|
|
|
String accountId = decode.getClaim("accountId").asString(); |
|
|
|
Admin admin = adminMapper.getAdminByAccountId(accountId); |
|
|
|
String accountName = decode.getClaim("accountName").asString(); |
|
|
|
|
|
|
|
int userid=Integer.valueOf(admin.getId()); |
|
|
|
|
|
|
|
int ret = classifyService.addNewClass(pullTopClass,topClass,sonClass,userid,accountName); |
|
|
|
jsonObject.put("code",200); |
|
|
|
jsonObject.put("msg","成功"); |
|
|
|
jsonObject.put("data",sonclass); |
|
|
|
jsonObject.put("data",ret); |
|
|
|
return jsonObject; |
|
|
|
} |
|
|
|
} |
|
|
|
|