提交 ccaccfaa 编写于 作者: ibizdev's avatar ibizdev

tony001 部署微服务接口 [后台服务,接口示例]

上级 dca7bde6
package cn.ibizlab.core.sample.filter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import lombok.*;
import lombok.extern.slf4j.Slf4j;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.alibaba.fastjson.annotation.JSONField;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import cn.ibizlab.util.filter.QueryWrapperContext;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.ibizlab.core.sample.domain.MicroComponent;
/**
* 关系型数据实体[MicroComponent] 查询条件对象
*/
@Slf4j
@Data
public class MicroComponentSearchContext extends QueryWrapperContext<MicroComponent> {
private String n_microcomponentname_like;//[微组件名称]
public void setN_microcomponentname_like(String n_microcomponentname_like) {
this.n_microcomponentname_like = n_microcomponentname_like;
if(!ObjectUtils.isEmpty(this.n_microcomponentname_like)){
this.getSearchCond().like("microcomponentname", n_microcomponentname_like);
}
}
/**
* 启用快速搜索
*/
@Override
public void setQuery(String query)
{
this.query=query;
if(!StringUtils.isEmpty(query)){
this.getSearchCond().and( wrapper ->
wrapper.like("microcomponentname", query)
);
}
}
}
package cn.ibizlab.core.sample.mapper;
import java.util.List;
import org.apache.ibatis.annotations.*;
import java.util.Map;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import java.util.HashMap;
import org.apache.ibatis.annotations.Select;
import cn.ibizlab.core.sample.domain.MicroComponent;
import cn.ibizlab.core.sample.filter.MicroComponentSearchContext;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import java.io.Serializable;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.alibaba.fastjson.JSONObject;
public interface MicroComponentMapper extends BaseMapper<MicroComponent> {
Page<MicroComponent> searchDefault(IPage page, @Param("srf") MicroComponentSearchContext context, @Param("ew") Wrapper<MicroComponent> wrapper);
@Override
MicroComponent selectById(Serializable id);
@Override
int insert(MicroComponent entity);
@Override
int updateById(@Param(Constants.ENTITY) MicroComponent entity);
@Override
int update(@Param(Constants.ENTITY) MicroComponent entity, @Param("ew") Wrapper<MicroComponent> updateWrapper);
@Override
int deleteById(Serializable id);
/**
* 自定义查询SQL
* @param sql
* @return
*/
@Select("${sql}")
List<JSONObject> selectBySQL(@Param("sql") String sql, @Param("et")Map param);
/**
* 自定义更新SQL
* @param sql
* @return
*/
@Update("${sql}")
boolean updateBySQL(@Param("sql") String sql, @Param("et")Map param);
/**
* 自定义插入SQL
* @param sql
* @return
*/
@Insert("${sql}")
boolean insertBySQL(@Param("sql") String sql, @Param("et")Map param);
/**
* 自定义删除SQL
* @param sql
* @return
*/
@Delete("${sql}")
boolean deleteBySQL(@Param("sql") String sql, @Param("et")Map param);
}
......@@ -8,16 +8,16 @@ import java.util.List;
public interface IBIZBOOKDataImport {
@Mappings({
@Mapping(target = "ibizbookid", source = "ibizbookid"),
@Mapping(target = "press", source = "press"),
@Mapping(target = "author", source = "author"),
@Mapping(target = "type", source = "type"),
@Mapping(target = "price", source = "price"),
@Mapping(target = "createdate", source = "createdate"),
@Mapping(target = "booknumber", source = "booknumber"),
@Mapping(target = "createman", source = "createman"),
@Mapping(target = "createdate", source = "createdate"),
@Mapping(target = "ibizbookname", source = "ibizbookname"),
@Mapping(target = "updateman", source = "updateman"),
@Mapping(target = "updatedate", source = "updatedate"),
@Mapping(target = "type", source = "type"),
@Mapping(target = "press", source = "press"),
@Mapping(target = "author", source = "author"),
})
@BeanMapping(ignoreByDefault = true)
IBIZBOOK toDomain(IBIZBOOK entity);
......
......@@ -8,9 +8,9 @@ import java.util.List;
public interface IBIZOrderImport {
@Mappings({
@Mapping(target = "ibizorderid", source = "ibizorderid"),
@Mapping(target = "orderuid", source = "orderuid"),
@Mapping(target = "ordertype", source = "ordertype"),
@Mapping(target = "ordertime", source = "ordertime"),
@Mapping(target = "orderuid", source = "orderuid"),
@Mapping(target = "ibizordername", source = "ibizordername"),
})
@BeanMapping(ignoreByDefault = true)
......
package cn.ibizlab.core.sample.service;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import java.math.BigInteger;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.scheduling.annotation.Async;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cache.annotation.CacheEvict;
import cn.ibizlab.core.sample.domain.MicroComponent;
import cn.ibizlab.core.sample.filter.MicroComponentSearchContext;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* 实体[MicroComponent] 服务对象接口
*/
public interface IMicroComponentService extends IService<MicroComponent> {
boolean create(MicroComponent et);
void createBatch(List<MicroComponent> list);
boolean update(MicroComponent et);
void updateBatch(List<MicroComponent> list);
boolean remove(String key);
void removeBatch(Collection<String> idList);
MicroComponent get(String key);
MicroComponent getDraft(MicroComponent et);
boolean checkKey(MicroComponent et);
boolean save(MicroComponent et);
void saveBatch(List<MicroComponent> list);
Page<MicroComponent> searchDefault(MicroComponentSearchContext context);
/**
*自定义查询SQL
* @param sql select * from table where id =#{et.param}
* @param param 参数列表 param.put("param","1");
* @return select * from table where id = '1'
*/
List<JSONObject> select(String sql, Map param);
/**
*自定义SQL
* @param sql update table set name ='test' where id =#{et.param}
* @param param 参数列表 param.put("param","1");
* @return update table set name ='test' where id = '1'
*/
boolean execute(String sql, Map param);
List<MicroComponent> getMicrocomponentByIds(List<String> ids);
List<MicroComponent> getMicrocomponentByEntities(List<MicroComponent> entities);
}
package cn.ibizlab.core.sample.service.impl;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.Map;
import java.util.HashSet;
import java.util.HashMap;
import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import java.math.BigInteger;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.util.ObjectUtils;
import org.springframework.beans.factory.annotation.Value;
import cn.ibizlab.util.errors.BadRequestAlertException;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Lazy;
import cn.ibizlab.core.sample.domain.MicroComponent;
import cn.ibizlab.core.sample.filter.MicroComponentSearchContext;
import cn.ibizlab.core.sample.service.IMicroComponentService;
import cn.ibizlab.util.helper.CachedBeanCopier;
import cn.ibizlab.util.helper.DEFieldCacheMap;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.ibizlab.core.sample.mapper.MicroComponentMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.alibaba.fastjson.JSONObject;
import org.springframework.util.StringUtils;
/**
* 实体[微组件] 服务对象接口实现
*/
@Slf4j
@Service("MicroComponentServiceImpl")
public class MicroComponentServiceImpl extends ServiceImpl<MicroComponentMapper, MicroComponent> implements IMicroComponentService {
protected int batchSize = 500;
@Override
@Transactional
public boolean create(MicroComponent et) {
if(!this.retBool(this.baseMapper.insert(et))) {
return false;
}
CachedBeanCopier.copy(get(et.getMicrocomponentid()), et);
return true;
}
@Override
@Transactional
public void createBatch(List<MicroComponent> list) {
this.saveBatch(list, batchSize);
}
@Override
@Transactional
public boolean update(MicroComponent et) {
if(!update(et, (Wrapper) et.getUpdateWrapper(true).eq("microcomponentid", et.getMicrocomponentid()))) {
return false;
}
CachedBeanCopier.copy(get(et.getMicrocomponentid()), et);
return true;
}
@Override
@Transactional
public void updateBatch(List<MicroComponent> list) {
updateBatchById(list, batchSize);
}
@Override
@Transactional
public boolean remove(String key) {
boolean result = removeById(key);
return result ;
}
@Override
@Transactional
public void removeBatch(Collection<String> idList) {
removeByIds(idList);
}
@Override
@Transactional
public MicroComponent get(String key) {
MicroComponent et = getById(key);
if(et == null){
et = new MicroComponent();
et.setMicrocomponentid(key);
}
else {
}
return et;
}
@Override
public MicroComponent getDraft(MicroComponent et) {
return et;
}
@Override
public boolean checkKey(MicroComponent et) {
return (!ObjectUtils.isEmpty(et.getMicrocomponentid())) && (!Objects.isNull(this.getById(et.getMicrocomponentid())));
}
@Override
@Transactional
public boolean save(MicroComponent et) {
if(!saveOrUpdate(et)) {
return false;
}
return true;
}
@Override
@Transactional
public boolean saveOrUpdate(MicroComponent et) {
if (null == et) {
return false;
} else {
return checkKey(et) ? this.update(et) : this.create(et);
}
}
@Override
@Transactional
public boolean saveBatch(Collection<MicroComponent> list) {
saveOrUpdateBatch(list,batchSize);
return true;
}
@Override
@Transactional
public void saveBatch(List<MicroComponent> list) {
saveOrUpdateBatch(list,batchSize);
}
/**
* 查询集合 数据集
*/
@Override
public Page<MicroComponent> searchDefault(MicroComponentSearchContext context) {
com.baomidou.mybatisplus.extension.plugins.pagination.Page<MicroComponent> pages=baseMapper.searchDefault(context.getPages(),context,context.getSelectCond());
return new PageImpl<MicroComponent>(pages.getRecords(), context.getPageable(), pages.getTotal());
}
@Override
public List<JSONObject> select(String sql, Map param){
return this.baseMapper.selectBySQL(sql,param);
}
@Override
@Transactional
public boolean execute(String sql , Map param){
if (sql == null || sql.isEmpty()) {
return false;
}
if (sql.toLowerCase().trim().startsWith("insert")) {
return this.baseMapper.insertBySQL(sql,param);
}
if (sql.toLowerCase().trim().startsWith("update")) {
return this.baseMapper.updateBySQL(sql,param);
}
if (sql.toLowerCase().trim().startsWith("delete")) {
return this.baseMapper.deleteBySQL(sql,param);
}
log.warn("暂未支持的SQL语法");
return true;
}
@Override
public List<MicroComponent> getMicrocomponentByIds(List<String> ids) {
return this.listByIds(ids);
}
@Override
public List<MicroComponent> getMicrocomponentByEntities(List<MicroComponent> entities) {
List ids =new ArrayList();
for(MicroComponent entity : entities){
Serializable id=entity.getMicrocomponentid();
if(!ObjectUtils.isEmpty(id)){
ids.add(id);
}
}
if(ids.size()>0) {
return this.listByIds(ids);
}
else {
return entities;
}
}
}
......@@ -1136,7 +1136,7 @@
<!--输出实体[IBIZSAMPLE0021]数据结构 -->
<changeSet author="a_LAB01_df847bdfd" id="tab-ibizsample0021-52-38">
<changeSet author="a_LAB01_df847bdfd" id="tab-ibizsample0021-54-38">
<createTable tableName="T_IBIZSAMPLE0021">
<column name="IBIZSAMPLE0021ID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_IBIZSAMPLE0021_IBIZSAMPLE00"/>
......@@ -1278,6 +1278,74 @@
</createTable>
</changeSet>
<!--输出实体[MICROCOMPONENT]数据结构 -->
<changeSet author="a_LAB01_df847bdfd" id="tab-microcomponent-37-44">
<createTable tableName="T_MICROCOMPONENT">
<column name="CREATEDATE" remarks="" type="DATETIME">
</column>
<column name="CREATEMAN" remarks="" type="VARCHAR(60)">
</column>
<column name="MICROCOMPONENTNAME" remarks="" type="VARCHAR(200)">
</column>
<column name="MICROCOMPONENTID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_MICROCOMPONENT_MICROCOMPONE"/>
</column>
<column name="UPDATEDATE" remarks="" type="DATETIME">
</column>
<column name="UPDATEMAN" remarks="" type="VARCHAR(60)">
</column>
<column name="FIELD" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD2" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD3" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD4" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD5" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD6" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD7" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD8" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD9" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD10" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD11" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD12" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD13" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD14" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD15" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD16" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD17" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD18" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD19" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD20" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD21" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD22" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD23" remarks="" type="VARCHAR(100)">
</column>
<column name="FIELD24" remarks="" type="VARCHAR(100)">
</column>
</createTable>
</changeSet>
<!--输出实体[DYNADASHBOARD]外键关系 -->
<!--输出实体[IBIZAPPCTRL]外键关系 -->
<!--输出实体[IBIZAPPEDITOR]外键关系 -->
......@@ -1296,7 +1364,7 @@
<!--输出实体[IBIZQJ]外键关系 -->
<!--输出实体[IBIZSAMPLE]外键关系 -->
<!--输出实体[IBIZSAMPLE0001]外键关系 -->
<changeSet author="a_LAB01_df847bdfd" id="fk-ibizsample0001-407-44">
<changeSet author="a_LAB01_df847bdfd" id="fk-ibizsample0001-407-45">
<addForeignKeyConstraint baseColumnNames="IBIZSAMPLE0002ID" baseTableName="T_IBIZSAMPLE0001" constraintName="DER1N_IBIZSAMPLE0001_IBIZSAMPL" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="IBIZSAMPLE0002ID" referencedTableName="T_IBIZSAMPLE0002" validate="true"/>
</changeSet>
<!--输出实体[IBIZSAMPLE0002]外键关系 -->
......@@ -1305,7 +1373,7 @@
<!--输出实体[IBIZSAMPLE0005]外键关系 -->
<!--输出实体[IBIZSAMPLE0006]外键关系 -->
<!--输出实体[IBIZSAMPLE0007]外键关系 -->
<changeSet author="a_LAB01_df847bdfd" id="fk-ibizsample0007-4-45">
<changeSet author="a_LAB01_df847bdfd" id="fk-ibizsample0007-4-46">
<addForeignKeyConstraint baseColumnNames="IBIZSAMPLE0006ID" baseTableName="T_IBIZSAMPLE0007" constraintName="DER1N_IBIZSAMPLE0007_IBIZSAMPL" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="IBIZSAMPLE0006ID" referencedTableName="T_IBIZSAMPLE0006" validate="true"/>
</changeSet>
<!--输出实体[IBIZSAMPLE0008]外键关系 -->
......@@ -1321,7 +1389,7 @@
<!--输出实体[IBIZSAMPLE0018]外键关系 -->
<!--输出实体[IBIZSAMPLE0019]外键关系 -->
<!--输出实体[IBIZSAMPLE0020]外键关系 -->
<changeSet author="a_LAB01_df847bdfd" id="fk-ibizsample0020-4-46">
<changeSet author="a_LAB01_df847bdfd" id="fk-ibizsample0020-4-47">
<addForeignKeyConstraint baseColumnNames="IBIZSAMPLE0019ID" baseTableName="T_IBIZSAMPLE0020" constraintName="DER1N_IBIZSAMPLE0020_IBIZSAMPL" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="IBIZSAMPLE0019ID" referencedTableName="T_IBIZSAMPLE0019" validate="true"/>
</changeSet>
<!--输出实体[IBIZSAMPLE0021]外键关系 -->
......@@ -1330,5 +1398,6 @@
<!--输出实体[IBIZSUPPLIER]外键关系 -->
<!--输出实体[IBIZUNIPRODUCT]外键关系 -->
<!--输出实体[IBIZVIEWMSG]外键关系 -->
<!--输出实体[MICROCOMPONENT]外键关系 -->
</databaseChangeLog>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.ibizlab.core.sample.mapper.MicroComponentMapper">
<!--该方法用于重写mybatis中selectById方法,以实现查询逻辑属性-->
<select id="selectById" resultMap="MicroComponentResultMap" databaseId="mysql">
<![CDATA[select t1.* from (SELECT t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`FIELD`, t1.`FIELD10`, t1.`FIELD11`, t1.`FIELD12`, t1.`FIELD13`, t1.`FIELD14`, t1.`FIELD15`, t1.`FIELD16`, t1.`FIELD17`, t1.`FIELD18`, t1.`FIELD19`, t1.`FIELD2`, t1.`FIELD20`, t1.`FIELD21`, t1.`FIELD22`, t1.`FIELD23`, t1.`FIELD24`, t1.`FIELD3`, t1.`FIELD4`, t1.`FIELD5`, t1.`FIELD6`, t1.`FIELD7`, t1.`FIELD8`, t1.`FIELD9`, t1.`MICROCOMPONENTID`, t1.`MICROCOMPONENTNAME`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `T_MICROCOMPONENT` t1 ) t1 where microcomponentid=#{id}]]>
</select>
<!--通过mybatis将查询结果注入到entity中,通过配置autoMapping="true"由mybatis自动处理映射关系 -->
<resultMap id="MicroComponentResultMap" type="cn.ibizlab.core.sample.domain.MicroComponent" autoMapping="true">
<id property="microcomponentid" column="microcomponentid" /><!--主键字段映射-->
</resultMap>
<!--数据集合[Default]-->
<select id="searchDefault" parameterType="cn.ibizlab.core.sample.filter.MicroComponentSearchContext" resultMap="MicroComponentResultMap">
select t1.* from (
<include refid="Default" />
)t1
<where><if test="ew!=null and ew.sqlSegment!=null and !ew.emptyOfWhere">${ew.sqlSegment}</if></where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">${ew.sqlSegment}</if>
</select>
<!--数据查询[Default]-->
<sql id="Default" databaseId="mysql">
<![CDATA[ SELECT t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`FIELD`, t1.`FIELD10`, t1.`FIELD11`, t1.`FIELD12`, t1.`FIELD13`, t1.`FIELD14`, t1.`FIELD15`, t1.`FIELD16`, t1.`FIELD17`, t1.`FIELD18`, t1.`FIELD19`, t1.`FIELD2`, t1.`FIELD20`, t1.`FIELD21`, t1.`FIELD22`, t1.`FIELD23`, t1.`FIELD24`, t1.`FIELD3`, t1.`FIELD4`, t1.`FIELD5`, t1.`FIELD6`, t1.`FIELD7`, t1.`FIELD8`, t1.`FIELD9`, t1.`MICROCOMPONENTID`, t1.`MICROCOMPONENTNAME`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `T_MICROCOMPONENT` t1
]]>
</sql>
<!--数据查询[View]-->
<sql id="View" databaseId="mysql">
<![CDATA[ SELECT t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`FIELD`, t1.`FIELD10`, t1.`FIELD11`, t1.`FIELD12`, t1.`FIELD13`, t1.`FIELD14`, t1.`FIELD15`, t1.`FIELD16`, t1.`FIELD17`, t1.`FIELD18`, t1.`FIELD19`, t1.`FIELD2`, t1.`FIELD20`, t1.`FIELD21`, t1.`FIELD22`, t1.`FIELD23`, t1.`FIELD24`, t1.`FIELD3`, t1.`FIELD4`, t1.`FIELD5`, t1.`FIELD6`, t1.`FIELD7`, t1.`FIELD8`, t1.`FIELD9`, t1.`MICROCOMPONENTID`, t1.`MICROCOMPONENTNAME`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `T_MICROCOMPONENT` t1
]]>
</sql>
</mapper>
package cn.ibizlab.demoapi.mapping;
import org.mapstruct.*;
import cn.ibizlab.core.sample.domain.MicroComponent;
import cn.ibizlab.demoapi.dto.MicroComponentDTO;
import cn.ibizlab.util.domain.MappingBase;
@Mapper(componentModel = "spring", uses = {}, implementationName = "DemoAPIMicroComponentMapping",
nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE,
nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface MicroComponentMapping extends MappingBase<MicroComponentDTO, MicroComponent> {
}
package cn.ibizlab.demoapi.rest;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.math.BigInteger;
import java.util.HashMap;
import lombok.extern.slf4j.Slf4j;
import com.alibaba.fastjson.JSONObject;
import javax.servlet.ServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.http.HttpStatus;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.util.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.validation.annotation.Validated;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import cn.ibizlab.demoapi.dto.*;
import cn.ibizlab.demoapi.mapping.*;
import cn.ibizlab.core.sample.domain.MicroComponent;
import cn.ibizlab.core.sample.service.IMicroComponentService;
import cn.ibizlab.core.sample.filter.MicroComponentSearchContext;
import cn.ibizlab.util.annotation.VersionCheck;
@Slf4j
@Api(tags = {"微组件" })
@RestController("DemoAPI-microcomponent")
@RequestMapping("")
public class MicroComponentResource {
@Autowired
public IMicroComponentService microcomponentService;
@Autowired
@Lazy
public MicroComponentMapping microcomponentMapping;
@PreAuthorize("hasPermission(this.microcomponentMapping.toDomain(#microcomponentdto),'DemoSys-MicroComponent-Create')")
@ApiOperation(value = "新建微组件", tags = {"微组件" }, notes = "新建微组件")
@RequestMapping(method = RequestMethod.POST, value = "/microcomponents")
public ResponseEntity<MicroComponentDTO> create(@Validated @RequestBody MicroComponentDTO microcomponentdto) {
MicroComponent domain = microcomponentMapping.toDomain(microcomponentdto);
microcomponentService.create(domain);
MicroComponentDTO dto = microcomponentMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@PreAuthorize("hasPermission(this.microcomponentMapping.toDomain(#microcomponentdtos),'DemoSys-MicroComponent-Create')")
@ApiOperation(value = "批量新建微组件", tags = {"微组件" }, notes = "批量新建微组件")
@RequestMapping(method = RequestMethod.POST, value = "/microcomponents/batch")
public ResponseEntity<Boolean> createBatch(@RequestBody List<MicroComponentDTO> microcomponentdtos) {
microcomponentService.createBatch(microcomponentMapping.toDomain(microcomponentdtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@VersionCheck(entity = "microcomponent" , versionfield = "updatedate")
@PreAuthorize("hasPermission(this.microcomponentService.get(#microcomponent_id),'DemoSys-MicroComponent-Update')")
@ApiOperation(value = "更新微组件", tags = {"微组件" }, notes = "更新微组件")
@RequestMapping(method = RequestMethod.PUT, value = "/microcomponents/{microcomponent_id}")
public ResponseEntity<MicroComponentDTO> update(@PathVariable("microcomponent_id") String microcomponent_id, @RequestBody MicroComponentDTO microcomponentdto) {
MicroComponent domain = microcomponentMapping.toDomain(microcomponentdto);
domain .setMicrocomponentid(microcomponent_id);
microcomponentService.update(domain );
MicroComponentDTO dto = microcomponentMapping.toDto(domain );
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@PreAuthorize("hasPermission(this.microcomponentService.getMicrocomponentByEntities(this.microcomponentMapping.toDomain(#microcomponentdtos)),'DemoSys-MicroComponent-Update')")
@ApiOperation(value = "批量更新微组件", tags = {"微组件" }, notes = "批量更新微组件")
@RequestMapping(method = RequestMethod.PUT, value = "/microcomponents/batch")
public ResponseEntity<Boolean> updateBatch(@RequestBody List<MicroComponentDTO> microcomponentdtos) {
microcomponentService.updateBatch(microcomponentMapping.toDomain(microcomponentdtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@PreAuthorize("hasPermission(this.microcomponentService.get(#microcomponent_id),'DemoSys-MicroComponent-Remove')")
@ApiOperation(value = "删除微组件", tags = {"微组件" }, notes = "删除微组件")
@RequestMapping(method = RequestMethod.DELETE, value = "/microcomponents/{microcomponent_id}")
public ResponseEntity<Boolean> remove(@PathVariable("microcomponent_id") String microcomponent_id) {
return ResponseEntity.status(HttpStatus.OK).body(microcomponentService.remove(microcomponent_id));
}
@PreAuthorize("hasPermission(this.microcomponentService.getMicrocomponentByIds(#ids),'DemoSys-MicroComponent-Remove')")
@ApiOperation(value = "批量删除微组件", tags = {"微组件" }, notes = "批量删除微组件")
@RequestMapping(method = RequestMethod.DELETE, value = "/microcomponents/batch")
public ResponseEntity<Boolean> removeBatch(@RequestBody List<String> ids) {
microcomponentService.removeBatch(ids);
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@PostAuthorize("hasPermission(this.microcomponentMapping.toDomain(returnObject.body),'DemoSys-MicroComponent-Get')")
@ApiOperation(value = "获取微组件", tags = {"微组件" }, notes = "获取微组件")
@RequestMapping(method = RequestMethod.GET, value = "/microcomponents/{microcomponent_id}")
public ResponseEntity<MicroComponentDTO> get(@PathVariable("microcomponent_id") String microcomponent_id) {
MicroComponent domain = microcomponentService.get(microcomponent_id);
MicroComponentDTO dto = microcomponentMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@ApiOperation(value = "获取微组件草稿", tags = {"微组件" }, notes = "获取微组件草稿")
@RequestMapping(method = RequestMethod.GET, value = "/microcomponents/getdraft")
public ResponseEntity<MicroComponentDTO> getDraft() {
return ResponseEntity.status(HttpStatus.OK).body(microcomponentMapping.toDto(microcomponentService.getDraft(new MicroComponent())));
}
@ApiOperation(value = "检查微组件", tags = {"微组件" }, notes = "检查微组件")
@RequestMapping(method = RequestMethod.POST, value = "/microcomponents/checkkey")
public ResponseEntity<Boolean> checkKey(@RequestBody MicroComponentDTO microcomponentdto) {
return ResponseEntity.status(HttpStatus.OK).body(microcomponentService.checkKey(microcomponentMapping.toDomain(microcomponentdto)));
}
@PreAuthorize("hasPermission(this.microcomponentMapping.toDomain(#microcomponentdto),'DemoSys-MicroComponent-Save')")
@ApiOperation(value = "保存微组件", tags = {"微组件" }, notes = "保存微组件")
@RequestMapping(method = RequestMethod.POST, value = "/microcomponents/save")
public ResponseEntity<Boolean> save(@RequestBody MicroComponentDTO microcomponentdto) {
return ResponseEntity.status(HttpStatus.OK).body(microcomponentService.save(microcomponentMapping.toDomain(microcomponentdto)));
}
@PreAuthorize("hasPermission(this.microcomponentMapping.toDomain(#microcomponentdtos),'DemoSys-MicroComponent-Save')")
@ApiOperation(value = "批量保存微组件", tags = {"微组件" }, notes = "批量保存微组件")
@RequestMapping(method = RequestMethod.POST, value = "/microcomponents/savebatch")
public ResponseEntity<Boolean> saveBatch(@RequestBody List<MicroComponentDTO> microcomponentdtos) {
microcomponentService.saveBatch(microcomponentMapping.toDomain(microcomponentdtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','DemoSys-MicroComponent-searchDefault-all') and hasPermission(#context,'DemoSys-MicroComponent-Get')")
@ApiOperation(value = "获取数据集", tags = {"微组件" } ,notes = "获取数据集")
@RequestMapping(method= RequestMethod.GET , value="/microcomponents/fetchdefault")
public ResponseEntity<List<MicroComponentDTO>> fetchDefault(MicroComponentSearchContext context) {
Page<MicroComponent> domains = microcomponentService.searchDefault(context) ;
List<MicroComponentDTO> list = microcomponentMapping.toDto(domains.getContent());
return ResponseEntity.status(HttpStatus.OK)
.header("x-page", String.valueOf(context.getPageable().getPageNumber()))
.header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
.header("x-total", String.valueOf(domains.getTotalElements()))
.body(list);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','DemoSys-MicroComponent-searchDefault-all') and hasPermission(#context,'DemoSys-MicroComponent-Get')")
@ApiOperation(value = "查询数据集", tags = {"微组件" } ,notes = "查询数据集")
@RequestMapping(method= RequestMethod.POST , value="/microcomponents/searchdefault")
public ResponseEntity<Page<MicroComponentDTO>> searchDefault(@RequestBody MicroComponentSearchContext context) {
Page<MicroComponent> domains = microcomponentService.searchDefault(context) ;
return ResponseEntity.status(HttpStatus.OK)
.body(new PageImpl(microcomponentMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
}
}
......@@ -87,7 +87,6 @@ public class PermissionSyncJob implements ApplicationRunner {
bpmnfiles.add(new HashMap<String,Object>(){{put("LPv1.bpmn",IOUtils.toString(this.getClass().getResourceAsStream("/workflow/LPv1.bpmn"),"UTF-8"));}});
bpmnfiles.add(new HashMap<String,Object>(){{put("ODSPMVv1.bpmn",IOUtils.toString(this.getClass().getResourceAsStream("/workflow/ODSPMVv1.bpmn"),"UTF-8"));}});
bpmnfiles.add(new HashMap<String,Object>(){{put("ODSPMVv2.bpmn",IOUtils.toString(this.getClass().getResourceAsStream("/workflow/ODSPMVv2.bpmn"),"UTF-8"));}});
bpmnfiles.add(new HashMap<String,Object>(){{put("ACTv1.bpmn",IOUtils.toString(this.getClass().getResourceAsStream("/workflow/ACTv1.bpmn"),"UTF-8"));}});
bpmnfiles.add(new HashMap<String,Object>(){{put("SNv1.bpmn",IOUtils.toString(this.getClass().getResourceAsStream("/workflow/SNv1.bpmn"),"UTF-8"));}});
bpmnfiles.add(new HashMap<String,Object>(){{put("MNv1.bpmn",IOUtils.toString(this.getClass().getResourceAsStream("/workflow/MNv1.bpmn"),"UTF-8"));}});
bpmnfiles.add(new HashMap<String,Object>(){{put("ODSPv1.bpmn",IOUtils.toString(this.getClass().getResourceAsStream("/workflow/ODSPv1.bpmn"),"UTF-8"));}});
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册