Commit 0ca50697 authored by 王夏晖's avatar 王夏晖

厂家后台维护

parent ac9fb226
package org.rcisoft.business.manage.controller;
/*固定导入*/
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.rcisoft.business.manage.entity.BusFactory;
import org.rcisoft.business.manage.service.BusFactoryService;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.controller.PaginationController;
import org.rcisoft.core.model.GridModel;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.Result;
import org.rcisoft.core.util.UserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
/**
* Created by on 2018-5-16 14:34:55.
*/
@RestController
@RequestMapping("manage/busfactory")
public class BusFactoryController extends PaginationController<BusFactory> {
@Autowired
private BusFactoryService busFactoryServiceImpl;
@ApiOperation(value="添加", notes="添加")
@PostMapping(value = "/add")
public Result add(@Valid BusFactory busFactory) {
PersistModel data = busFactoryServiceImpl.save(busFactory);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
busFactory);
}
@ApiOperation(value="修改", notes="修改")
@PutMapping("/update")
public Result update(@Valid BusFactory busFactory) {
PersistModel data = busFactoryServiceImpl.merge(busFactory);
return Result.builder(data);
}
@ApiOperation(value="删除", notes="删除")
@DeleteMapping("/delete")
public Result delete(@RequestParam String id) {
PersistModel data = busFactoryServiceImpl.delete(id);
return Result.builder(data);
}
@ApiOperation(value="查看列表", notes="查看列表")
@GetMapping(value = "/queryBusFactoryList")
public List<Map<String,Object>> queryBusFactoryList() {
return busFactoryServiceImpl.queryBusFactoryList();
}
}
package org.rcisoft.business.manage.dao;
import org.apache.ibatis.annotations.Select;
import org.rcisoft.business.manage.entity.BusFactory;
import org.rcisoft.core.base.BaseMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* Created with on 2018-5-16 14:34:55.
*/
@Repository
public interface BusFactoryRepository extends BaseMapper<BusFactory> {
/**
* 查询列表
*
*/
@Select("<script>select * from bus_factory where 1=1 "
+ "</script>")
List<Map<String,Object>> queryBusFactorys();
}
package org.rcisoft.business.manage.entity;
import lombok.*;
import org.rcisoft.core.entity.IdNotDataEntity;
import javax.persistence.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* Created with on 2018-5-16 14:34:55.
*/
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "bus_factory")
public class BusFactory{
private String facId;
private String facNm;
}
package org.rcisoft.business.manage.service;
import org.rcisoft.business.manage.entity.BusFactory;
import org.rcisoft.core.model.PersistModel;
import java.util.List;
import java.util.Map;
/**
* Created by on 2018-5-16 14:34:55.
*/
public interface BusFactoryService {
/**
* 保存
* @param busFactory
* @return
*/
PersistModel save(BusFactory busFactory);
/**
* 修改
* @param busFactory
* @return
*/
PersistModel merge(BusFactory busFactory);
/**
* 删除
* @return
*/
PersistModel delete(String id);
/**
* 列表
* @return
*/
List<Map<String,Object>> queryBusFactoryList();
}
package org.rcisoft.business.manage.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.rcisoft.business.manage.dao.BusFactoryRepository;
import org.rcisoft.business.manage.entity.BusFactory;
import org.rcisoft.business.manage.service.BusFactoryService;
import org.rcisoft.core.model.PersistModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* Created by on 2018-5-16 14:34:55.
*/
@Service
@Transactional(readOnly = true,propagation = Propagation.NOT_SUPPORTED)
@Slf4j
public class BusFactoryServiceImpl implements BusFactoryService {
@Autowired
private BusFactoryRepository busFactoryRepository;
/**
* 保存 busFactory
* @param busFactory
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel save(BusFactory busFactory){
//增加操作
busFactory.setFacId(UUID.randomUUID().toString().replace("-",""));
int line = busFactoryRepository.insertSelective(busFactory);
return new PersistModel(line);
}
/**
* 修改 busFactory
* @param busFactory
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel merge(BusFactory busFactory){
Integer line = 0;
String message = "";
Example example = new Example(BusFactory.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("facId",busFactory.getFacId());
if(busFactory.getFacId()!=null && !busFactory.getFacId().equals("")){
line = busFactoryRepository.updateByExampleSelective(busFactory,example);
}else{
message = "ID为空,更新失败";
}
return new PersistModel(line,message);
}
@Override
public PersistModel delete(String id) {
Integer line = 0;
String message = "";
Example example = new Example(BusFactory.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("facId",id);
if(id!=null && !id.equals("")){
line = busFactoryRepository.deleteByExample(example);
}else{
message = "ID为空,删除失败";
}
return new PersistModel(line,message);
}
@Override
public List<Map<String,Object>> queryBusFactoryList() {
return busFactoryRepository.queryBusFactorys();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment