产品搜索

pull/451/head
starrysky 2020-03-02 05:55:37 +08:00
parent a9e892842b
commit 89feab2385
6 changed files with 39 additions and 9 deletions

View File

@ -6,6 +6,7 @@ import me.zhengjie.modules.system.domain.Menu;
import me.zhengjie.modules.system.domain.Message; import me.zhengjie.modules.system.domain.Message;
import me.zhengjie.modules.system.service.MessageService; import me.zhengjie.modules.system.service.MessageService;
import me.zhengjie.modules.system.service.dto.MessageCriteria; import me.zhengjie.modules.system.service.dto.MessageCriteria;
import me.zhengjie.modules.system.service.dto.MessageDTO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@ -30,12 +31,12 @@ public class MessageController {
return new ResponseEntity(messageService.queryAll(criteria), HttpStatus.OK); return new ResponseEntity(messageService.queryAll(criteria), HttpStatus.OK);
} }
@Log("修改消息") @Log("查看消息")
@PutMapping(value = "/message") @GetMapping(value = "/message/{id}")
// @PreAuthorize("hasAnyRole('ADMIN','MESSAGE_ALL','MESSAGE_EDIT')") // @PreAuthorize("hasAnyRole('ADMIN','MESSAGE_ALL','MESSAGE_EDIT')")
public ResponseEntity update(@Validated(Menu.Update.class) @RequestBody Message resources){ public ResponseEntity findById(@PathVariable Long id){
messageService.update(resources); MessageDTO messageDTO = messageService.findById(id);
return new ResponseEntity(HttpStatus.NO_CONTENT); return new ResponseEntity(messageDTO, HttpStatus.OK);
} }
@Log("删除消息") @Log("删除消息")

View File

@ -23,6 +23,6 @@ public interface MessageService {
Object queryAll(MessageCriteria criteria); Object queryAll(MessageCriteria criteria);
void update(Message resources); MessageDTO update(Message resources);
} }

View File

@ -57,4 +57,6 @@ public class MessageDTO {
* *
*/ */
private String initCode; private String initCode;
private Integer completeStatus;
} }

View File

@ -43,7 +43,14 @@ public class MessageServiceImpl implements MessageService {
@Override @Override
public MessageDTO findById(long id) { public MessageDTO findById(long id) {
return null; Optional<Message> messageOptional = messageRepository.findById(id);
Message message = messageOptional.get();
message.setStatus(false);
messageRepository.save(message);
MessageDTO messageDTO = messageMapper.toDto(message);
messageDTO.setCompleteStatus(1);
return messageDTO;
} }
@Override @Override
@ -88,7 +95,7 @@ public class MessageServiceImpl implements MessageService {
Predicate statusPredicate = criteriaBuilder.equal(root.get("status"), 1); Predicate statusPredicate = criteriaBuilder.equal(root.get("status"), 1);
targetPredicateList.add(statusPredicate); targetPredicateList.add(statusPredicate);
criteriaQuery.orderBy(criteriaBuilder.desc(root.get("createTime")),criteriaBuilder.desc(root.get("createTime")));
if(CollectionUtils.isEmpty(targetPredicateList)){ if(CollectionUtils.isEmpty(targetPredicateList)){
return null; return null;
}else{ }else{
@ -103,10 +110,14 @@ public class MessageServiceImpl implements MessageService {
} }
@Override @Override
public void update(Message resources) { public MessageDTO update(Message resources) {
Optional<Message> messageOptional = messageRepository.findById(resources.getId()); Optional<Message> messageOptional = messageRepository.findById(resources.getId());
Message message = messageOptional.get(); Message message = messageOptional.get();
message.setStatus(false); message.setStatus(false);
messageRepository.save(resources); messageRepository.save(resources);
MessageDTO messageDTO = messageMapper.toDto(message);
messageDTO.setCompleteStatus(1);
return messageDTO;
} }
} }

View File

@ -10,4 +10,8 @@ import me.zhengjie.annotation.Query;
*/ */
@Data @Data
public class ProductInfoQueryCriteria { public class ProductInfoQueryCriteria {
private Long productSeriesId;
private String productCode;
} }

View File

@ -81,6 +81,18 @@ public class ProductInfoServiceImpl implements ProductInfoService {
Predicate statusPredicate = criteriaBuilder.equal(root.get("status"), 1); Predicate statusPredicate = criteriaBuilder.equal(root.get("status"), 1);
targetPredicateList.add(statusPredicate); targetPredicateList.add(statusPredicate);
String productCode = criteria.getProductCode();
if(!StringUtils.isEmpty(productCode)){
Predicate productCodePredicate = criteriaBuilder.equal(root.get("productCode"), productCode);
targetPredicateList.add(productCodePredicate);
}
Long productSeriesId = criteria.getProductSeriesId();
if(null != productSeriesId){
Predicate productCodePredicate = criteriaBuilder.equal(root.get("productSeriesId"), productSeriesId);
targetPredicateList.add(productCodePredicate);
}
if(CollectionUtils.isEmpty(targetPredicateList)){ if(CollectionUtils.isEmpty(targetPredicateList)){
return null; return null;
}else{ }else{