|
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import me.zhyd.oauth.utils.UuidUtils;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
@@ -14,8 +15,11 @@ import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
import org.jeecg.common.util.DictAnnotationUtil;
|
|
|
import org.jeecg.modules.system.app.entity.AppInsure;
|
|
|
+import org.jeecg.modules.system.app.entity.InsurePrice;
|
|
|
import org.jeecg.modules.system.app.service.IAppInsureService;
|
|
|
+import org.jeecg.modules.system.app.service.IInsurePriceService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
@@ -37,6 +41,9 @@ import java.util.List;
|
|
|
public class AppInsureController extends JeecgController<AppInsure, IAppInsureService> {
|
|
|
@Autowired
|
|
|
private IAppInsureService appInsureService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IInsurePriceService iInsurePriceService;
|
|
|
|
|
|
/**
|
|
|
* 分页列表查询
|
|
@@ -54,11 +61,15 @@ public class AppInsureController extends JeecgController<AppInsure, IAppInsureSe
|
|
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
HttpServletRequest req) {
|
|
|
-
|
|
|
-
|
|
|
QueryWrapper<AppInsure> queryWrapper = QueryGenerator.initQueryWrapper(appInsure, req.getParameterMap());
|
|
|
Page<AppInsure> page = new Page<AppInsure>(pageNo, pageSize);
|
|
|
IPage<AppInsure> pageList = appInsureService.page(page, queryWrapper);
|
|
|
+ if (pageList!=null&&pageList.getRecords()!=null){
|
|
|
+ for (AppInsure record : pageList.getRecords()) {
|
|
|
+ List<InsurePrice> list = iInsurePriceService.list(new QueryWrapper<InsurePrice>().lambda().eq(InsurePrice::getInsureId, record.getId()).eq(InsurePrice::getDelFlag,0));
|
|
|
+ record.setPriceDataList(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
return Result.OK(pageList);
|
|
|
}
|
|
|
|
|
@@ -71,9 +82,17 @@ public class AppInsureController extends JeecgController<AppInsure, IAppInsureSe
|
|
|
@AutoLog(value = "保险表-添加")
|
|
|
@Operation(summary="保险表-添加")
|
|
|
@PostMapping(value = "/add")
|
|
|
+ @Transactional
|
|
|
public Result<String> add(@RequestBody AppInsure appInsure) {
|
|
|
+ if (appInsure.getPriceDataList()==null||appInsure.getPriceDataList().size()!=5){
|
|
|
+ return Result.error("保险期限价格错误");
|
|
|
+ }
|
|
|
appInsureService.save(appInsure);
|
|
|
-
|
|
|
+ for (InsurePrice insurePrice : appInsure.getPriceDataList()) {
|
|
|
+ insurePrice.setInsureId(appInsure.getId());
|
|
|
+ insurePrice.setId(UuidUtils.getUUID());
|
|
|
+ }
|
|
|
+ iInsurePriceService.saveBatch(appInsure.getPriceDataList());
|
|
|
return Result.OK("添加成功!");
|
|
|
}
|
|
|
|
|
@@ -85,9 +104,14 @@ public class AppInsureController extends JeecgController<AppInsure, IAppInsureSe
|
|
|
*/
|
|
|
@AutoLog(value = "保险表-编辑")
|
|
|
@Operation(summary="保险表-编辑")
|
|
|
+ @Transactional
|
|
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
|
public Result<String> edit(@RequestBody AppInsure appInsure) {
|
|
|
+ if (appInsure.getPriceDataList()==null||appInsure.getPriceDataList().size()!=5){
|
|
|
+ return Result.error("保险期限价格错误");
|
|
|
+ }
|
|
|
appInsureService.updateById(appInsure);
|
|
|
+ iInsurePriceService.updateBatchById(appInsure.getPriceDataList());
|
|
|
return Result.OK("编辑成功!");
|
|
|
}
|
|
|
|
|
@@ -100,8 +124,10 @@ public class AppInsureController extends JeecgController<AppInsure, IAppInsureSe
|
|
|
@AutoLog(value = "保险表-通过id删除")
|
|
|
@Operation(summary="保险表-通过id删除")
|
|
|
@DeleteMapping(value = "/delete")
|
|
|
+ @Transactional
|
|
|
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
|
|
appInsureService.removeById(id);
|
|
|
+ iInsurePriceService.remove(new QueryWrapper<InsurePrice>().lambda().eq(InsurePrice::getInsureId,id));
|
|
|
return Result.OK("删除成功!");
|
|
|
}
|
|
|
|
|
@@ -134,6 +160,8 @@ public class AppInsureController extends JeecgController<AppInsure, IAppInsureSe
|
|
|
if(appInsure==null) {
|
|
|
return Result.error("未找到对应数据");
|
|
|
}
|
|
|
+ List<InsurePrice> list = iInsurePriceService.list(new QueryWrapper<InsurePrice>().lambda().eq(InsurePrice::getInsureId, appInsure.getId()).eq(InsurePrice::getDelFlag,0));
|
|
|
+ appInsure.setPriceDataList(list);
|
|
|
return Result.OK(appInsure);
|
|
|
}
|
|
|
|