Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
B
BasicAPI
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杜科
BasicAPI
Commits
b9cc5ffb
Commit
b9cc5ffb
authored
Dec 19, 2022
by
杜科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
fc3b9416
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
116 additions
and
0 deletions
+116
-0
DemoUtil.java
src/com/yonde/common/DemoUtil.java
+68
-0
DemoController.java
src/com/yonde/part/controller/DemoController.java
+16
-0
DemoService.java
src/com/yonde/part/service/impl/DemoService.java
+32
-0
No files found.
src/com/yonde/common/DemoUtil.java
0 → 100644
View file @
b9cc5ffb
package
com
.
yonde
.
common
;
import
wt.fc.PersistenceHelper
;
import
wt.fc.QueryResult
;
import
wt.method.RemoteAccess
;
import
wt.method.RemoteMethodServer
;
import
wt.part.WTPart
;
import
wt.query.QuerySpec
;
import
wt.query.SearchCondition
;
import
wt.session.SessionServerHelper
;
import
wt.util.WTException
;
import
wt.vc.views.View
;
import
wt.vc.views.ViewHelper
;
import
wt.vc.views.ViewReference
;
import
java.lang.reflect.InvocationTargetException
;
import
java.rmi.RemoteException
;
public
class
DemoUtil
implements
RemoteAccess
{
public
static
WTPart
getPartByNumberAndView
(
String
number
,
String
viewStr
,
boolean
accessControlled
)
throws
WTException
{
WTPart
part
=
null
;
try
{
number
=
number
.
toUpperCase
();
if
(!
RemoteMethodServer
.
ServerFlag
)
{
return
(
WTPart
)
RemoteMethodServer
.
getDefault
().
invoke
(
"getPartByNumberAndView"
,
DemoUtil
.
class
.
getName
(),
null
,
new
Class
[]{
String
.
class
,
String
.
class
,
boolean
.
class
},
new
Object
[]{
number
,
viewStr
,
accessControlled
});
}
else
{
boolean
enforce
=
SessionServerHelper
.
manager
.
setAccessEnforced
(
accessControlled
);
try
{
QuerySpec
querySpec
=
new
QuerySpec
(
WTPart
.
class
);
SearchCondition
searchCondition
=
new
SearchCondition
(
WTPart
.
class
,
WTPart
.
NUMBER
,
SearchCondition
.
LIKE
,
number
.
toUpperCase
(),
false
);
querySpec
.
appendWhere
(
searchCondition
,
new
int
[]{
0
});
querySpec
.
appendAnd
();
querySpec
.
appendWhere
(
new
SearchCondition
(
WTPart
.
class
,
WTPart
.
LATEST_ITERATION
,
SearchCondition
.
IS_TRUE
),
new
int
[]{
0
});
querySpec
.
appendAnd
();
querySpec
.
appendOpenParen
();
View
view
=
ViewHelper
.
service
.
getView
(
viewStr
);
querySpec
.
appendWhere
(
new
SearchCondition
(
WTPart
.
class
,
WTPart
.
VIEW
+
"."
+
ViewReference
.
KEY
,
SearchCondition
.
EQUAL
,
PersistenceHelper
.
getObjectIdentifier
(
view
)),
new
int
[]{
0
});
querySpec
.
appendOr
();
querySpec
.
appendWhere
(
new
SearchCondition
(
WTPart
.
class
,
WTPart
.
VIEW
,
true
),
new
int
[]{
0
});
querySpec
.
appendCloseParen
();
QueryResult
queryResult
=
PersistenceHelper
.
manager
.
find
(
querySpec
);
if
(
queryResult
.
hasMoreElements
())
{
part
=
(
WTPart
)
queryResult
.
nextElement
();
}
if
(
part
!=
null
){
System
.
out
.
println
(
"--------Part info-----"
);
System
.
out
.
println
(
"----partNumber-----"
+
part
.
getNumber
());
System
.
out
.
println
(
"----creatorName-----"
+
part
.
getCreatorName
());
System
.
out
.
println
(
"----------------------"
);
}
}
finally
{
SessionServerHelper
.
manager
.
setAccessEnforced
(
enforce
);
}
}
}
catch
(
RemoteException
e
)
{
e
.
printStackTrace
();
}
catch
(
InvocationTargetException
e
)
{
e
.
printStackTrace
();
}
return
part
;
}
}
src/com/yonde/part/controller/DemoController.java
0 → 100644
View file @
b9cc5ffb
package
com
.
yonde
.
part
.
controller
;
import
com.yonde.part.service.impl.DemoService
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
value
=
"/demo"
)
public
class
DemoController
{
@GetMapping
(
value
=
"/part"
)
public
void
getPartByNumber
(
@RequestParam
String
number
,
@RequestParam
String
view
)
throws
Exception
{
DemoService
.
getPartByNumber
(
number
,
view
);
}
}
src/com/yonde/part/service/impl/DemoService.java
0 → 100644
View file @
b9cc5ffb
package
com
.
yonde
.
part
.
service
.
impl
;
import
com.yonde.common.DemoUtil
;
import
com.yonde.common.PartUtil
;
import
org.springframework.stereotype.Service
;
import
wt.method.RemoteAccess
;
import
wt.method.RemoteMethodServer
;
import
wt.part.WTPart
;
import
wt.util.WTException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.rmi.RemoteException
;
@Service
public
class
DemoService
{
public
static
void
getPartByNumber
(
String
number
,
String
view
)
throws
InvocationTargetException
,
RemoteException
,
WTException
{
boolean
accessControlled
=
false
;
WTPart
part
=
DemoUtil
.
getPartByNumberAndView
(
number
,
view
,
accessControlled
);
System
.
out
.
println
(
"--------2Part info2-----"
);
System
.
out
.
println
(
"----partNumber2-----"
+
part
.
getNumber
());
System
.
out
.
println
(
"----creatorName2-----"
+
part
.
getCreatorName
());
System
.
out
.
println
(
"-----------2-----------"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment