Commit 8dcbd4f3 authored by YuCheng Hu's avatar YuCheng Hu

Update Spring Boot File

parent ef06bf90
Pipeline #51 failed with stages
......@@ -3,25 +3,17 @@ sudo: required
language: java
jdk:
- openjdk8
- oraclejdk8
- oraclejdk11
- openjdk11
- openjdk12
cache:
directories:
- $HOME/.m2
- $HOME/.sonar/cache
addons:
firefox: latest
install: true
script:
- |
if [ "$TRAVIS_BRANCH" != "master" -o "$TRAVIS_PULL_REQUEST" == "true" ]; then
./mvnw -U verify jacoco:report coveralls:report
fi
- |
if [ "$TRAVIS_PULL_REQUEST" == "false" -a "$TRAVIS_BRANCH" == "master" ]; then
./mvnw -U verify jacoco:report coveralls:report sonar:sonar -Dsonar.host.url=https://sonarqube.com -Dsonar.login=${SONAR_TOKEN}
fi
- mvn -U package jacoco:report coveralls:report
cache:
directories:
- $HOME/.m2
- $HOME/.sonar/cache
This diff is collapsed.
/*
* Copyright 2016-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ossez.spring.boot.jpetstore.mapper
import com.ossez.spring.boot.jpetstore.domain.Account
import org.apache.ibatis.annotations.CacheNamespace
import org.apache.ibatis.annotations.Insert
import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Select
import org.apache.ibatis.annotations.Update
/**
* @author Kazuki Shimizu
*/
@Mapper
@CacheNamespace
interface AccountMapper {
@Select('''
SELECT
SIGNON.USERNAME,
SIGNON.PASSWORD,
ACCOUNT.EMAIL,
ACCOUNT.FIRSTNAME,
ACCOUNT.LASTNAME,
ACCOUNT.STATUS,
ACCOUNT.ADDR1 AS address1,
ACCOUNT.ADDR2 AS address2,
ACCOUNT.CITY,
ACCOUNT.STATE,
ACCOUNT.ZIP,
ACCOUNT.COUNTRY,
ACCOUNT.PHONE,
PROFILE.LANGPREF AS languagePreference,
PROFILE.FAVCATEGORY AS favouriteCategoryId,
PROFILE.MYLISTOPT AS listOption,
PROFILE.BANNEROPT AS bannerOption,
BANNERDATA.BANNERNAME
FROM
ACCOUNT, PROFILE, SIGNON, BANNERDATA
WHERE
ACCOUNT.USERID = #{username}
AND SIGNON.USERNAME = ACCOUNT.USERID
AND PROFILE.USERID = ACCOUNT.USERID
AND PROFILE.FAVCATEGORY = BANNERDATA.FAVCATEGORY
''')
Account getAccountByUsername(String username)
@Insert('''
INSERT INTO ACCOUNT (
EMAIL,
FIRSTNAME,
LASTNAME,
STATUS,
ADDR1,
ADDR2,
CITY,
STATE,
ZIP,
COUNTRY,
PHONE,
USERID
)
VALUES (
#{email},
#{firstName},
#{lastName},
#{status},
#{address1},
#{address2},
#{city},
#{state},
#{zip},
#{country},
#{phone},
#{username}
)
''')
void insertAccount(Account account)
@Insert('''
INSERT INTO PROFILE (
LANGPREF,
FAVCATEGORY,
MYLISTOPT,
BANNEROPT,
USERID
)
VALUES (
#{languagePreference},
#{favouriteCategoryId},
#{listOption},
#{bannerOption},
#{username}
)
''')
void insertProfile(Account account)
@Insert('''
INSERT INTO SIGNON (
PASSWORD,
USERNAME
)
VALUES (
#{password},
#{username}
)
''')
void insertSignon(Account account)
@Update('''
UPDATE ACCOUNT SET
EMAIL = #{email},
FIRSTNAME = #{firstName},
LASTNAME = #{lastName},
STATUS = #{status},
ADDR1 = #{address1},
ADDR2 = #{address2},
CITY = #{city},
STATE = #{state},
ZIP = #{zip},
COUNTRY = #{country},
PHONE = #{phone}
WHERE
USERID = #{username}
''')
void updateAccount(Account account)
@Update('''
UPDATE PROFILE SET
LANGPREF = #{languagePreference},
FAVCATEGORY = #{favouriteCategoryId},
MYLISTOPT = #{listOption},
BANNEROPT = #{bannerOption}
WHERE
USERID = #{username}
''')
void updateProfile(Account account)
@Update('''
UPDATE SIGNON SET
PASSWORD = #{password}
WHERE
USERNAME = #{username}
''')
void updateSignon(Account account)
}
/*
* Copyright 2016-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ossez.spring.boot.jpetstore.mapper
import com.ossez.spring.boot.jpetstore.domain.Category
import org.apache.ibatis.annotations.CacheNamespace
import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Select
/**
* @author Kazuki Shimizu
*/
@Mapper
@CacheNamespace
interface CategoryMapper {
@Select('''
SELECT
CATID AS categoryId,
NAME,
DESCN AS description
FROM
CATEGORY
WHERE
CATID = #{categoryId}
''')
Category getCategory(String categoryId)
}
/*
* Copyright 2016-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ossez.spring.boot.jpetstore.mapper
import com.ossez.spring.boot.jpetstore.domain.Item
import org.apache.ibatis.annotations.CacheNamespace
import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Param
import org.apache.ibatis.annotations.Select
import org.apache.ibatis.annotations.Update
/**
* @author Kazuki Shimizu
*/
@Mapper
@CacheNamespace
interface ItemMapper {
@Update('''
UPDATE INVENTORY SET
QTY = QTY - #{increment}
WHERE
ITEMID = #{itemId}
''')
void updateInventoryQuantity(@Param("itemId") String itemId, @Param("increment") int increment)
@Select('''
SELECT
QTY AS value
FROM
INVENTORY
WHERE
ITEMID = #{itemId}
''')
int getInventoryQuantity(String itemId)
@Select('''
SELECT
I.ITEMID,
LISTPRICE,
UNITCOST,
SUPPLIER AS supplierId,
I.PRODUCTID AS "product.productId",
NAME AS "product.name",
DESCN AS "product.description",
CATEGORY AS "product.categoryId",
STATUS,
ATTR1 AS attribute1,
ATTR2 AS attribute2,
ATTR3 AS attribute3,
ATTR4 AS attribute4,
ATTR5 AS attribute5
FROM
ITEM I, PRODUCT P
WHERE
P.PRODUCTID = I.PRODUCTID
AND I.PRODUCTID = #{productId}
''')
List<Item> getItemListByProduct(String productId)
@Select('''
SELECT
I.ITEMID,
LISTPRICE,
UNITCOST,
SUPPLIER AS supplierId,
I.PRODUCTID AS "product.productId",
NAME AS "product.name",
DESCN AS "product.description",
CATEGORY AS "product.categoryId",
STATUS,
ATTR1 AS attribute1,
ATTR2 AS attribute2,
ATTR3 AS attribute3,
ATTR4 AS attribute4,
ATTR5 AS attribute5,
QTY AS quantity
FROM
ITEM I,
INVENTORY V,
PRODUCT P
WHERE
P.PRODUCTID = I.PRODUCTID
AND I.ITEMID = V.ITEMID
AND I.ITEMID = #{itemId}
''')
Item getItem(String itemId)
}
/*
* Copyright 2016-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ossez.spring.boot.jpetstore.mapper
import com.ossez.spring.boot.jpetstore.domain.Order
import com.ossez.spring.boot.jpetstore.domain.OrderLine
import org.apache.ibatis.annotations.CacheNamespace
import org.apache.ibatis.annotations.Insert
import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Select
/**
* @author Kazuki Shimizu
*/
@Mapper
@CacheNamespace
interface OrderMapper {
@Select('''
SELECT
BILLADDR1 AS billAddress1,
BILLADDR2 AS billAddress2,
BILLCITY,
BILLCOUNTRY,
BILLSTATE,
BILLTOFIRSTNAME,
BILLTOLASTNAME,
BILLZIP,
SHIPADDR1 AS shipAddress1,
SHIPADDR2 AS shipAddress2,
SHIPCITY,
SHIPCOUNTRY,
SHIPSTATE,
SHIPTOFIRSTNAME,
SHIPTOLASTNAME,
SHIPZIP,
CARDTYPE,
COURIER,
CREDITCARD,
EXPRDATE AS expiryDate,
LOCALE,
ORDERDATE,
ORDERS.ORDERID,
TOTALPRICE,
USERID AS username,
STATUS
FROM
ORDERS,
ORDERSTATUS
WHERE
ORDERS.USERID = #{username}
AND ORDERS.ORDERID = ORDERSTATUS.ORDERID
ORDER BY
ORDERDATE
''')
List<Order> getOrdersByUsername(String username)
@Select('''
SELECT
BILLADDR1 AS billAddress1,
BILLADDR2 AS billAddress2,
BILLCITY,
BILLCOUNTRY,
BILLSTATE,
BILLTOFIRSTNAME,
BILLTOLASTNAME,
BILLZIP,
SHIPADDR1 AS shipAddress1,
SHIPADDR2 AS shipAddress2,
SHIPCITY,
SHIPCOUNTRY,
SHIPSTATE,
SHIPTOFIRSTNAME,
SHIPTOLASTNAME,
SHIPZIP,
CARDTYPE,
COURIER,
CREDITCARD,
EXPRDATE AS expiryDate,
LOCALE,
ORDERDATE,
ORDERS.ORDERID,
TOTALPRICE,
USERID AS username,
STATUS
FROM
ORDERS, ORDERSTATUS
WHERE
ORDERS.ORDERID = #{orderId}
AND ORDERS.ORDERID = ORDERSTATUS.ORDERID
''')
Order getOrder(int orderId)
@Insert('''
INSERT INTO ORDERS (
ORDERID,
USERID,
ORDERDATE,
SHIPADDR1,
SHIPADDR2,
SHIPCITY,
SHIPSTATE,
SHIPZIP,
SHIPCOUNTRY,
BILLADDR1,
BILLADDR2,
BILLCITY,
BILLSTATE,
BILLZIP,
BILLCOUNTRY,
COURIER,
TOTALPRICE,
BILLTOFIRSTNAME,
BILLTOLASTNAME,
SHIPTOFIRSTNAME,
SHIPTOLASTNAME,
CREDITCARD,
EXPRDATE,
CARDTYPE,
LOCALE
)
VALUES(
#{orderId},
#{username},
#{orderDate},
#{shipAddress1},
#{shipAddress2},
#{shipCity},
#{shipState},
#{shipZip},
#{shipCountry},
#{billAddress1},
#{billAddress2},
#{billCity},
#{billState},
#{billZip},
#{billCountry},
#{courier},
#{totalPrice},
#{billToFirstName},
#{billToLastName},
#{shipToFirstName},
#{shipToLastName},
#{creditCard},
#{expiryDate},
#{cardType},
#{locale}
)
''')
void insertOrder(Order order)
@Insert('''<script>
<bind name="lineNum" value="_parameter.getLines().size()" />
INSERT INTO ORDERSTATUS (
ORDERID,
LINENUM,
TIMESTAMP,
STATUS
)
VALUES (
#{orderId},
#{lineNum},
#{orderDate},
#{status}
)
</script>''')
void insertOrderStatus(Order order)
@Select('''
SELECT
ORDERID,
LINENUM AS lineNumber,
ITEMID,
QUANTITY,
UNITPRICE
FROM
ORDERLINES
WHERE
ORDERID = #{orderId}
''')
List<OrderLine> getOrderLines(int orderId)
@Insert('''
INSERT INTO ORDERLINES (
ORDERID,
LINENUM,
ITEMID,
QUANTITY,
UNITPRICE
)
VALUES (
#{orderId},
#{lineNumber},
#{itemId},
#{quantity},
#{unitPrice}
)
''')
void insertOrderLine(OrderLine orderLine)
}
/*
* Copyright 2016-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ossez.spring.boot.jpetstore.mapper
import com.ossez.spring.boot.jpetstore.domain.Product
import org.apache.ibatis.annotations.CacheNamespace
import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Select
/**
* @author Kazuki Shimizu
*/
@Mapper
@CacheNamespace
interface ProductMapper {
@Select('''
SELECT
PRODUCTID,
NAME,
DESCN as description,
CATEGORY as categoryId
FROM
PRODUCT
WHERE
CATEGORY = #{categoryId}
''')
List<Product> getProductListByCategory(String categoryId);
@Select('''
SELECT
PRODUCTID,
NAME,
DESCN as description,
CATEGORY as categoryId
FROM
PRODUCT
WHERE
PRODUCTID = #{productId}
''')
Product getProduct(String productId);
@Select('''
SELECT
PRODUCTID,
NAME,
DESCN as description,
CATEGORY as categoryId
FROM
PRODUCT
WHERE
LOWER(NAME) LIKE '%' || #{keyword} || '%'
''')
List<Product> selectProductList(String keyword);
}
/*
* Copyright 2016-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ossez.spring.boot.jpetstore.mapper
import com.ossez.spring.boot.jpetstore.domain.Sequence
import org.apache.ibatis.annotations.CacheNamespace
import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Select
import org.apache.ibatis.annotations.Update
/**
* @author Kazuki Shimizu
*/
@Mapper
@CacheNamespace
interface SequenceMapper {
@Select('''
SELECT
NAME,
NEXTID
FROM
SEQUENCE
WHERE
NAME = #{name}
FOR UPDATE
''')
Sequence getSequence(String name);
@Update('''
UPDATE SEQUENCE SET
NEXTID = NEXTID + 1
WHERE
NAME = #{name}
''')
void incrementSequence(String name);
}
/*
* Copyright 2016-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*