|
@@ -0,0 +1,121 @@
|
|
|
+package com.ruoyi.web.controller.api;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Arrays;
|
|
|
+
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import com.ruoyi.common.annotation.Log;
|
|
|
+import com.ruoyi.common.core.controller.BaseController;
|
|
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
+import com.ruoyi.common.enums.BusinessType;
|
|
|
+import com.ruoyi.app.domain.TbFamily;
|
|
|
+import com.ruoyi.app.service.ITbFamilyService;
|
|
|
+import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
+import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 家族Controller
|
|
|
+ *
|
|
|
+ * @author Alex
|
|
|
+ * @date 2020-09-28
|
|
|
+ */
|
|
|
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
|
|
+@RestController
|
|
|
+@RequestMapping("/system/family" )
|
|
|
+public class TbFamilyController extends BaseController {
|
|
|
+
|
|
|
+ private final ITbFamilyService iTbFamilyService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询家族列表
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:family:list')")
|
|
|
+ @GetMapping("/list")
|
|
|
+ public TableDataInfo list(TbFamily tbFamily)
|
|
|
+ {
|
|
|
+ startPage();
|
|
|
+ LambdaQueryWrapper<TbFamily> lqw = new LambdaQueryWrapper<>();
|
|
|
+ if (StringUtils.isNotBlank(tbFamily.getName())){
|
|
|
+ lqw.like(TbFamily::getName ,tbFamily.getName());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(tbFamily.getAddress())){
|
|
|
+ lqw.eq(TbFamily::getAddress ,tbFamily.getAddress());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(tbFamily.getContents())){
|
|
|
+ lqw.eq(TbFamily::getContents ,tbFamily.getContents());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(tbFamily.getAvatar())){
|
|
|
+ lqw.eq(TbFamily::getAvatar ,tbFamily.getAvatar());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(tbFamily.getCity())){
|
|
|
+ lqw.eq(TbFamily::getCity ,tbFamily.getCity());
|
|
|
+ }
|
|
|
+ List<TbFamily> list = iTbFamilyService.list(lqw);
|
|
|
+ return getDataTable(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出家族列表
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:family:export')" )
|
|
|
+ @Log(title = "家族" , businessType = BusinessType.EXPORT)
|
|
|
+ @GetMapping("/export" )
|
|
|
+ public AjaxResult export(TbFamily tbFamily) {
|
|
|
+ LambdaQueryWrapper<TbFamily> lqw = new LambdaQueryWrapper<>(tbFamily);
|
|
|
+ List<TbFamily> list = iTbFamilyService.list(lqw);
|
|
|
+ ExcelUtil<TbFamily> util = new ExcelUtil<TbFamily>(TbFamily. class);
|
|
|
+ return util.exportExcel(list, "family" );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取家族详细信息
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:family:query')" )
|
|
|
+ @GetMapping(value = "/{id}" )
|
|
|
+ public AjaxResult getInfo(@PathVariable("id" ) Long id) {
|
|
|
+ return AjaxResult.success(iTbFamilyService.getById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增家族
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:family:add')" )
|
|
|
+ @Log(title = "家族" , businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping
|
|
|
+ public AjaxResult add(@RequestBody TbFamily tbFamily) {
|
|
|
+ return toAjax(iTbFamilyService.save(tbFamily) ? 1 : 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改家族
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:family:edit')" )
|
|
|
+ @Log(title = "家族" , businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping
|
|
|
+ public AjaxResult edit(@RequestBody TbFamily tbFamily) {
|
|
|
+ return toAjax(iTbFamilyService.updateById(tbFamily) ? 1 : 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除家族
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:family:remove')" )
|
|
|
+ @Log(title = "家族" , businessType = BusinessType.DELETE)
|
|
|
+ @DeleteMapping("/{ids}" )
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
+ return toAjax(iTbFamilyService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
|
|
|
+ }
|
|
|
+}
|