|
@@ -0,0 +1,89 @@
|
|
|
+package com.jd.brume.controller
|
|
|
+
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page
|
|
|
+import com.jd.brume.entity.SmsEntity
|
|
|
+import com.jd.brume.entity.func.SmsFunc
|
|
|
+import com.jd.brume.entity.resultmap.SmsSelect
|
|
|
+import com.jd.brume.service.SmsService
|
|
|
+import com.jd.brume.util.Result
|
|
|
+import com.jd.brume.util.ResultEnum
|
|
|
+import com.jd.brume.vo.SmsVo
|
|
|
+import com.jd.brume.vo.group.PagingGroup
|
|
|
+import com.jd.brume.vo.group.SaveGroup
|
|
|
+import com.jd.brume.vo.group.UpdateGroup
|
|
|
+import org.springframework.validation.annotation.Validated
|
|
|
+import org.springframework.web.bind.annotation.GetMapping
|
|
|
+import org.springframework.web.bind.annotation.PostMapping
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping
|
|
|
+import org.springframework.web.bind.annotation.RestController
|
|
|
+
|
|
|
+import javax.annotation.Resource
|
|
|
+import javax.validation.constraints.NotNull
|
|
|
+import java.sql.Wrapper
|
|
|
+
|
|
|
+@Validated
|
|
|
+@RestController
|
|
|
+@RequestMapping('sms')
|
|
|
+class SmsController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ SmsService smsService
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询配置
|
|
|
+ * @param deptId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping('one')
|
|
|
+ def getConfig(@NotNull Integer smsId) {
|
|
|
+ return new Result().ok(smsService.getById(deptId))
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存菜单信息
|
|
|
+ * @param menuVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping('save')
|
|
|
+ def saveMenu(@Validated(SaveGroup) SmsVo smsVo) {
|
|
|
+ def count = smsService.count(Wrapper.lambdaQuery().eq(SmsFunc.userId(), smsVo.userId))
|
|
|
+ if (count > 0) return new Result().msg(100, '用户重复')
|
|
|
+ return new Result().ok(smsService.save(new SmsEntity(userId: smsVo.userId, status: smsVo.status, createTime: new Date())))
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询
|
|
|
+ * @param menuVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping('paging')
|
|
|
+ def getMenuPaging(@Validated(PagingGroup) SmsVo smsVo) {
|
|
|
+ Wrapper<SmsEntity> wrapper = Wrappers.lambdaQuery()
|
|
|
+ .eq(smsVo.userId != null, SmsFunc.userId(), smsVo.userId)
|
|
|
+ .eq(smsVo.status != null,SmsFunc.status(),smsVo.userId)
|
|
|
+
|
|
|
+ def count = smsService.count(wrapper)
|
|
|
+ if (count == 0) return new Result().msg(ResultEnum.NO_DATA_TABLE)
|
|
|
+ wrapper.select(SmsSelect.page)
|
|
|
+ .orderByAsc(SmsFunc.status())
|
|
|
+ .orderByDesc(SmsFunc.createTime())
|
|
|
+ def data = smsService.page(new Page(smsVo.page, smsVo.limit, count), wrapper)
|
|
|
+ return new Result().layTable([list: data.records, count: data.total])
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改配置
|
|
|
+ * @param corVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping('update')
|
|
|
+ def updateConfig(@Validated(UpdateGroup) SmsVo smsVo) {
|
|
|
+ return new Result().ok(smsService.updateById(new SmsEntity(id: smsVo.id,userId: smsVo.userId,status: smsVo.status)))
|
|
|
+ }
|
|
|
+
|
|
|
+}
|