|
@@ -0,0 +1,137 @@
|
|
|
+package com.txz.mall.controller;
|
|
|
+
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import com.txz.mall.core.Result;
|
|
|
+import com.txz.mall.core.ResultCode;
|
|
|
+import com.txz.mall.model.SystemGroupData;
|
|
|
+import com.txz.mall.service.SystemGroupDataService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import tk.mybatis.mapper.entity.Condition;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by CodeGenerator on 2025/07/11.
|
|
|
+ */
|
|
|
+@Api(tags = "[后台]systemGroupData管理")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/system/group/data")
|
|
|
+public class SystemGroupDataController {
|
|
|
+
|
|
|
+ private static Logger log = LoggerFactory.getLogger(SystemGroupDataController.class);
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private SystemGroupDataService systemGroupDataService;
|
|
|
+
|
|
|
+ @PostMapping("/add")
|
|
|
+ @ApiOperation(value = "systemGroupData新增", httpMethod = "POST")
|
|
|
+ public Result add(@RequestBody SystemGroupData systemGroupData, Long userId) {
|
|
|
+ if (systemGroupData == null) {
|
|
|
+ return Result.fail(ResultCode.OBJECT_IS_NULL);
|
|
|
+ }
|
|
|
+ if (userId == null) {
|
|
|
+ return Result.fail(ResultCode.USERID_IS_NULL);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ systemGroupData.setCreateTime(new Date());
|
|
|
+ systemGroupData.setCreateUserId(userId);
|
|
|
+ systemGroupDataService.save(systemGroupData);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("新增对象操作异常e:{}", e);
|
|
|
+ return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/delete")
|
|
|
+ @ApiOperation(value = "systemGroupData删除", httpMethod = "POST")
|
|
|
+ public Result delete(@RequestParam Long id, Long userId) {
|
|
|
+ if (id == null) {
|
|
|
+ return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
+ }
|
|
|
+ if (userId == null) {
|
|
|
+ return Result.fail(ResultCode.USERID_IS_NULL);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ SystemGroupData systemGroupData = new SystemGroupData();
|
|
|
+ systemGroupData.setId(id);
|
|
|
+ systemGroupData.setIsDelete(1);
|
|
|
+ systemGroupDataService.update(systemGroupData);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("删除对象操作异常e:{}", e);
|
|
|
+ return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/update")
|
|
|
+ @ApiOperation(value = "systemGroupData更新", httpMethod = "POST")
|
|
|
+ public Result update(@RequestBody SystemGroupData systemGroupData, Long userId) {
|
|
|
+ if (systemGroupData == null) {
|
|
|
+ return Result.fail(ResultCode.OBJECT_IS_NULL);
|
|
|
+ }
|
|
|
+ if (systemGroupData.getId() == null) {
|
|
|
+ return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
+ }
|
|
|
+ if (userId == null) {
|
|
|
+ return Result.fail(ResultCode.USERID_IS_NULL);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ systemGroupData.setUpdateTime(new Date());
|
|
|
+ systemGroupData.setUpdateUserId(userId);
|
|
|
+ systemGroupDataService.update(systemGroupData);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("更新对象操作异常e:{}", e);
|
|
|
+ return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/detail")
|
|
|
+ @ApiOperation(value = "systemGroupData获取详情", httpMethod = "POST")
|
|
|
+ public Result<SystemGroupData> detail(@RequestParam Long id, Long userId) {
|
|
|
+ if (id == null) {
|
|
|
+ return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
+ }
|
|
|
+ if (userId == null) {
|
|
|
+ return Result.fail(ResultCode.USERID_IS_NULL);
|
|
|
+ }
|
|
|
+ SystemGroupData systemGroupData = null;
|
|
|
+ try {
|
|
|
+ systemGroupData = systemGroupDataService.findById(id);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询对象操作异常e:{}", e);
|
|
|
+ return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return Result.success(systemGroupData);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/list")
|
|
|
+ @ApiOperation(value = "systemGroupData获取列表", httpMethod = "POST")
|
|
|
+ public Result<List<SystemGroupData>> list(@RequestBody SystemGroupData systemGroupData, @RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size, Long userId) {
|
|
|
+ if (userId == null) {
|
|
|
+ return Result.fail(ResultCode.USERID_IS_NULL);
|
|
|
+ }
|
|
|
+ PageHelper.startPage(page, size);
|
|
|
+
|
|
|
+ Condition condition = new Condition(systemGroupData.getClass());
|
|
|
+// Criteria criteria = condition.createCriteria();
|
|
|
+// criteria.andEqualTo("name", city.getName());
|
|
|
+ PageInfo pageInfo = null;
|
|
|
+ try {
|
|
|
+ List<SystemGroupData> list = systemGroupDataService.findByCondition(condition);
|
|
|
+ pageInfo = new PageInfo(list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询对象操作异常e:{}", e);
|
|
|
+ return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return Result.success(pageInfo);
|
|
|
+ }
|
|
|
+}
|