Commit 9cefa529 by wxh

对物品分类、添加等接口制作完成上传

parent 1d2a57f0
package com.orhon.smartcampus.material;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import graphql.servlet.config.ObjectMapperConfigurer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;
......
package com.orhon.smartcampus.material.modules.management.dao;
import com.orhon.smartcampus.material.basicComponents.baseDao.BaseDaoImpl;
import com.orhon.smartcampus.material.modules.management.entity.Buildings;
import com.orhon.smartcampus.material.modules.management.entity.GoodsManage;
import org.springframework.stereotype.Component;
@Component
public class BuildingsDao extends BaseDaoImpl<Buildings> {
}
package com.orhon.smartcampus.material.modules.management.dao;
import com.orhon.smartcampus.material.basicComponents.baseDao.BaseDaoImpl;
import com.orhon.smartcampus.material.modules.management.entity.GoodsManage;
import org.springframework.stereotype.Component;
@Component
public class GoodsManageDao extends BaseDaoImpl<GoodsManage> {
}
package com.orhon.smartcampus.material.modules.management.dao;
import com.orhon.smartcampus.material.basicComponents.baseDao.BaseDaoImpl;
import com.orhon.smartcampus.material.modules.management.entity.Buildings;
import com.orhon.smartcampus.material.modules.management.entity.Unit;
import org.springframework.stereotype.Component;
@Component
public class UnitDao extends BaseDaoImpl<Unit> {
}
package com.orhon.smartcampus.material.modules.management.entity;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import java.util.Date;
@Setter
@Getter
@EqualsAndHashCode
@Entity
@Table(name = "material_buildings", schema = "material", catalog = "")
public class Buildings {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Long id;
@Column(name = "buildings_name", nullable = false)
private String buildings_name;
@Column(name = "site_id", nullable = false)
private String site_id;
@Column(name = "buildings_units", nullable = false)
private String buildings_units;
@Column(name = "buildings_introduce", nullable = false)
private String buildings_introduce;
@Column(name = "buildings_status", nullable = false)
private int buildings_status;
@Column(name = "buildings_head_id", nullable = false)
private String buildings_head_id;
@Column(name = "add_id", nullable = false)
private String add_id;
@Column(name = "school_id", nullable = false)
private String school_id;
@Column(name = "created_at", nullable = false)
private Date created_at;
@Column(name = "updated_at", nullable = false)
private Date updated_at;
// @ManyToOne
// @JoinColumn(name = "unit_id", referencedColumnName = "id")
// @Where(clause = "ISNULL(deleted_at)")
// @NotFound(action= NotFoundAction.IGNORE)
// private Unit materialUnitByUnitId;
//
// @ManyToOne
// @JoinColumn(name = "school_id", referencedColumnName = "id")
// @Where(clause = "ISNULL(deleted_at)")
// @NotFound(action=NotFoundAction.IGNORE)
// private Schools baseSchoolsBySchoolId;
}
......@@ -21,10 +21,10 @@ public class GoodsClassify {
private String classify_name;
@Column(name = "classify_status", nullable = false)
private Integer classify_status;
@Column(name = "classify_campus_id", nullable = false)
private String classify_campus_id;
@Column(name = "classify_userid", nullable = false)
private String classify_userid;
@Column(name = "school_id", nullable = false)
private String school_id;
@Column(name = "add_id", nullable = false)
private String add_id;
@Column(name = "created_at", nullable = false)
private Date created_at;
@Column(name = "updated_at", nullable = false)
......
package com.orhon.smartcampus.material.modules.management.entity;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import java.util.Date;
@Setter
@Getter
@EqualsAndHashCode
@Entity
@Table(name = "material_goods", schema = "material", catalog = "")
public class GoodsManage {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Long id;
@Column(name = "classify_id", nullable = false)
private Integer classify_id;
@Column(name = "goods_name", nullable = false)
private String goods_name;
@Column(name = "main_image", nullable = false)
private String main_image;
@Column(name = "sub_images", nullable = false)
private String sub_images;
@Column(name = "goods_number", nullable = false)
private String goods_number;
@Column(name = "good_status", nullable = false)
private int good_status;
@Column(name = "goods_price", nullable = false)
private String goods_price;
@Column(name = "goods_stock", nullable = false)
private Integer goods_stock;
@Column(name = "userid", nullable = false)
private String userid;
@Column(name = "school_id", nullable = false)
private String school_id;
@Column(name = "created_at", nullable = false)
private Date created_at;
@Column(name = "updated_at", nullable = false)
private Date updated_at;
// @ManyToOne
// @JoinColumn(name = "unit_id", referencedColumnName = "id")
// @Where(clause = "ISNULL(deleted_at)")
// @NotFound(action= NotFoundAction.IGNORE)
// private Unit materialUnitByUnitId;
//
// @ManyToOne
// @JoinColumn(name = "school_id", referencedColumnName = "id")
// @Where(clause = "ISNULL(deleted_at)")
// @NotFound(action=NotFoundAction.IGNORE)
// private Schools baseSchoolsBySchoolId;
}
package com.orhon.smartcampus.material.modules.management.entity;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import java.util.Date;
@Setter
@Getter
@EqualsAndHashCode
@Entity
@Table(name = "material_unit", schema = "material", catalog = "")
public class Unit {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Long id;
@Column(name = "building_id", nullable = false)
private String building_id;
@Column(name = "head_id", nullable = false)
private String head_id;
@Column(name = "floor_status", nullable = false)
private String floor_status;
@Column(name = "floor_number", nullable = false)
private String floor_number;
@Column(name = "floor_start", nullable = false)
private int floor_start;
@Column(name = "floor_end", nullable = false)
private String floor_end;
@Column(name = "add_id", nullable = false)
private String add_id;
@Column(name = "school_id", nullable = false)
private String school_id;
@Column(name = "created_at", nullable = false)
private Date created_at;
@Column(name = "updated_at", nullable = false)
private Date updated_at;
// @ManyToOne
// @JoinColumn(name = "unit_id", referencedColumnName = "id")
// @Where(clause = "ISNULL(deleted_at)")
// @NotFound(action= NotFoundAction.IGNORE)
// private Unit materialUnitByUnitId;
//
// @ManyToOne
// @JoinColumn(name = "school_id", referencedColumnName = "id")
// @Where(clause = "ISNULL(deleted_at)")
// @NotFound(action=NotFoundAction.IGNORE)
// private Schools baseSchoolsBySchoolId;
}
package com.orhon.smartcampus.material.modules.management.fetcher;
import com.orhon.smartcampus.material.basicComponents.Result;
import com.orhon.smartcampus.material.modules.base.gqlModel.GQLPageParam;
import com.orhon.smartcampus.material.modules.base.mm.EnvArgsMapper;
import com.orhon.smartcampus.material.modules.management.dao.BuildingsDao;
import com.orhon.smartcampus.material.modules.management.dao.GoodsManageDao;
import com.orhon.smartcampus.material.modules.management.entity.Buildings;
import com.orhon.smartcampus.material.modules.management.entity.GoodsManage;
import com.orhon.smartcampus.material.modules.management.gqlModel.GQLBuildings;
import com.orhon.smartcampus.material.modules.management.gqlModel.GQLGoodsManage;
import com.orhon.smartcampus.material.modules.management.mm.BuildingsMapper;
import com.orhon.smartcampus.material.modules.management.mm.GoodsManageMapper;
import com.orhon.smartcampus.material.utils.ObjectToMap;
import com.orhon.smartcampus.material.utils.Util;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
@Component
public class BuildingsListFetcher implements DataFetcher {
@Autowired
BuildingsDao buildingsDao;
@Override
public Object get(DataFetchingEnvironment env) throws Exception {
// + schoolId
String hql = "from Buildings";
GQLPageParam page = EnvArgsMapper.MAPPER.fromArgs(env);
if (env.containsArgument("condition")) {
HashMap<String, Object> map = ObjectToMap.to(env.getArgument("condition"));
if (map.get("id") != null) {
hql += "and id " + Util.decide(map.get("id"));
}
if (map.get("buildings_name") != null) {
hql += "and buildings_name " + Util.decide(map.get("buildings_name"));
}
if (map.get("buildings_status") != null) {
hql += "and buildings_status " + Util.decide(map.get("buildings_status"));
}
}
List<Buildings> list = buildingsDao.find(hql, null, page.getPage(), page.getLimit());
List<GQLBuildings> gqlGoodsClassifies = BuildingsMapper.MAPPER.toBuildingsList(list);
Long total = 0L;
if (env.getSelectionSet().contains("total")) {
total = buildingsDao.getTotalCount(hql);
}
return Result.ok().put("data", gqlGoodsClassifies).put("total", total);
}
}
package com.orhon.smartcampus.material.modules.management.fetcher;
import com.orhon.smartcampus.material.basicComponents.Result;
import com.orhon.smartcampus.material.modules.base.gqlModel.GQLPageParam;
import com.orhon.smartcampus.material.modules.base.mm.EnvArgsMapper;
import com.orhon.smartcampus.material.modules.management.dao.GoodsManageDao;
import com.orhon.smartcampus.material.modules.management.entity.GoodsManage;
import com.orhon.smartcampus.material.modules.management.gqlModel.GQLGoodsManage;
import com.orhon.smartcampus.material.modules.management.mm.GoodsClassifyMapper;
import com.orhon.smartcampus.material.modules.management.mm.GoodsManageMapper;
import com.orhon.smartcampus.material.utils.ObjectToMap;
import com.orhon.smartcampus.material.utils.Util;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
@Component
public class GoodsManageListFetcher implements DataFetcher {
@Autowired
GoodsManageDao goodsManageDao;
@Override
public Object get(DataFetchingEnvironment env) throws Exception {
// + schoolId
String hql = "from GoodsManage";
GQLPageParam page = EnvArgsMapper.MAPPER.fromArgs(env);
if(env.containsArgument("condition")) {
HashMap<String,Object> map = ObjectToMap.to(env.getArgument("condition"));
if(map.get("id")!=null) {
hql += "and id " + Util.decide(map.get("id"));
}
if(map.get("goods_name")!=null) {
hql += "and goods_name " + Util.decide(map.get("goods_name"));
}
if(map.get("good_status")!=null) {
hql += "and good_status " + Util.decide(map.get("good_status"));
}
}
List<GoodsManage> list = goodsManageDao.find(hql,null,page.getPage(),page.getLimit());
List<GQLGoodsManage> gqlGoodsClassifies = GoodsManageMapper.MAPPER.toGoodsManageList(list);
Long total = 0L;
if (env.getSelectionSet().contains("total")){
total = goodsManageDao.getTotalCount(hql);
}
return Result.ok().put("data", gqlGoodsClassifies).put("total", total);
}
}
......@@ -16,103 +16,24 @@ public class MaterialFetchersLoader {
@Autowired
GoodsClassifyFetcher goodsClassifyFetcher;
//
// @Autowired
// AddRoomMutation addRoomMutation;
//
// @Autowired
// DeleteRoomMutation deleteRoomMutation;
//
// @Autowired
// AddFloorMutation addFloorMutation;
//
// @Autowired
// DeleteFloorMutation deleteFloorMutation;
//
// @Autowired
// AddUnitMutation addUnitMutation;
//
// @Autowired
// DeleteUnitMutation deleteUnitMutation;
//
//
// @Autowired
// AddBuildingMutation addBuildingMutation;
//
// @Autowired
// DeleteBuildingMutation deleteBuildingMutation;
//
// @Autowired
// AddSiteMutation addSiteMutation;
//
// @Autowired
// DeleteSiteMutation deleteSiteMutation;
//
// @Autowired
// AddCampusMutation addCampusMutation;
//
// @Autowired
// DeleteCampusMutation deleteCampusMutation;
//
//
// @Autowired
// BuildingFetcher buildingFetcher;
// @Autowired
// BuildingListFetcher buildingListFetcher;
//
// @Autowired
// CampusFetcher campusFetcher;
// @Autowired
// CampusListFetcher campusListFetcher;
//
// @Autowired
// FloorFetcher floorFetcher;
// @Autowired
// FloorListFetcher floorListFetcher;
//
// @Autowired
// RoomFetcher roomFetcher;
// @Autowired
// RoomListFetcher roomListFetcher;
//
// @Autowired
// SiteFetcher siteFetcher;
// @Autowired
// SiteListFetcher siteListFetcher;
//
// @Autowired
// UnitFetcher unitFetcher;
// @Autowired
// UnitListFetcher unitListFetcher;
@Autowired
GoodsManageListFetcher goodsManageListFetcher;
@Autowired
BuildingsListFetcher buildingsListFetcher;
public void LoadFetchers(RuntimeWiring.Builder builder){
builder.type("Query" , t->t.dataFetcher("GoodsClassify" , goodsClassifyFetcher));
builder.type("Query" , t->t.dataFetcher("GoodsClassifys" , goodsClassifyListFetcher));
// builder.type("Query" , t->t.dataFetcher("Buildings" , buildingListFetcher));
// builder.type("Query" , t->t.dataFetcher("Building" , buildingFetcher));
// builder.type("Query" , t->t.dataFetcher("Campuses" , campusListFetcher));
// builder.type("Query" , t->t.dataFetcher("Campus" , campusFetcher));
// builder.type("Query" , t->t.dataFetcher("Floors" , floorListFetcher));
// builder.type("Query" , t->t.dataFetcher("Rooms" , roomListFetcher));
// builder.type("Query" , t->t.dataFetcher("Room" , roomFetcher));
// builder.type("Query" , t->t.dataFetcher("Sites" , siteListFetcher));
// builder.type("Query" , t->t.dataFetcher("Site" , siteFetcher));
// builder.type("Query" , t->t.dataFetcher("Units" , unitListFetcher));
// builder.type("Query" , t->t.dataFetcher("Unit" , unitFetcher));
builder.type("Query" , t->t.dataFetcher("GoodsManages" , goodsManageListFetcher));
builder.type("Query" , t->t.dataFetcher("BuildingsList" , buildingsListFetcher));
// builder.type("Mutation" , t->t.dataFetcher("addRoom" , addRoomMutation));
// builder.type("Mutation" , t->t.dataFetcher("deleteRoom" , deleteRoomMutation));
builder.type("Mutation" , t->t.dataFetcher("addGoodsClassify" , addGoodsClassifyMutation));
// builder.type("Mutation" , t->t.dataFetcher("deleteFloor" , deleteFloorMutation));
// builder.type("Mutation" , t->t.dataFetcher("addUnit" , addUnitMutation));
// builder.type("Mutation" , t->t.dataFetcher("deleteUnit" , deleteUnitMutation));
// builder.type("Mutation" , t->t.dataFetcher("addBuilding" , addBuildingMutation));
// builder.type("Mutation" , t->t.dataFetcher("deleteBuilding" , deleteBuildingMutation));
// builder.type("Mutation" , t->t.dataFetcher("addSite" , addSiteMutation));
// builder.type("Mutation" , t->t.dataFetcher("deleteSite" , deleteSiteMutation));
// builder.type("Mutation" , t->t.dataFetcher("addCampus" , addCampusMutation));
// builder.type("Mutation" , t->t.dataFetcher("deleteCampus" , deleteCampusMutation));
builder.type("Mutation" , t->t.dataFetcher("addGoodsClassify" , addGoodsClassifyMutation));
builder.type("Mutation" , t->t.dataFetcher("addGoodsManage" , goodsManageListFetcher));
builder.type("Mutation" , t->t.dataFetcher("addBuildings" , buildingsListFetcher));
}
......
package com.orhon.smartcampus.material.modules.management.fetcher;
import com.orhon.smartcampus.material.basicComponents.Result;
import com.orhon.smartcampus.material.modules.base.gqlModel.GQLPageParam;
import com.orhon.smartcampus.material.modules.base.mm.EnvArgsMapper;
import com.orhon.smartcampus.material.modules.management.dao.UnitDao;
import com.orhon.smartcampus.material.modules.management.entity.Unit;
import com.orhon.smartcampus.material.modules.management.gqlModel.GQLUnit;
import com.orhon.smartcampus.material.modules.management.mm.UnitMapper;
import com.orhon.smartcampus.material.utils.ObjectToMap;
import com.orhon.smartcampus.material.utils.Util;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
@Component
public class UnitListFetcher implements DataFetcher {
@Autowired
UnitDao unitDao;
@Override
public Object get(DataFetchingEnvironment env) throws Exception {
// + schoolId
String hql = "from Buildings";
GQLPageParam page = EnvArgsMapper.MAPPER.fromArgs(env);
if (env.containsArgument("condition")) {
HashMap<String, Object> map = ObjectToMap.to(env.getArgument("condition"));
if (map.get("id") != null) {
hql += "and id " + Util.decide(map.get("id"));
}
if (map.get("building_id") != null) {
hql += "and building_id " + Util.decide(map.get("building_id"));
}
if (map.get("floor_status") != null) {
hql += "and floor_status " + Util.decide(map.get("floor_status"));
}
}
List<Unit> list = unitDao.find(hql, null, page.getPage(), page.getLimit());
List<GQLUnit> gqlGoodsClassifies = UnitMapper.MAPPER.toUnitList(list);
Long total = 0L;
if (env.getSelectionSet().contains("total")) {
total = unitDao.getTotalCount(hql);
}
return Result.ok().put("data", gqlGoodsClassifies).put("total", total);
}
}
package com.orhon.smartcampus.material.modules.management.gqlInputModel;
import lombok.Data;
@Data
public class GQLBuildingsInput {
private Long id;
private String buildings_name;
private String site_id;
private String buildings_units;
private String buildings_introduce;
private int buildings_status;
private String buildings_head_id;
private String add_id;
private String school_id;
}
......@@ -2,18 +2,17 @@ package com.orhon.smartcampus.material.modules.management.gqlInputModel;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Data
public class GQLGoodsClassifyInput {
private Long id;
private String classify_name;
private Integer classify_status;
private String classify_campus_id;
private String classify_userid;
private String school_id;
private String add_id;
}
package com.orhon.smartcampus.material.modules.management.gqlInputModel;
import lombok.Data;
@Data
public class GQLGoodsManageInput {
private Long id;
private Integer classify_id;
private String goods_name;
private String main_image;
private String sub_images;
private String goods_number;
private Integer good_status;
private String goods_price;
private Integer goods_stock;
private String userid;
private String school_id;
}
package com.orhon.smartcampus.material.modules.management.gqlInputModel;
import lombok.Data;
@Data
public class GQLUnitInput {
private Long id;
private String building_id;
private String head_id;
private String floor_status;
private String floor_number;
private int floor_start;
private String floor_end;
private String add_id;
private String school_id;
}
package com.orhon.smartcampus.material.modules.management.gqlModel;
import lombok.Data;
@Data
public class GQLBuildings {
private Long id;
private String buildings_name;
private String site_id;
private String buildings_units;
private String buildings_introduce;
private int buildings_status;
private String buildings_head_id;
private String add_id;
private String school_id;
}
......@@ -9,8 +9,8 @@ public class GQLGoodsClassify {
private Long id;
private String classify_name;
private Integer classify_status;
private String classify_campus_id;
private String classify_userid;
private String school_id;
private String add_id;
private Date created_at;
private Date updated_at;
}
package com.orhon.smartcampus.material.modules.management.gqlModel;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.Date;
@Data
public class GQLGoodsManage {
private Long id;
private Integer classify_id;
private String goods_name;
private String main_image;
private String sub_images;
private String goods_number;
private Integer good_status;
private String goods_price;
private Integer goods_stock;
private String userid;
private String school_id;
private Date created_at;
private Date updated_at;
}
package com.orhon.smartcampus.material.modules.management.gqlModel;
import lombok.Data;
@Data
public class GQLUnit {
private Long id;
private String building_id;
private String head_id;
private String floor_status;
private String floor_number;
private int floor_start;
private String floor_end;
private String add_id;
private String school_id;
}
package com.orhon.smartcampus.material.modules.management.inputMapper;
import com.alibaba.fastjson.JSON;
import com.orhon.smartcampus.material.basicComponents.ConvertHelper;
import com.orhon.smartcampus.material.modules.management.gqlInputModel.GQLBuildingsInput;
import com.orhon.smartcampus.material.modules.management.gqlInputModel.GQLGoodsManageInput;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.Map;
@Mapper(uses = {
ConvertHelper.class
})
public interface BuildingsInputMapper {
BuildingsInputMapper MAPPER = Mappers.getMapper(BuildingsInputMapper.class);
default GQLBuildingsInput mapInput(final Map map){
String json = JSON.toJSONString(map);
GQLBuildingsInput input = JSON.parseObject(json , GQLBuildingsInput.class);
return input;
}
}
package com.orhon.smartcampus.material.modules.management.inputMapper;
import com.alibaba.fastjson.JSON;
import com.orhon.smartcampus.material.basicComponents.ConvertHelper;
import com.orhon.smartcampus.material.modules.management.gqlInputModel.GQLGoodsClassifyInput;
import com.orhon.smartcampus.material.modules.management.gqlInputModel.GQLGoodsManageInput;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.Map;
@Mapper(uses = {
ConvertHelper.class
})
public interface GoodsManageInputMapper {
GoodsManageInputMapper MAPPER = Mappers.getMapper(GoodsManageInputMapper.class);
default GQLGoodsManageInput mapInput(final Map map){
String json = JSON.toJSONString(map);
GQLGoodsManageInput input = JSON.parseObject(json , GQLGoodsManageInput.class);
return input;
}
}
package com.orhon.smartcampus.material.modules.management.inputMapper;
import com.alibaba.fastjson.JSON;
import com.orhon.smartcampus.material.basicComponents.ConvertHelper;
import com.orhon.smartcampus.material.modules.management.gqlInputModel.GQLUnitInput;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.Map;
@Mapper(uses = {
ConvertHelper.class
})
public interface UnitInputMapper {
UnitInputMapper MAPPER = Mappers.getMapper(UnitInputMapper.class);
default GQLUnitInput mapInput(final Map map){
String json = JSON.toJSONString(map);
GQLUnitInput input = JSON.parseObject(json , GQLUnitInput.class);
return input;
}
}
package com.orhon.smartcampus.material.modules.management.mm;
import com.orhon.smartcampus.material.basicComponents.ConvertHelper;
import com.orhon.smartcampus.material.modules.management.entity.Buildings;
import com.orhon.smartcampus.material.modules.management.entity.GoodsClassify;
import com.orhon.smartcampus.material.modules.management.entity.GoodsManage;
import com.orhon.smartcampus.material.modules.management.gqlModel.GQLBuildings;
import com.orhon.smartcampus.material.modules.management.gqlModel.GQLGoodsClassify;
import com.orhon.smartcampus.material.modules.management.gqlModel.GQLGoodsManage;
import org.mapstruct.InheritConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper(
uses = {
ConvertHelper.class
}
)
public interface BuildingsMapper {
BuildingsMapper MAPPER = Mappers.getMapper(BuildingsMapper.class);
@Mapping(source = "id" , target = "id")
@Mapping(source = "classify_name" , target = "classify_name")
@Mapping(source = "classify_status" , target = "classify_status")
@Mapping(source = "classify_campus_id" , target = "classify_campus_id")
@Mapping(source = "classify_userid" , target = "classify_userid")
@Mapping(source = "created_at" , target = "created_at")
@Mapping(source = "updated_at" , target = "updated_at")
GQLGoodsClassify toGoodsClassify(GoodsClassify entity);
@InheritConfiguration(name = "toBuildings")
List<GQLBuildings> toBuildingsList(List<Buildings> entities);
}
......@@ -23,8 +23,8 @@ public interface GoodsClassifyMapper {
@Mapping(source = "id" , target = "id")
@Mapping(source = "classify_name" , target = "classify_name")
@Mapping(source = "classify_status" , target = "classify_status")
@Mapping(source = "classify_campus_id" , target = "classify_campus_id")
@Mapping(source = "classify_userid" , target = "classify_userid")
@Mapping(source = "add_id" , target = "add_id")
@Mapping(source = "school_id" , target = "school_id")
@Mapping(source = "created_at" , target = "created_at")
@Mapping(source = "updated_at" , target = "updated_at")
GQLGoodsClassify toGoodsClassify(GoodsClassify entity);
......
package com.orhon.smartcampus.material.modules.management.mm;
import com.orhon.smartcampus.material.basicComponents.ConvertHelper;
import com.orhon.smartcampus.material.modules.management.entity.GoodsClassify;
import com.orhon.smartcampus.material.modules.management.entity.GoodsManage;
import com.orhon.smartcampus.material.modules.management.gqlModel.GQLGoodsClassify;
import com.orhon.smartcampus.material.modules.management.gqlModel.GQLGoodsManage;
import org.mapstruct.InheritConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper(
uses = {
ConvertHelper.class
}
)
public interface GoodsManageMapper {
GoodsManageMapper MAPPER = Mappers.getMapper(GoodsManageMapper.class);
// @Mapping(source = "id" , target = "id")
// @Mapping(source = "classify_name" , target = "classify_name")
// @Mapping(source = "classify_status" , target = "classify_status")
// @Mapping(source = "classify_campus_id" , target = "classify_campus_id")
// @Mapping(source = "classify_userid" , target = "classify_userid")
// @Mapping(source = "created_at" , target = "created_at")
// @Mapping(source = "updated_at" , target = "updated_at")
// GQLGoodsClassify toGoodsClassify(GoodsClassify entity);
@InheritConfiguration(name = "toGoodsClassify")
List<GQLGoodsManage> toGoodsManageList(List<GoodsManage> entities);
}
package com.orhon.smartcampus.material.modules.management.mm;
import com.orhon.smartcampus.material.basicComponents.ConvertHelper;
import com.orhon.smartcampus.material.modules.management.entity.GoodsClassify;
import com.orhon.smartcampus.material.modules.management.entity.Unit;
import com.orhon.smartcampus.material.modules.management.gqlModel.GQLGoodsClassify;
import com.orhon.smartcampus.material.modules.management.gqlModel.GQLUnit;
import org.mapstruct.InheritConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper(
uses = {
ConvertHelper.class
}
)
public interface UnitMapper {
UnitMapper MAPPER = Mappers.getMapper(UnitMapper.class);
@Mapping(source = "id" , target = "id")
@Mapping(source = "classify_name" , target = "classify_name")
@Mapping(source = "classify_status" , target = "classify_status")
@Mapping(source = "classify_campus_id" , target = "classify_campus_id")
@Mapping(source = "classify_userid" , target = "classify_userid")
@Mapping(source = "created_at" , target = "created_at")
@Mapping(source = "updated_at" , target = "updated_at")
GQLGoodsClassify toGoodsClassify(GoodsClassify entity);
@InheritConfiguration(name = "toUnit")
List<GQLUnit> toUnitList(List<Unit> entities);
}
package com.orhon.smartcampus.material.modules.management.mutation;
import com.orhon.smartcampus.material.basicComponents.Result;
import com.orhon.smartcampus.material.modules.management.dao.BuildingsDao;
import com.orhon.smartcampus.material.modules.management.dao.GoodsManageDao;
import com.orhon.smartcampus.material.modules.management.entity.Buildings;
import com.orhon.smartcampus.material.modules.management.entity.GoodsManage;
import com.orhon.smartcampus.material.modules.management.gqlInputModel.GQLBuildingsInput;
import com.orhon.smartcampus.material.modules.management.gqlInputModel.GQLGoodsManageInput;
import com.orhon.smartcampus.material.modules.management.inputMapper.BuildingsInputMapper;
import com.orhon.smartcampus.material.modules.management.inputMapper.GoodsManageInputMapper;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
@Component
public class AddBuildingsMutation implements DataFetcher {
@Autowired
BuildingsDao buildingsDao;
/**
* 楼层管理
* editor : ths
*/
@Override
public Object get(DataFetchingEnvironment environment) throws Exception {
//String token = (String) SecurityUtils.getSubject().getPrincipal();
GQLBuildingsInput input = BuildingsInputMapper.MAPPER.mapInput(environment.getArgument("inputData"));
Buildings buildings = null;
if (input.getId() != null) {
buildings = buildingsDao.get(Buildings.class, input.getId());
buildings.setUpdated_at(new Date());
} else {
buildings = new Buildings();
buildings.setCreated_at(new Date());
}
if(input.getBuildings_name() != null){
buildings.setBuildings_name(input.getBuildings_name());
}
if(input.getSite_id() != null){
buildings.setSite_id(input.getSite_id());
}
if(input.getBuildings_units() != null){
buildings.setBuildings_units(input.getBuildings_units());
}
if(input.getBuildings_introduce()!= null){
buildings.setBuildings_introduce(input.getBuildings_introduce());
}
if(input.getBuildings_head_id() != null){
buildings.setBuildings_head_id(input.getBuildings_head_id());
}
if(input.getAdd_id() != null){
buildings.setAdd_id(input.getAdd_id());
}
if(input.getSchool_id() != null){
buildings.setSchool_id(input.getSchool_id());
}
try {
buildingsDao.saveOrUpdate(buildings);
} catch (Exception e) {
return Result.error(500, "" + e);
}
return Result.ok();
}
}
......@@ -44,17 +44,17 @@ public class AddGoodsClassifyMutation implements DataFetcher {
goodsClassify.setClassify_name(input.getClassify_name());
}
if(input.getClassify_campus_id() != null){
if(input.getSchool_id() != null){
goodsClassify.setClassify_campus_id(input.getClassify_campus_id());
goodsClassify.setSchool_id(input.getSchool_id());
}
if(input.getClassify_status() != null){
goodsClassify.setClassify_status(input.getClassify_status());
}
if(input.getClassify_userid() != null){
if(input.getAdd_id() != null){
goodsClassify.setClassify_userid(JSON.toJSONString(input.getClassify_userid()));
goodsClassify.setAdd_id(JSON.toJSONString(input.getAdd_id()));
}
try {
goodsClassifyDao.saveOrUpdate(goodsClassify);
......
package com.orhon.smartcampus.material.modules.management.mutation;
import com.alibaba.fastjson.JSON;
import com.orhon.smartcampus.material.basicComponents.Result;
import com.orhon.smartcampus.material.modules.management.dao.GoodsClassifyDao;
import com.orhon.smartcampus.material.modules.management.dao.GoodsManageDao;
import com.orhon.smartcampus.material.modules.management.entity.GoodsClassify;
import com.orhon.smartcampus.material.modules.management.entity.GoodsManage;
import com.orhon.smartcampus.material.modules.management.gqlInputModel.GQLGoodsClassifyInput;
import com.orhon.smartcampus.material.modules.management.gqlInputModel.GQLGoodsManageInput;
import com.orhon.smartcampus.material.modules.management.inputMapper.GoodsClassifyInputMapper;
import com.orhon.smartcampus.material.modules.management.inputMapper.GoodsManageInputMapper;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
@Component
public class AddGoodsManageMutation implements DataFetcher {
@Autowired
GoodsManageDao goodsManageDao;
/**
* 楼层管理
* editor : ths
*/
@Override
public Object get(DataFetchingEnvironment environment) throws Exception {
//String token = (String) SecurityUtils.getSubject().getPrincipal();
GQLGoodsManageInput input = GoodsManageInputMapper.MAPPER.mapInput(environment.getArgument("inputData"));
GoodsManage goodsManage = null;
if (input.getId() != null) {
goodsManage = goodsManageDao.get(GoodsManage.class, input.getId());
goodsManage.setUpdated_at(new Date());
} else {
goodsManage = new GoodsManage();
goodsManage.setCreated_at(new Date());
}
if(input.getClassify_id() != null){
goodsManage.setClassify_id(input.getClassify_id());
}
if(input.getGoods_name() != null){
goodsManage.setGoods_name(input.getGoods_name());
}
if(input.getMain_image() != null){
goodsManage.setMain_image(input.getMain_image());
}
if(input.getGoods_number() != null){
goodsManage.setGoods_number(input.getGoods_number());
}
if(input.getGood_status() != null){
goodsManage.setGood_status(input.getGood_status());
}
if(input.getGoods_price() != null){
goodsManage.setGoods_price(input.getGoods_price());
}
if(input.getGoods_stock() != null){
goodsManage.setGoods_price(input.getGoods_price());
}
if(input.getUserid() != null){
goodsManage.setUserid(input.getUserid());
}
if(input.getSchool_id() != null){
goodsManage.setSchool_id(input.getSchool_id());
}
try {
goodsManageDao.saveOrUpdate(goodsManage);
} catch (Exception e) {
return Result.error(500, "" + e);
}
return Result.ok();
}
}
package com.orhon.smartcampus.material.modules.management.mutation;
import com.orhon.smartcampus.material.basicComponents.Result;
import com.orhon.smartcampus.material.modules.management.dao.BuildingsDao;
import com.orhon.smartcampus.material.modules.management.dao.UnitDao;
import com.orhon.smartcampus.material.modules.management.entity.Buildings;
import com.orhon.smartcampus.material.modules.management.entity.Unit;
import com.orhon.smartcampus.material.modules.management.gqlInputModel.GQLBuildingsInput;
import com.orhon.smartcampus.material.modules.management.gqlInputModel.GQLUnitInput;
import com.orhon.smartcampus.material.modules.management.inputMapper.BuildingsInputMapper;
import com.orhon.smartcampus.material.modules.management.inputMapper.UnitInputMapper;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
@Component
public class AddUnitMutation implements DataFetcher {
@Autowired
UnitDao unitDao;
/**
* 楼层管理
* editor : ths
*/
@Override
public Object get(DataFetchingEnvironment environment) throws Exception {
//String token = (String) SecurityUtils.getSubject().getPrincipal();
GQLUnitInput input = UnitInputMapper.MAPPER.mapInput(environment.getArgument("inputData"));
Unit unit = null;
if (input.getId() != null) {
unit = unitDao.get(Unit.class, input.getId());
unit.setUpdated_at(new Date());
} else {
unit = new Unit();
unit.setCreated_at(new Date());
}
if(input.getBuilding_id() != null){
unit.setBuilding_id(input.getBuilding_id());
}
if(input.getHead_id() != null){
unit.setHead_id(input.getHead_id());
}
if(input.getFloor_status() != null){
unit.setFloor_status(input.getFloor_status());
}
if(input.getFloor_number()!= null){
unit.setFloor_number(input.getFloor_number());
}
if(input.getAdd_id() != null){
unit.setAdd_id(input.getAdd_id());
}
if(input.getSchool_id() != null){
unit.setSchool_id(input.getSchool_id());
}
try {
unitDao.saveOrUpdate(unit);
} catch (Exception e) {
return Result.error(500, "" + e);
}
return Result.ok();
}
}
"楼层"
#物品分类
type GoodsClassify {
id:Long
"单元"
id:Int
classify_name:String
"楼层电话"
classify_status:Int
"楼层负责人"
classify_campus_id:String
"楼层名"
classify_userid:String
school_id:String
add_id:String
created_at:Date
updated_at:Date
}
input GoodsClassifyInput {
id:Int
classify_name:String
classify_status:Int
classify_campus_id:String
classify_userid:String
school_id:String
add_id:String
}
input GoodsClassifyCondition {
id:Int
classify_name:String
classify_status:Int
code:String
classify_campus_id:String
classify_userid:String
school_id:String
add_id:String
created_at:Date
updated_at:Date
}
type GoodsClassifyResponse {
code:Int
msg:String
data:[GoodsClassify]
total:Int
}
#物品管理
type GoodsManage {
id:Int
classify_id:Int
goods_name:String
main_image:String
sub_images:String
goods_number:String
good_status:Int
goods_price:String
goods_stock:Int
userid:String
school_id:String
created_at:Date
updated_at:Date
}
input GoodsManageInput {
id:Int
classify_id:Int
goods_name:String
main_image:String
sub_images:String
goods_number:String
good_status:Int
goods_price:String
goods_stock:Int
userid:String
school_id:String
}
input GoodsManageCondition {
id:Int
code:String
userid:String
school_id:String
classify_id:Int
created_at:Date
updated_at:Date
}
type GoodsManageResponse {
code:Int
msg:String
data:[GoodsManage]
total:Int
}
#楼宇管理
type Buildings {
id:Int
buildings_name:String
site_id:String
buildings_units:String
buildings_introduce:String
buildings_status:Int
buildings_head_id:String
add_id:String
school_id:String
created_at:Date
updated_at:Date
}
input BuildingsInput {
id:Int
buildings_name:String
site_id:String
buildings_units:String
buildings_introduce:String
buildings_status:Int
buildings_head_id:String
add_id:String
school_id:String
}
input BuildingsCondition {
id:Int
code:String
buildings_name:String
site_id:String
add_id:String
school_id:String
created_at:Date
updated_at:Date
}
type BuildingsResponse {
code:Int
msg:String
data:[Buildings]
total:Int
}
\ No newline at end of file
......@@ -2,9 +2,15 @@ type Query {
query:Query
hello(a:SubjectType):String
#物品分类
GoodsClassifys(page:Int,limit:Int,condition: GoodsClassifyCondition):GoodsClassifyResponse
GoodsClassify(id:Long!):GoodsClassify
GoodsClassify(id:Int!):GoodsClassify
#物品管理
GoodsManages(page:Int,limit:Int,condition: GoodsManageCondition):GoodsManageResponse
GoodsManage(id:Int!):GoodsManage
#楼宇管理
BuildingsList(page:Int,limit:Int,condition: BuildingsCondition):BuildingsResponse
Buildings(id:Int!):Buildings
}
input MessageInput{
......@@ -12,7 +18,12 @@ input MessageInput{
}
type Mutation {
#物品分类
addGoodsClassify(inputData:GoodsClassifyInput): GoodsClassifyResponse
#物品管理
addGoodsManage(inputData:GoodsManageInput): GoodsManageResponse
#楼宇管理
addBuildings(inputData:BuildingsInput): BuildingsResponse
}
......
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