申报完善
This commit is contained in:
parent
d92a9fb6d0
commit
5b56c1f1ce
|
@ -1,4 +1,4 @@
|
|||
package com.ruoyi.bst.article.domain;
|
||||
|
||||
public class ArticleQuery {
|
||||
public class ArticleQuery extends Article{
|
||||
}
|
||||
|
|
|
@ -2,8 +2,12 @@ package com.ruoyi.bst.article.service.impl;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.bst.area.service.AreaService;
|
||||
import com.ruoyi.bst.article.service.ArticleService;
|
||||
import com.ruoyi.bst.articleCategory.service.ArticleCategoryService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.bst.article.mapper.ArticleMapper;
|
||||
|
@ -24,6 +28,11 @@ public class ArticleServiceImpl implements ArticleService
|
|||
@Autowired
|
||||
private ArticleMapper articleMapper;
|
||||
|
||||
@Autowired
|
||||
private ArticleCategoryService articleCategoryService;
|
||||
|
||||
@Autowired
|
||||
private AreaService areaService;
|
||||
/**
|
||||
* 查询文章
|
||||
*
|
||||
|
@ -57,6 +66,16 @@ public class ArticleServiceImpl implements ArticleService
|
|||
@Override
|
||||
public int insertArticle(Article article)
|
||||
{
|
||||
//分类必须存在
|
||||
if(articleCategoryService.selectArticleCategoryById(article.getCategoryId()) ==null){
|
||||
throw new ServiceException("当前分类不存在");
|
||||
}
|
||||
|
||||
//所属区域必须存在
|
||||
if (areaService.selectAreaById(article.getAreaId()) == null){
|
||||
throw new ServiceException("所属区域不存在");
|
||||
}
|
||||
|
||||
article.setCreateTime(DateUtils.getNowDate());
|
||||
return articleMapper.insertArticle(article);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class ArticleCategory extends TreeEntity
|
|||
|
||||
@Excel(name = "状态:0-禁用 1-启用")
|
||||
@ApiModelProperty("状态:0-禁用 1-启用")
|
||||
private Integer categoryStatus;
|
||||
private String categoryStatus;
|
||||
|
||||
@Excel(name = "父分类ID")
|
||||
@ApiModelProperty("父分类ID")
|
||||
|
|
|
@ -117,6 +117,7 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService
|
|||
List<Long> allIdsToDelete = new ArrayList<>();
|
||||
allIdsToDelete.addAll(cids);
|
||||
allIdsToDelete.addAll(Arrays.asList(ids));
|
||||
|
||||
if (!allIdsToDelete.isEmpty()){
|
||||
return articleCategoryMapper.deleteArticleCategoryByIds(ids);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class Fault extends BaseEntity
|
|||
|
||||
@Excel(name = "车辆编号")
|
||||
@ApiModelProperty("车辆编号")
|
||||
private Long vehicleCode;
|
||||
private String vehicleCode;
|
||||
|
||||
@Excel(name = "图片")
|
||||
@ApiModelProperty("图片")
|
||||
|
@ -48,4 +48,8 @@ public class Fault extends BaseEntity
|
|||
@ApiModelProperty("状态")
|
||||
private String appealStatus;
|
||||
|
||||
@Excel(name = "用户id")
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.bst.fault.domain;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
|
|
|
@ -1,8 +1,17 @@
|
|||
package com.ruoyi.bst.fault.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class FaultVO extends Fault{
|
||||
|
||||
@ApiModelProperty("订单时间")
|
||||
private LocalDateTime orderEndTime;
|
||||
|
||||
@ApiModelProperty("故障原因")
|
||||
private String faultSite;
|
||||
|
||||
}
|
||||
|
|
|
@ -71,4 +71,6 @@ public interface FaultMapper
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteFaultByIds(Long[] ids);
|
||||
|
||||
FaultVO selectFaultByUserId(Long id);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bf.fault_site,
|
||||
bf.fault_detail,
|
||||
bf.appeal_status,
|
||||
bf.create_time
|
||||
bf.create_time,
|
||||
bf.order_end_time,
|
||||
bf.user_id
|
||||
from bst_fault bf
|
||||
</sql>
|
||||
|
||||
|
@ -25,6 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="query.vehicleCode != null "> and bf.vehicle_code = #{query.vehicleCode}</if>
|
||||
<if test="query.picture != null and query.picture != ''"> and bf.picture = #{query.picture}</if>
|
||||
<if test="query.orderId != null and query.orderId != ''"> and bf.order_id = #{query.orderId}</if>
|
||||
<if test="query.userId != null and query.userId != ''"> and bf.user_id = #{query.userId}</if>
|
||||
<if test="query.faultSiteList != null and query.faultSiteList != ''">
|
||||
AND
|
||||
<foreach collection="query.faultSiteList" item="item" open="(" separator=" AND " close=")">
|
||||
|
@ -47,6 +50,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<include refid="selectFaultVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="selectFaultByUserId" resultType="com.ruoyi.bst.fault.domain.FaultVO">
|
||||
select
|
||||
order_end_time,
|
||||
vehicle_code,
|
||||
fault_site,
|
||||
create_time
|
||||
from bst_fault where user_id = #{userId}
|
||||
|
||||
</select>
|
||||
|
||||
<insert id="insertFault" parameterType="Fault" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into bst_fault
|
||||
|
@ -59,6 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="faultDetail != null">fault_detail,</if>
|
||||
<if test="appealStatus != null and appealStatus != ''">appeal_status,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="userName != null and userName != ''">#{userName},</if>
|
||||
|
@ -69,6 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="faultDetail != null">#{faultDetail},</if>
|
||||
<if test="appealStatus != null and appealStatus != ''">#{appealStatus},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
|
|
@ -60,4 +60,6 @@ public interface FaultService
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteFaultById(Long id);
|
||||
|
||||
FaultVO selectFaultByUserId(Long id);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.ruoyi.bst.fault.service.impl;
|
|||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.bst.fault.mapper.FaultMapper;
|
||||
|
@ -31,6 +32,7 @@ public class FaultServiceImpl implements FaultService
|
|||
@Override
|
||||
public FaultVO selectFaultById(Long id)
|
||||
{
|
||||
|
||||
return faultMapper.selectFaultById(id);
|
||||
}
|
||||
|
||||
|
@ -56,6 +58,7 @@ public class FaultServiceImpl implements FaultService
|
|||
public int insertFault(Fault fault)
|
||||
{
|
||||
fault.setCreateTime(DateUtils.getNowDate());
|
||||
fault.setUserId(SecurityUtils.getLoginUser().getUserId());
|
||||
return faultMapper.insertFault(fault);
|
||||
}
|
||||
|
||||
|
@ -94,4 +97,9 @@ public class FaultServiceImpl implements FaultService
|
|||
{
|
||||
return faultMapper.deleteFaultById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaultVO selectFaultByUserId(Long id) {
|
||||
return faultMapper.selectFaultByUserId(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package com.ruoyi.web.app;
|
||||
|
||||
|
||||
import com.ruoyi.bst.areaSub.domain.AreaSubQuery;
|
||||
import com.ruoyi.bst.areaSub.domain.enums.AreaSubStatus;
|
||||
import com.ruoyi.bst.article.domain.ArticleQuery;
|
||||
import com.ruoyi.bst.article.service.ArticleService;
|
||||
import com.ruoyi.bst.articleCategory.domain.ArticleCategoryQuery;
|
||||
import com.ruoyi.bst.articleCategory.domain.enums.ArticleCategoryStatus;
|
||||
import com.ruoyi.common.annotation.Anonymous;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/app/article")
|
||||
public class AppArticleController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ArticleService articleService;
|
||||
|
||||
|
||||
@ApiOperation("查看文章信息")
|
||||
@GetMapping("/detail")
|
||||
@Anonymous
|
||||
public AjaxResult getCategoryList(ArticleQuery query) {
|
||||
if(query.getId() == null){
|
||||
return error("文章id不能为空");
|
||||
}
|
||||
return AjaxResult.success(articleService.selectArticleList(query));
|
||||
}
|
||||
}
|
|
@ -1,30 +1,30 @@
|
|||
package com.ruoyi.web.app;
|
||||
|
||||
import com.ruoyi.bst.areaSub.domain.AreaSubQuery;
|
||||
import com.ruoyi.bst.areaSub.domain.enums.AreaSubStatus;
|
||||
import com.ruoyi.bst.articleCategory.domain.ArticleCategoryQuery;
|
||||
import com.ruoyi.bst.articleCategory.domain.enums.ArticleCategoryStatus;
|
||||
import com.ruoyi.bst.articleCategory.service.ArticleCategoryService;
|
||||
import com.ruoyi.common.annotation.Anonymous;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static com.ruoyi.common.core.domain.AjaxResult.error;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/app/articleCategory")
|
||||
public class AppAtricleCategoryController extends BaseController {
|
||||
|
||||
@ApiOperation("获取分类列表")
|
||||
@Autowired
|
||||
private ArticleCategoryService articleCategoryService;
|
||||
|
||||
@ApiOperation("展示分类信息")
|
||||
@GetMapping("/list")
|
||||
@Anonymous
|
||||
public AjaxResult getAreaSubList(ArticleCategoryQuery query) {
|
||||
if (query.getAreaId() == null) {
|
||||
return error("areaId不能为空");
|
||||
}
|
||||
query.setStatus(AreaSubStatus.ENABLED.getCode());
|
||||
return success(areaSubService.selectAreaSubList(query));
|
||||
public AjaxResult getCategoryList(ArticleCategoryQuery query) {
|
||||
query.setCategoryStatus(ArticleCategoryStatus.ENABLED.getCode());
|
||||
return success(articleCategoryService.selectArticleCategoryList(query));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,24 @@
|
|||
package com.ruoyi.web.app;
|
||||
|
||||
import com.ruoyi.bst.device.domain.DeviceVO;
|
||||
import com.ruoyi.bst.device.service.DeviceService;
|
||||
import com.ruoyi.bst.fault.domain.Fault;
|
||||
import com.ruoyi.bst.fault.domain.FaultQuery;
|
||||
import com.ruoyi.bst.fault.domain.FaultVO;
|
||||
import com.ruoyi.bst.fault.service.FaultService;
|
||||
import com.ruoyi.bst.order.service.OrderService;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户查询自己提交的故障信息
|
||||
* 故障申报前台
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/app/fault")
|
||||
|
@ -21,14 +27,46 @@ public class AppFaultController extends BaseController {
|
|||
@Autowired
|
||||
private FaultService faultService;
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public AjaxResult get(@PathVariable Long id) {
|
||||
Long userId = SecurityUtils.getLoginUser().getUserId();
|
||||
// 当用户查询的故障信息是自己的或当前用户是超级管理员时
|
||||
if (userId.equals(id)|| userId == 1){
|
||||
FaultVO faultVO = faultService.selectFaultById(id);
|
||||
return success(faultVO);
|
||||
@Autowired
|
||||
private DeviceService deviceService;
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param fault
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Fault fault) {
|
||||
faultService.insertFault(fault);
|
||||
return success();
|
||||
}
|
||||
|
||||
|
||||
@GetMapping
|
||||
public AjaxResult get(FaultQuery query) {
|
||||
query.setUserId(getUserId());
|
||||
List<FaultVO> list = faultService.selectFaultList(query);
|
||||
List<FaultVO> validList = new ArrayList<>();
|
||||
|
||||
list.forEach(faultVO -> {
|
||||
DeviceVO deviceVO = deviceService.selectDeviceBySn(faultVO.getVehicleCode());
|
||||
if (deviceVO == null){
|
||||
return;
|
||||
}
|
||||
Long orderId = deviceVO.getOrderId();
|
||||
if (orderId == null) {
|
||||
return;
|
||||
}
|
||||
LocalDateTime orderEndTime = orderService.selectOrderById(orderId).getEndTime();
|
||||
if (orderEndTime == null) {
|
||||
return;
|
||||
}
|
||||
faultVO.setOrderEndTime(orderEndTime);
|
||||
validList.add(faultVO);
|
||||
});
|
||||
return success(validList);
|
||||
}
|
||||
return error("您的查询不合法!");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user