Browse Source

代码更新

master
xyiege 4 years ago
parent
commit
33e6a1dc37
  1. 41
      src/main/java/cn/chjyj/szwh/controller/admin/AdminGoodsController.java
  2. 15
      src/main/java/cn/chjyj/szwh/service/GoodsDetailService.java
  3. 7
      src/main/java/cn/chjyj/szwh/service/GoodsService.java
  4. 18
      src/main/java/cn/chjyj/szwh/service/impl/GoodsDetailServiceImpl.java
  5. 5
      src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java
  6. 15
      src/main/resources/mapper/szwh/GoodsDetailMapper.xml
  7. 11
      src/main/resources/mapper/szwh/GoodsMapper.xml
  8. 2
      src/test/java/cn/chjyj/szwh/mapper/GoodsMapperTest.java

41
src/main/java/cn/chjyj/szwh/controller/admin/AdminGoodsController.java

@ -1,30 +1,30 @@
package cn.chjyj.szwh.controller.admin;
import cn.chjyj.szwh.annotation.PassToken;
import cn.chjyj.szwh.bean.Goods;
import cn.chjyj.szwh.bean.GoodsDetail;
import cn.chjyj.szwh.controller.BaseController;
import cn.chjyj.szwh.exception.ChException;
import cn.chjyj.szwh.service.GoodsDetailService;
import cn.chjyj.szwh.service.GoodsService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Controller
@RequestMapping("/admin/admin.Goods")
public class AdminGoodsController {
@RestController
@RequestMapping(value = "/admin/admin.Goods",method = RequestMethod.POST)
public class AdminGoodsController extends BaseController {
@Autowired
private GoodsService goodsService;
@Autowired
private GoodsDetailService goodsDetailService;
/**
* 商品列表
* @return
*/
@ResponseBody
@RequestMapping("/list")
public String list(@RequestParam(name = "page",defaultValue = "1") String page){
int ipage=Integer.parseInt(page);
@ -34,4 +34,25 @@ public class AdminGoodsController {
jsonObject.put("data",goodsList);
return jsonObject.toJSONString();
}
/**
* 商品详情
* @param islicode
* @return
*/
@RequestMapping("/goodsDetail")
public JSONObject goodsDetail(String islicode){
// 商品明细id
Goods goods = goodsService.getGoodsByIsli(islicode);
if(goods!=null){
GoodsDetail goodsDetail = goodsDetailService.getGoodsDetailBygid(goods.getGoodsDetailsId());
}else{
throw new ChException("未查询到该标的");
}
jsonObject.put("code",200);
jsonObject.put("msg","success");
// jsonObject.put("data",goodsDetail);
return jsonObject;
}
}

15
src/main/java/cn/chjyj/szwh/service/GoodsDetailService.java

@ -0,0 +1,15 @@
package cn.chjyj.szwh.service;
import cn.chjyj.szwh.bean.GoodsDetail;
/**
* 商品详情
*/
public interface GoodsDetailService {
/**
* 商品详情
* @param goodDetailId
* @return
*/
GoodsDetail getGoodsDetailBygid(Integer goodDetailId);
}

7
src/main/java/cn/chjyj/szwh/service/GoodsService.java

@ -14,4 +14,11 @@ public interface GoodsService {
* @return
*/
List<Goods> getGoodsList(int page);
/**
* 根据goodsIsli 查询商品信息
* @param goodsIsli
* @return
*/
Goods getGoodsByIsli(String goodsIsli);
}

18
src/main/java/cn/chjyj/szwh/service/impl/GoodsDetailServiceImpl.java

@ -0,0 +1,18 @@
package cn.chjyj.szwh.service.impl;
import cn.chjyj.szwh.bean.GoodsDetail;
import cn.chjyj.szwh.mapper.GoodsDetailMapper;
import cn.chjyj.szwh.service.GoodsDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class GoodsDetailServiceImpl implements GoodsDetailService {
@Autowired
private GoodsDetailMapper goodsDetailMapper;
@Override
public GoodsDetail getGoodsDetailBygid(Integer goodDetailId) {
return goodsDetailMapper.getGoodsDetailBygid(goodDetailId);
}
}

5
src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java

@ -21,4 +21,9 @@ public class GoodsServiceImpl implements GoodsService {
//todo 字段转化啥的
return goodsList;
}
@Override
public Goods getGoodsByIsli(String goodsIsli) {
return goodsMapper.getGoodsByIsli(goodsIsli);
}
}

15
src/main/resources/mapper/szwh/GoodsDetailMapper.xml

@ -27,7 +27,20 @@
<!--根据id查询-->
<select id="getGoodsDetailBygid" parameterType="java.lang.Integer" resultType="cn.chjyj.szwh.bean.GoodsDetail">
select <include refid="column"/>
select
id,goods_name as goodsName,
goods_image as goodsImage,
identifier,identifiers,stock,
price,
goods_ownership as goodsOwnership,
goods_ownership_str as goodsOwnershipStr,
goods_type as goodsType,
charges_type as chargesType,
goods_islicode as goodsIslicode,
goods_entrust as goodsEntrust,
data_json as dataJson,
source_json as sourceJson,
sourcedata_islicode as sourcedataIslicode,
from <include refid="tbName"/>
where id=#{goodDetailId}
</select>

11
src/main/resources/mapper/szwh/GoodsMapper.xml

@ -41,11 +41,16 @@
<!--根据 goodsIsli 查询商品信息-->
<select id="getGoodsByIsli" parameterType="java.lang.String" resultType="cn.chjyj.szwh.bean.Goods">
select
<include refid="column"/>
select id,user_islicode as userIslicode,username,
goods_detail_id as goodsDetailId,
goods_islicode as goodsIslicode,
is_deleted as isDelete,
contract_status as contractStatus,
contractual_start_time as contractualStartTime,
contractualtime_end_time as contractualtimeEndTime
from
<include refid="tbName"/>
where goods_islicode=#{goodsIsli} limit 1;
where is_deleted=0 AND goods_islicode=#{goodsIsli} limit 1;
</select>
<!--查询用户-->

2
src/test/java/cn/chjyj/szwh/mapper/GoodsMapperTest.java

@ -29,6 +29,6 @@ public class GoodsMapperTest {
public void goodslictest(){
String gc="010007-00000000002799999999-9";
Goods goods = goodsMapper.getGoodsByIsli(gc);
System.out.println(goods.getUsername());
System.out.println(goods.toString());
}
}
Loading…
Cancel
Save