본문 바로가기

엉터리 개발 이야기/개인프로젝트

소스 예제

반응형
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<link rel='stylesheet' href='/stylesheets/style.css' />
<% include ./partials/head %>
</head>
<body>
<% include ./partials/nav %>

<div class="container-fluid">
<div class="row">
<div class="col-lg-2">
<h3 class="mt-lg-5">목록</h3>
<h3 class="mt-lg-5"><a href="/partner/addPartner">입력</a></h3>
</div>
<div class="col-lg-10">
<h3 class="mt-lg-5">제휴사 정보</h3>
<div class="row">
<div class="col-lg-10">
<div class="row">
<div class="col-lg-3">
<p>주문번호</p>
</div>
<div class="col-lg-3">
<p>제휴사</p>
</div>
<div class="col-lg-4">
<p>발주기간</p>
</div>
</div>
<div class="row">
<div class="col-lg-3">
<input type="text"/>
</div>
<div class="col-lg-3">
<input type="text"/>
</div>
<div class="col-lg-4">
<input type="text"/>
~
<input type="text"/>
</div>
</div>
</div>
<div class="col-lg-2">
<button type="button" class="btn btn-primary">Search</button>
</div>
</div>
</div>
</div>
</div>

</body>

<script>
function uploadBtn() {

}

function clickBtn() {
alert('분석');
}
</script>

</html>


<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<link rel='stylesheet' href='/stylesheets/style.css' />
<% include ./partials/head %>
</head>
<body>
<% include ./partials/nav %>

<div class="container-fluid">
<div class="row">
<div class="col-lg-2">
<h3 class="mt-lg-5">목록</h3>
<h3 class="mt-lg-5"><a href="/partner/addPartner">입력</a></h3>
</div>
<div class="col-lg-10">
<h3 class="mt-lg-5">제휴사 정보 입력</h3>
<div class="row">
<form action="/partner/create" method="post">
<div class="form-group">
<label>제휴사명</label>
<input type="text" name="partner_name" class="form-control" />
</div>
<div class="form-group">
<label>제휴사 코드</label>
<input type="text" name="partner_code" class="form-control" />
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
</div>
</div>

</body>

<script>
function uploadBtn() {

}

function clickBtn() {
alert('분석');
}
</script>

</html>


<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="/">Hair Boss</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav mr-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">정산</a>
<div class="dropdown-menu" aria-labelledby="dropdown01">
<a class="dropdown-item" href="/order">원주문</a>
<a class="dropdown-item" href="#">제휴사 주문</a>
<a class="dropdown-item" href="#">정산하기</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="dropdown02" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">관리</a>
<div class="dropdown-menu" aria-labelledby="dropdown02">
<a class="dropdown-item" href="/partner">제휴사 정보</a>
<a class="dropdown-item" href="#">원주문 열 정보</a>
<a class="dropdown-item" href="#">제휴사 열 정보</a>
<a class="dropdown-item" href="#">상품 정보</a>
</div>
</li>
</ul>
<!--
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
-->
</div>
</nav>


const sequelize = require('../dbconn');
const Sequelize = require('sequelize');

const Partner = sequelize.define('partner', {
id: {
type: Sequelize.DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},

name: {
type: Sequelize.DataTypes.STRING,
unique: 'compositeIndex'
},

code: {
type: Sequelize.DataTypes.STRING,
unique: 'compositeIndex'
},

createdAt: Sequelize.DataTypes.DATE,
updatedAt: Sequelize.DataTypes.DATE,
});


Partner.sync({force: false}).then(() => {
});


module.exports = Partner;


var express = require('express');
var router = express.Router();
const Partner = require('../model/partner');

/* GET users listing. */
router.get('/', function(req, res, next) {
res.render('partner', { title: 'Partner Information' });
});

router.get('/addPartner', function(req, res, next) {
res.render('addPartner', { title: 'Partner Information' });
});

router.post('/create', function(req, res, next) {

console.log(req.body);
const partner_name = req.body.partner_name;
const partner_code = req.body.partner_code;

const partner_info = {
name : partner_name,
code : partner_code
};

Partner.create(
partner_info
).then((result) => {
console.log(result);
res.render('partner', {title: 'New'});
});

});

module.exports = router;


반응형

'엉터리 개발 이야기 > 개인프로젝트' 카테고리의 다른 글

참고코드 - routes  (0) 2018.11.28
참고 코드 - app.js  (0) 2018.11.28
참고 코드 - 모델  (0) 2018.11.28
VS Code Node 디버깅  (0) 2018.11.27
[털사장 프로젝트] 모델링  (0) 2018.11.26