diff --git a/meapi/src/main/java/com/foreverwin/mesnac/meapi/controller/NcCodeController.java b/meapi/src/main/java/com/foreverwin/mesnac/meapi/controller/NcCodeController.java new file mode 100644 index 00000000..5a798fe5 --- /dev/null +++ b/meapi/src/main/java/com/foreverwin/mesnac/meapi/controller/NcCodeController.java @@ -0,0 +1,123 @@ +package com.foreverwin.mesnac.meapi.controller; + +import com.foreverwin.modular.core.util.R; +import com.foreverwin.modular.core.util.FrontPage; +import com.foreverwin.modular.core.util.CommonMethods; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import com.foreverwin.mesnac.meapi.service.NcCodeService; +import com.foreverwin.mesnac.meapi.model.NcCode; +import java.util.List; + +/** + * + * @author robert + * @since 2021-06-23 + */ +@RestController +@RequestMapping("/NC-CODE") +public class NcCodeController { + + @Autowired + public NcCodeService ncCodeService; + + /** + * 根据id查询 + * + * @param id 主键 + * @return + */ + @ResponseBody + @GetMapping("/{id:.+}") + public R getNcCodeById(@PathVariable String id) { + return R.ok( ncCodeService.getById(id)); + } + + /** + * 查询所有数据 + * + * @return + */ + @ResponseBody + @GetMapping("") + public R getNcCodeList(NcCode ncCode){ + List result; + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.setEntity(ncCode); + result = ncCodeService.list(queryWrapper); + return R.ok(result); + } + + /** + * 分页查询数据 + * + * @param frontPage 分页信息 + * @return + */ + @ResponseBody + @GetMapping("/page") + public R page(FrontPage frontPage, NcCode ncCode){ + IPage result; + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.setEntity(ncCode); + if (frontPage.getGlobalQuery() != null && !"".equals(frontPage.getGlobalQuery().trim())) { + //TODO modify global query + queryWrapper.lambda().and(wrapper -> wrapper + .like(NcCode::getHandle, frontPage.getGlobalQuery()) + .or().like(NcCode::getSite, frontPage.getGlobalQuery()) + .or().like(NcCode::getNcCode, frontPage.getGlobalQuery()) + .or().like(NcCode::getStatusBo, frontPage.getGlobalQuery()) + .or().like(NcCode::getNcCategory, frontPage.getGlobalQuery()) + .or().like(NcCode::getDpmoCategoryBo, frontPage.getGlobalQuery()) + ); + } + result = ncCodeService.page(frontPage.getPagePlus(), queryWrapper); + return R.ok(result); + } + + /** + * 新增 + * @param ncCode 传递的实体 + * @return null 失败 实体成功 + */ + @PostMapping + public R save(@RequestBody NcCode ncCode) { + return R.ok(ncCodeService.save(ncCode)); + } + + /** + * 修改 + * @param ncCode 传递的实体 + * @return null 失败 实体成功 + */ + @PutMapping + public R updateById(@RequestBody NcCode ncCode) { + return R.ok(ncCodeService.updateById(ncCode)); + } + + /** + * 根据id删除对象 + * @param id 实体ID + * @return 0 失败 1 成功 + */ + @ResponseBody + @RequestMapping(method = RequestMethod.DELETE, value = "/{id:.+}") + public R removeById(@PathVariable("id") String id){ + return R.ok(ncCodeService.removeById(id)); + } + + /** + * 批量删除对象 + * @param ids 实体集合ID + * @return 0 失败 1 成功 + */ + @ResponseBody + @RequestMapping(method = RequestMethod.POST, value = "/delete-batch") + public R removeByIds(List ids){ + return R.ok(ncCodeService.removeByIds(ids)); + } +} \ No newline at end of file diff --git a/meapi/src/main/java/com/foreverwin/mesnac/meapi/mapper/NcCodeMapper.java b/meapi/src/main/java/com/foreverwin/mesnac/meapi/mapper/NcCodeMapper.java new file mode 100644 index 00000000..da99fd70 --- /dev/null +++ b/meapi/src/main/java/com/foreverwin/mesnac/meapi/mapper/NcCodeMapper.java @@ -0,0 +1,18 @@ +package com.foreverwin.mesnac.meapi.mapper; + +import com.foreverwin.mesnac.meapi.model.NcCode; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springframework.stereotype.Repository; + +/** + *

+ * Mapper 接口 + *

+ * + * @author robert + * @since 2021-06-23 + */ +@Repository +public interface NcCodeMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/meapi/src/main/java/com/foreverwin/mesnac/meapi/model/NcCode.java b/meapi/src/main/java/com/foreverwin/mesnac/meapi/model/NcCode.java new file mode 100644 index 00000000..a7bd3a9b --- /dev/null +++ b/meapi/src/main/java/com/foreverwin/mesnac/meapi/model/NcCode.java @@ -0,0 +1,155 @@ +package com.foreverwin.mesnac.meapi.model; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + *

+ * + *

+ * + * @author robert + * @since 2021-06-23 + */ + +@TableName("NC_CODE") + +public class NcCode extends Model { + + private static final long serialVersionUID = 1L; + + @TableField("HANDLE") + private String handle; + @TableField("CHANGE_STAMP") + private Long changeStamp; + @TableField("SITE") + private String site; + @TableField("NC_CODE") + private String ncCode; + @TableField("STATUS_BO") + private String statusBo; + @TableField("CREATED_DATE_TIME") + private LocalDateTime createdDateTime; + @TableField("MODIFIED_DATE_TIME") + private LocalDateTime modifiedDateTime; + @TableField("NC_CATEGORY") + private String ncCategory; + @TableField("DPMO_CATEGORY_BO") + private String dpmoCategoryBo; + + + public String getHandle() { + return handle; + } + + public void setHandle(String handle) { + this.handle = handle; + } + + public Long getChangeStamp() { + return changeStamp; + } + + public void setChangeStamp(Long changeStamp) { + this.changeStamp = changeStamp; + } + + public String getSite() { + return site; + } + + public void setSite(String site) { + this.site = site; + } + + public String getNcCode() { + return ncCode; + } + + public void setNcCode(String ncCode) { + this.ncCode = ncCode; + } + + public String getStatusBo() { + return statusBo; + } + + public void setStatusBo(String statusBo) { + this.statusBo = statusBo; + } + + public LocalDateTime getCreatedDateTime() { + return createdDateTime; + } + + public void setCreatedDateTime(LocalDateTime createdDateTime) { + this.createdDateTime = createdDateTime; + } + + public LocalDateTime getModifiedDateTime() { + return modifiedDateTime; + } + + public void setModifiedDateTime(LocalDateTime modifiedDateTime) { + this.modifiedDateTime = modifiedDateTime; + } + + public String getNcCategory() { + return ncCategory; + } + + public void setNcCategory(String ncCategory) { + this.ncCategory = ncCategory; + } + + public String getDpmoCategoryBo() { + return dpmoCategoryBo; + } + + public void setDpmoCategoryBo(String dpmoCategoryBo) { + this.dpmoCategoryBo = dpmoCategoryBo; + } + +public static final String HANDLE = "HANDLE"; + +public static final String CHANGE_STAMP = "CHANGE_STAMP"; + +public static final String SITE = "SITE"; + +public static final String NC_CODE = "NC_CODE"; + +public static final String STATUS_BO = "STATUS_BO"; + +public static final String CREATED_DATE_TIME = "CREATED_DATE_TIME"; + +public static final String MODIFIED_DATE_TIME = "MODIFIED_DATE_TIME"; + +public static final String NC_CATEGORY = "NC_CATEGORY"; + +public static final String DPMO_CATEGORY_BO = "DPMO_CATEGORY_BO"; + + + @Override + protected Serializable pkVal() { + return this.handle; + } + + @Override + public String toString() { + return "NcCode{" + + "handle = " + handle + + ", changeStamp = " + changeStamp + + ", site = " + site + + ", ncCode = " + ncCode + + ", statusBo = " + statusBo + + ", createdDateTime = " + createdDateTime + + ", modifiedDateTime = " + modifiedDateTime + + ", ncCategory = " + ncCategory + + ", dpmoCategoryBo = " + dpmoCategoryBo + + "}"; + } +} \ No newline at end of file diff --git a/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/NcCodeService.java b/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/NcCodeService.java new file mode 100644 index 00000000..ca6c319e --- /dev/null +++ b/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/NcCodeService.java @@ -0,0 +1,28 @@ +package com.foreverwin.mesnac.meapi.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.foreverwin.mesnac.meapi.model.NcCode; +import com.baomidou.mybatisplus.extension.service.IService; +import com.foreverwin.modular.core.util.FrontPage; + +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author robert + * @since 2021-06-23 + */ +public interface NcCodeService extends IService { + + /** + * 分页查询 + * @param frontPage + * @return + */ + IPage selectPage(FrontPage frontPage, NcCode ncCode); + + List selectList(NcCode ncCode); +} \ No newline at end of file diff --git a/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/impl/NcCodeServiceImpl.java b/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/impl/NcCodeServiceImpl.java new file mode 100644 index 00000000..d7dcb67d --- /dev/null +++ b/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/impl/NcCodeServiceImpl.java @@ -0,0 +1,46 @@ +package com.foreverwin.mesnac.meapi.service.impl; + +import com.foreverwin.modular.core.util.FrontPage; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.foreverwin.mesnac.meapi.model.NcCode; +import com.foreverwin.mesnac.meapi.mapper.NcCodeMapper; +import com.foreverwin.mesnac.meapi.service.NcCodeService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +/** + *

+ * 服务实现类 + *

+ * + * @author robert + * @since 2021-06-23 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class NcCodeServiceImpl extends ServiceImpl implements NcCodeService { + + + @Autowired + private NcCodeMapper ncCodeMapper; + + @Override + public IPage selectPage(FrontPage frontPage, NcCode ncCode) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.setEntity(ncCode); + return super.page(frontPage.getPagePlus(), queryWrapper); + } + + @Override + public List selectList(NcCode ncCode) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.setEntity(ncCode); + return super.list(queryWrapper); + } + + +} \ No newline at end of file diff --git a/meapi/src/main/resources/mapper/NcCodeMapper.xml b/meapi/src/main/resources/mapper/NcCodeMapper.xml new file mode 100644 index 00000000..0da959c7 --- /dev/null +++ b/meapi/src/main/resources/mapper/NcCodeMapper.xml @@ -0,0 +1,346 @@ + + + + + + + + + + + + + + + + + + + + HANDLE, CHANGE_STAMP, SITE, NC_CODE, STATUS_BO, CREATED_DATE_TIME, MODIFIED_DATE_TIME, NC_CATEGORY, DPMO_CATEGORY_BO + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO NC_CODE + + HANDLE, + CHANGE_STAMP, + SITE, + NC_CODE, + STATUS_BO, + CREATED_DATE_TIME, + MODIFIED_DATE_TIME, + NC_CATEGORY, + DPMO_CATEGORY_BO, + VALUES + + #{handle}, + #{changeStamp}, + #{site}, + #{ncCode}, + #{statusBo}, + #{createdDateTime}, + #{modifiedDateTime}, + #{ncCategory}, + #{dpmoCategoryBo}, + + + + + INSERT INTO NC_CODE + + + VALUES + + #{handle}, + #{changeStamp}, + #{site}, + #{ncCode}, + #{statusBo}, + #{createdDateTime}, + #{modifiedDateTime}, + #{ncCategory}, + #{dpmoCategoryBo}, + + + + + + + + + + UPDATE NC_CODE + HANDLE=#{et.handle}, + CHANGE_STAMP=#{et.changeStamp}, + SITE=#{et.site}, + NC_CODE=#{et.ncCode}, + STATUS_BO=#{et.statusBo}, + CREATED_DATE_TIME=#{et.createdDateTime}, + MODIFIED_DATE_TIME=#{et.modifiedDateTime}, + NC_CATEGORY=#{et.ncCategory}, + DPMO_CATEGORY_BO=#{et.dpmoCategoryBo}, + + + + + HANDLE=#{ew.entity.handle} + AND CHANGE_STAMP=#{ew.entity.changeStamp} + AND SITE=#{ew.entity.site} + AND NC_CODE=#{ew.entity.ncCode} + AND STATUS_BO=#{ew.entity.statusBo} + AND CREATED_DATE_TIME=#{ew.entity.createdDateTime} + AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime} + AND NC_CATEGORY=#{ew.entity.ncCategory} + AND DPMO_CATEGORY_BO=#{ew.entity.dpmoCategoryBo} + + + ${ew.sqlSegment} + + + + + ${ew.sqlSegment} + + + + + + DELETE FROM NC_CODE + + + + + ${k} = #{cm[${k}]} + + + + + + + + DELETE FROM NC_CODE + + + + + HANDLE=#{ew.entity.handle} + + AND CHANGE_STAMP=#{ew.entity.changeStamp} + AND SITE=#{ew.entity.site} + AND NC_CODE=#{ew.entity.ncCode} + AND STATUS_BO=#{ew.entity.statusBo} + AND CREATED_DATE_TIME=#{ew.entity.createdDateTime} + AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime} + AND NC_CATEGORY=#{ew.entity.ncCategory} + AND DPMO_CATEGORY_BO=#{ew.entity.dpmoCategoryBo} + + + ${ew.sqlSegment} + + + + + ${ew.sqlSegment} + + + + + +