123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- package service
- import (
- "ulink-admin/modules/system/dao"
- "ulink-admin/modules/system/models/model"
- "ulink-admin/modules/system/models/req"
- response2 "ulink-admin/modules/system/models/response"
- )
- type SysAttachmentService struct {
- SysAttachmentDao *dao.SysAttachmentDao `inject:""`
- }
- // FindAll 查询所有附件业务方法
- func (s SysAttachmentService) FindAll() []*model.SysAttachment {
- return s.SysAttachmentDao.SelectAll()
- }
- // FindList 查询附件分页列表
- func (s SysAttachmentService) FindList(query *req.SysAttachmentQuery) (*[]model.SysAttachment, int64) {
- return s.SysAttachmentDao.Find(query)
- }
- // Insert 添加附件数据
- func (s SysAttachmentService) Insert(sysAttachment *model.SysAttachment) bool {
- return s.SysAttachmentDao.Insert(sysAttachment) > 0
- }
- // GetSysAttachmentById 根据id查询附件数据
- func (s SysAttachmentService) GetSysAttachmentById(id int64) *model.SysAttachment {
- sysAttachment := model.SysAttachment{
- Id: id,
- }
- return s.SysAttachmentDao.GetSysAttachmentById(sysAttachment)
- }
- // Delete 批量删除附件信息
- func (s SysAttachmentService) Delete(ids []int64) bool {
- return s.SysAttachmentDao.Delete(ids) > 0
- }
- // Update 修改附件数据
- func (s SysAttachmentService) Update(sysAttachment *model.SysAttachment) bool {
- return s.SysAttachmentDao.Update(sysAttachment)
- }
- // CheckUnique 唯一性检查
- func (s SysAttachmentService) CheckUnique(sysAttachment model.SysAttachment, condition []string) int64 {
- return s.SysAttachmentDao.CheckUnique(sysAttachment, condition)
- }
- func (s SysAttachmentService) UploadConfig() (*response2.OmsUploadConfigResponse, error) {
- //获取配置
- /* rtnData := new(response2.OmsUploadConfigResponse)
- dat := api.CommonSetting()
- if dat != nil && dat.Code == 100 {
- gurl := dat.Result.ApiUrl + config.GetOmsApiCfg().UploadConfig
- parseUrl, _ := url.Parse(gurl)
- params := url.Values{}
- parseUrl.RawQuery = params.Encode() //如果有中文
- urlPath := parseUrl.String()
- req, err := http.NewRequest("GET", urlPath, nil)
- if err != nil {
- log.Println(err)
- return rtnData, err
- }
- req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
- t := strconv.FormatInt(time.Now().Unix(), 10)
- tokenParam := api.TokenParam{}
- cfg := config.GetOmsApiCfg()
- tokenParam.AppId = cfg.ServiceAppId
- tokenParam.AppSecret = cfg.ServiceAppSecret
- tokenParam.ApiUrl = dat.Result.ApiUrl
- token, _ := api.GetToken(tokenParam)
- //增加header选项
- req.Header.Add("AppId", cfg.ServiceAppId)
- req.Header.Add("AppToken", api.Sha1(tokenParam.AppId+tokenParam.AppSecret+parseUrl.RequestURI()+t))
- req.Header.Add("Token", token)
- req.Header.Add("AppTimestamp", t)
- //获取客户端对象,发送请求
- client := &http.Client{}
- rttp, err := client.Do(req)
- if err != nil {
- log.Println(err)
- return rtnData, err
- }
- defer rttp.Body.Close()
- //读取返回值
- res, err := ioutil.ReadAll(rttp.Body)
- if err != nil {
- fmt.Println(err)
- return rtnData, err
- }
- fmt.Println(string(res))
- if err := json.Unmarshal(res, rtnData); err == nil {
- return rtnData, nil
- if dat.Code == 100 {
- resp.OK(c, page.Page{
- List: dat.Result.Data,
- Total: dat.Result.Total,
- Size: 20,
- })
- return
- } else {
- if dat.Code == api.StatusUnauthorized || dat.Code == api.StatusSecretError {
- api.ResetToken()
- }
- resp.Error(c, dat.Msg)
- }
- } else {
- return rtnData, err
- }
- } else {
- return rtnData, errors.New("获取token错误")
- }*/
- return nil, nil
- }
|